mirror of
https://github.com/ppy/osu
synced 2024-12-14 19:06:07 +00:00
Merge pull request #9766 from Game4all/gameplay-disable-overlays
Disable activation of overlays while in gameplay
This commit is contained in:
commit
4c40d8f503
54
osu.Game.Tests/Visual/Gameplay/TestSceneOverlayActivation.cs
Normal file
54
osu.Game.Tests/Visual/Gameplay/TestSceneOverlayActivation.cs
Normal file
@ -0,0 +1,54 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Rulesets;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public class TestSceneOverlayActivation : OsuPlayerTestScene
|
||||
{
|
||||
protected new OverlayTestPlayer Player => base.Player as OverlayTestPlayer;
|
||||
|
||||
[Test]
|
||||
public void TestGameplayOverlayActivation()
|
||||
{
|
||||
AddAssert("activation mode is disabled", () => Player.OverlayActivationMode == OverlayActivation.Disabled);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGameplayOverlayActivationPaused()
|
||||
{
|
||||
AddUntilStep("activation mode is disabled", () => Player.OverlayActivationMode == OverlayActivation.Disabled);
|
||||
AddStep("pause gameplay", () => Player.Pause());
|
||||
AddUntilStep("activation mode is user triggered", () => Player.OverlayActivationMode == OverlayActivation.UserTriggered);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGameplayOverlayActivationReplayLoaded()
|
||||
{
|
||||
AddAssert("activation mode is disabled", () => Player.OverlayActivationMode == OverlayActivation.Disabled);
|
||||
AddStep("load a replay", () => Player.DrawableRuleset.HasReplayLoaded.Value = true);
|
||||
AddAssert("activation mode is user triggered", () => Player.OverlayActivationMode == OverlayActivation.UserTriggered);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGameplayOverlayActivationBreaks()
|
||||
{
|
||||
AddAssert("activation mode is disabled", () => Player.OverlayActivationMode == OverlayActivation.Disabled);
|
||||
AddStep("seek to break", () => Player.GameplayClockContainer.Seek(Beatmap.Value.Beatmap.Breaks.First().StartTime));
|
||||
AddUntilStep("activation mode is user triggered", () => Player.OverlayActivationMode == OverlayActivation.UserTriggered);
|
||||
AddStep("seek to break end", () => Player.GameplayClockContainer.Seek(Beatmap.Value.Beatmap.Breaks.First().EndTime));
|
||||
AddUntilStep("activation mode is disabled", () => Player.OverlayActivationMode == OverlayActivation.Disabled);
|
||||
}
|
||||
|
||||
protected override TestPlayer CreatePlayer(Ruleset ruleset) => new OverlayTestPlayer();
|
||||
|
||||
protected class OverlayTestPlayer : TestPlayer
|
||||
{
|
||||
public new OverlayActivation OverlayActivationMode => base.OverlayActivationMode.Value;
|
||||
}
|
||||
}
|
||||
}
|
@ -231,6 +231,6 @@ namespace osu.Game.Configuration
|
||||
UIHoldActivationDelay,
|
||||
HitLighting,
|
||||
MenuBackgroundSource,
|
||||
GameplayDisableWinKey
|
||||
GameplayDisableWinKey,
|
||||
}
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ namespace osu.Game.Screens.Menu
|
||||
{
|
||||
"You can press Ctrl-T anywhere in the game to toggle the toolbar!",
|
||||
"You can press Ctrl-O anywhere in the game to access options!",
|
||||
"All settings are dynamic and take effect in real-time. Try changing the skin while playing!",
|
||||
"All settings are dynamic and take effect in real-time. Try pausing and changing the skin while playing!",
|
||||
"New features are coming online every update. Make sure to stay up-to-date!",
|
||||
"If you find the UI too large or small, try adjusting UI scale in settings!",
|
||||
"Try adjusting the \"Screen Scaling\" mode to change your gameplay or UI area, even in fullscreen!",
|
||||
|
@ -203,6 +203,10 @@ namespace osu.Game.Screens.Play
|
||||
skipOverlay.Hide();
|
||||
}
|
||||
|
||||
DrawableRuleset.IsPaused.BindValueChanged(_ => updateOverlayActivationMode());
|
||||
DrawableRuleset.HasReplayLoaded.BindValueChanged(_ => updateOverlayActivationMode());
|
||||
breakTracker.IsBreakTime.BindValueChanged(_ => updateOverlayActivationMode());
|
||||
|
||||
DrawableRuleset.HasReplayLoaded.BindValueChanged(_ => updatePauseOnFocusLostState(), true);
|
||||
|
||||
// bind clock into components that require it
|
||||
@ -347,6 +351,16 @@ namespace osu.Game.Screens.Play
|
||||
HUDOverlay.KeyCounter.IsCounting = !isBreakTime.NewValue;
|
||||
}
|
||||
|
||||
private void updateOverlayActivationMode()
|
||||
{
|
||||
bool canTriggerOverlays = DrawableRuleset.IsPaused.Value || breakTracker.IsBreakTime.Value;
|
||||
|
||||
if (DrawableRuleset.HasReplayLoaded.Value || canTriggerOverlays)
|
||||
OverlayActivationMode.Value = OverlayActivation.UserTriggered;
|
||||
else
|
||||
OverlayActivationMode.Value = OverlayActivation.Disabled;
|
||||
}
|
||||
|
||||
private void updatePauseOnFocusLostState() =>
|
||||
HUDOverlay.HoldToQuit.PauseOnFocusLost = PauseOnFocusLost
|
||||
&& !DrawableRuleset.HasReplayLoaded.Value
|
||||
@ -640,6 +654,8 @@ namespace osu.Game.Screens.Play
|
||||
musicController.ResetTrackAdjustments();
|
||||
foreach (var mod in Mods.Value.OfType<IApplicableToTrack>())
|
||||
mod.ApplyToTrack(musicController.CurrentTrack);
|
||||
|
||||
updateOverlayActivationMode();
|
||||
}
|
||||
|
||||
public override void OnSuspending(IScreen next)
|
||||
|
Loading…
Reference in New Issue
Block a user