2019-01-24 08:43:03 +00:00
|
|
|
|
// 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.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2021-07-26 07:59:59 +00:00
|
|
|
|
using osu.Framework;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 10:04:31 +00:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Framework.Configuration;
|
|
|
|
|
using osu.Framework.Graphics;
|
2021-03-12 09:38:16 +00:00
|
|
|
|
using osu.Framework.Input.Handlers.Mouse;
|
2021-06-25 17:10:04 +00:00
|
|
|
|
using osu.Framework.Localisation;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Configuration;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2020-08-16 01:34:28 +00:00
|
|
|
|
using osu.Game.Input;
|
2021-07-15 03:50:34 +00:00
|
|
|
|
using osu.Game.Localisation;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Settings.Sections.Input
|
|
|
|
|
{
|
|
|
|
|
public class MouseSettings : SettingsSubsection
|
|
|
|
|
{
|
2021-03-12 09:38:16 +00:00
|
|
|
|
private readonly MouseHandler mouseHandler;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2021-07-15 03:50:34 +00:00
|
|
|
|
protected override LocalisableString Header => MouseSettingsStrings.Mouse;
|
2021-03-03 07:47:42 +00:00
|
|
|
|
|
2021-03-12 09:38:16 +00:00
|
|
|
|
private Bindable<double> handlerSensitivity;
|
2021-03-03 07:47:42 +00:00
|
|
|
|
|
2021-03-03 11:36:41 +00:00
|
|
|
|
private Bindable<double> localSensitivity;
|
2021-03-03 07:47:42 +00:00
|
|
|
|
|
2020-12-05 21:13:51 +00:00
|
|
|
|
private Bindable<WindowMode> windowMode;
|
|
|
|
|
private SettingsEnumDropdown<OsuConfineMouseMode> confineMouseModeSetting;
|
2021-03-12 09:38:16 +00:00
|
|
|
|
private Bindable<bool> relativeMode;
|
|
|
|
|
|
2021-07-26 07:59:59 +00:00
|
|
|
|
private SettingsCheckbox highPrecisionMouse;
|
|
|
|
|
|
2021-03-12 09:38:16 +00:00
|
|
|
|
public MouseSettings(MouseHandler mouseHandler)
|
|
|
|
|
{
|
|
|
|
|
this.mouseHandler = mouseHandler;
|
|
|
|
|
}
|
2020-12-05 21:13:51 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuConfigManager osuConfig, FrameworkConfigManager config)
|
|
|
|
|
{
|
2020-05-15 08:31:06 +00:00
|
|
|
|
// use local bindable to avoid changing enabled state of game host's bindable.
|
2021-03-12 09:38:16 +00:00
|
|
|
|
handlerSensitivity = mouseHandler.Sensitivity.GetBoundCopy();
|
|
|
|
|
localSensitivity = handlerSensitivity.GetUnboundCopy();
|
2021-03-03 07:47:42 +00:00
|
|
|
|
|
2021-03-12 09:38:16 +00:00
|
|
|
|
relativeMode = mouseHandler.UseRelativeMode.GetBoundCopy();
|
2021-03-03 07:47:42 +00:00
|
|
|
|
windowMode = config.GetBindable<WindowMode>(FrameworkSetting.WindowMode);
|
2020-05-15 08:31:06 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2021-07-26 07:59:59 +00:00
|
|
|
|
highPrecisionMouse = new SettingsCheckbox
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2021-07-15 04:07:35 +00:00
|
|
|
|
LabelText = MouseSettingsStrings.HighPrecisionMouse,
|
|
|
|
|
TooltipText = MouseSettingsStrings.HighPrecisionMouseTooltip,
|
2021-07-15 03:37:52 +00:00
|
|
|
|
Current = relativeMode,
|
2021-07-15 04:07:35 +00:00
|
|
|
|
Keywords = new[] { @"raw", @"input", @"relative", @"cursor" }
|
2018-04-13 09:19:50 +00:00
|
|
|
|
},
|
2020-05-16 02:03:27 +00:00
|
|
|
|
new SensitivitySetting
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2021-07-15 04:07:35 +00:00
|
|
|
|
LabelText = MouseSettingsStrings.CursorSensitivity,
|
2021-03-03 07:47:42 +00:00
|
|
|
|
Current = localSensitivity
|
2018-04-13 09:19:50 +00:00
|
|
|
|
},
|
2020-12-05 21:13:51 +00:00
|
|
|
|
confineMouseModeSetting = new SettingsEnumDropdown<OsuConfineMouseMode>
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2021-07-15 04:07:35 +00:00
|
|
|
|
LabelText = MouseSettingsStrings.ConfineMouseMode,
|
2020-10-07 00:37:00 +00:00
|
|
|
|
Current = osuConfig.GetBindable<OsuConfineMouseMode>(OsuSetting.ConfineMouseMode)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
},
|
|
|
|
|
new SettingsCheckbox
|
|
|
|
|
{
|
2021-07-15 04:07:35 +00:00
|
|
|
|
LabelText = MouseSettingsStrings.DisableMouseWheel,
|
2020-10-06 08:18:41 +00:00
|
|
|
|
Current = osuConfig.GetBindable<bool>(OsuSetting.MouseDisableWheel)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
},
|
|
|
|
|
new SettingsCheckbox
|
|
|
|
|
{
|
2021-07-15 04:07:35 +00:00
|
|
|
|
LabelText = MouseSettingsStrings.DisableMouseButtons,
|
2020-10-06 08:18:41 +00:00
|
|
|
|
Current = osuConfig.GetBindable<bool>(OsuSetting.MouseDisableButtons)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
},
|
|
|
|
|
};
|
2021-03-03 07:47:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
2021-03-12 09:38:16 +00:00
|
|
|
|
relativeMode.BindValueChanged(relative => localSensitivity.Disabled = !relative.NewValue, true);
|
|
|
|
|
|
|
|
|
|
handlerSensitivity.BindValueChanged(val =>
|
2021-03-04 12:00:46 +00:00
|
|
|
|
{
|
2021-10-27 04:04:41 +00:00
|
|
|
|
bool disabled = localSensitivity.Disabled;
|
2021-03-04 12:00:46 +00:00
|
|
|
|
|
|
|
|
|
localSensitivity.Disabled = false;
|
|
|
|
|
localSensitivity.Value = val.NewValue;
|
|
|
|
|
localSensitivity.Disabled = disabled;
|
|
|
|
|
}, true);
|
|
|
|
|
|
2021-03-12 09:38:16 +00:00
|
|
|
|
localSensitivity.BindValueChanged(val => handlerSensitivity.Value = val.NewValue);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2021-03-02 08:44:56 +00:00
|
|
|
|
windowMode.BindValueChanged(mode =>
|
|
|
|
|
{
|
2021-10-27 04:04:41 +00:00
|
|
|
|
bool isFullscreen = mode.NewValue == WindowMode.Fullscreen;
|
2021-03-02 08:44:56 +00:00
|
|
|
|
|
|
|
|
|
if (isFullscreen)
|
|
|
|
|
{
|
|
|
|
|
confineMouseModeSetting.Current.Disabled = true;
|
2021-07-15 04:07:35 +00:00
|
|
|
|
confineMouseModeSetting.TooltipText = MouseSettingsStrings.NotApplicableFullscreen;
|
2021-03-02 08:44:56 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
confineMouseModeSetting.Current.Disabled = false;
|
|
|
|
|
confineMouseModeSetting.TooltipText = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
}, true);
|
2021-07-26 07:59:59 +00:00
|
|
|
|
|
|
|
|
|
highPrecisionMouse.Current.BindValueChanged(highPrecision =>
|
|
|
|
|
{
|
2021-07-26 08:24:43 +00:00
|
|
|
|
if (RuntimeInfo.OS != RuntimeInfo.Platform.Windows)
|
2021-07-26 07:59:59 +00:00
|
|
|
|
{
|
|
|
|
|
if (highPrecision.NewValue)
|
2021-07-26 08:24:43 +00:00
|
|
|
|
highPrecisionMouse.WarningText = MouseSettingsStrings.HighPrecisionPlatformWarning;
|
2021-07-26 07:59:59 +00:00
|
|
|
|
else
|
|
|
|
|
highPrecisionMouse.WarningText = null;
|
|
|
|
|
}
|
|
|
|
|
}, true);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class SensitivitySetting : SettingsSlider<double, SensitivitySlider>
|
|
|
|
|
{
|
|
|
|
|
public SensitivitySetting()
|
|
|
|
|
{
|
|
|
|
|
KeyboardStep = 0.01f;
|
2019-01-17 10:18:40 +00:00
|
|
|
|
TransferValueOnCommit = true;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class SensitivitySlider : OsuSliderBar<double>
|
|
|
|
|
{
|
2021-07-15 04:07:35 +00:00
|
|
|
|
public override LocalisableString TooltipText => Current.Disabled ? MouseSettingsStrings.EnableHighPrecisionForSensitivityAdjust : $"{base.TooltipText}x";
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|