Skip to content

Commit

Permalink
Merge pull request #17977 from peppy/show-during-gameplay-improvement
Browse files Browse the repository at this point in the history
Change conditions for HUD being shown to include pause/fail states
  • Loading branch information
smoogipoo authored Apr 26, 2022
2 parents 51b4821 + 8ab3636 commit 9911584
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions osu.Game.Tests/Visual/Gameplay/TestSceneFailJudgement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ protected override Player CreatePlayer(Ruleset ruleset)

protected override void AddCheckSteps()
{
AddUntilStep("player is playing", () => Player.LocalUserPlaying.Value);
AddUntilStep("wait for fail", () => Player.GameplayState.HasFailed);
AddAssert("player is not playing", () => !Player.LocalUserPlaying.Value);
AddUntilStep("wait for multiple judgements", () => ((FailPlayer)Player).ScoreProcessor.JudgedHits > 1);
AddAssert("total number of results == 1", () =>
{
Expand Down
3 changes: 3 additions & 0 deletions osu.Game.Tests/Visual/Gameplay/TestScenePause.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ public void TestPauseResume()
{
AddStep("move cursor outside", () => InputManager.MoveMouseTo(Player.ScreenSpaceDrawQuad.TopLeft - new Vector2(10)));
pauseAndConfirm();
AddAssert("player not playing", () => !Player.LocalUserPlaying.Value);

resumeAndConfirm();
AddUntilStep("player playing", () => Player.LocalUserPlaying.Value);
}

[Test]
Expand Down
6 changes: 3 additions & 3 deletions osu.Game/Screens/Play/HUDOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class HUDOverlay : Container, IKeyBindingHandler<GlobalAction>
private readonly FillFlowContainer bottomRightElements;
private readonly FillFlowContainer topRightElements;

internal readonly IBindable<bool> IsBreakTime = new Bindable<bool>();
internal readonly IBindable<bool> IsPlaying = new Bindable<bool>();

private bool holdingForHUD;

Expand Down Expand Up @@ -152,7 +152,7 @@ protected override void LoadComplete()

ShowHud.BindValueChanged(visible => hideTargets.ForEach(d => d.FadeTo(visible.NewValue ? 1 : 0, FADE_DURATION, FADE_EASING)));

IsBreakTime.BindValueChanged(_ => updateVisibility());
IsPlaying.BindValueChanged(_ => updateVisibility());
configVisibilityMode.BindValueChanged(_ => updateVisibility(), true);

replayLoaded.BindValueChanged(replayLoadedValueChanged, true);
Expand Down Expand Up @@ -218,7 +218,7 @@ private void updateVisibility()

case HUDVisibilityMode.HideDuringGameplay:
// always show during replay as we want the seek bar to be visible.
ShowHud.Value = replayLoaded.Value || IsBreakTime.Value;
ShowHud.Value = replayLoaded.Value || !IsPlaying.Value;
break;

case HUDVisibilityMode.Always:
Expand Down
6 changes: 4 additions & 2 deletions osu.Game/Screens/Play/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ private void onBreakTimeChanged(ValueChangedEvent<bool> isBreakTime)

private void updateGameplayState()
{
bool inGameplay = !DrawableRuleset.HasReplayLoaded.Value && !DrawableRuleset.IsPaused.Value && !breakTracker.IsBreakTime.Value;
bool inGameplay = !DrawableRuleset.HasReplayLoaded.Value && !DrawableRuleset.IsPaused.Value && !breakTracker.IsBreakTime.Value && !GameplayState.HasFailed;
OverlayActivationMode.Value = inGameplay ? OverlayActivation.Disabled : OverlayActivation.UserTriggered;
localUserPlaying.Value = inGameplay;
}
Expand Down Expand Up @@ -812,6 +812,8 @@ private bool onFail()
GameplayState.HasFailed = true;
Score.ScoreInfo.Passed = false;

updateGameplayState();

// There is a chance that we could be in a paused state as the ruleset's internal clock (see FrameStabilityContainer)
// could process an extra frame after the GameplayClock is stopped.
// In such cases we want the fail state to precede a user triggered pause.
Expand Down Expand Up @@ -945,7 +947,7 @@ public override void OnEntering(ScreenTransitionEvent e)
failAnimationLayer.Background = b;
});

HUDOverlay.IsBreakTime.BindTo(breakTracker.IsBreakTime);
HUDOverlay.IsPlaying.BindTo(localUserPlaying);
DimmableStoryboard.IsBreakTime.BindTo(breakTracker.IsBreakTime);

DimmableStoryboard.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground);
Expand Down

0 comments on commit 9911584

Please sign in to comment.