Merge remote-tracking branch 'origin/fix-idle-weirdness' into samah-ios

This commit is contained in:
Dean Herbert 2019-01-25 18:49:41 +09:00
commit e3fde56780
2 changed files with 27 additions and 6 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

@ -221,9 +221,7 @@ namespace osu.Game
return; return;
} }
var databasedSet = beatmap.OnlineBeatmapSetID != null ? var databasedSet = beatmap.OnlineBeatmapSetID != null ? BeatmapManager.QueryBeatmapSet(s => s.OnlineBeatmapSetID == beatmap.OnlineBeatmapSetID) : BeatmapManager.QueryBeatmapSet(s => s.Hash == beatmap.Hash);
BeatmapManager.QueryBeatmapSet(s => s.OnlineBeatmapSetID == beatmap.OnlineBeatmapSetID) :
BeatmapManager.QueryBeatmapSet(s => s.Hash == beatmap.Hash);
if (databasedSet != null) if (databasedSet != null)
{ {
@ -369,7 +367,7 @@ namespace osu.Game
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, },
floatingOverlayContent = new Container { RelativeSizeAxes = Axes.Both, Depth = float.MinValue }, floatingOverlayContent = 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 =>
@ -437,7 +435,7 @@ namespace osu.Game
Depth = -8, Depth = -8,
}, floatingOverlayContent.Add); }, floatingOverlayContent.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);
@ -518,6 +516,24 @@ namespace osu.Game
notifications.StateChanged += _ => updateScreenOffset(); 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() private void forwardLoggedErrorsToNotifications()
{ {
int recentLogCount = 0; int recentLogCount = 0;