-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix various shortcomings in juice stream selection blueprint #28999
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
using osu.Framework.Graphics.UserInterface; | ||
using osu.Framework.Input.Events; | ||
using osu.Game.Graphics.UserInterface; | ||
using osu.Game.Rulesets.Catch.Objects; | ||
using osu.Game.Screens.Edit; | ||
using osuTK; | ||
using osuTK.Input; | ||
|
@@ -19,22 +20,28 @@ public partial class SelectionEditablePath : EditablePath, IHasContextMenu | |
{ | ||
public MenuItem[] ContextMenuItems => getContextMenuItems().ToArray(); | ||
|
||
private readonly JuiceStream juiceStream; | ||
|
||
// To handle when the editor is scrolled while dragging. | ||
private Vector2 dragStartPosition; | ||
|
||
[Resolved] | ||
private IEditorChangeHandler? changeHandler { get; set; } | ||
|
||
public SelectionEditablePath(Func<float, double> positionToTime) | ||
public SelectionEditablePath(JuiceStream juiceStream, Func<float, double> positionToTime) | ||
: base(positionToTime) | ||
{ | ||
this.juiceStream = juiceStream; | ||
} | ||
|
||
public void AddVertex(Vector2 relativePosition) | ||
{ | ||
changeHandler?.BeginChange(); | ||
double time = Math.Max(0, PositionToTime(relativePosition.Y)); | ||
int index = AddVertex(time, relativePosition.X); | ||
UpdateHitObjectFromPath(juiceStream); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Calls are required to actually make undo/redo work, because without this call, nothing in the actual beatmap changes, and |
||
selectOnly(index); | ||
changeHandler?.EndChange(); | ||
} | ||
|
||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => InternalChildren.Any(d => d.ReceivePositionalInputAt(screenSpacePos)); | ||
|
@@ -45,9 +52,13 @@ protected override bool OnMouseDown(MouseDownEvent e) | |
if (index == -1 || VertexStates[index].IsFixed) | ||
return false; | ||
|
||
if (e.Button == MouseButton.Left && e.ShiftPressed) | ||
if (e.Button == MouseButton.Right && e.ShiftPressed) | ||
{ | ||
changeHandler?.BeginChange(); | ||
RemoveVertex(index); | ||
UpdateHitObjectFromPath(juiceStream); | ||
changeHandler?.EndChange(); | ||
|
||
return true; | ||
} | ||
|
||
|
@@ -118,11 +129,17 @@ private void selectOnly(int index) | |
|
||
private void deleteSelectedVertices() | ||
{ | ||
changeHandler?.BeginChange(); | ||
|
||
for (int i = VertexCount - 1; i >= 0; i--) | ||
{ | ||
if (VertexStates[i].IsSelected) | ||
RemoveVertex(i); | ||
} | ||
|
||
UpdateHitObjectFromPath(juiceStream); | ||
|
||
changeHandler?.EndChange(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these test "fixes" appear arbitrary - that is because they are. They would fail after the rest of the changes, and as far as I can tell that is just a manifestation of #28915 that wasn't there before due to the lack of inline
UpdateHitObjectFromPath()
calls. I would ask to look away from this for now while I attempt to figure out what is going on over there (it is not easy, 99% chance it is floating point hell).