1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-07 22:22:59 +08:00

Fix global idle state being entered when overlays are visible

This commit is contained in:
Dean Herbert 2018-12-26 18:39:57 +09:00
parent e596d4fc10
commit 4c2c7bd937
2 changed files with 19 additions and 3 deletions

View File

@ -27,6 +27,11 @@ namespace osu.Game.Input
private readonly BindableBool isIdle = new BindableBool(); private readonly BindableBool isIdle = new BindableBool();
/// <summary>
/// Whether the game can currently enter an idle state.
/// </summary>
protected virtual bool AllowIdle => true;
/// <summary> /// <summary>
/// Intstantiate a new <see cref="IdleTracker"/>. /// Intstantiate a new <see cref="IdleTracker"/>.
/// </summary> /// </summary>
@ -40,7 +45,7 @@ namespace osu.Game.Input
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();
isIdle.Value = TimeSpentIdle > timeToIdle; isIdle.Value = TimeSpentIdle > timeToIdle && AllowIdle;
} }
public bool OnPressed(PlatformAction action) => updateLastInteractionTime(); public bool OnPressed(PlatformAction action) => updateLastInteractionTime();

View File

@ -187,6 +187,7 @@ namespace osu.Game
} }
private ExternalLinkOpener externalLinkOpener; private ExternalLinkOpener externalLinkOpener;
public void OpenUrlExternally(string url) public void OpenUrlExternally(string url)
{ {
if (url.StartsWith("/")) if (url.StartsWith("/"))
@ -355,7 +356,7 @@ namespace osu.Game
}, },
mainContent = new Container { RelativeSizeAxes = Axes.Both }, mainContent = new Container { RelativeSizeAxes = Axes.Both },
overlayContent = new Container { RelativeSizeAxes = Axes.Both, Depth = float.MinValue }, overlayContent = new Container { RelativeSizeAxes = Axes.Both, Depth = float.MinValue },
idleTracker = new IdleTracker(6000) idleTracker = new GameIdleTracker(6000)
}); });
loadComponentSingleFile(screenStack = new Loader(), d => loadComponentSingleFile(screenStack = new Loader(), d =>
@ -423,7 +424,7 @@ namespace osu.Game
Depth = -8, Depth = -8,
}, overlayContent.Add); }, overlayContent.Add);
dependencies.Cache(idleTracker); dependencies.CacheAs(idleTracker);
dependencies.Cache(settings); dependencies.Cache(settings);
dependencies.Cache(onscreenDisplay); dependencies.Cache(onscreenDisplay);
dependencies.Cache(social); dependencies.Cache(social);
@ -504,6 +505,16 @@ namespace osu.Game
notifications.StateChanged += _ => updateScreenOffset(); notifications.StateChanged += _ => updateScreenOffset();
} }
public class GameIdleTracker : IdleTracker
{
public GameIdleTracker(int time)
: base(time)
{
}
protected override bool AllowIdle => GetContainingInputManager().FocusedDrawable == null;
}
private void forwardLoggedErrorsToNotifications() private void forwardLoggedErrorsToNotifications()
{ {
int recentLogCount = 0; int recentLogCount = 0;