mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 15:03:13 +08:00
Add support for both legacy styles
This commit is contained in:
parent
bdebf2f1a4
commit
f0b15813e2
@ -12,7 +12,11 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
public class SkinnableHealthDisplay : SkinnableDrawable, IHealthDisplay
|
||||
{
|
||||
public Bindable<double> Current { get; } = new Bindable<double>();
|
||||
public Bindable<double> Current { get; } = new BindableDouble(1)
|
||||
{
|
||||
MinValue = 0,
|
||||
MaxValue = 1
|
||||
};
|
||||
|
||||
public void Flash(JudgementResult result) => skinnedCounter?.Flash(result);
|
||||
|
||||
|
@ -18,14 +18,18 @@ namespace osu.Game.Skinning
|
||||
public class LegacyHealthDisplay : CompositeDrawable, IHealthDisplay
|
||||
{
|
||||
private readonly Skin skin;
|
||||
private Sprite fill;
|
||||
private Marker marker;
|
||||
private Drawable fill;
|
||||
private LegacyMarker marker;
|
||||
|
||||
private float maxFillWidth;
|
||||
|
||||
private Texture isNewStyle;
|
||||
private bool isNewStyle;
|
||||
|
||||
public Bindable<double> Current { get; } = new BindableDouble { MinValue = 0, MaxValue = 1 };
|
||||
public Bindable<double> Current { get; } = new BindableDouble(1)
|
||||
{
|
||||
MinValue = 0,
|
||||
MaxValue = 1
|
||||
};
|
||||
|
||||
public LegacyHealthDisplay(Skin skin)
|
||||
{
|
||||
@ -37,25 +41,29 @@ namespace osu.Game.Skinning
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
|
||||
isNewStyle = getTexture(skin, "marker");
|
||||
isNewStyle = getTexture(skin, "marker") != null;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
// background implementation is the same for both versions.
|
||||
AddInternal(new Sprite { Texture = getTexture(skin, "bg") });
|
||||
|
||||
if (isNewStyle)
|
||||
{
|
||||
new Sprite
|
||||
AddRangeInternal(new[]
|
||||
{
|
||||
Texture = getTexture(skin, "bg")
|
||||
},
|
||||
fill = new Sprite
|
||||
{
|
||||
Texture = getTexture(skin, "colour"),
|
||||
Position = new Vector2(7.5f, 7.8f) * 1.6f
|
||||
},
|
||||
marker = new Marker(skin)
|
||||
{
|
||||
Current = { BindTarget = Current },
|
||||
fill = new LegacyNewStyleFill(skin),
|
||||
marker = new LegacyNewStyleMarker(skin),
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
AddRangeInternal(new[]
|
||||
{
|
||||
fill = new LegacyOldStyleFill(skin),
|
||||
marker = new LegacyOldStyleMarker(skin),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
marker.Current.BindTo(Current);
|
||||
maxFillWidth = fill.Width;
|
||||
}
|
||||
|
||||
@ -70,24 +78,28 @@ namespace osu.Game.Skinning
|
||||
marker.Position = fill.Position + new Vector2(fill.DrawWidth, fill.DrawHeight / 2);
|
||||
}
|
||||
|
||||
public void Flash(JudgementResult result)
|
||||
public void Flash(JudgementResult result) => marker.Flash(result);
|
||||
|
||||
private static Texture getTexture(Skin skin, string name) => skin.GetTexture($"scorebar-{name}");
|
||||
|
||||
public class LegacyOldStyleMarker : LegacyMarker
|
||||
{
|
||||
marker.ScaleTo(1.4f).Then().ScaleTo(1, 200, Easing.Out);
|
||||
public LegacyOldStyleMarker(Skin skin)
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Sprite
|
||||
{
|
||||
Texture = getTexture(skin, "ki"),
|
||||
Origin = Anchor.Centre,
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private class Marker : CompositeDrawable
|
||||
public class LegacyNewStyleMarker : LegacyMarker
|
||||
{
|
||||
public Bindable<double> Current { get; } = new Bindable<double>();
|
||||
|
||||
public Marker(Skin skin)
|
||||
{
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
if (getTexture(skin, "ki") != null)
|
||||
{
|
||||
// TODO: old style (marker changes as health decreases)
|
||||
}
|
||||
else
|
||||
public LegacyNewStyleMarker(Skin skin)
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
@ -99,8 +111,52 @@ namespace osu.Game.Skinning
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class LegacyMarker : CompositeDrawable, IHealthDisplay
|
||||
{
|
||||
public Bindable<double> Current { get; } = new Bindable<double>();
|
||||
|
||||
public LegacyMarker()
|
||||
{
|
||||
Origin = Anchor.Centre;
|
||||
}
|
||||
|
||||
private static Texture getTexture(Skin skin, string name) => skin.GetTexture($"scorebar-{name}");
|
||||
public void Flash(JudgementResult result)
|
||||
{
|
||||
this.ScaleTo(1.4f).Then().ScaleTo(1, 200, Easing.Out);
|
||||
}
|
||||
}
|
||||
|
||||
internal class LegacyOldStyleFill : CompositeDrawable
|
||||
{
|
||||
public LegacyOldStyleFill(Skin skin)
|
||||
{
|
||||
// required for sizing correctly..
|
||||
var firstFrame = getTexture(skin, "colour-0");
|
||||
|
||||
if (firstFrame == null)
|
||||
{
|
||||
InternalChild = new Sprite { Texture = getTexture(skin, "colour") };
|
||||
Size = InternalChild.Size;
|
||||
}
|
||||
else
|
||||
{
|
||||
InternalChild = skin.GetAnimation("scorebar-colour", true, true, startAtCurrentTime: false, applyConfigFrameRate: true) ?? Drawable.Empty();
|
||||
Size = new Vector2(firstFrame.DisplayWidth, firstFrame.DisplayHeight);
|
||||
}
|
||||
|
||||
Position = new Vector2(3, 10) * 1.6f;
|
||||
Masking = true;
|
||||
}
|
||||
}
|
||||
|
||||
internal class LegacyNewStyleFill : Sprite
|
||||
{
|
||||
public LegacyNewStyleFill(Skin skin)
|
||||
{
|
||||
Texture = getTexture(skin, "colour");
|
||||
Position = new Vector2(7.5f, 7.8f) * 1.6f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user