diff --git a/osu.Game/Input/IdleTracker.cs b/osu.Game/Input/IdleTracker.cs index bf747472de..ab010a9532 100644 --- a/osu.Game/Input/IdleTracker.cs +++ b/osu.Game/Input/IdleTracker.cs @@ -27,6 +27,11 @@ namespace osu.Game.Input private readonly BindableBool isIdle = new BindableBool(); + /// + /// Whether the game can currently enter an idle state. + /// + protected virtual bool AllowIdle => true; + /// /// Intstantiate a new . /// @@ -40,7 +45,7 @@ namespace osu.Game.Input protected override void Update() { base.Update(); - isIdle.Value = TimeSpentIdle > timeToIdle; + isIdle.Value = TimeSpentIdle > timeToIdle && AllowIdle; } public bool OnPressed(PlatformAction action) => updateLastInteractionTime(); diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 771dacfed3..d8499f4159 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -221,9 +221,7 @@ namespace osu.Game return; } - var databasedSet = beatmap.OnlineBeatmapSetID != null ? - BeatmapManager.QueryBeatmapSet(s => s.OnlineBeatmapSetID == beatmap.OnlineBeatmapSetID) : - BeatmapManager.QueryBeatmapSet(s => s.Hash == beatmap.Hash); + var databasedSet = beatmap.OnlineBeatmapSetID != null ? BeatmapManager.QueryBeatmapSet(s => s.OnlineBeatmapSetID == beatmap.OnlineBeatmapSetID) : BeatmapManager.QueryBeatmapSet(s => s.Hash == beatmap.Hash); if (databasedSet != null) { @@ -369,7 +367,7 @@ namespace osu.Game RelativeSizeAxes = Axes.Both, }, floatingOverlayContent = new Container { RelativeSizeAxes = Axes.Both, Depth = float.MinValue }, - idleTracker = new IdleTracker(6000) + idleTracker = new GameIdleTracker(6000) }); loadComponentSingleFile(screenStack = new Loader(), d => @@ -437,7 +435,7 @@ namespace osu.Game Depth = -8, }, floatingOverlayContent.Add); - dependencies.Cache(idleTracker); + dependencies.CacheAs(idleTracker); dependencies.Cache(settings); dependencies.Cache(onscreenDisplay); dependencies.Cache(social); @@ -518,6 +516,24 @@ namespace osu.Game notifications.StateChanged += _ => updateScreenOffset(); } + public class GameIdleTracker : IdleTracker + { + private InputManager inputManager; + + public GameIdleTracker(int time) + : base(time) + { + } + + protected override void LoadComplete() + { + base.LoadComplete(); + inputManager = GetContainingInputManager(); + } + + protected override bool AllowIdle => inputManager.FocusedDrawable == null; + } + private void forwardLoggedErrorsToNotifications() { int recentLogCount = 0;