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
|
|
|
|
|
|
|
|
|
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;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Settings.Sections.Input
|
|
|
|
|
{
|
|
|
|
|
public class MouseSettings : SettingsSubsection
|
|
|
|
|
{
|
2021-03-12 17:38:16 +08:00
|
|
|
|
private readonly MouseHandler mouseHandler;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-03-12 17:38:16 +08:00
|
|
|
|
protected override string Header => "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;
|
|
|
|
|
|
|
|
|
|
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[]
|
|
|
|
|
{
|
|
|
|
|
new SettingsCheckbox
|
|
|
|
|
{
|
2021-03-12 17:38:16 +08:00
|
|
|
|
LabelText = "High precision mouse",
|
|
|
|
|
Current = relativeMode
|
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
|
|
|
|
{
|
2018-09-15 22:30:11 +08:00
|
|
|
|
LabelText = "Cursor sensitivity",
|
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
|
|
|
|
{
|
|
|
|
|
LabelText = "Confine mouse cursor to window",
|
2020-10-07 08:37:00 +08:00
|
|
|
|
Current = osuConfig.GetBindable<OsuConfineMouseMode>(OsuSetting.ConfineMouseMode)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
new SettingsCheckbox
|
|
|
|
|
{
|
|
|
|
|
LabelText = "Disable mouse wheel during gameplay",
|
2020-10-06 16:18:41 +08:00
|
|
|
|
Current = osuConfig.GetBindable<bool>(OsuSetting.MouseDisableWheel)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
new SettingsCheckbox
|
|
|
|
|
{
|
|
|
|
|
LabelText = "Disable mouse buttons during gameplay",
|
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
|
|
|
|
{
|
|
|
|
|
var disabled = localSensitivity.Disabled;
|
|
|
|
|
|
|
|
|
|
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 =>
|
|
|
|
|
{
|
|
|
|
|
var isFullscreen = mode.NewValue == WindowMode.Fullscreen;
|
|
|
|
|
|
|
|
|
|
if (isFullscreen)
|
|
|
|
|
{
|
|
|
|
|
confineMouseModeSetting.Current.Disabled = true;
|
|
|
|
|
confineMouseModeSetting.TooltipText = "Not applicable in full screen mode";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
confineMouseModeSetting.Current.Disabled = false;
|
|
|
|
|
confineMouseModeSetting.TooltipText = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
}, true);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class SensitivitySetting : SettingsSlider<double, SensitivitySlider>
|
|
|
|
|
{
|
|
|
|
|
public SensitivitySetting()
|
|
|
|
|
{
|
|
|
|
|
KeyboardStep = 0.01f;
|
2019-01-17 18:18:40 +08:00
|
|
|
|
TransferValueOnCommit = true;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class SensitivitySlider : OsuSliderBar<double>
|
|
|
|
|
{
|
2021-06-26 01:10:04 +08:00
|
|
|
|
public override LocalisableString TooltipText => Current.Disabled ? "enable high precision mouse to adjust sensitivity" : $"{base.TooltipText}x";
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|