1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-20 09:03:00 +08:00

Move implementation and colour logic to legacy implementation

This commit is contained in:
Dean Herbert 2019-07-30 23:06:18 +09:00
parent 7cab0fcfb8
commit fb1f77bd04
2 changed files with 21 additions and 10 deletions

View File

@ -4,7 +4,6 @@
using System;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
@ -57,7 +56,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
{
RelativeSizeAxes = Axes.Both,
// TODO: support skin filename animation (sliderb0, sliderb1...)
Child = new SkinnableDrawable("Play/osu/sliderb", _ => new DefaultSliderBall()),
Child = new SkinnableDrawable("Play/osu/sliderball", _ => new DefaultSliderBall()),
}
}
};
@ -204,10 +203,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
public class DefaultSliderBall : CompositeDrawable
{
private readonly Bindable<Color4> accentColour = new Bindable<Color4>();
private Drawable drawableBall;
[BackgroundDependencyLoader]
private void load(DrawableHitObject drawableObject, ISkinSource skin)
{
@ -225,15 +220,13 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
BorderThickness = 10,
BorderColour = Color4.White,
Alpha = 1,
Child = drawableBall = new Box
Child = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.White,
Alpha = 0.4f,
}
};
accentColour.BindTo(drawableObject.AccentColour);
accentColour.BindValueChanged(colour => drawableBall.Colour = colour.NewValue, true);
}
}
}

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics;
@ -15,6 +16,7 @@ using osu.Framework.IO.Stores;
using osu.Game.Database;
using osu.Game.Graphics.Sprites;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Skinning
{
@ -71,6 +73,12 @@ namespace osu.Game.Skinning
{
switch (componentName)
{
case "Play/osu/sliderball":
if (GetTexture("sliderb") != null)
return new LegacySliderBall();
break;
case "Play/Miss":
componentName = "hit0";
break;
@ -109,6 +117,16 @@ namespace osu.Game.Skinning
return new Sprite { Texture = texture };
}
public class LegacySliderBall : Sprite
{
[BackgroundDependencyLoader]
private void load(ISkinSource skin)
{
Texture = skin.GetTexture("sliderb");
Colour = skin.GetValue<SkinConfiguration, Color4?>(s => s.CustomColours.ContainsKey("SliderBall") ? s.CustomColours["SliderBall"] : (Color4?)null) ?? Color4.White;
}
}
public override Texture GetTexture(string componentName)
{
float ratio = 2;