mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:27:29 +08:00
Merge pull request #11101 from bdach/confine-mode-dropdown-fullscreen
Hide confine mode dropdown when full-screen
This commit is contained in:
commit
56699df0cf
102
osu.Game.Tests/Input/ConfineMouseTrackerTest.cs
Normal file
102
osu.Game.Tests/Input/ConfineMouseTrackerTest.cs
Normal file
@ -0,0 +1,102 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Input;
|
||||
using osu.Game.Tests.Visual.Navigation;
|
||||
|
||||
namespace osu.Game.Tests.Input
|
||||
{
|
||||
[HeadlessTest]
|
||||
public class ConfineMouseTrackerTest : OsuGameTestScene
|
||||
{
|
||||
[Resolved]
|
||||
private FrameworkConfigManager frameworkConfigManager { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private OsuConfigManager osuConfigManager { get; set; }
|
||||
|
||||
[TestCase(WindowMode.Windowed)]
|
||||
[TestCase(WindowMode.Borderless)]
|
||||
public void TestDisableConfining(WindowMode windowMode)
|
||||
{
|
||||
setWindowModeTo(windowMode);
|
||||
setGameSideModeTo(OsuConfineMouseMode.Never);
|
||||
|
||||
setLocalUserPlayingTo(false);
|
||||
frameworkSideModeIs(ConfineMouseMode.Never);
|
||||
|
||||
setLocalUserPlayingTo(true);
|
||||
frameworkSideModeIs(ConfineMouseMode.Never);
|
||||
}
|
||||
|
||||
[TestCase(WindowMode.Windowed)]
|
||||
[TestCase(WindowMode.Borderless)]
|
||||
public void TestConfiningDuringGameplay(WindowMode windowMode)
|
||||
{
|
||||
setWindowModeTo(windowMode);
|
||||
setGameSideModeTo(OsuConfineMouseMode.DuringGameplay);
|
||||
|
||||
setLocalUserPlayingTo(false);
|
||||
frameworkSideModeIs(ConfineMouseMode.Never);
|
||||
|
||||
setLocalUserPlayingTo(true);
|
||||
frameworkSideModeIs(ConfineMouseMode.Always);
|
||||
}
|
||||
|
||||
[TestCase(WindowMode.Windowed)]
|
||||
[TestCase(WindowMode.Borderless)]
|
||||
public void TestConfineAlwaysUserSetting(WindowMode windowMode)
|
||||
{
|
||||
setWindowModeTo(windowMode);
|
||||
setGameSideModeTo(OsuConfineMouseMode.Always);
|
||||
|
||||
setLocalUserPlayingTo(false);
|
||||
frameworkSideModeIs(ConfineMouseMode.Always);
|
||||
|
||||
setLocalUserPlayingTo(true);
|
||||
frameworkSideModeIs(ConfineMouseMode.Always);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestConfineAlwaysInFullscreen()
|
||||
{
|
||||
setGameSideModeTo(OsuConfineMouseMode.Never);
|
||||
|
||||
setWindowModeTo(WindowMode.Fullscreen);
|
||||
|
||||
setLocalUserPlayingTo(false);
|
||||
frameworkSideModeIs(ConfineMouseMode.Fullscreen);
|
||||
|
||||
setLocalUserPlayingTo(true);
|
||||
frameworkSideModeIs(ConfineMouseMode.Fullscreen);
|
||||
|
||||
setWindowModeTo(WindowMode.Windowed);
|
||||
|
||||
// old state is restored
|
||||
gameSideModeIs(OsuConfineMouseMode.Never);
|
||||
frameworkSideModeIs(ConfineMouseMode.Never);
|
||||
}
|
||||
|
||||
private void setWindowModeTo(WindowMode mode)
|
||||
// needs to go through .GetBindable().Value instead of .Set() due to default overrides
|
||||
=> AddStep($"make window {mode}", () => frameworkConfigManager.GetBindable<WindowMode>(FrameworkSetting.WindowMode).Value = mode);
|
||||
|
||||
private void setGameSideModeTo(OsuConfineMouseMode mode)
|
||||
=> AddStep($"set {mode} game-side", () => Game.LocalConfig.Set(OsuSetting.ConfineMouseMode, mode));
|
||||
|
||||
private void setLocalUserPlayingTo(bool playing)
|
||||
=> AddStep($"local user {(playing ? "playing" : "not playing")}", () => Game.LocalUserPlaying.Value = playing);
|
||||
|
||||
private void gameSideModeIs(OsuConfineMouseMode mode)
|
||||
=> AddAssert($"mode is {mode} game-side", () => Game.LocalConfig.Get<OsuConfineMouseMode>(OsuSetting.ConfineMouseMode) == mode);
|
||||
|
||||
private void frameworkSideModeIs(ConfineMouseMode mode)
|
||||
=> AddAssert($"mode is {mode} framework-side", () => frameworkConfigManager.Get<ConfineMouseMode>(FrameworkSetting.ConfineMouseMode) == mode);
|
||||
}
|
||||
}
|
@ -20,6 +20,9 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
private Bindable<double> sensitivityBindable = new BindableDouble();
|
||||
private Bindable<string> ignoredInputHandlers;
|
||||
|
||||
private Bindable<WindowMode> windowMode;
|
||||
private SettingsEnumDropdown<OsuConfineMouseMode> confineMouseModeSetting;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager osuConfig, FrameworkConfigManager config)
|
||||
{
|
||||
@ -30,6 +33,9 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
configSensitivity.BindValueChanged(val => sensitivityBindable.Value = val.NewValue);
|
||||
sensitivityBindable.BindValueChanged(val => configSensitivity.Value = val.NewValue);
|
||||
|
||||
windowMode = config.GetBindable<WindowMode>(FrameworkSetting.WindowMode);
|
||||
windowMode.BindValueChanged(mode => confineMouseModeSetting.Alpha = mode.NewValue == WindowMode.Fullscreen ? 0 : 1);
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SettingsCheckbox
|
||||
@ -47,7 +53,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
LabelText = "Map absolute input to window",
|
||||
Current = config.GetBindable<bool>(FrameworkSetting.MapAbsoluteInputToWindow)
|
||||
},
|
||||
new SettingsEnumDropdown<OsuConfineMouseMode>
|
||||
confineMouseModeSetting = new SettingsEnumDropdown<OsuConfineMouseMode>
|
||||
{
|
||||
LabelText = "Confine mouse cursor to window",
|
||||
Current = osuConfig.GetBindable<OsuConfineMouseMode>(OsuSetting.ConfineMouseMode)
|
||||
|
Loading…
Reference in New Issue
Block a user