Skip to content
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

Support undo/redo for control points in the Editor #18668

Merged
merged 17 commits into from
Jun 22, 2022

Conversation

smoogipoo
Copy link
Contributor

Works towards resolving #10314. Now handles control points.

... In the interim until we have binary object comparisons.

@smoogipoo
Copy link
Contributor Author

smoogipoo commented Jun 13, 2022

It doesn't seem to be perfect in all cases:

  • Changing scroll speed doesn't revert in osu! mode. It does revert in e.g. mania, where it actually has an effect.
  • Changing slider velocity in the timeline doesn't revert.

These are issues elsewhere and relate to the way DifficultyControlPoint are extracted. It's a little bit of a mess, and this is a best effort.
More work will be required to actually apply new DifficultyControlPoints to hitobjects.

@peppy peppy self-requested a review June 13, 2022 06:57
Co-authored-by: Berkan Diler <berkan.diler1@ingka.ikea.com>
@peppy
Copy link
Member

peppy commented Jun 13, 2022

Probably fine / much better than nothing at all. Not sure the scroll speed setting should even be visible there.

@smoogipoo smoogipoo self-assigned this Jun 13, 2022
@smoogipoo smoogipoo force-pushed the editor-controlpoint-undo-redo branch from ef87b8a to 5a18547 Compare June 13, 2022 07:47
@smoogipoo
Copy link
Contributor Author

Sorry for the force push, I changed no earlier code, only removed a new commit that tried to fix DifficultyControlPoints not updating on HitObjects, then realised it caused damage on the actual timing screen :( Going to require more thought as previously said.

@bdach
Copy link
Collaborator

bdach commented Jun 13, 2022

Are the assertion failures from the earlier runs here (example 1, example 2) related to the removed commit? As in, is this in a reviewable state right now?

@smoogipoo
Copy link
Contributor Author

Nah, I'm currently fixing the assertion failures.

@smoogipoo
Copy link
Contributor Author

Should be reviewable now.

@bdach
Copy link
Collaborator

bdach commented Jun 13, 2022

Also not sure if related, but there's a weird bug with the bottom timeline display where control points are supposed to be shown:

2022-06-13.10-17-26.mp4

Appears that consecutive undoes hide and show the control point indicators... for some reason? Not sure if related, just bringing it up as something I noticed.

@smoogipoo
Copy link
Contributor Author

The timeline issue could be related to incrementally adding every control point rather than giving a list with every control point populated at once. But probably a separate issue from this branch...?

bdach
bdach previously approved these changes Jun 13, 2022
Copy link
Collaborator

@bdach bdach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok to me

@peppy
Copy link
Member

peppy commented Jun 14, 2022

This doesn't seem to handle the case where a new type is added to an existing group, is that known / expected?

And after doing this then adding a new control point... things get really weird...

osu.Game.Tests.2022-06-14.at.10.03.38.mp4

@smoogipoo
Copy link
Contributor Author

Probably because the type isn't doing anything? It's only undoing/redoing based on what actually gets written to the file, so those points are probably becoming redundant & removed during write?

@peppy
Copy link
Member

peppy commented Jun 14, 2022

Hmm... that's... very awkward. Especially since it doesn't clear redo states. So you hit redo and suddenly you are in a completely broken looking state.

At very least I think the redo history needs to be purged in these cases.

@peppy
Copy link
Member

peppy commented Jun 14, 2022

Something has regressed with selected rows on the timing screen. After cloning a point, the newly cloned point is not selected visually (but seems to have the selection internally). I've checked that this works correctly on master

osu.Game.Tests.2022-06-14.at.10.08.08.mp4
  • Select point
  • Move to new time
  • Clone

Observed row not selected.

@smoogipoo
Copy link
Contributor Author

Admittedly I didn't thoroughly test redoing so I didn't notice it breaking it, though your video doesn't show it.

@peppy
Copy link
Member

peppy commented Jun 14, 2022

I had a video which has me redoing, but I didn't know what was going on and didn't think it would transfer well to a video 😅

@peppy peppy dismissed bdach’s stale review June 16, 2022 08:32

Dismissing for now

Previously, all control points would get replaced, which led to
performance issues that was worked around in this PR. By comparing
control points, we're able to get good performance without requiring the
workaround.
@smoogipoo
Copy link
Contributor Author

smoogipoo commented Jun 20, 2022

Please try this PR again and see if you can break it still. I think I might've resolved both the above issues by not replacing all control points.

There's still some weirdness (which I can't handle), that's best described with a video:

2022-06-20.15-35-15.mp4

In the video, I'm doing much the same actions as #18668 (comment).

  1. I add an effect point to the first timing point.
    • No undo/redo state created (redundant point).
  2. I duplicate an effect point later on.
    • No undo/redo state created (redundant point).
  3. I change the duplicated effect point to adjust kiai time.
    • Creates an undo state.
  4. I press undo.
    • Both the duplicated effect point and the effect point added in (1) are removed.
  5. I press redo.
    • The effect point added in (1) does not return.
    • The duplicated effect point is merged into the one following it (which also starts kiai), because the one following it has been deemed redundant.

@peppy
Copy link
Member

peppy commented Jun 20, 2022

I can still get in a state where the row isn't selected. I'm not too concerned about certain changes remaining unsupported (like the scroll speed one in the video) but having the row non-selectable is quite breaking. Haven't looked at the code changes yet, but maybe a fix can be applied more locally to the table control rather than adding the overhead with equality etc?

osu.Game.Tests.2022-06-20.at.07.12.34.mp4

@smoogipoo
Copy link
Contributor Author

smoogipoo commented Jun 20, 2022

Looks like the breaking is reproed by:

  1. Select timing point.
  2. Adjust BPM.
  3. Select any other point.
  4. Undo.

fix can be applied more locally to the table control rather than adding the overhead with equality etc

That's exactly what I was doing before, but it's even worse that way (breakage-wise) because performance starts to become a factor and you need to add layers of workarounds to resolve it. As it is, the current (/new) code is basically what we'd have to do with per-object diffing anyway.

I prefer equality, but let's see if the above issue changes my view on things.

@smoogipoo
Copy link
Contributor Author

smoogipoo commented Jun 20, 2022

Above issue should be fixed (via ca287d0). Though I understand there's quite a lot of files changed here, I still believe that control point equality is the way to go.

I can split the changes out if it makes it easier to review - these changes are MVP and I'd also like to annotate ControlPointInfo with #nullable but that's a bit more involved, so I could bundle this in a separate PR.

@bdach
Copy link
Collaborator

bdach commented Jun 21, 2022

I've checked this branch out again today, and I feel that this branch is as good a state as it can probably be. Which is to say, there is still breakage, but it's breakage that is definitely out of scope of this pull. See the following example:

2022-06-21.22-18-07.mp4

In the above video I manage to duplicate an "omit bar line" effect point by doing undo and redo. The reason why I am able to do this boils down to the abuse we have inflicted on LegacyBeatmap{Decoder,Encoder} to support per-hitobject control points. During the process of encoding, the per-hitobject points get converted back to global points, and the effect spec is applied onto legacy control points that are extracted from hitobjects. This breaks on decode, because OmitFirstBarLine = true effect points are never redundant, so they never get pruned, hence the magic cloning.

I don't see us fully fixing this without getting rid of .osu as the primary storage format for beatmaps. Which is mostly why I'm saying that this branch is in as good a state as probably can be at this stage.

@bdach bdach requested a review from peppy June 21, 2022 20:27
Copy link
Member

@peppy peppy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems pretty good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants