mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:12:54 +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);
|
setWindowModeTo(windowMode);
|
||||||
setGameSideModeTo(OsuConfineMouseMode.Never);
|
setGameSideModeTo(OsuConfineMouseMode.Never);
|
||||||
|
|
||||||
gameSideConfineModeDisabled(false);
|
|
||||||
|
|
||||||
setLocalUserPlayingTo(false);
|
setLocalUserPlayingTo(false);
|
||||||
frameworkSideModeIs(ConfineMouseMode.Never);
|
frameworkSideModeIs(ConfineMouseMode.Never);
|
||||||
|
|
||||||
@ -44,8 +42,6 @@ namespace osu.Game.Tests.Input
|
|||||||
setWindowModeTo(windowMode);
|
setWindowModeTo(windowMode);
|
||||||
setGameSideModeTo(OsuConfineMouseMode.DuringGameplay);
|
setGameSideModeTo(OsuConfineMouseMode.DuringGameplay);
|
||||||
|
|
||||||
gameSideConfineModeDisabled(false);
|
|
||||||
|
|
||||||
setLocalUserPlayingTo(false);
|
setLocalUserPlayingTo(false);
|
||||||
frameworkSideModeIs(ConfineMouseMode.Never);
|
frameworkSideModeIs(ConfineMouseMode.Never);
|
||||||
|
|
||||||
@ -60,8 +56,6 @@ namespace osu.Game.Tests.Input
|
|||||||
setWindowModeTo(windowMode);
|
setWindowModeTo(windowMode);
|
||||||
setGameSideModeTo(OsuConfineMouseMode.Always);
|
setGameSideModeTo(OsuConfineMouseMode.Always);
|
||||||
|
|
||||||
gameSideConfineModeDisabled(false);
|
|
||||||
|
|
||||||
setLocalUserPlayingTo(false);
|
setLocalUserPlayingTo(false);
|
||||||
frameworkSideModeIs(ConfineMouseMode.Always);
|
frameworkSideModeIs(ConfineMouseMode.Always);
|
||||||
|
|
||||||
@ -75,20 +69,18 @@ namespace osu.Game.Tests.Input
|
|||||||
setGameSideModeTo(OsuConfineMouseMode.Never);
|
setGameSideModeTo(OsuConfineMouseMode.Never);
|
||||||
|
|
||||||
setWindowModeTo(WindowMode.Fullscreen);
|
setWindowModeTo(WindowMode.Fullscreen);
|
||||||
gameSideConfineModeDisabled(true);
|
|
||||||
|
|
||||||
setLocalUserPlayingTo(false);
|
setLocalUserPlayingTo(false);
|
||||||
frameworkSideModeIs(ConfineMouseMode.Always);
|
frameworkSideModeIs(ConfineMouseMode.Fullscreen);
|
||||||
|
|
||||||
setLocalUserPlayingTo(true);
|
setLocalUserPlayingTo(true);
|
||||||
frameworkSideModeIs(ConfineMouseMode.Always);
|
frameworkSideModeIs(ConfineMouseMode.Fullscreen);
|
||||||
|
|
||||||
setWindowModeTo(WindowMode.Windowed);
|
setWindowModeTo(WindowMode.Windowed);
|
||||||
|
|
||||||
// old state is restored
|
// old state is restored
|
||||||
gameSideModeIs(OsuConfineMouseMode.Never);
|
gameSideModeIs(OsuConfineMouseMode.Never);
|
||||||
frameworkSideModeIs(ConfineMouseMode.Never);
|
frameworkSideModeIs(ConfineMouseMode.Never);
|
||||||
gameSideConfineModeDisabled(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setWindowModeTo(WindowMode mode)
|
private void setWindowModeTo(WindowMode mode)
|
||||||
@ -106,9 +98,5 @@ namespace osu.Game.Tests.Input
|
|||||||
|
|
||||||
private void frameworkSideModeIs(ConfineMouseMode mode)
|
private void frameworkSideModeIs(ConfineMouseMode mode)
|
||||||
=> AddAssert($"mode is {mode} framework-side", () => frameworkConfigManager.Get<ConfineMouseMode>(FrameworkSetting.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);
|
frameworkConfineMode = frameworkConfigManager.GetBindable<ConfineMouseMode>(FrameworkSetting.ConfineMouseMode);
|
||||||
frameworkWindowMode = frameworkConfigManager.GetBindable<WindowMode>(FrameworkSetting.WindowMode);
|
frameworkWindowMode = frameworkConfigManager.GetBindable<WindowMode>(FrameworkSetting.WindowMode);
|
||||||
frameworkWindowMode.BindValueChanged(_ => updateGameConfineMode());
|
frameworkWindowMode.BindValueChanged(_ => updateConfineMode());
|
||||||
|
|
||||||
osuConfineMode = osuConfigManager.GetBindable<OsuConfineMouseMode>(OsuSetting.ConfineMouseMode);
|
osuConfineMode = osuConfigManager.GetBindable<OsuConfineMouseMode>(OsuSetting.ConfineMouseMode);
|
||||||
localUserPlaying = game.LocalUserPlaying.GetBoundCopy();
|
localUserPlaying = game.LocalUserPlaying.GetBoundCopy();
|
||||||
|
|
||||||
osuConfineMode.ValueChanged += _ => updateFrameworkConfineMode();
|
osuConfineMode.ValueChanged += _ => updateConfineMode();
|
||||||
localUserPlaying.BindValueChanged(_ => updateFrameworkConfineMode(), true);
|
localUserPlaying.BindValueChanged(_ => updateConfineMode(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private LeasedBindable<OsuConfineMouseMode> leasedOsuConfineMode;
|
private void updateConfineMode()
|
||||||
|
|
||||||
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
|
// confine mode is unavailable on some platforms
|
||||||
if (frameworkConfineMode.Disabled)
|
if (frameworkConfineMode.Disabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (frameworkWindowMode.Value == WindowMode.Fullscreen)
|
||||||
|
{
|
||||||
|
frameworkConfineMode.Value = ConfineMouseMode.Fullscreen;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (osuConfineMode.Value)
|
switch (osuConfineMode.Value)
|
||||||
{
|
{
|
||||||
case OsuConfineMouseMode.Never:
|
case OsuConfineMouseMode.Never:
|
||||||
|
Loading…
Reference in New Issue
Block a user