From 58dbc63c6e85fecf9f13aea709e1397bd790161b Mon Sep 17 00:00:00 2001 From: tgi74000 Date: Sun, 8 Apr 2018 15:24:34 +0200 Subject: [PATCH 1/6] Add HardRock position mangling for CatchTheBeat --- .../Mods/CatchModHardRock.cs | 77 ++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs b/osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs index ed33bf7124..5dadec9b15 100644 --- a/osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs +++ b/osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs @@ -1,13 +1,88 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.MathUtils; +using osu.Game.Rulesets.Catch.Objects; using osu.Game.Rulesets.Mods; +using System; namespace osu.Game.Rulesets.Catch.Mods { - public class CatchModHardRock : ModHardRock + public class CatchModHardRock : ModHardRock, IApplicableToHitObject { public override double ScoreMultiplier => 1.12; public override bool Ranked => true; + + private float lastStartX; + private int lastStartTime; + + public void ApplyToHitObject(CatchHitObject hitObject) + { + // Code from Stable, we keep calculation on a scale of 0 to 512 + float position = hitObject.X * 512; + int startTime = (int)hitObject.StartTime; + + if (lastStartX == 0) + { + lastStartX = position; + lastStartTime = startTime; + return; + } + + float diff = lastStartX - position; + int timeDiff = startTime - lastStartTime; + + if (timeDiff > 1000) + { + lastStartX = position; + lastStartTime = startTime; + return; + } + + if (diff == 0) + { + bool right = RNG.NextBool(); + + float rand = Math.Min(20, (float)RNG.NextDouble(0, timeDiff / 4)); + + if (right) + { + if (position + rand <= 512) + position += rand; + else + position -= rand; + } + else + { + if (position - rand >= 0) + position -= rand; + else + position += rand; + } + + hitObject.X = position / 512; + + return; + } + + if (Math.Abs(diff) < timeDiff / 3) + { + if (diff > 0) + { + if (position - diff > 0) + position -= diff; + } + else + { + if (position - diff < 512) + position -= diff; + } + } + + hitObject.X = position / 512; + + lastStartX = position; + lastStartTime = startTime; + } } } From b40af0848f5cb2b4579ac30730bbd7606c3e5ee2 Mon Sep 17 00:00:00 2001 From: tgi74000 Date: Sun, 8 Apr 2018 15:52:40 +0200 Subject: [PATCH 2/6] White space --- osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs b/osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs index 5dadec9b15..97b1645e85 100644 --- a/osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs +++ b/osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs @@ -12,7 +12,7 @@ namespace osu.Game.Rulesets.Catch.Mods { public override double ScoreMultiplier => 1.12; public override bool Ranked => true; - + private float lastStartX; private int lastStartTime; From 82d9504cbf866e601dd3e7c519113354f7433c36 Mon Sep 17 00:00:00 2001 From: tgi74000 Date: Mon, 9 Apr 2018 09:02:32 +0200 Subject: [PATCH 3/6] Changed relative position to [0, 1] --- osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs b/osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs index 97b1645e85..1656a5c40b 100644 --- a/osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs +++ b/osu.Game.Rulesets.Catch/Mods/CatchModHardRock.cs @@ -3,6 +3,7 @@ using osu.Framework.MathUtils; using osu.Game.Rulesets.Catch.Objects; +using osu.Game.Rulesets.Catch.UI; using osu.Game.Rulesets.Mods; using System; @@ -18,8 +19,7 @@ namespace osu.Game.Rulesets.Catch.Mods public void ApplyToHitObject(CatchHitObject hitObject) { - // Code from Stable, we keep calculation on a scale of 0 to 512 - float position = hitObject.X * 512; + float position = hitObject.X; int startTime = (int)hitObject.StartTime; if (lastStartX == 0) @@ -43,11 +43,11 @@ namespace osu.Game.Rulesets.Catch.Mods { bool right = RNG.NextBool(); - float rand = Math.Min(20, (float)RNG.NextDouble(0, timeDiff / 4)); + float rand = Math.Min(20, (float)RNG.NextDouble(0, timeDiff / 4d)) / CatchPlayfield.BASE_WIDTH; if (right) { - if (position + rand <= 512) + if (position + rand <= 1) position += rand; else position -= rand; @@ -60,12 +60,12 @@ namespace osu.Game.Rulesets.Catch.Mods position += rand; } - hitObject.X = position / 512; + hitObject.X = position; return; } - if (Math.Abs(diff) < timeDiff / 3) + if (Math.Abs(diff) < timeDiff / 3d) { if (diff > 0) { @@ -74,12 +74,12 @@ namespace osu.Game.Rulesets.Catch.Mods } else { - if (position - diff < 512) + if (position - diff < 1) position -= diff; } } - hitObject.X = position / 512; + hitObject.X = position; lastStartX = position; lastStartTime = startTime; From e3cd0ef20045dfd16874760d9215b1515878614e Mon Sep 17 00:00:00 2001 From: tgi74000 Date: Fri, 13 Apr 2018 11:09:49 +0200 Subject: [PATCH 4/6] Add right click scrolling in song select (and its option) --- osu.Game/Configuration/OsuConfigManager.cs | 5 +++- .../Sections/Gameplay/SongSelectSettings.cs | 5 ++++ osu.Game/Screens/Select/BeatmapCarousel.cs | 29 +++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 70260b349e..a3025a65f4 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -84,6 +84,8 @@ namespace osu.Game.Configuration Set(OsuSetting.Version, string.Empty); Set(OsuSetting.ScreenshotFormat, ScreenshotFormat.Jpg); + + Set(OsuSetting.SelectScrollRightClick, false); } public OsuConfigManager(Storage storage) : base(storage) @@ -128,6 +130,7 @@ namespace osu.Game.Configuration ShowConvertedBeatmaps, SpeedChangeVisualisation, Skin, - ScreenshotFormat + ScreenshotFormat, + SelectScrollRightClick } } diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/SongSelectSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/SongSelectSettings.cs index 4bbd87c7e6..e8d65a1ed3 100644 --- a/osu.Game/Overlays/Settings/Sections/Gameplay/SongSelectSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/SongSelectSettings.cs @@ -17,6 +17,11 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay { Children = new Drawable[] { + new SettingsCheckbox + { + LabelText = "Right click to scroll", + Bindable = config.GetBindable(OsuSetting.SelectScrollRightClick), + }, new SettingsCheckbox { LabelText = "Show converted beatmaps", diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 15f4d5cf96..5c3518b46c 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -97,6 +97,9 @@ namespace osu.Game.Screens.Select private readonly Container scrollableContent; + + public Bindable RightClickScrollingEnabled = new Bindable(); + public Bindable RandomAlgorithm = new Bindable(); private readonly List previouslyVisitedRandomSets = new List(); private readonly Stack randomSelectedBeatmaps = new Stack(); @@ -121,6 +124,7 @@ namespace osu.Game.Screens.Select private void load(OsuConfigManager config) { config.BindWith(OsuSetting.RandomSelectAlgorithm, RandomAlgorithm); + config.BindWith(OsuSetting.SelectScrollRightClick, RightClickScrollingEnabled); } public void RemoveBeatmapSet(BeatmapSetInfo beatmapSet) @@ -398,6 +402,31 @@ namespace osu.Game.Screens.Select return true; } + private bool rightClickScrolling = false; + + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) + { + bool result = base.OnMouseDown(state, args); + + if (RightClickScrollingEnabled.Value && !result && args.Button == MouseButton.Right) + { + rightClickScrolling = true; + return true; + } + + return result; + } + + protected override bool OnMouseMove(InputState state) + { + if (state.Mouse.Buttons.Contains(MouseButton.Right) && rightClickScrolling) + ScrollTo((state.Mouse.Position.Y / DrawHeight) * scrollableContent.Height); + else + rightClickScrolling = false; + + return base.OnMouseMove(state); + } + protected override void Update() { base.Update(); From 1a2b1d4c98f9d18485704e7349ae9f8626688a3b Mon Sep 17 00:00:00 2001 From: tgi74000 Date: Fri, 13 Apr 2018 11:32:33 +0200 Subject: [PATCH 5/6] Use the already existent RightMouseScrollbar field --- osu.Game/Screens/Select/BeatmapCarousel.cs | 28 +++------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index 5c3518b46c..793759908d 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -125,6 +125,9 @@ namespace osu.Game.Screens.Select { config.BindWith(OsuSetting.RandomSelectAlgorithm, RandomAlgorithm); config.BindWith(OsuSetting.SelectScrollRightClick, RightClickScrollingEnabled); + + RightClickScrollingEnabled.ValueChanged += v => RightMouseScrollbar = v; + RightClickScrollingEnabled.TriggerChange(); } public void RemoveBeatmapSet(BeatmapSetInfo beatmapSet) @@ -402,31 +405,6 @@ namespace osu.Game.Screens.Select return true; } - private bool rightClickScrolling = false; - - protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) - { - bool result = base.OnMouseDown(state, args); - - if (RightClickScrollingEnabled.Value && !result && args.Button == MouseButton.Right) - { - rightClickScrolling = true; - return true; - } - - return result; - } - - protected override bool OnMouseMove(InputState state) - { - if (state.Mouse.Buttons.Contains(MouseButton.Right) && rightClickScrolling) - ScrollTo((state.Mouse.Position.Y / DrawHeight) * scrollableContent.Height); - else - rightClickScrolling = false; - - return base.OnMouseMove(state); - } - protected override void Update() { base.Update(); From e395a471125bc360035062e25a62856859cd1d0a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 18 Apr 2018 19:26:54 +0900 Subject: [PATCH 6/6] Changes to naming and text --- osu.Game/Configuration/OsuConfigManager.cs | 4 ++-- .../Overlays/Settings/Sections/Gameplay/SongSelectSettings.cs | 4 ++-- osu.Game/Screens/Select/BeatmapCarousel.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index ebc674c900..3efaa02a31 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -86,7 +86,7 @@ namespace osu.Game.Configuration Set(OsuSetting.ScreenshotFormat, ScreenshotFormat.Jpg); Set(OsuSetting.ScreenshotCaptureMenuCursor, false); - Set(OsuSetting.SelectScrollRightClick, false); + Set(OsuSetting.SongSelectRightMouseScroll, false); } public OsuConfigManager(Storage storage) : base(storage) @@ -133,6 +133,6 @@ namespace osu.Game.Configuration Skin, ScreenshotFormat, ScreenshotCaptureMenuCursor, - SelectScrollRightClick + SongSelectRightMouseScroll } } diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/SongSelectSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/SongSelectSettings.cs index c3d8022a63..7893d76fb8 100644 --- a/osu.Game/Overlays/Settings/Sections/Gameplay/SongSelectSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/SongSelectSettings.cs @@ -19,8 +19,8 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay { new SettingsCheckbox { - LabelText = "Right click to scroll", - Bindable = config.GetBindable(OsuSetting.SelectScrollRightClick), + LabelText = "Right mouse drag to absolute scroll", + Bindable = config.GetBindable(OsuSetting.SongSelectRightMouseScroll), }, new SettingsCheckbox { diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index e88fec8106..3c9a14e1f4 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -125,7 +125,7 @@ namespace osu.Game.Screens.Select private void load(OsuConfigManager config) { config.BindWith(OsuSetting.RandomSelectAlgorithm, RandomAlgorithm); - config.BindWith(OsuSetting.SelectScrollRightClick, RightClickScrollingEnabled); + config.BindWith(OsuSetting.SongSelectRightMouseScroll, RightClickScrollingEnabled); RightClickScrollingEnabled.ValueChanged += v => RightMouseScrollbar = v; RightClickScrollingEnabled.TriggerChange();