From 5ac3bb73ee2569b62f5a928606b16bfc2b969a9e Mon Sep 17 00:00:00 2001 From: Darius Wattimena Date: Mon, 18 Nov 2024 22:19:08 +0100 Subject: [PATCH 1/3] Adds an option to the catch editor to convert sliders to fruits --- .../JuiceStreamSelectionBlueprint.cs | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/osu.Game.Rulesets.Catch/Edit/Blueprints/JuiceStreamSelectionBlueprint.cs b/osu.Game.Rulesets.Catch/Edit/Blueprints/JuiceStreamSelectionBlueprint.cs index 3eb8d6c018cb..2f2ccae38b2e 100644 --- a/osu.Game.Rulesets.Catch/Edit/Blueprints/JuiceStreamSelectionBlueprint.cs +++ b/osu.Game.Rulesets.Catch/Edit/Blueprints/JuiceStreamSelectionBlueprint.cs @@ -10,10 +10,12 @@ using osu.Framework.Graphics.UserInterface; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; +using osu.Framework.Utils; using osu.Game.Graphics.UserInterface; using osu.Game.Rulesets.Catch.Edit.Blueprints.Components; using osu.Game.Rulesets.Catch.Objects; using osu.Game.Rulesets.Objects; +using osu.Game.Rulesets.Objects.Types; using osu.Game.Screens.Edit; using osuTK; using osuTK.Input; @@ -54,6 +56,12 @@ public partial class JuiceStreamSelectionBlueprint : CatchSelectionBlueprint= 1) + pathPosition = 1 - pathPosition; + + float fruitXValue = HitObject.OriginalX + HitObject.Path.PositionAt(pathPosition).X; + + editorBeatmap.Add(new Fruit + { + StartTime = time, + OriginalX = fruitXValue, + NewCombo = i == 0 && HitObject.NewCombo, + Samples = HitObject.Samples.Select(s => s.With()).ToList() + }); + + i += 1; + time = HitObject.StartTime + i * streamSpacing; + } + + editorBeatmap.Remove(HitObject); + + changeHandler?.EndChange(); + } + private IEnumerable getContextMenuItems() { yield return new OsuMenuItem("Add vertex", MenuItemType.Standard, () => @@ -177,6 +241,11 @@ private IEnumerable getContextMenuItems() { Hotkey = new Hotkey(new KeyCombination(InputKey.Control, InputKey.MouseLeft)) }; + + yield return new OsuMenuItem("Convert to fruits", MenuItemType.Destructive, convertToFruits) + { + Hotkey = new Hotkey(new KeyCombination(InputKey.Control, InputKey.Shift, InputKey.F)) + }; } protected override void Dispose(bool isDisposing) From 00e3b20ff0bb3d6f001fc375034cef8406fab799 Mon Sep 17 00:00:00 2001 From: Darius Wattimena Date: Mon, 18 Nov 2024 22:30:15 +0100 Subject: [PATCH 2/3] Change text to stream instead of fruits as that is the term by catch mappers --- .../Edit/Blueprints/JuiceStreamSelectionBlueprint.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Edit/Blueprints/JuiceStreamSelectionBlueprint.cs b/osu.Game.Rulesets.Catch/Edit/Blueprints/JuiceStreamSelectionBlueprint.cs index 2f2ccae38b2e..a61478f5d553 100644 --- a/osu.Game.Rulesets.Catch/Edit/Blueprints/JuiceStreamSelectionBlueprint.cs +++ b/osu.Game.Rulesets.Catch/Edit/Blueprints/JuiceStreamSelectionBlueprint.cs @@ -134,7 +134,7 @@ protected override bool OnKeyDown(KeyDownEvent e) if (e.Key == Key.F && e.ControlPressed && e.ShiftPressed) { - convertToFruits(); + convertToStream(); return true; } @@ -190,7 +190,7 @@ private void updateHitObjectFromPath() lastSliderPathVersion = HitObject.Path.Version.Value; } - private void convertToFruits() + private void convertToStream() { if (editorBeatmap == null || beatDivisor == null) return; @@ -242,7 +242,7 @@ private IEnumerable getContextMenuItems() Hotkey = new Hotkey(new KeyCombination(InputKey.Control, InputKey.MouseLeft)) }; - yield return new OsuMenuItem("Convert to fruits", MenuItemType.Destructive, convertToFruits) + yield return new OsuMenuItem("Convert to stream", MenuItemType.Destructive, convertToStream) { Hotkey = new Hotkey(new KeyCombination(InputKey.Control, InputKey.Shift, InputKey.F)) }; From 5a0b732ee32e66e24118e390706795a419cd3954 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 11 Dec 2024 16:26:11 +0900 Subject: [PATCH 3/3] Add comments backreferences to copies of duplicated code for future use --- .../Edit/Blueprints/JuiceStreamSelectionBlueprint.cs | 2 ++ .../Edit/Blueprints/Sliders/SliderSelectionBlueprint.cs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/osu.Game.Rulesets.Catch/Edit/Blueprints/JuiceStreamSelectionBlueprint.cs b/osu.Game.Rulesets.Catch/Edit/Blueprints/JuiceStreamSelectionBlueprint.cs index a61478f5d553..6a0ce35a0768 100644 --- a/osu.Game.Rulesets.Catch/Edit/Blueprints/JuiceStreamSelectionBlueprint.cs +++ b/osu.Game.Rulesets.Catch/Edit/Blueprints/JuiceStreamSelectionBlueprint.cs @@ -190,6 +190,8 @@ private void updateHitObjectFromPath() lastSliderPathVersion = HitObject.Path.Version.Value; } + // duplicated in `SliderSelectionBlueprint.convertToStream()` + // consider extracting common helper when applying changes here private void convertToStream() { if (editorBeatmap == null || beatDivisor == null) diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderSelectionBlueprint.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderSelectionBlueprint.cs index 34de81f1baf2..02f76b51b06d 100644 --- a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderSelectionBlueprint.cs +++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderSelectionBlueprint.cs @@ -551,6 +551,8 @@ private void splitControlPoints(List controlPointsToSplitAt) HitObject.Position += first; } + // duplicated in `JuiceStreamSelectionBlueprint.convertToStream()` + // consider extracting common helper when applying changes here private void convertToStream() { if (editorBeatmap == null || beatDivisor == null)