1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-28 20:47:22 +08:00

Disable ability to adjust sensitivity when raw input is disabled

This commit is contained in:
Dean Herbert 2017-06-05 12:13:15 +09:00
parent 01243a6e75
commit ff0888449f

View File

@ -16,27 +16,29 @@ namespace osu.Game.Overlays.Settings.Sections.Input
private readonly BindableBool rawInputToggle = new BindableBool(); private readonly BindableBool rawInputToggle = new BindableBool();
private Bindable<string> activeInputHandlers; private Bindable<string> activeInputHandlers;
private SettingsSlider<double, SensitivitySlider> sensitivity;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuConfigManager osuConfig, FrameworkConfigManager config) private void load(OsuConfigManager osuConfig, FrameworkConfigManager config)
{ {
activeInputHandlers = config.GetBindable<string>(FrameworkSetting.ActiveInputHandlers); activeInputHandlers = config.GetBindable<string>(FrameworkSetting.ActiveInputHandlers);
rawInputToggle.Value = activeInputHandlers.Value.Contains("Raw"); rawInputToggle.Value = activeInputHandlers.Value.Contains("Raw");
rawInputToggle.ValueChanged += enabled =>
{
const string raw_mouse_handler = @"OpenTKRawMouseHandler";
const string standard_mouse_handler = @"OpenTKMouseHandler";
activeInputHandlers.Value = enabled ?
activeInputHandlers.Value.Replace(standard_mouse_handler, raw_mouse_handler) :
activeInputHandlers.Value.Replace(raw_mouse_handler, standard_mouse_handler);
};
Children = new Drawable[] Children = new Drawable[]
{ {
new SettingsCheckbox
{
LabelText = "Raw Input",
Bindable = rawInputToggle
},
sensitivity = new SettingsSlider<double, SensitivitySlider>
{
LabelText = "Cursor Sensitivity",
Bindable = config.GetBindable<double>(FrameworkSetting.CursorSensitivity)
},
new SettingsEnumDropdown<ConfineMouseMode> new SettingsEnumDropdown<ConfineMouseMode>
{ {
LabelText = "Confine mouse cursor", LabelText = "Confine mouse cursor to window",
Bindable = config.GetBindable<ConfineMouseMode>(FrameworkSetting.ConfineMouseMode), Bindable = config.GetBindable<ConfineMouseMode>(FrameworkSetting.ConfineMouseMode),
}, },
new SettingsCheckbox new SettingsCheckbox
@ -49,22 +51,27 @@ namespace osu.Game.Overlays.Settings.Sections.Input
LabelText = "Disable mouse buttons during gameplay", LabelText = "Disable mouse buttons during gameplay",
Bindable = osuConfig.GetBindable<bool>(OsuSetting.MouseDisableButtons) Bindable = osuConfig.GetBindable<bool>(OsuSetting.MouseDisableButtons)
}, },
new SettingsCheckbox
{
LabelText = "Raw Input",
Bindable = rawInputToggle
},
new SettingsSlider<double, SensitivitySlider>
{
LabelText = "Cursor Sensitivity",
Bindable = config.GetBindable<double>(FrameworkSetting.CursorSensitivity)
}
}; };
rawInputToggle.ValueChanged += enabled =>
{
// this is temporary until we support per-handler settings.
const string raw_mouse_handler = @"OpenTKRawMouseHandler";
const string standard_mouse_handler = @"OpenTKMouseHandler";
activeInputHandlers.Value = enabled ?
activeInputHandlers.Value.Replace(standard_mouse_handler, raw_mouse_handler) :
activeInputHandlers.Value.Replace(raw_mouse_handler, standard_mouse_handler);
sensitivity.Bindable.Disabled = !enabled;
};
rawInputToggle.TriggerChange();
} }
private class SensitivitySlider : OsuSliderBar<double> private class SensitivitySlider : OsuSliderBar<double>
{ {
public override string TooltipText => Current.Value.ToString(@"0.##x"); public override string TooltipText => Current.Disabled ? "Enable raw input to adjust sensitivity" : Current.Value.ToString(@"0.##x");
} }
} }
} }