Editor: proper Undo/Redo system for the Room Editor #2321
Labels
context: ui/ux
type: enhancement
a suggestion or necessity to have something improved
what: editor
related to the game editor
Room Editor lacks proper Undo/Redo. There's an "Undo" in the mask paint mode, but it supports only 1 level of undo, and is implemented suboptimally.
How to implement a proper Undo/Redo system?
Suggestion
Implement a "Operation" class (example, actual name may be different) that defines an operation that may be performed in a particular context (like, certain editor). Operation has an "operation type" ID (enum or string) and a set of parameters. Operation may be subclassed, because some operations require specific arguments. Alternatively, it's not Operation itself is subclassed, but some nested "OperationArgs" member. Look the C# EventArgs for example.
Implement a "UndoRedo" manager class, as a generic manager for some editor. This manager does following:
For the Room Editor and its Filter classes (Character, Object, etc):
How to organize "backwards operations" for Undo. This may be done in a straightforward way, by converting each operation on event.
On another hand, this may be done in another way, by supplying a conversion delegate for the UndoRedo Manager class. This may work like this: the operations are recorded in "forward" way, but right before calling Undo, Operation is cloned and clone is converted "backwards" using this delegate.
If this is done so, then maybe there's no need for two events (Undo/Redo) and only 1 "DoOperation" event, and 1 "DoOperation" method in the Editor class. But this method will receive either a forward operation for Redoing, or reverted operation for Undoing.
If this will work for the Room Editor, perhaps similar thing may be implemented for some others afterwards, such as View editor, for example.
The text was updated successfully, but these errors were encountered: