mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 10:22:54 +08:00
Revert commit 939441ae
This commit is contained in:
parent
396ada7f39
commit
4102dae999
@ -11,26 +11,26 @@ namespace osu.Desktop.Windows
|
|||||||
{
|
{
|
||||||
public class GameplayWinKeyHandler : Component
|
public class GameplayWinKeyHandler : Component
|
||||||
{
|
{
|
||||||
|
private Bindable<bool> allowScreenSuspension;
|
||||||
private Bindable<bool> disableWinKey;
|
private Bindable<bool> disableWinKey;
|
||||||
private Bindable<bool> disableWinKeySetting;
|
|
||||||
|
|
||||||
private GameHost host;
|
private GameHost host;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(GameHost host, OsuConfigManager config, SessionStatics statics)
|
private void load(GameHost host, OsuConfigManager config)
|
||||||
{
|
{
|
||||||
this.host = host;
|
this.host = host;
|
||||||
|
|
||||||
disableWinKey = statics.GetBindable<bool>(Static.DisableWindowsKey);
|
allowScreenSuspension = host.AllowScreenSuspension.GetBoundCopy();
|
||||||
disableWinKey.ValueChanged += toggleWinKey;
|
allowScreenSuspension.ValueChanged += toggleWinKey;
|
||||||
|
|
||||||
disableWinKeySetting = config.GetBindable<bool>(OsuSetting.GameplayDisableWinKey);
|
disableWinKey = config.GetBindable<bool>(OsuSetting.GameplayDisableWinKey);
|
||||||
disableWinKeySetting.BindValueChanged(t => disableWinKey.TriggerChange(), true);
|
disableWinKey.BindValueChanged(t => allowScreenSuspension.TriggerChange(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toggleWinKey(ValueChangedEvent<bool> e)
|
private void toggleWinKey(ValueChangedEvent<bool> e)
|
||||||
{
|
{
|
||||||
if (e.NewValue && disableWinKeySetting.Value)
|
if (!e.NewValue && disableWinKey.Value)
|
||||||
host.InputThread.Scheduler.Add(WindowsKey.Disable);
|
host.InputThread.Scheduler.Add(WindowsKey.Disable);
|
||||||
else
|
else
|
||||||
host.InputThread.Scheduler.Add(WindowsKey.Enable);
|
host.InputThread.Scheduler.Add(WindowsKey.Enable);
|
||||||
|
@ -12,14 +12,12 @@ namespace osu.Game.Configuration
|
|||||||
{
|
{
|
||||||
Set(Static.LoginOverlayDisplayed, false);
|
Set(Static.LoginOverlayDisplayed, false);
|
||||||
Set(Static.MutedAudioNotificationShownOnce, false);
|
Set(Static.MutedAudioNotificationShownOnce, false);
|
||||||
Set(Static.DisableWindowsKey, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Static
|
public enum Static
|
||||||
{
|
{
|
||||||
LoginOverlayDisplayed,
|
LoginOverlayDisplayed,
|
||||||
MutedAudioNotificationShownOnce,
|
MutedAudioNotificationShownOnce
|
||||||
DisableWindowsKey
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ namespace osu.Game.Screens.Play
|
|||||||
InternalChild = GameplayClockContainer = new GameplayClockContainer(Beatmap.Value, Mods.Value, DrawableRuleset.GameplayStartTime);
|
InternalChild = GameplayClockContainer = new GameplayClockContainer(Beatmap.Value, Mods.Value, DrawableRuleset.GameplayStartTime);
|
||||||
|
|
||||||
AddInternal(gameplayBeatmap = new GameplayBeatmap(playableBeatmap));
|
AddInternal(gameplayBeatmap = new GameplayBeatmap(playableBeatmap));
|
||||||
AddInternal(screenSuspension = new ScreenSuspensionHandler(GameplayClockContainer, DrawableRuleset.HasReplayLoaded));
|
AddInternal(screenSuspension = new ScreenSuspensionHandler(GameplayClockContainer));
|
||||||
|
|
||||||
dependencies.CacheAs(gameplayBeatmap);
|
dependencies.CacheAs(gameplayBeatmap);
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Game.Configuration;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
{
|
{
|
||||||
@ -19,18 +18,13 @@ 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> hasReplayLoaded;
|
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private GameHost host { get; set; }
|
private GameHost host { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
public ScreenSuspensionHandler([NotNull] GameplayClockContainer gameplayClockContainer)
|
||||||
private SessionStatics statics { get; set; }
|
|
||||||
|
|
||||||
public ScreenSuspensionHandler([NotNull] GameplayClockContainer gameplayClockContainer, Bindable<bool> hasReplayLoaded)
|
|
||||||
{
|
{
|
||||||
this.gameplayClockContainer = gameplayClockContainer ?? throw new ArgumentNullException(nameof(gameplayClockContainer));
|
this.gameplayClockContainer = gameplayClockContainer ?? throw new ArgumentNullException(nameof(gameplayClockContainer));
|
||||||
this.hasReplayLoaded = hasReplayLoaded.GetBoundCopy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -42,12 +36,7 @@ namespace osu.Game.Screens.Play
|
|||||||
Debug.Assert(host.AllowScreenSuspension.Value);
|
Debug.Assert(host.AllowScreenSuspension.Value);
|
||||||
|
|
||||||
isPaused = gameplayClockContainer.IsPaused.GetBoundCopy();
|
isPaused = gameplayClockContainer.IsPaused.GetBoundCopy();
|
||||||
isPaused.BindValueChanged(paused =>
|
isPaused.BindValueChanged(paused => host.AllowScreenSuspension.Value = paused.NewValue, true);
|
||||||
{
|
|
||||||
host.AllowScreenSuspension.Value = paused.NewValue;
|
|
||||||
statics.Set(Static.DisableWindowsKey, !paused.NewValue && !hasReplayLoaded.Value);
|
|
||||||
}, true);
|
|
||||||
hasReplayLoaded.BindValueChanged(_ => isPaused.TriggerChange(), true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
@ -55,13 +44,9 @@ namespace osu.Game.Screens.Play
|
|||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
isPaused?.UnbindAll();
|
isPaused?.UnbindAll();
|
||||||
hasReplayLoaded.UnbindAll();
|
|
||||||
|
|
||||||
if (host != null)
|
if (host != null)
|
||||||
{
|
|
||||||
host.AllowScreenSuspension.Value = true;
|
host.AllowScreenSuspension.Value = true;
|
||||||
statics.Set(Static.DisableWindowsKey, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user