libreofficecalc / BBCF-Improvement-Mod

Additional features and tweaks for BlazBlue Centralfiction
GNU General Public License v3.0
19 stars 5 forks source link

Add Undo/Redo To Palette Editor #22

Closed AnthonyYoManz closed 1 year ago

AnthonyYoManz commented 1 year ago

Implements an undo and redo button for the palette editor, handling individual colour changes and bulk changes with the gradient editor.

Most janky bit of this is recording history when changing a single colour. It's a pain (most likely requiring changes to ImGui source) to determine when a user is done with the colour picker, and every time it changes we get told about it. This includes every frame they spend dragging the picker from one corner of the popup to the other. To work around this, there's a timestamp on recorded changes, and if the user makes a change within 0.2 seconds of their previous one it just updates the latest entry instead of pushing a new one.

Also since there are different types of things that can be undone (changing a single colour or changing a bunch via gradient generator) there are a few lists involved; one records changes to individual colours, one records changes via gradient generation, and the last keeps a record of all changes, storing their type (palette or gradient) and the index of the change's details in their respective list. If some crazy shit happens and we end up with more means of changing colours, it shouldn't be too much of a trial to append that to this system.