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<WindowMode> windowMode;
private Bindable<bool> minimiseOnFocusLoss;
private SettingsEnumDropdown<OsuConfineMouseMode> confineMouseModeSetting;
private Bindable<bool> relativeMode;
@ -47,6 +48,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
relativeMode = mouseHandler.UseRelativeMode.GetBoundCopy();
windowMode = config.GetBindable<WindowMode>(FrameworkSetting.WindowMode);
minimiseOnFocusLoss = config.GetBindable<bool>(FrameworkSetting.MinimiseOnFocusLossInFullscreen);
Children = new Drawable[]
{
@ -98,21 +100,8 @@ namespace osu.Game.Overlays.Settings.Sections.Input
localSensitivity.BindValueChanged(val => handlerSensitivity.Value = val.NewValue);
windowMode.BindValueChanged(mode =>
{
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);
windowMode.BindValueChanged(_ => updateConfineMouseModeSettingVisibility());
minimiseOnFocusLoss.BindValueChanged(_ => updateConfineMouseModeSettingVisibility(), true);
highPrecisionMouse.Current.BindValueChanged(highPrecision =>
{
@ -126,6 +115,25 @@ namespace osu.Game.Overlays.Settings.Sections.Input
}, 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 SensitivitySetting()