mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 07:42:57 +08:00
Revert leasing logic
This commit is contained in:
parent
15ce7bacf1
commit
08f23cc424
@ -28,8 +28,6 @@ namespace osu.Game.Tests.Input
|
||||
setWindowModeTo(windowMode);
|
||||
setGameSideModeTo(OsuConfineMouseMode.Never);
|
||||
|
||||
gameSideConfineModeDisabled(false);
|
||||
|
||||
setLocalUserPlayingTo(false);
|
||||
frameworkSideModeIs(ConfineMouseMode.Never);
|
||||
|
||||
@ -44,8 +42,6 @@ namespace osu.Game.Tests.Input
|
||||
setWindowModeTo(windowMode);
|
||||
setGameSideModeTo(OsuConfineMouseMode.DuringGameplay);
|
||||
|
||||
gameSideConfineModeDisabled(false);
|
||||
|
||||
setLocalUserPlayingTo(false);
|
||||
frameworkSideModeIs(ConfineMouseMode.Never);
|
||||
|
||||
@ -60,8 +56,6 @@ namespace osu.Game.Tests.Input
|
||||
setWindowModeTo(windowMode);
|
||||
setGameSideModeTo(OsuConfineMouseMode.Always);
|
||||
|
||||
gameSideConfineModeDisabled(false);
|
||||
|
||||
setLocalUserPlayingTo(false);
|
||||
frameworkSideModeIs(ConfineMouseMode.Always);
|
||||
|
||||
@ -75,20 +69,18 @@ namespace osu.Game.Tests.Input
|
||||
setGameSideModeTo(OsuConfineMouseMode.Never);
|
||||
|
||||
setWindowModeTo(WindowMode.Fullscreen);
|
||||
gameSideConfineModeDisabled(true);
|
||||
|
||||
setLocalUserPlayingTo(false);
|
||||
frameworkSideModeIs(ConfineMouseMode.Always);
|
||||
frameworkSideModeIs(ConfineMouseMode.Fullscreen);
|
||||
|
||||
setLocalUserPlayingTo(true);
|
||||
frameworkSideModeIs(ConfineMouseMode.Always);
|
||||
frameworkSideModeIs(ConfineMouseMode.Fullscreen);
|
||||
|
||||
setWindowModeTo(WindowMode.Windowed);
|
||||
|
||||
// old state is restored
|
||||
gameSideModeIs(OsuConfineMouseMode.Never);
|
||||
frameworkSideModeIs(ConfineMouseMode.Never);
|
||||
gameSideConfineModeDisabled(false);
|
||||
}
|
||||
|
||||
private void setWindowModeTo(WindowMode mode)
|
||||
@ -106,9 +98,5 @@ namespace osu.Game.Tests.Input
|
||||
|
||||
private void frameworkSideModeIs(ConfineMouseMode mode)
|
||||
=> AddAssert($"mode is {mode} framework-side", () => frameworkConfigManager.Get<ConfineMouseMode>(FrameworkSetting.ConfineMouseMode) == mode);
|
||||
|
||||
private void gameSideConfineModeDisabled(bool disabled)
|
||||
=> AddAssert($"game-side confine mode {(disabled ? "disabled" : "enabled")}",
|
||||
() => Game.LocalConfig.GetBindable<OsuConfineMouseMode>(OsuSetting.ConfineMouseMode).Disabled == disabled);
|
||||
}
|
||||
}
|
||||
|
@ -28,38 +28,27 @@ namespace osu.Game.Input
|
||||
{
|
||||
frameworkConfineMode = frameworkConfigManager.GetBindable<ConfineMouseMode>(FrameworkSetting.ConfineMouseMode);
|
||||
frameworkWindowMode = frameworkConfigManager.GetBindable<WindowMode>(FrameworkSetting.WindowMode);
|
||||
frameworkWindowMode.BindValueChanged(_ => updateGameConfineMode());
|
||||
frameworkWindowMode.BindValueChanged(_ => updateConfineMode());
|
||||
|
||||
osuConfineMode = osuConfigManager.GetBindable<OsuConfineMouseMode>(OsuSetting.ConfineMouseMode);
|
||||
localUserPlaying = game.LocalUserPlaying.GetBoundCopy();
|
||||
|
||||
osuConfineMode.ValueChanged += _ => updateFrameworkConfineMode();
|
||||
localUserPlaying.BindValueChanged(_ => updateFrameworkConfineMode(), true);
|
||||
osuConfineMode.ValueChanged += _ => updateConfineMode();
|
||||
localUserPlaying.BindValueChanged(_ => updateConfineMode(), true);
|
||||
}
|
||||
|
||||
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()
|
||||
private void updateConfineMode()
|
||||
{
|
||||
// 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:
|
||||
|
Loading…
Reference in New Issue
Block a user