CircuitLord / NotReaper

A mapper for the VR rhythm game Audica
GNU General Public License v3.0
22 stars 14 forks source link

New action system #41

Closed Mettra closed 4 years ago

Mettra commented 4 years ago

This PR fixes #14 by reworking how actions are used in NotReaper.

Previously, the timeline would modify targets, then generate an action to undo/redo whatever it did. Unfortunately, many of the target references would get messed up by other actions when chaining many of them together.

This new system makes it so the action is responsible for both the forward action (like when the user initiates it, or on a re-do) and the backwards action. Because of this, the timeline now just generates actions and adds them to the queue.

These actions also now hold onto TargetData, which is a small set of data that represents a target. Actions can use these to instantiate Targets, or to find a target in the timeline that matches its data.

Since actions now own their own flow, they can modify their data in order to re-find targets even through long undo/redo chains. For example, NRActionGridMoveNotes moves their notes to the destination position, then sets all of their TargetData to point at that new position, so when they undo it will always find the correct note.

Along with this PR is some cleanup of state associated with the old action system, since we always generate actions from the timeline, and there is never a case where we wouldn't want to clear the redo stack when adding an action.

Undo/Redo in action

undoredo