1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 03:27:24 +08:00

Merge pull request #20681 from peppy/fix-hidden-hud-interaction

Fix HUD components being interactive even when the HUD is visually hidden
This commit is contained in:
Dan Balasescu 2022-10-11 17:19:27 +09:00 committed by GitHub
commit 88e82d3154
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 0 deletions

View File

@ -16,6 +16,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;
using osu.Game.Screens.Play.HUD.HitErrorMeters;
using osu.Game.Skinning;
using osu.Game.Tests.Gameplay;
@ -148,6 +149,42 @@ namespace osu.Game.Tests.Visual.Gameplay
AddAssert("key counters still hidden", () => !keyCounterFlow.IsPresent);
}
[Test]
public void TestInputDoesntWorkWhenHUDHidden()
{
SongProgressBar getSongProgress() => hudOverlay.ChildrenOfType<SongProgressBar>().Single();
bool seeked = false;
createNew();
AddStep("bind seek", () =>
{
seeked = false;
var progress = getSongProgress();
progress.ShowHandle = true;
progress.OnSeek += _ => seeked = true;
});
AddStep("set showhud false", () => hudOverlay.ShowHud.Value = false);
AddUntilStep("hidetarget is hidden", () => !hideTarget.IsPresent);
AddStep("attempt seek", () =>
{
InputManager.MoveMouseTo(getSongProgress());
InputManager.Click(MouseButton.Left);
});
AddAssert("seek not performed", () => !seeked);
AddStep("set showhud true", () => hudOverlay.ShowHud.Value = true);
AddStep("attempt seek", () => InputManager.Click(MouseButton.Left));
AddAssert("seek performed", () => seeked);
}
[Test]
public void TestHiddenHUDDoesntBlockComponentUpdates()
{

View File

@ -39,6 +39,10 @@ namespace osu.Game.Screens.Play
/// </summary>
public float BottomScoringElementsHeight { get; private set; }
// HUD uses AlwaysVisible on child components so they can be in an updated state for next display.
// Without blocking input, this would also allow them to be interacted with in such a state.
public override bool PropagatePositionalInputSubTree => ShowHud.Value;
public readonly KeyCounterDisplay KeyCounter;
public readonly ModDisplay ModDisplay;
public readonly HoldForMenuButton HoldToQuit;