From 4c2c7bd9370390330b31440d1ab02b9379737b7a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 26 Dec 2018 18:39:57 +0900 Subject: [PATCH 1/2] Fix global idle state being entered when overlays are visible --- osu.Game/Input/IdleTracker.cs | 7 ++++++- osu.Game/OsuGame.cs | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/osu.Game/Input/IdleTracker.cs b/osu.Game/Input/IdleTracker.cs index d96fa8bd34..51b51c6761 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 2a4c812401..ad438a20c6 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -187,6 +187,7 @@ namespace osu.Game } private ExternalLinkOpener externalLinkOpener; + public void OpenUrlExternally(string url) { if (url.StartsWith("/")) @@ -355,7 +356,7 @@ namespace osu.Game }, mainContent = new Container { RelativeSizeAxes = Axes.Both }, overlayContent = new Container { RelativeSizeAxes = Axes.Both, Depth = float.MinValue }, - idleTracker = new IdleTracker(6000) + idleTracker = new GameIdleTracker(6000) }); loadComponentSingleFile(screenStack = new Loader(), d => @@ -423,7 +424,7 @@ namespace osu.Game Depth = -8, }, overlayContent.Add); - dependencies.Cache(idleTracker); + dependencies.CacheAs(idleTracker); dependencies.Cache(settings); dependencies.Cache(onscreenDisplay); dependencies.Cache(social); @@ -504,6 +505,16 @@ namespace osu.Game notifications.StateChanged += _ => updateScreenOffset(); } + public class GameIdleTracker : IdleTracker + { + public GameIdleTracker(int time) + : base(time) + { + } + + protected override bool AllowIdle => GetContainingInputManager().FocusedDrawable == null; + } + private void forwardLoggedErrorsToNotifications() { int recentLogCount = 0; From 7415a6e764c607b2c61912416ac79d622fc48339 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 23 Jan 2019 20:37:56 +0900 Subject: [PATCH 2/2] Cache input manager --- osu.Game/OsuGame.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 8917dc742c..628550576e 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) { @@ -520,12 +518,20 @@ namespace osu.Game public class GameIdleTracker : IdleTracker { + private InputManager inputManager; + public GameIdleTracker(int time) : base(time) { } - protected override bool AllowIdle => GetContainingInputManager().FocusedDrawable == null; + protected override void LoadComplete() + { + base.LoadComplete(); + inputManager = GetContainingInputManager(); + } + + protected override bool AllowIdle => inputManager.FocusedDrawable == null; } private void forwardLoggedErrorsToNotifications()