1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:17:26 +08:00

Merge pull request #11092 from peppy/fix-fullscreen-mouse-confining

Always confine mouse to screen when running fullscreen
This commit is contained in:
Dean Herbert 2020-12-04 21:52:20 +09:00 committed by GitHub
commit 91c5183b3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 9 deletions

View File

@ -18,6 +18,8 @@ namespace osu.Game.Input
public class ConfineMouseTracker : Component
{
private Bindable<ConfineMouseMode> frameworkConfineMode;
private Bindable<WindowMode> frameworkWindowMode;
private Bindable<OsuConfineMouseMode> osuConfineMode;
private IBindable<bool> localUserPlaying;
@ -25,6 +27,9 @@ namespace osu.Game.Input
private void load(OsuGame game, FrameworkConfigManager frameworkConfigManager, OsuConfigManager osuConfigManager)
{
frameworkConfineMode = frameworkConfigManager.GetBindable<ConfineMouseMode>(FrameworkSetting.ConfineMouseMode);
frameworkWindowMode = frameworkConfigManager.GetBindable<WindowMode>(FrameworkSetting.WindowMode);
frameworkWindowMode.BindValueChanged(_ => updateConfineMode());
osuConfineMode = osuConfigManager.GetBindable<OsuConfineMouseMode>(OsuSetting.ConfineMouseMode);
localUserPlaying = game.LocalUserPlaying.GetBoundCopy();
@ -38,16 +43,18 @@ namespace osu.Game.Input
if (frameworkConfineMode.Disabled)
return;
if (frameworkWindowMode.Value == WindowMode.Fullscreen)
{
frameworkConfineMode.Value = ConfineMouseMode.Fullscreen;
return;
}
switch (osuConfineMode.Value)
{
case OsuConfineMouseMode.Never:
frameworkConfineMode.Value = ConfineMouseMode.Never;
break;
case OsuConfineMouseMode.Fullscreen:
frameworkConfineMode.Value = ConfineMouseMode.Fullscreen;
break;
case OsuConfineMouseMode.DuringGameplay:
frameworkConfineMode.Value = localUserPlaying.Value ? ConfineMouseMode.Always : ConfineMouseMode.Never;
break;

View File

@ -17,11 +17,6 @@ namespace osu.Game.Input
/// </summary>
Never,
/// <summary>
/// The mouse cursor will be locked to the window bounds while in fullscreen mode.
/// </summary>
Fullscreen,
/// <summary>
/// The mouse cursor will be locked to the window bounds during gameplay,
/// but may otherwise move freely.