1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 09:02:58 +08:00

Disable confine mode dropdown when full-screen

After hard-locking the mouse confine mode to `Always` in full-screen to
prevent confine issues from popping up, the confine mode dropdown in
settings had confusing UX due to seemingly having no effect when
full-screen.
This commit is contained in:
Bartłomiej Dach 2020-12-05 13:11:52 +01:00
parent 9064ca9064
commit 0a745144e3

View File

@ -28,27 +28,38 @@ namespace osu.Game.Input
{
frameworkConfineMode = frameworkConfigManager.GetBindable<ConfineMouseMode>(FrameworkSetting.ConfineMouseMode);
frameworkWindowMode = frameworkConfigManager.GetBindable<WindowMode>(FrameworkSetting.WindowMode);
frameworkWindowMode.BindValueChanged(_ => updateConfineMode());
frameworkWindowMode.BindValueChanged(_ => updateGameConfineMode());
osuConfineMode = osuConfigManager.GetBindable<OsuConfineMouseMode>(OsuSetting.ConfineMouseMode);
localUserPlaying = game.LocalUserPlaying.GetBoundCopy();
osuConfineMode.ValueChanged += _ => updateConfineMode();
localUserPlaying.BindValueChanged(_ => updateConfineMode(), true);
osuConfineMode.ValueChanged += _ => updateFrameworkConfineMode();
localUserPlaying.BindValueChanged(_ => updateFrameworkConfineMode(), true);
}
private void updateConfineMode()
private LeasedBindable<OsuConfineMouseMode> leasedOsuConfineMode;
private void updateGameConfineMode()
{
if (frameworkWindowMode.Value == WindowMode.Fullscreen && leasedOsuConfineMode == null)
{
leasedOsuConfineMode = osuConfineMode.BeginLease(true);
leasedOsuConfineMode.Value = OsuConfineMouseMode.Always;
}
if (frameworkWindowMode.Value != WindowMode.Fullscreen && leasedOsuConfineMode != null)
{
leasedOsuConfineMode.Return();
leasedOsuConfineMode = null;
}
}
private void updateFrameworkConfineMode()
{
// confine mode is unavailable on some platforms
if (frameworkConfineMode.Disabled)
return;
if (frameworkWindowMode.Value == WindowMode.Fullscreen)
{
frameworkConfineMode.Value = ConfineMouseMode.Fullscreen;
return;
}
switch (osuConfineMode.Value)
{
case OsuConfineMouseMode.Never: