From e8462ac134d0026f65f419c570912cdd4cbead8a Mon Sep 17 00:00:00 2001 From: gabixdev Date: Sun, 17 Sep 2017 00:47:55 +0200 Subject: [PATCH] Add option to disable cursor rotation. --- osu.Game/Configuration/OsuConfigManager.cs | 3 ++ osu.Game/Graphics/Cursor/MenuCursor.cs | 42 ++++++++++++------- .../Sections/Graphics/DetailSettings.cs | 16 +++++++ 3 files changed, 45 insertions(+), 16 deletions(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 44a6af841c..42474ce80b 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -54,6 +54,8 @@ namespace osu.Game.Configuration // Graphics Set(OsuSetting.ShowFpsDisplay, false); + Set(OsuSetting.CursorRotation, true); + Set(OsuSetting.MenuParallax, true); Set(OsuSetting.SnakingInSliders, true); @@ -96,6 +98,7 @@ namespace osu.Game.Configuration AudioOffset, MenuMusic, MenuVoice, + CursorRotation, MenuParallax, BeatmapDetailTab, Username, diff --git a/osu.Game/Graphics/Cursor/MenuCursor.cs b/osu.Game/Graphics/Cursor/MenuCursor.cs index 36f23d1ae9..c20bcce1a4 100644 --- a/osu.Game/Graphics/Cursor/MenuCursor.cs +++ b/osu.Game/Graphics/Cursor/MenuCursor.cs @@ -26,26 +26,28 @@ namespace osu.Game.Graphics.Cursor protected override bool OnMouseMove(InputState state) { - if (dragging) - { - Debug.Assert(state.Mouse.PositionMouseDown != null); + if (((Cursor)ActiveCursor).DragRotating) { + if (dragging) { + Debug.Assert (state.Mouse.PositionMouseDown != null); - // don't start rotating until we're moved a minimum distance away from the mouse down location, - // else it can have an annoying effect. - startRotation |= Vector2Extensions.Distance(state.Mouse.Position, state.Mouse.PositionMouseDown.Value) > 30; + // don't start rotating until we're moved a minimum distance away from the mouse down location, + // else it can have an annoying effect. + startRotation |= Vector2Extensions.Distance (state.Mouse.Position, state.Mouse.PositionMouseDown.Value) > 30; - if (startRotation) - { - Vector2 offset = state.Mouse.Position - state.Mouse.PositionMouseDown.Value; - float degrees = (float)MathHelper.RadiansToDegrees(Math.Atan2(-offset.X, offset.Y)) + 24.3f; + if (startRotation) { + Vector2 offset = state.Mouse.Position - state.Mouse.PositionMouseDown.Value; + float degrees = (float)MathHelper.RadiansToDegrees (Math.Atan2 (-offset.X, offset.Y)) + 24.3f; - // Always rotate in the direction of least distance - float diff = (degrees - ActiveCursor.Rotation) % 360; - if (diff < -180) diff += 360; - if (diff > 180) diff -= 360; - degrees = ActiveCursor.Rotation + diff; + // Always rotate in the direction of least distance + float diff = (degrees - ActiveCursor.Rotation) % 360; + if (diff < -180) + diff += 360; + if (diff > 180) + diff -= 360; + degrees = ActiveCursor.Rotation + diff; - ActiveCursor.RotateTo(degrees, 600, Easing.OutQuint); + ActiveCursor.RotateTo (degrees, 600, Easing.OutQuint); + } } } @@ -106,10 +108,14 @@ namespace osu.Game.Graphics.Cursor { private Container cursorContainer; private Bindable cursorScale; + public Bindable cursorRotate; + private const float base_scale = 0.15f; public Sprite AdditiveLayer; + public bool DragRotating; + public Cursor() { AutoSizeAxes = Axes.Both; @@ -143,6 +149,10 @@ namespace osu.Game.Graphics.Cursor cursorScale = config.GetBindable(OsuSetting.MenuCursorSize); cursorScale.ValueChanged += newScale => cursorContainer.Scale = new Vector2((float)newScale * base_scale); cursorScale.TriggerChange(); + + cursorRotate = config.GetBindable (OsuSetting.CursorRotation); + cursorRotate.ValueChanged += newValue => this.DragRotating = newValue; + cursorRotate.TriggerChange(); } } } diff --git a/osu.Game/Overlays/Settings/Sections/Graphics/DetailSettings.cs b/osu.Game/Overlays/Settings/Sections/Graphics/DetailSettings.cs index c068da8129..3d44a30254 100644 --- a/osu.Game/Overlays/Settings/Sections/Graphics/DetailSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Graphics/DetailSettings.cs @@ -1,10 +1,26 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Allocation; +using osu.Game.Configuration; + namespace osu.Game.Overlays.Settings.Sections.Graphics { public class DetailSettings : SettingsSubsection { protected override string Header => "Detail Settings"; + + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + Children = new[] + { + new SettingsCheckbox + { + LabelText = "Rotate cursor when dragging", + Bindable = config.GetBindable(OsuSetting.CursorRotation) + }, + }; + } } }