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