mirror of
https://github.com/ppy/osu.git
synced 2025-03-28 10:17:19 +08:00
Merge pull request #18669 from peppy/fix-hit-error-when-not-visible
Fix hit error meters not updating visual state when hidden
This commit is contained in:
commit
674a9bb399
@ -14,6 +14,7 @@ using osu.Game.Rulesets.Mods;
|
|||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
|
using osu.Game.Screens.Play.HUD.HitErrorMeters;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osu.Game.Tests.Gameplay;
|
using osu.Game.Tests.Gameplay;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
@ -145,6 +146,26 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddAssert("key counters still hidden", () => !keyCounterFlow.IsPresent);
|
AddAssert("key counters still hidden", () => !keyCounterFlow.IsPresent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestHiddenHUDDoesntBlockComponentUpdates()
|
||||||
|
{
|
||||||
|
int updateCount = 0;
|
||||||
|
|
||||||
|
AddStep("set hud to never show", () => localConfig.SetValue(OsuSetting.HUDVisibilityMode, HUDVisibilityMode.Never));
|
||||||
|
|
||||||
|
createNew();
|
||||||
|
|
||||||
|
AddUntilStep("wait for hud load", () => hudOverlay.IsLoaded);
|
||||||
|
AddUntilStep("wait for components to be hidden", () => hudOverlay.ChildrenOfType<SkinnableTargetContainer>().Single().Alpha == 0);
|
||||||
|
|
||||||
|
AddStep("bind on update", () =>
|
||||||
|
{
|
||||||
|
hudOverlay.ChildrenOfType<BarHitErrorMeter>().First().OnUpdate += _ => updateCount++;
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep("wait for updates", () => updateCount > 0);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestHiddenHUDDoesntBlockSkinnableComponentsLoad()
|
public void TestHiddenHUDDoesntBlockSkinnableComponentsLoad()
|
||||||
{
|
{
|
||||||
@ -153,7 +174,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
createNew();
|
createNew();
|
||||||
|
|
||||||
AddUntilStep("wait for hud load", () => hudOverlay.IsLoaded);
|
AddUntilStep("wait for hud load", () => hudOverlay.IsLoaded);
|
||||||
AddUntilStep("wait for components to be hidden", () => !hudOverlay.ChildrenOfType<SkinnableTargetContainer>().Single().IsPresent);
|
AddUntilStep("wait for components to be hidden", () => hudOverlay.ChildrenOfType<SkinnableTargetContainer>().Single().Alpha == 0);
|
||||||
|
|
||||||
AddStep("reload components", () => hudOverlay.ChildrenOfType<SkinnableTargetContainer>().Single().Reload());
|
AddStep("reload components", () => hudOverlay.ChildrenOfType<SkinnableTargetContainer>().Single().Reload());
|
||||||
AddUntilStep("skinnable components loaded", () => hudOverlay.ChildrenOfType<SkinnableTargetContainer>().Single().ComponentsLoaded);
|
AddUntilStep("skinnable components loaded", () => hudOverlay.ChildrenOfType<SkinnableTargetContainer>().Single().ComponentsLoaded);
|
||||||
|
@ -142,6 +142,36 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddAssert("no circle added", () => !this.ChildrenOfType<ColourHitErrorMeter.HitErrorCircle>().Any());
|
AddAssert("no circle added", () => !this.ChildrenOfType<ColourHitErrorMeter.HitErrorCircle>().Any());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestProcessingWhileHidden()
|
||||||
|
{
|
||||||
|
AddStep("OD 1", () => recreateDisplay(new OsuHitWindows(), 1));
|
||||||
|
|
||||||
|
AddStep("hide displays", () =>
|
||||||
|
{
|
||||||
|
foreach (var hitErrorMeter in this.ChildrenOfType<HitErrorMeter>())
|
||||||
|
hitErrorMeter.Hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
AddRepeatStep("hit", () => newJudgement(), ColourHitErrorMeter.MAX_DISPLAYED_JUDGEMENTS * 2);
|
||||||
|
|
||||||
|
AddAssert("bars added", () => this.ChildrenOfType<BarHitErrorMeter.JudgementLine>().Any());
|
||||||
|
AddAssert("circle added", () => this.ChildrenOfType<ColourHitErrorMeter.HitErrorCircle>().Any());
|
||||||
|
|
||||||
|
AddUntilStep("wait for bars to disappear", () => !this.ChildrenOfType<BarHitErrorMeter.JudgementLine>().Any());
|
||||||
|
AddUntilStep("ensure max circles not exceeded", () =>
|
||||||
|
{
|
||||||
|
return this.ChildrenOfType<ColourHitErrorMeter>()
|
||||||
|
.All(m => m.ChildrenOfType<ColourHitErrorMeter.HitErrorCircle>().Count() <= ColourHitErrorMeter.MAX_DISPLAYED_JUDGEMENTS);
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("show displays", () =>
|
||||||
|
{
|
||||||
|
foreach (var hitErrorMeter in this.ChildrenOfType<HitErrorMeter>())
|
||||||
|
hitErrorMeter.Show();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestClear()
|
public void TestClear()
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,11 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
|||||||
{
|
{
|
||||||
public class ColourHitErrorMeter : HitErrorMeter
|
public class ColourHitErrorMeter : HitErrorMeter
|
||||||
{
|
{
|
||||||
|
internal const int MAX_DISPLAYED_JUDGEMENTS = 20;
|
||||||
|
|
||||||
private const int animation_duration = 200;
|
private const int animation_duration = 200;
|
||||||
|
private const int drawable_judgement_size = 8;
|
||||||
|
private const int spacing = 2;
|
||||||
|
|
||||||
private readonly JudgementFlow judgementsFlow;
|
private readonly JudgementFlow judgementsFlow;
|
||||||
|
|
||||||
@ -37,16 +41,12 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
|||||||
|
|
||||||
private class JudgementFlow : FillFlowContainer<HitErrorCircle>
|
private class JudgementFlow : FillFlowContainer<HitErrorCircle>
|
||||||
{
|
{
|
||||||
private const int max_available_judgements = 20;
|
|
||||||
private const int drawable_judgement_size = 8;
|
|
||||||
private const int spacing = 2;
|
|
||||||
|
|
||||||
public override IEnumerable<Drawable> FlowingChildren => base.FlowingChildren.Reverse();
|
public override IEnumerable<Drawable> FlowingChildren => base.FlowingChildren.Reverse();
|
||||||
|
|
||||||
public JudgementFlow()
|
public JudgementFlow()
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.X;
|
AutoSizeAxes = Axes.X;
|
||||||
Height = max_available_judgements * (drawable_judgement_size + spacing) - spacing;
|
Height = MAX_DISPLAYED_JUDGEMENTS * (drawable_judgement_size + spacing) - spacing;
|
||||||
Spacing = new Vector2(0, spacing);
|
Spacing = new Vector2(0, spacing);
|
||||||
Direction = FillDirection.Vertical;
|
Direction = FillDirection.Vertical;
|
||||||
LayoutDuration = animation_duration;
|
LayoutDuration = animation_duration;
|
||||||
@ -57,7 +57,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
|||||||
{
|
{
|
||||||
Add(new HitErrorCircle(colour, drawable_judgement_size));
|
Add(new HitErrorCircle(colour, drawable_judgement_size));
|
||||||
|
|
||||||
if (Children.Count > max_available_judgements)
|
if (Children.Count > MAX_DISPLAYED_JUDGEMENTS)
|
||||||
Children.FirstOrDefault(c => !c.IsRemoved)?.Remove();
|
Children.FirstOrDefault(c => !c.IsRemoved)?.Remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,9 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
|||||||
private void load(DrawableRuleset drawableRuleset)
|
private void load(DrawableRuleset drawableRuleset)
|
||||||
{
|
{
|
||||||
HitWindows = drawableRuleset?.FirstAvailableHitWindows ?? HitWindows.Empty;
|
HitWindows = drawableRuleset?.FirstAvailableHitWindows ?? HitWindows.Empty;
|
||||||
|
|
||||||
|
// This is to allow the visual state to be correct after HUD comes visible after being hidden.
|
||||||
|
AlwaysPresent = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
|
@ -86,11 +86,15 @@ namespace osu.Game.Screens.Play
|
|||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
CreateFailingLayer(),
|
CreateFailingLayer(),
|
||||||
mainComponents = new MainComponentsContainer(),
|
mainComponents = new MainComponentsContainer
|
||||||
|
{
|
||||||
|
AlwaysPresent = true,
|
||||||
|
},
|
||||||
topRightElements = new FillFlowContainer
|
topRightElements = new FillFlowContainer
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
|
AlwaysPresent = true,
|
||||||
Margin = new MarginPadding(10),
|
Margin = new MarginPadding(10),
|
||||||
Spacing = new Vector2(10),
|
Spacing = new Vector2(10),
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user