1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-19 12:22:57 +08:00

Update confine mode settings checkbox to match the new ConfineMouseTracker logic

Not too happy with the duplicated logic, but settings can't depend on `ConfineMouseTracker`
for testability reasons.
This commit is contained in:
Susko3 2023-12-27 16:54:01 +01:00
parent 0fde9cd6ae
commit a6bed04e50

View File

@ -28,6 +28,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
private Bindable<double> localSensitivity; private Bindable<double> localSensitivity;
private Bindable<WindowMode> windowMode; private Bindable<WindowMode> windowMode;
private Bindable<bool> minimiseOnFocusLoss;
private SettingsEnumDropdown<OsuConfineMouseMode> confineMouseModeSetting; private SettingsEnumDropdown<OsuConfineMouseMode> confineMouseModeSetting;
private Bindable<bool> relativeMode; private Bindable<bool> relativeMode;
@ -47,6 +48,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
relativeMode = mouseHandler.UseRelativeMode.GetBoundCopy(); relativeMode = mouseHandler.UseRelativeMode.GetBoundCopy();
windowMode = config.GetBindable<WindowMode>(FrameworkSetting.WindowMode); windowMode = config.GetBindable<WindowMode>(FrameworkSetting.WindowMode);
minimiseOnFocusLoss = config.GetBindable<bool>(FrameworkSetting.MinimiseOnFocusLossInFullscreen);
Children = new Drawable[] Children = new Drawable[]
{ {
@ -98,21 +100,8 @@ namespace osu.Game.Overlays.Settings.Sections.Input
localSensitivity.BindValueChanged(val => handlerSensitivity.Value = val.NewValue); localSensitivity.BindValueChanged(val => handlerSensitivity.Value = val.NewValue);
windowMode.BindValueChanged(mode => windowMode.BindValueChanged(_ => updateConfineMouseModeSettingVisibility());
{ minimiseOnFocusLoss.BindValueChanged(_ => updateConfineMouseModeSettingVisibility(), true);
bool isFullscreen = mode.NewValue == WindowMode.Fullscreen;
if (isFullscreen)
{
confineMouseModeSetting.Current.Disabled = true;
confineMouseModeSetting.TooltipText = MouseSettingsStrings.NotApplicableFullscreen;
}
else
{
confineMouseModeSetting.Current.Disabled = false;
confineMouseModeSetting.TooltipText = string.Empty;
}
}, true);
highPrecisionMouse.Current.BindValueChanged(highPrecision => highPrecisionMouse.Current.BindValueChanged(highPrecision =>
{ {
@ -126,6 +115,25 @@ namespace osu.Game.Overlays.Settings.Sections.Input
}, true); }, true);
} }
/// <summary>
/// Updates disabled state and tooltip of <see cref="confineMouseModeSetting"/> to match when <see cref="ConfineMouseTracker"/> is overriding the confine mode.
/// </summary>
private void updateConfineMouseModeSettingVisibility()
{
bool confineModeOverriden = windowMode.Value == WindowMode.Fullscreen && minimiseOnFocusLoss.Value;
if (confineModeOverriden)
{
confineMouseModeSetting.Current.Disabled = true;
confineMouseModeSetting.TooltipText = MouseSettingsStrings.NotApplicableFullscreen;
}
else
{
confineMouseModeSetting.Current.Disabled = false;
confineMouseModeSetting.TooltipText = string.Empty;
}
}
public partial class SensitivitySetting : SettingsSlider<double, SensitivitySlider> public partial class SensitivitySetting : SettingsSlider<double, SensitivitySlider>
{ {
public SensitivitySetting() public SensitivitySetting()