mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 15:33:05 +08:00
Extract legacy spinner presence to lazy field
This commit is contained in:
parent
e4afe717d5
commit
1841a4d1c9
@ -13,6 +13,10 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
|||||||
{
|
{
|
||||||
private Lazy<bool> hasHitCircle;
|
private Lazy<bool> hasHitCircle;
|
||||||
|
|
||||||
|
private Lazy<SpinnerStyle> spinnerStyle;
|
||||||
|
|
||||||
|
private bool hasSpinner => spinnerStyle.Value != SpinnerStyle.Modern;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// On osu-stable, hitcircles have 5 pixels of transparent padding on each side to allow for shadows etc.
|
/// On osu-stable, hitcircles have 5 pixels of transparent padding on each side to allow for shadows etc.
|
||||||
/// Their hittable area is 128px, but the actual circle portion is 118px.
|
/// Their hittable area is 128px, but the actual circle portion is 118px.
|
||||||
@ -30,6 +34,19 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
|||||||
private void sourceChanged()
|
private void sourceChanged()
|
||||||
{
|
{
|
||||||
hasHitCircle = new Lazy<bool>(() => Source.GetTexture("hitcircle") != null);
|
hasHitCircle = new Lazy<bool>(() => Source.GetTexture("hitcircle") != null);
|
||||||
|
|
||||||
|
spinnerStyle = new Lazy<SpinnerStyle>(() =>
|
||||||
|
{
|
||||||
|
bool hasBackground = Source.GetTexture("spinner-background") != null;
|
||||||
|
|
||||||
|
if (Source.GetTexture("spinner-top") != null && !hasBackground)
|
||||||
|
return SpinnerStyle.NewLegacy;
|
||||||
|
|
||||||
|
if (hasBackground)
|
||||||
|
return SpinnerStyle.OldLegacy;
|
||||||
|
|
||||||
|
return SpinnerStyle.Modern;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Drawable GetDrawableComponent(ISkinComponent component)
|
public override Drawable GetDrawableComponent(ISkinComponent component)
|
||||||
@ -110,11 +127,9 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
|||||||
};
|
};
|
||||||
|
|
||||||
case OsuSkinComponents.SpinnerBody:
|
case OsuSkinComponents.SpinnerBody:
|
||||||
bool hasBackground = Source.GetTexture("spinner-background") != null;
|
if (spinnerStyle.Value == SpinnerStyle.NewLegacy)
|
||||||
|
|
||||||
if (Source.GetTexture("spinner-top") != null && !hasBackground)
|
|
||||||
return new LegacyNewStyleSpinner();
|
return new LegacyNewStyleSpinner();
|
||||||
else if (hasBackground)
|
else if (spinnerStyle.Value == SpinnerStyle.OldLegacy)
|
||||||
return new LegacyOldStyleSpinner();
|
return new LegacyOldStyleSpinner();
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -151,5 +166,12 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
|||||||
|
|
||||||
return Source.GetConfig<TLookup, TValue>(lookup);
|
return Source.GetConfig<TLookup, TValue>(lookup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private enum SpinnerStyle
|
||||||
|
{
|
||||||
|
NewLegacy,
|
||||||
|
OldLegacy,
|
||||||
|
Modern,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user