From e7c9ad245e71bbbef17e07ed83c21f48d143011b Mon Sep 17 00:00:00 2001 From: EVAST9919 Date: Fri, 15 Sep 2017 09:24:31 +0300 Subject: [PATCH 01/18] Fix icons in main button system jumps on one side for a long time --- osu.Game/Screens/Menu/Button.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Menu/Button.cs b/osu.Game/Screens/Menu/Button.cs index 6952f66f95..ccd61643ce 100644 --- a/osu.Game/Screens/Menu/Button.cs +++ b/osu.Game/Screens/Menu/Button.cs @@ -121,13 +121,14 @@ namespace osu.Game.Screens.Menu }; } + private bool rightward; + protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes) { base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes); if (!IsHovered) return; - bool rightward = beatIndex % 2 == 1; double duration = timingPoint.BeatLength / 2; icon.RotateTo(rightward ? 10 : -10, duration * 2, Easing.InOutSine); @@ -139,6 +140,8 @@ namespace osu.Game.Screens.Menu i => i.MoveToY(0, duration, Easing.In), i => i.ScaleTo(new Vector2(1, 0.9f), duration, Easing.In) ); + + rightward = !rightward; } protected override bool OnHover(InputState state) @@ -152,7 +155,7 @@ namespace osu.Game.Screens.Menu double duration = TimeUntilNextBeat; icon.ClearTransforms(); - icon.RotateTo(10, duration, Easing.InOutSine); + icon.RotateTo(rightward ? -10 : 10, duration, Easing.InOutSine); icon.ScaleTo(new Vector2(1, 0.9f), duration, Easing.Out); return true; } From e8462ac134d0026f65f419c570912cdd4cbead8a Mon Sep 17 00:00:00 2001 From: gabixdev Date: Sun, 17 Sep 2017 00:47:55 +0200 Subject: [PATCH 02/18] 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) + }, + }; + } } } From bfe1febef211fe85bc046f51e79c36baa8cb1def Mon Sep 17 00:00:00 2001 From: gabixdev Date: Sun, 17 Sep 2017 01:00:44 +0200 Subject: [PATCH 03/18] Fix field access + remove unneeded this --- osu.Game/Graphics/Cursor/MenuCursor.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/Cursor/MenuCursor.cs b/osu.Game/Graphics/Cursor/MenuCursor.cs index c20bcce1a4..e3d30c5a7c 100644 --- a/osu.Game/Graphics/Cursor/MenuCursor.cs +++ b/osu.Game/Graphics/Cursor/MenuCursor.cs @@ -108,7 +108,7 @@ namespace osu.Game.Graphics.Cursor { private Container cursorContainer; private Bindable cursorScale; - public Bindable cursorRotate; + private Bindable cursorRotate; private const float base_scale = 0.15f; @@ -151,7 +151,7 @@ namespace osu.Game.Graphics.Cursor cursorScale.TriggerChange(); cursorRotate = config.GetBindable (OsuSetting.CursorRotation); - cursorRotate.ValueChanged += newValue => this.DragRotating = newValue; + cursorRotate.ValueChanged += newValue => DragRotating = newValue; cursorRotate.TriggerChange(); } } From 846838c621afa90299a0643a19f34b3eaec80f89 Mon Sep 17 00:00:00 2001 From: gabixdev Date: Sun, 17 Sep 2017 01:14:33 +0200 Subject: [PATCH 04/18] Move to MenuCursor --- osu.Game/Graphics/Cursor/MenuCursor.cs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/osu.Game/Graphics/Cursor/MenuCursor.cs b/osu.Game/Graphics/Cursor/MenuCursor.cs index e3d30c5a7c..bfa7b30fc2 100644 --- a/osu.Game/Graphics/Cursor/MenuCursor.cs +++ b/osu.Game/Graphics/Cursor/MenuCursor.cs @@ -20,13 +20,16 @@ namespace osu.Game.Graphics.Cursor { protected override Drawable CreateCursor() => new Cursor(); + private Bindable cursorRotate; + private bool dragRotating; + private bool dragging; private bool startRotation; protected override bool OnMouseMove(InputState state) { - if (((Cursor)ActiveCursor).DragRotating) { + if (dragRotating) { if (dragging) { Debug.Assert (state.Mouse.PositionMouseDown != null); @@ -104,18 +107,23 @@ namespace osu.Game.Graphics.Cursor ActiveCursor.ScaleTo(0, 500, Easing.In); } + [BackgroundDependencyLoader] + private void load(OsuConfigManager config, TextureStore textures, OsuColour colour) + { + cursorRotate = config.GetBindable (OsuSetting.CursorRotation); + cursorRotate.ValueChanged += newValue => dragRotating = newValue; + cursorRotate.TriggerChange(); + } + public class Cursor : Container { private Container cursorContainer; private Bindable cursorScale; - private Bindable cursorRotate; private const float base_scale = 0.15f; public Sprite AdditiveLayer; - public bool DragRotating; - public Cursor() { AutoSizeAxes = Axes.Both; @@ -149,10 +157,6 @@ 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 => DragRotating = newValue; - cursorRotate.TriggerChange(); } } } From a8ada75633265a78cb1350336ed0d5f7c4db21a8 Mon Sep 17 00:00:00 2001 From: gabixdev Date: Sun, 17 Sep 2017 01:28:02 +0200 Subject: [PATCH 05/18] CODE STYLE XD --- osu.Game/Graphics/Cursor/MenuCursor.cs | 39 ++++++++++++-------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/osu.Game/Graphics/Cursor/MenuCursor.cs b/osu.Game/Graphics/Cursor/MenuCursor.cs index bfa7b30fc2..9f8808539d 100644 --- a/osu.Game/Graphics/Cursor/MenuCursor.cs +++ b/osu.Game/Graphics/Cursor/MenuCursor.cs @@ -21,7 +21,6 @@ namespace osu.Game.Graphics.Cursor protected override Drawable CreateCursor() => new Cursor(); private Bindable cursorRotate; - private bool dragRotating; private bool dragging; @@ -29,28 +28,27 @@ namespace osu.Game.Graphics.Cursor protected override bool OnMouseMove(InputState state) { - if (dragRotating) { - if (dragging) { - Debug.Assert (state.Mouse.PositionMouseDown != null); + if (cursorRotate && 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); } } @@ -108,10 +106,9 @@ namespace osu.Game.Graphics.Cursor } [BackgroundDependencyLoader] - private void load(OsuConfigManager config, TextureStore textures, OsuColour colour) + private void load(OsuConfigManager config) { cursorRotate = config.GetBindable (OsuSetting.CursorRotation); - cursorRotate.ValueChanged += newValue => dragRotating = newValue; cursorRotate.TriggerChange(); } From 48008cd7e655673a0b8f87e4bd2c4e51ade8ca6a Mon Sep 17 00:00:00 2001 From: gabixdev Date: Sun, 17 Sep 2017 01:34:56 +0200 Subject: [PATCH 06/18] ... --- osu.Game/Graphics/Cursor/MenuCursor.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Graphics/Cursor/MenuCursor.cs b/osu.Game/Graphics/Cursor/MenuCursor.cs index 9f8808539d..1b126edf4a 100644 --- a/osu.Game/Graphics/Cursor/MenuCursor.cs +++ b/osu.Game/Graphics/Cursor/MenuCursor.cs @@ -109,7 +109,6 @@ namespace osu.Game.Graphics.Cursor private void load(OsuConfigManager config) { cursorRotate = config.GetBindable (OsuSetting.CursorRotation); - cursorRotate.TriggerChange(); } public class Cursor : Container From a33dfbba25f41ad40a1adcc551d416f76849bac6 Mon Sep 17 00:00:00 2001 From: gabixdev Date: Sun, 17 Sep 2017 01:40:38 +0200 Subject: [PATCH 07/18] Code reformat --- osu.Game/Graphics/Cursor/MenuCursor.cs | 81 ++++++++++++-------------- osu.Game/osu.Game.csproj | 18 ++++-- 2 files changed, 50 insertions(+), 49 deletions(-) diff --git a/osu.Game/Graphics/Cursor/MenuCursor.cs b/osu.Game/Graphics/Cursor/MenuCursor.cs index 1b126edf4a..fe356b5dc1 100644 --- a/osu.Game/Graphics/Cursor/MenuCursor.cs +++ b/osu.Game/Graphics/Cursor/MenuCursor.cs @@ -18,7 +18,7 @@ namespace osu.Game.Graphics.Cursor { public class MenuCursor : CursorContainer { - protected override Drawable CreateCursor() => new Cursor(); + protected override Drawable CreateCursor () => new Cursor(); private Bindable cursorRotate; @@ -26,10 +26,9 @@ namespace osu.Game.Graphics.Cursor private bool startRotation; - protected override bool OnMouseMove(InputState state) + protected override bool OnMouseMove (InputState state) { - if (cursorRotate && dragging) - { + if (cursorRotate && dragging) { Debug.Assert (state.Mouse.PositionMouseDown != null); // don't start rotating until we're moved a minimum distance away from the mouse down location, @@ -52,61 +51,60 @@ namespace osu.Game.Graphics.Cursor } } - return base.OnMouseMove(state); + return base.OnMouseMove (state); } - protected override bool OnDragStart(InputState state) + protected override bool OnDragStart (InputState state) { dragging = true; - return base.OnDragStart(state); + return base.OnDragStart (state); } - protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) + protected override bool OnMouseDown (InputState state, MouseDownEventArgs args) { - ActiveCursor.Scale = new Vector2(1); - ActiveCursor.ScaleTo(0.90f, 800, Easing.OutQuint); + ActiveCursor.Scale = new Vector2 (1); + ActiveCursor.ScaleTo (0.90f, 800, Easing.OutQuint); ((Cursor)ActiveCursor).AdditiveLayer.Alpha = 0; - ((Cursor)ActiveCursor).AdditiveLayer.FadeInFromZero(800, Easing.OutQuint); - return base.OnMouseDown(state, args); + ((Cursor)ActiveCursor).AdditiveLayer.FadeInFromZero (800, Easing.OutQuint); + return base.OnMouseDown (state, args); } - protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) + protected override bool OnMouseUp (InputState state, MouseUpEventArgs args) { - if (!state.Mouse.HasMainButtonPressed) - { + if (!state.Mouse.HasMainButtonPressed) { dragging = false; startRotation = false; - ((Cursor)ActiveCursor).AdditiveLayer.FadeOut(500, Easing.OutQuint); - ActiveCursor.RotateTo(0, 600 * (1 + Math.Abs(ActiveCursor.Rotation / 720)), Easing.OutElasticHalf); - ActiveCursor.ScaleTo(1, 500, Easing.OutElastic); + ((Cursor)ActiveCursor).AdditiveLayer.FadeOut (500, Easing.OutQuint); + ActiveCursor.RotateTo (0, 600 * (1 + Math.Abs (ActiveCursor.Rotation / 720)), Easing.OutElasticHalf); + ActiveCursor.ScaleTo (1, 500, Easing.OutElastic); } - return base.OnMouseUp(state, args); + return base.OnMouseUp (state, args); } - protected override bool OnClick(InputState state) + protected override bool OnClick (InputState state) { - ((Cursor)ActiveCursor).AdditiveLayer.FadeOutFromOne(500, Easing.OutQuint); + ((Cursor)ActiveCursor).AdditiveLayer.FadeOutFromOne (500, Easing.OutQuint); - return base.OnClick(state); + return base.OnClick (state); } - protected override void PopIn() + protected override void PopIn () { - ActiveCursor.FadeTo(1, 250, Easing.OutQuint); - ActiveCursor.ScaleTo(1, 400, Easing.OutQuint); + ActiveCursor.FadeTo (1, 250, Easing.OutQuint); + ActiveCursor.ScaleTo (1, 400, Easing.OutQuint); } - protected override void PopOut() + protected override void PopOut () { - ActiveCursor.FadeTo(0, 900, Easing.OutQuint); - ActiveCursor.ScaleTo(0, 500, Easing.In); + ActiveCursor.FadeTo (0, 900, Easing.OutQuint); + ActiveCursor.ScaleTo (0, 500, Easing.In); } [BackgroundDependencyLoader] - private void load(OsuConfigManager config) + private void load (OsuConfigManager config) { cursorRotate = config.GetBindable (OsuSetting.CursorRotation); } @@ -120,7 +118,7 @@ namespace osu.Game.Graphics.Cursor public Sprite AdditiveLayer; - public Cursor() + public Cursor () { AutoSizeAxes = Axes.Both; } @@ -128,30 +126,25 @@ namespace osu.Game.Graphics.Cursor [BackgroundDependencyLoader] private void load(OsuConfigManager config, TextureStore textures, OsuColour colour) { - Children = new Drawable[] - { - cursorContainer = new Container - { + Children = new Drawable[] { + cursorContainer = new Container { AutoSizeAxes = Axes.Both, - Children = new Drawable[] - { - new Sprite - { - Texture = textures.Get(@"Cursor/menu-cursor"), + Children = new Drawable[] { + new Sprite { + Texture = textures.Get (@"Cursor/menu-cursor"), }, - AdditiveLayer = new Sprite - { + AdditiveLayer = new Sprite { Blending = BlendingMode.Additive, Colour = colour.Pink, Alpha = 0, - Texture = textures.Get(@"Cursor/menu-cursor-additive"), + Texture = textures.Get (@"Cursor/menu-cursor-additive"), }, } } }; - cursorScale = config.GetBindable(OsuSetting.MenuCursorSize); - cursorScale.ValueChanged += newScale => cursorContainer.Scale = new Vector2((float)newScale * base_scale); + cursorScale = config.GetBindable (OsuSetting.MenuCursorSize); + cursorScale.ValueChanged += newScale => cursorContainer.Scale = new Vector2 ((float)newScale * base_scale); cursorScale.TriggerChange(); } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 92bcaf90f0..2bd7cbef77 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -1,5 +1,5 @@  - + Debug @@ -23,7 +23,6 @@ DEBUG;TRACE prompt 4 - false 6 @@ -33,7 +32,6 @@ TRACE prompt 4 - false @@ -561,11 +559,11 @@ - {c76bf5b3-985e-4d39-95fe-97c9c879b83a} + {C76BF5B3-985E-4D39-95FE-97C9C879B83A} osu.Framework - {d9a367c9-4c1a-489f-9b05-a0cea2b53b58} + {D9A367C9-4C1A-489F-9B05-A0CEA2B53B58} osu.Game.Resources @@ -585,4 +583,14 @@ --> + + + + + + + + + + \ No newline at end of file From 3c00a7cc513f925f9e0a0ceabe9ee7b9f001086d Mon Sep 17 00:00:00 2001 From: gabixdev Date: Sun, 17 Sep 2017 01:44:49 +0200 Subject: [PATCH 08/18] Reformat again... --- osu.Game/Graphics/Cursor/MenuCursor.cs | 94 ++++++++++++++------------ 1 file changed, 51 insertions(+), 43 deletions(-) diff --git a/osu.Game/Graphics/Cursor/MenuCursor.cs b/osu.Game/Graphics/Cursor/MenuCursor.cs index fe356b5dc1..ae37aca6a4 100644 --- a/osu.Game/Graphics/Cursor/MenuCursor.cs +++ b/osu.Game/Graphics/Cursor/MenuCursor.cs @@ -18,7 +18,7 @@ namespace osu.Game.Graphics.Cursor { public class MenuCursor : CursorContainer { - protected override Drawable CreateCursor () => new Cursor(); + protected override Drawable CreateCursor() => new Cursor(); private Bindable cursorRotate; @@ -26,18 +26,20 @@ namespace osu.Game.Graphics.Cursor private bool startRotation; - protected override bool OnMouseMove (InputState state) + protected override bool OnMouseMove(InputState state) { - if (cursorRotate && dragging) { - Debug.Assert (state.Mouse.PositionMouseDown != null); + if (cursorRotate && 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; + startRotation |= Vector2Extensions.Distance(state.Mouse.Position, state.Mouse.PositionMouseDown.Value) > 30; - if (startRotation) { + if (startRotation) + { Vector2 offset = state.Mouse.Position - state.Mouse.PositionMouseDown.Value; - float degrees = (float)MathHelper.RadiansToDegrees (Math.Atan2 (-offset.X, offset.Y)) + 24.3f; + 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; @@ -47,66 +49,67 @@ namespace osu.Game.Graphics.Cursor diff -= 360; degrees = ActiveCursor.Rotation + diff; - ActiveCursor.RotateTo (degrees, 600, Easing.OutQuint); + ActiveCursor.RotateTo(degrees, 600, Easing.OutQuint); } } - return base.OnMouseMove (state); + return base.OnMouseMove(state); } - protected override bool OnDragStart (InputState state) + protected override bool OnDragStart(InputState state) { dragging = true; - return base.OnDragStart (state); + return base.OnDragStart(state); } - protected override bool OnMouseDown (InputState state, MouseDownEventArgs args) + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) { - ActiveCursor.Scale = new Vector2 (1); - ActiveCursor.ScaleTo (0.90f, 800, Easing.OutQuint); + ActiveCursor.Scale = new Vector2(1); + ActiveCursor.ScaleTo(0.90f, 800, Easing.OutQuint); ((Cursor)ActiveCursor).AdditiveLayer.Alpha = 0; - ((Cursor)ActiveCursor).AdditiveLayer.FadeInFromZero (800, Easing.OutQuint); - return base.OnMouseDown (state, args); + ((Cursor)ActiveCursor).AdditiveLayer.FadeInFromZero(800, Easing.OutQuint); + return base.OnMouseDown(state, args); } - protected override bool OnMouseUp (InputState state, MouseUpEventArgs args) + protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) { - if (!state.Mouse.HasMainButtonPressed) { + if (!state.Mouse.HasMainButtonPressed) + { dragging = false; startRotation = false; - ((Cursor)ActiveCursor).AdditiveLayer.FadeOut (500, Easing.OutQuint); - ActiveCursor.RotateTo (0, 600 * (1 + Math.Abs (ActiveCursor.Rotation / 720)), Easing.OutElasticHalf); - ActiveCursor.ScaleTo (1, 500, Easing.OutElastic); + ((Cursor)ActiveCursor).AdditiveLayer.FadeOut(500, Easing.OutQuint); + ActiveCursor.RotateTo(0, 600 * (1 + Math.Abs(ActiveCursor.Rotation / 720)), Easing.OutElasticHalf); + ActiveCursor.ScaleTo(1, 500, Easing.OutElastic); } - return base.OnMouseUp (state, args); + return base.OnMouseUp(state, args); } - protected override bool OnClick (InputState state) + protected override bool OnClick(InputState state) { - ((Cursor)ActiveCursor).AdditiveLayer.FadeOutFromOne (500, Easing.OutQuint); + ((Cursor)ActiveCursor).AdditiveLayer.FadeOutFromOne(500, Easing.OutQuint); - return base.OnClick (state); + return base.OnClick(state); } - protected override void PopIn () + protected override void PopIn() { - ActiveCursor.FadeTo (1, 250, Easing.OutQuint); - ActiveCursor.ScaleTo (1, 400, Easing.OutQuint); + ActiveCursor.FadeTo(1, 250, Easing.OutQuint); + ActiveCursor.ScaleTo(1, 400, Easing.OutQuint); } - protected override void PopOut () + protected override void PopOut() { - ActiveCursor.FadeTo (0, 900, Easing.OutQuint); - ActiveCursor.ScaleTo (0, 500, Easing.In); + ActiveCursor.FadeTo(0, 900, Easing.OutQuint); + ActiveCursor.ScaleTo(0, 500, Easing.In); } [BackgroundDependencyLoader] - private void load (OsuConfigManager config) + private void load(OsuConfigManager config) { - cursorRotate = config.GetBindable (OsuSetting.CursorRotation); + cursorRotate = config.GetBindable(OsuSetting.CursorRotation); } public class Cursor : Container @@ -118,7 +121,7 @@ namespace osu.Game.Graphics.Cursor public Sprite AdditiveLayer; - public Cursor () + public Cursor() { AutoSizeAxes = Axes.Both; } @@ -126,25 +129,30 @@ namespace osu.Game.Graphics.Cursor [BackgroundDependencyLoader] private void load(OsuConfigManager config, TextureStore textures, OsuColour colour) { - Children = new Drawable[] { - cursorContainer = new Container { + Children = new Drawable[] + { + cursorContainer = new Container + { AutoSizeAxes = Axes.Both, - Children = new Drawable[] { - new Sprite { - Texture = textures.Get (@"Cursor/menu-cursor"), + Children = new Drawable[] + { + new Sprite + { + Texture = textures.Get(@"Cursor/menu-cursor"), }, - AdditiveLayer = new Sprite { + AdditiveLayer = new Sprite + { Blending = BlendingMode.Additive, Colour = colour.Pink, Alpha = 0, - Texture = textures.Get (@"Cursor/menu-cursor-additive"), + Texture = textures.Get(@"Cursor/menu-cursor-additive"), }, } } }; - cursorScale = config.GetBindable (OsuSetting.MenuCursorSize); - cursorScale.ValueChanged += newScale => cursorContainer.Scale = new Vector2 ((float)newScale * base_scale); + cursorScale = config.GetBindable(OsuSetting.MenuCursorSize); + cursorScale.ValueChanged += newScale => cursorContainer.Scale = new Vector2((float)newScale * base_scale); cursorScale.TriggerChange(); } } From 387705b2b63ec0d709eddb15cf26db5b40ae9ce8 Mon Sep 17 00:00:00 2001 From: gabixdev Date: Sun, 17 Sep 2017 19:43:53 +0200 Subject: [PATCH 09/18] revert csproj --- osu.Game/osu.Game.csproj | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 2bd7cbef77..92bcaf90f0 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -1,5 +1,5 @@  - + Debug @@ -23,6 +23,7 @@ DEBUG;TRACE prompt 4 + false 6 @@ -32,6 +33,7 @@ TRACE prompt 4 + false @@ -559,11 +561,11 @@ - {C76BF5B3-985E-4D39-95FE-97C9C879B83A} + {c76bf5b3-985e-4d39-95fe-97c9c879b83a} osu.Framework - {D9A367C9-4C1A-489F-9B05-A0CEA2B53B58} + {d9a367c9-4c1a-489f-9b05-a0cea2b53b58} osu.Game.Resources @@ -583,14 +585,4 @@ --> - - - - - - - - - - \ No newline at end of file From 120446e4a72ddef607693884800d07b01547dfc1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 20 Sep 2017 14:31:17 +0900 Subject: [PATCH 10/18] Ensure only one dialog is being displayed by the SongSelect footer at a time Fixes #1208 --- osu.Game/Screens/Select/Footer.cs | 26 +++++++++++++++++++++++ osu.Game/Screens/Select/PlaySongSelect.cs | 2 +- osu.Game/Screens/Select/SongSelect.cs | 2 +- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Select/Footer.cs b/osu.Game/Screens/Select/Footer.cs index bb6d16da0f..6636dbde76 100644 --- a/osu.Game/Screens/Select/Footer.cs +++ b/osu.Game/Screens/Select/Footer.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Collections.Generic; using System.Linq; using OpenTK; using OpenTK.Graphics; @@ -58,6 +59,31 @@ namespace osu.Game.Screens.Select Action = action, }); + private readonly List overlays = new List(); + + /// Text on the button. + /// Colour of the button. + /// Hotkey of the button. + /// The to be toggled by this button. + /// + /// Higher depth to be put on the left, and lower to be put on the right. + /// Notice this is different to ! + /// + public void AddButton(string text, Color4 colour, OverlayContainer overlay, Key? hotkey = null, float depth = 0) + { + overlays.Add(overlay); + AddButton(text, colour, () => + { + foreach (var o in overlays) + { + if (o == overlay) + overlay.ToggleVisibility(); + else + overlay.Hide(); + } + }, hotkey, depth); + } + private void updateModeLight() => modeLight.FadeColour(buttons.FirstOrDefault(b => b.IsHovered)?.SelectedColour ?? Color4.Transparent, TRANSITION_LENGTH, Easing.OutQuint); public Footer() diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 7e03707d18..e0a3693371 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -45,7 +45,7 @@ namespace osu.Game.Screens.Select [BackgroundDependencyLoader] private void load(OsuColour colours) { - Footer.AddButton(@"mods", colours.Yellow, modSelect.ToggleVisibility, Key.F1, float.MaxValue); + Footer.AddButton(@"mods", colours.Yellow, modSelect, Key.F1, float.MaxValue); BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.fa_times_circle_o, colours.Purple, null, Key.Number1); BeatmapOptions.AddButton(@"Clear", @"local scores", FontAwesome.fa_eraser, colours.Purple, null, Key.Number2); diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 84457b77a7..836ed465c3 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -164,7 +164,7 @@ namespace osu.Game.Screens.Select if (Footer != null) { Footer.AddButton(@"random", colours.Green, triggerRandom, Key.F2); - Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3); + Footer.AddButton(@"options", colours.Blue, BeatmapOptions, Key.F3); BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, () => promptDelete(Beatmap.Value.BeatmapSetInfo), Key.Number4, float.MaxValue); } From 8438ea1267c28a2e86b210d099fb8a83dc904c6f Mon Sep 17 00:00:00 2001 From: gabixdev Date: Thu, 21 Sep 2017 22:11:35 +0200 Subject: [PATCH 11/18] Fix formatting ;_; --- osu.Game/Graphics/Cursor/MenuCursor.cs | 8 ++------ .../Overlays/Settings/Sections/Graphics/DetailSettings.cs | 1 - 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/osu.Game/Graphics/Cursor/MenuCursor.cs b/osu.Game/Graphics/Cursor/MenuCursor.cs index ae37aca6a4..da117a94c1 100644 --- a/osu.Game/Graphics/Cursor/MenuCursor.cs +++ b/osu.Game/Graphics/Cursor/MenuCursor.cs @@ -21,7 +21,6 @@ namespace osu.Game.Graphics.Cursor protected override Drawable CreateCursor() => new Cursor(); private Bindable cursorRotate; - private bool dragging; private bool startRotation; @@ -43,10 +42,8 @@ namespace osu.Game.Graphics.Cursor // Always rotate in the direction of least distance float diff = (degrees - ActiveCursor.Rotation) % 360; - if (diff < -180) - diff += 360; - if (diff > 180) - diff -= 360; + if (diff < -180) diff += 360; + if (diff > 180) diff -= 360; degrees = ActiveCursor.Rotation + diff; ActiveCursor.RotateTo(degrees, 600, Easing.OutQuint); @@ -116,7 +113,6 @@ namespace osu.Game.Graphics.Cursor { private Container cursorContainer; private Bindable cursorScale; - private const float base_scale = 0.15f; public Sprite AdditiveLayer; diff --git a/osu.Game/Overlays/Settings/Sections/Graphics/DetailSettings.cs b/osu.Game/Overlays/Settings/Sections/Graphics/DetailSettings.cs index 3d44a30254..0e348f3791 100644 --- a/osu.Game/Overlays/Settings/Sections/Graphics/DetailSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Graphics/DetailSettings.cs @@ -3,7 +3,6 @@ using osu.Framework.Allocation; using osu.Game.Configuration; - namespace osu.Game.Overlays.Settings.Sections.Graphics { public class DetailSettings : SettingsSubsection From e04526222cbf4f4024f680855b329b3251b84340 Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Fri, 22 Sep 2017 22:47:26 +0200 Subject: [PATCH 12/18] URL encode beatmap filename --- osu.Game/Online/API/Requests/GetBeatmapDetailsRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Online/API/Requests/GetBeatmapDetailsRequest.cs b/osu.Game/Online/API/Requests/GetBeatmapDetailsRequest.cs index 15e20a3d55..934ef7ffa2 100644 --- a/osu.Game/Online/API/Requests/GetBeatmapDetailsRequest.cs +++ b/osu.Game/Online/API/Requests/GetBeatmapDetailsRequest.cs @@ -10,7 +10,7 @@ namespace osu.Game.Online.API.Requests { private readonly BeatmapInfo beatmap; - private string lookupString => beatmap.OnlineBeatmapID > 0 ? beatmap.OnlineBeatmapID.ToString() : $@"lookup?checksum={beatmap.Hash}&filename={beatmap.Path}"; + private string lookupString => beatmap.OnlineBeatmapID > 0 ? beatmap.OnlineBeatmapID.ToString() : $@"lookup?checksum={beatmap.Hash}&filename={System.Uri.EscapeUriString(beatmap.Path)}"; public GetBeatmapDetailsRequest(BeatmapInfo beatmap) { From 442259d9e0b66d6a14a05bbd4ec36aee229f996b Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sat, 23 Sep 2017 19:47:23 +0800 Subject: [PATCH 13/18] Fix overlay toggling in song select. --- osu.Game/Screens/Select/Footer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Select/Footer.cs b/osu.Game/Screens/Select/Footer.cs index 6636dbde76..00f311e522 100644 --- a/osu.Game/Screens/Select/Footer.cs +++ b/osu.Game/Screens/Select/Footer.cs @@ -77,9 +77,9 @@ namespace osu.Game.Screens.Select foreach (var o in overlays) { if (o == overlay) - overlay.ToggleVisibility(); + o.ToggleVisibility(); else - overlay.Hide(); + o.Hide(); } }, hotkey, depth); } From d277952e0f72a7f3d78837d99627b002c4e5e0e2 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sun, 24 Sep 2017 00:42:46 +0800 Subject: [PATCH 14/18] Use DateTimeOffset.ToUnixTime --- osu.Game/Online/API/APIRequest.cs | 4 ++-- osu.Game/Online/API/OAuthToken.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Online/API/APIRequest.cs b/osu.Game/Online/API/APIRequest.cs index 307afb2d2b..bf70529ead 100644 --- a/osu.Game/Online/API/APIRequest.cs +++ b/osu.Game/Online/API/APIRequest.cs @@ -70,7 +70,7 @@ namespace osu.Game.Online.API protected virtual string Uri => $@"{API.Endpoint}/api/v2/{Target}"; - private double remainingTime => Math.Max(0, Timeout - (DateTime.Now.TotalMilliseconds() - (startTime ?? 0))); + private double remainingTime => Math.Max(0, Timeout - (DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() - (startTime ?? 0))); public bool ExceededTimeout => remainingTime == 0; @@ -96,7 +96,7 @@ namespace osu.Game.Online.API return; if (startTime == null) - startTime = DateTime.Now.TotalMilliseconds(); + startTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); if (remainingTime <= 0) throw new TimeoutException(@"API request timeout hit"); diff --git a/osu.Game/Online/API/OAuthToken.cs b/osu.Game/Online/API/OAuthToken.cs index 1788adbf56..477bcdd9b8 100644 --- a/osu.Game/Online/API/OAuthToken.cs +++ b/osu.Game/Online/API/OAuthToken.cs @@ -22,12 +22,12 @@ namespace osu.Game.Online.API { get { - return AccessTokenExpiry - DateTime.Now.ToUnixTimestamp(); + return AccessTokenExpiry - DateTimeOffset.UtcNow.ToUnixTimeSeconds(); } set { - AccessTokenExpiry = DateTime.Now.AddSeconds(value).ToUnixTimestamp(); + AccessTokenExpiry = DateTimeOffset.Now.AddSeconds(value).ToUnixTimeSeconds(); } } From c5aebf6401fd9c28002c4fdeaaf6ef8e9edfaad2 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sun, 24 Sep 2017 03:23:31 +0800 Subject: [PATCH 15/18] Use TimeSpan to represent time. --- osu.Game/Online/API/APIRequest.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/osu.Game/Online/API/APIRequest.cs b/osu.Game/Online/API/APIRequest.cs index bf70529ead..a354d77bc5 100644 --- a/osu.Game/Online/API/APIRequest.cs +++ b/osu.Game/Online/API/APIRequest.cs @@ -70,13 +70,11 @@ namespace osu.Game.Online.API protected virtual string Uri => $@"{API.Endpoint}/api/v2/{Target}"; - private double remainingTime => Math.Max(0, Timeout - (DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() - (startTime ?? 0))); + private double remainingTime => Math.Max(0, Timeout - (DateTimeOffset.UtcNow - (startTime ?? DateTimeOffset.MinValue)).TotalMilliseconds); public bool ExceededTimeout => remainingTime == 0; - private double? startTime; - - public double StartTime => startTime ?? -1; + private DateTimeOffset? startTime; protected APIAccess API; protected WebRequest WebRequest; @@ -96,7 +94,7 @@ namespace osu.Game.Online.API return; if (startTime == null) - startTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + startTime = DateTimeOffset.UtcNow; if (remainingTime <= 0) throw new TimeoutException(@"API request timeout hit"); From 87c8278139127acdba2fddc5e4416c8a33317d6e Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sun, 24 Sep 2017 03:45:46 +0800 Subject: [PATCH 16/18] Use Array.Empty. --- osu.Game/IO/Legacy/SerializationReader.cs | 4 ++-- osu.Game/Overlays/Mods/ModButton.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/IO/Legacy/SerializationReader.cs b/osu.Game/IO/Legacy/SerializationReader.cs index bad143fa6c..c7ea884821 100644 --- a/osu.Game/IO/Legacy/SerializationReader.cs +++ b/osu.Game/IO/Legacy/SerializationReader.cs @@ -49,7 +49,7 @@ namespace osu.Game.IO.Legacy int len = ReadInt32(); if (len > 0) return ReadBytes(len); if (len < 0) return null; - return new byte[0]; + return Array.Empty(); } /// Reads a char array from the buffer, handling nulls and the array length. @@ -58,7 +58,7 @@ namespace osu.Game.IO.Legacy int len = ReadInt32(); if (len > 0) return ReadChars(len); if (len < 0) return null; - return new char[0]; + return Array.Empty(); } /// Reads a DateTime from the buffer. diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index 3ca4a204a5..6bfe70d873 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -127,7 +127,7 @@ namespace osu.Game.Overlays.Mods if (mod == null) { - Mods = new Mod[0]; + Mods = Array.Empty(); Alpha = 0; } else From 2b11ecec1371088a5ebc4049004c5ff7ad0c4cf2 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sun, 24 Sep 2017 06:03:52 +0800 Subject: [PATCH 17/18] Remove usings to extensions. --- osu.Game/Online/API/APIRequest.cs | 1 - osu.Game/Online/API/OAuthToken.cs | 1 - 2 files changed, 2 deletions(-) diff --git a/osu.Game/Online/API/APIRequest.cs b/osu.Game/Online/API/APIRequest.cs index a354d77bc5..37903f924f 100644 --- a/osu.Game/Online/API/APIRequest.cs +++ b/osu.Game/Online/API/APIRequest.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using osu.Framework.Extensions; using osu.Framework.IO.Network; namespace osu.Game.Online.API diff --git a/osu.Game/Online/API/OAuthToken.cs b/osu.Game/Online/API/OAuthToken.cs index 477bcdd9b8..2abd7b6c1f 100644 --- a/osu.Game/Online/API/OAuthToken.cs +++ b/osu.Game/Online/API/OAuthToken.cs @@ -4,7 +4,6 @@ using System; using System.Globalization; using Newtonsoft.Json; -using osu.Framework.Extensions; namespace osu.Game.Online.API { From b6a6042b5c9c6077e5c83f7f0e8806f1be0acdc1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 25 Sep 2017 13:09:06 +0800 Subject: [PATCH 18/18] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index e1352a8b0b..5f3a7fe4d0 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit e1352a8b0b5d1ba8acd9335a56c714d2ccc2f6a6 +Subproject commit 5f3a7fe4d0537820a33b817a41623b4b22a3ec59