mirror of
https://github.com/ppy/osu
synced 2024-12-22 14:54:35 +00:00
Disable windows key only while in gameplay.
This commit is contained in:
parent
4102dae999
commit
5e6adfff99
@ -101,7 +101,7 @@ namespace osu.Desktop
|
||||
LoadComponentAsync(new DiscordRichPresence(), Add);
|
||||
|
||||
if (RuntimeInfo.OS == RuntimeInfo.Platform.Windows)
|
||||
LoadComponentAsync(new GameplayWinKeyHandler(), Add);
|
||||
LoadComponentAsync(new GameplayWinKeyHandler(ScreenStack), Add);
|
||||
}
|
||||
|
||||
protected override void ScreenChanged(IScreen lastScreen, IScreen newScreen)
|
||||
|
@ -1,11 +1,14 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.Play;
|
||||
|
||||
namespace osu.Desktop.Windows
|
||||
{
|
||||
@ -14,8 +17,16 @@ namespace osu.Desktop.Windows
|
||||
private Bindable<bool> allowScreenSuspension;
|
||||
private Bindable<bool> disableWinKey;
|
||||
|
||||
private readonly OsuScreenStack screenStack;
|
||||
private GameHost host;
|
||||
|
||||
private Type currentScreenType => screenStack.CurrentScreen?.GetType();
|
||||
|
||||
public GameplayWinKeyHandler(OsuScreenStack stack)
|
||||
{
|
||||
screenStack = stack;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(GameHost host, OsuConfigManager config)
|
||||
{
|
||||
@ -30,7 +41,9 @@ namespace osu.Desktop.Windows
|
||||
|
||||
private void toggleWinKey(ValueChangedEvent<bool> e)
|
||||
{
|
||||
if (!e.NewValue && disableWinKey.Value)
|
||||
var isPlayer = typeof(Player).IsAssignableFrom(currentScreenType) && currentScreenType != typeof(ReplayPlayer);
|
||||
|
||||
if (!e.NewValue && disableWinKey.Value && isPlayer)
|
||||
host.InputThread.Scheduler.Add(WindowsKey.Disable);
|
||||
else
|
||||
host.InputThread.Scheduler.Add(WindowsKey.Enable);
|
||||
|
Loading…
Reference in New Issue
Block a user