1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-18 06:27:18 +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:
Salman Ahmed 2022-06-15 00:39:19 +03:00 committed by GitHub
commit 674a9bb399
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 66 additions and 8 deletions

View File

@ -14,6 +14,7 @@ using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Play;
using osu.Game.Screens.Play.HUD.HitErrorMeters;
using osu.Game.Skinning;
using osu.Game.Tests.Gameplay;
using osuTK.Input;
@ -145,6 +146,26 @@ namespace osu.Game.Tests.Visual.Gameplay
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]
public void TestHiddenHUDDoesntBlockSkinnableComponentsLoad()
{
@ -153,7 +174,7 @@ namespace osu.Game.Tests.Visual.Gameplay
createNew();
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());
AddUntilStep("skinnable components loaded", () => hudOverlay.ChildrenOfType<SkinnableTargetContainer>().Single().ComponentsLoaded);

View File

@ -142,6 +142,36 @@ namespace osu.Game.Tests.Visual.Gameplay
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]
public void TestClear()
{

View File

@ -15,7 +15,11 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
{
public class ColourHitErrorMeter : HitErrorMeter
{
internal const int MAX_DISPLAYED_JUDGEMENTS = 20;
private const int animation_duration = 200;
private const int drawable_judgement_size = 8;
private const int spacing = 2;
private readonly JudgementFlow judgementsFlow;
@ -37,16 +41,12 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
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 JudgementFlow()
{
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);
Direction = FillDirection.Vertical;
LayoutDuration = animation_duration;
@ -57,7 +57,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
{
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();
}
}

View File

@ -31,6 +31,9 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
private void load(DrawableRuleset drawableRuleset)
{
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()

View File

@ -86,11 +86,15 @@ namespace osu.Game.Screens.Play
Children = new Drawable[]
{
CreateFailingLayer(),
mainComponents = new MainComponentsContainer(),
mainComponents = new MainComponentsContainer
{
AlwaysPresent = true,
},
topRightElements = new FillFlowContainer
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
AlwaysPresent = true,
Margin = new MarginPadding(10),
Spacing = new Vector2(10),
AutoSizeAxes = Axes.Both,