mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 01:47:30 +09:00
Merge branch 'apply-screen-suspension-changes' into multiplayer-spectator-screen
This commit is contained in:
commit
65014d9596
@ -2,7 +2,6 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -19,6 +18,8 @@ namespace osu.Game.Screens.Play
|
|||||||
private readonly GameplayClockContainer gameplayClockContainer;
|
private readonly GameplayClockContainer gameplayClockContainer;
|
||||||
private Bindable<bool> isPaused;
|
private Bindable<bool> isPaused;
|
||||||
|
|
||||||
|
private readonly Bindable<bool> disableSuspensionBindable = new Bindable<bool>();
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private GameHost host { get; set; }
|
private GameHost host { get; set; }
|
||||||
|
|
||||||
@ -31,12 +32,14 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
// This is the only usage game-wide of suspension changes.
|
|
||||||
// Assert to ensure we don't accidentally forget this in the future.
|
|
||||||
Debug.Assert(host.AllowScreenSuspension.Value);
|
|
||||||
|
|
||||||
isPaused = gameplayClockContainer.IsPaused.GetBoundCopy();
|
isPaused = gameplayClockContainer.IsPaused.GetBoundCopy();
|
||||||
isPaused.BindValueChanged(paused => host.AllowScreenSuspension.Value = paused.NewValue, true);
|
isPaused.BindValueChanged(paused =>
|
||||||
|
{
|
||||||
|
if (paused.NewValue)
|
||||||
|
host.AllowScreenSuspension.RemoveSource(disableSuspensionBindable);
|
||||||
|
else
|
||||||
|
host.AllowScreenSuspension.AddSource(disableSuspensionBindable);
|
||||||
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
@ -44,9 +47,7 @@ namespace osu.Game.Screens.Play
|
|||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
isPaused?.UnbindAll();
|
isPaused?.UnbindAll();
|
||||||
|
host?.AllowScreenSuspension.RemoveSource(disableSuspensionBindable);
|
||||||
if (host != null)
|
|
||||||
host.AllowScreenSuspension.Value = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user