mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:27:29 +08:00
Change circle/overlay sprite fields to protected
for better test assertion
This commit is contained in:
parent
a96664295b
commit
fd20c2bdcd
@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
{
|
||||
// available textures
|
||||
new[] { @"hitcircle", @"hitcircleoverlay" },
|
||||
// priority lookup
|
||||
// priority lookup prefix
|
||||
null,
|
||||
// expected circle and overlay
|
||||
@"hitcircle", @"hitcircleoverlay",
|
||||
@ -66,8 +66,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
[TestCaseSource(nameof(texture_priority_cases))]
|
||||
public void TestTexturePriorities(string[] textureFilenames, string priorityLookup, string? expectedCircle, string? expectedOverlay)
|
||||
{
|
||||
Sprite? circleSprite = null;
|
||||
Sprite? overlaySprite = null;
|
||||
TestLegacyMainCirclePiece piece = null!;
|
||||
|
||||
AddStep("load circle piece", () =>
|
||||
{
|
||||
@ -80,18 +79,26 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
Child = new DependencyProvidingContainer
|
||||
{
|
||||
CachedDependencies = new (Type, object)[] { (typeof(ISkinSource), skin.Object) },
|
||||
Child = new LegacyMainCirclePiece(priorityLookup, false),
|
||||
Child = piece = new TestLegacyMainCirclePiece(priorityLookup),
|
||||
};
|
||||
|
||||
var sprites = this.ChildrenOfType<Sprite>().Where(s => s.Texture.AssetName != null).DistinctBy(s => s.Texture.AssetName).ToArray();
|
||||
Debug.Assert(sprites.Length <= 2);
|
||||
|
||||
circleSprite = sprites.ElementAtOrDefault(0);
|
||||
overlaySprite = sprites.ElementAtOrDefault(1);
|
||||
});
|
||||
|
||||
AddAssert("check circle sprite", () => circleSprite?.Texture?.AssetName == expectedCircle);
|
||||
AddAssert("check overlay sprite", () => overlaySprite?.Texture?.AssetName == expectedOverlay);
|
||||
AddAssert("check circle sprite", () => piece.CircleSprite?.Texture?.AssetName == expectedCircle);
|
||||
AddAssert("check overlay sprite", () => piece.OverlaySprite?.Texture?.AssetName == expectedOverlay);
|
||||
}
|
||||
|
||||
private class TestLegacyMainCirclePiece : LegacyMainCirclePiece
|
||||
{
|
||||
public new Sprite? CircleSprite => base.CircleSprite.ChildrenOfType<Sprite>().DistinctBy(s => s.Texture.AssetName).SingleOrDefault();
|
||||
public new Sprite? OverlaySprite => base.OverlaySprite.ChildrenOfType<Sprite>().DistinctBy(s => s.Texture.AssetName).SingleOrDefault();
|
||||
|
||||
public TestLegacyMainCirclePiece(string? priorityLookupPrefix)
|
||||
: base(priorityLookupPrefix, false)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,11 +31,11 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
|
||||
private readonly bool hasNumber;
|
||||
|
||||
private Drawable hitCircleSprite = null!;
|
||||
protected Drawable CircleSprite = null!;
|
||||
protected Drawable OverlaySprite = null!;
|
||||
|
||||
protected Container OverlayLayer { get; private set; } = null!;
|
||||
|
||||
private Drawable hitCircleOverlay = null!;
|
||||
private SkinnableSpriteText hitCircleText = null!;
|
||||
|
||||
private readonly Bindable<Color4> accentColour = new Bindable<Color4>();
|
||||
@ -70,7 +70,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
|
||||
InternalChildren = new[]
|
||||
{
|
||||
hitCircleSprite = new KiaiFlashingDrawable(() => new Sprite { Texture = skin.GetTexture(circleName) })
|
||||
CircleSprite = new KiaiFlashingDrawable(() => new Sprite { Texture = skin.GetTexture(circleName) })
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
@ -79,7 +79,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Child = hitCircleOverlay = new KiaiFlashingDrawable(() => skin.GetAnimation(@$"{circleName}overlay", true, true, frameLength: 1000 / 2d))
|
||||
Child = OverlaySprite = new KiaiFlashingDrawable(() => skin.GetAnimation(@$"{circleName}overlay", true, true, frameLength: 1000 / 2d))
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
@ -103,7 +103,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
bool overlayAboveNumber = skin.GetConfig<OsuSkinConfiguration, bool>(OsuSkinConfiguration.HitCircleOverlayAboveNumber)?.Value ?? true;
|
||||
|
||||
if (overlayAboveNumber)
|
||||
OverlayLayer.ChangeChildDepth(hitCircleOverlay, float.MinValue);
|
||||
OverlayLayer.ChangeChildDepth(OverlaySprite, float.MinValue);
|
||||
|
||||
if (drawableOsuObject != null)
|
||||
{
|
||||
@ -116,7 +116,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
accentColour.BindValueChanged(colour => hitCircleSprite.Colour = LegacyColourCompatibility.DisallowZeroAlpha(colour.NewValue), true);
|
||||
accentColour.BindValueChanged(colour => CircleSprite.Colour = LegacyColourCompatibility.DisallowZeroAlpha(colour.NewValue), true);
|
||||
if (hasNumber)
|
||||
indexInCurrentCombo.BindValueChanged(index => hitCircleText.Text = (index.NewValue + 1).ToString(), true);
|
||||
|
||||
@ -136,11 +136,11 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
switch (state)
|
||||
{
|
||||
case ArmedState.Hit:
|
||||
hitCircleSprite.FadeOut(legacy_fade_duration, Easing.Out);
|
||||
hitCircleSprite.ScaleTo(1.4f, legacy_fade_duration, Easing.Out);
|
||||
CircleSprite.FadeOut(legacy_fade_duration, Easing.Out);
|
||||
CircleSprite.ScaleTo(1.4f, legacy_fade_duration, Easing.Out);
|
||||
|
||||
hitCircleOverlay.FadeOut(legacy_fade_duration, Easing.Out);
|
||||
hitCircleOverlay.ScaleTo(1.4f, legacy_fade_duration, Easing.Out);
|
||||
OverlaySprite.FadeOut(legacy_fade_duration, Easing.Out);
|
||||
OverlaySprite.ScaleTo(1.4f, legacy_fade_duration, Easing.Out);
|
||||
|
||||
if (hasNumber)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user