Add an undoing & redoing system to the editor (#1085)

* Add undoing & redoing to the editor

It's very easy to make mistakes in VVVVVV's built-in level editor, with
no way to undo them. This commit adds an undo and redo system, bound to
CTRL+Z for undo and CTRL+Y for redo. The undo and redo stacks don't
have any limits, but could easily happen in the future. VVVVVV's data
is small enough where this should never be an issue, however.

No notes show up for undoing and redoing, because keeping track of what
specific action you're doing may bloat the system, and would get
annoying for the end-user. Notes are a bit annoying in general, even.

* Add level resizing to undo/redo system

* searchable gettext for undo/redo notes

* A few fixes and cleanup

The main fix was how holding right click to remove tiles did not
commit an action.

* Spikes also need to commit

* Cancelling placing a terminal/script box shouldn't have undo events

* Don't commit tile events if removing entities

* Clear redo buffer on level load

* Remove unneeded pointers from memcpy

* Add strings to lang files

* Fix definition in Editor.h

* Explain double-uncommit

* Don't unconditionally commit tiles on room change

I'm not that sure what I was thinking back then, but switching rooms
would commit tiles no matter what, causing a huge mess. The behavior
was intended to stop the "tile placement" action and commit it, but
just happened no matter what... So this has been fixed, and a few
comments have been added as well.

* Fix mentioned issues & make process_undo static

---------

Co-authored-by: NyakoFox <nyakowofox@gmail.com>
This commit is contained in:
Ally
2026-04-25 14:46:01 -03:00
committed by GitHub
parent a5e353a0fa
commit 4e6697352c
27 changed files with 452 additions and 33 deletions
+2
View File
@@ -638,6 +638,8 @@
<string english="Enemy Type Changed" translation="نوع دشمن تغییر کرد" explanation="level editor, user changed enemy appearance for the room" max="38*3" max_local="38*3"/>
<string english="Platform speed is now {speed}" translation="سرعت سکو اکنون برابر با {speed} است" explanation="level editor, user changed speed of platforms for the room" max="38*3" max_local="38*3"/>
<string english="Enemy speed is now {speed}" translation="سرعت دشمن اکنون برابر با {speed} است" explanation="level editor, user changed speed of enemies for the room" max="38*3" max_local="38*3"/>
<string english="ERROR: Nothing to undo" translation="" explanation="level editor, user tried to undo with nothing to undo" max="38*3" max_local="38*3"/>
<string english="ERROR: Nothing to redo" translation="" explanation="level editor, user tried to redo with nothing to redo" max="38*3" max_local="38*3"/>
<string english="Reloaded resources" translation="بارگذاری مجدد منابع" explanation="level editor, reloaded graphics assets/resources, music and sound effects" max="38*3" max_local="38*3"/>
<string english="ERROR: Invalid format" translation="خطا: فرمت اشتباه" explanation="user was supposed to enter something like `12,12`, but entered `as@df`" max="38*3" max_local="38*3"/>
<string english="Loaded map: {filename}.vvvvvv" translation="نقشه‌ی بارگذاری شده {filename}.vvvvvv" explanation="successfully loaded level file" max="38*3" max_local="38*3"/>