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