Undoable action for edits to a custom ZSprite. More...
#include <sprite_undo_actions.h>
Public Types | |
| using | RestoreFn = std::function<void(const SpriteSnapshot&)> |
Public Member Functions | |
| SpriteEditAction (SpriteSnapshot before, SpriteSnapshot after, RestoreFn restore) | |
| absl::Status | Undo () override |
| absl::Status | Redo () override |
| std::string | Description () const override |
| Human-readable description (e.g., "Paint 12 tiles on map 5") | |
| size_t | MemoryUsage () const override |
| Approximate memory footprint for budget enforcement. | |
| bool | CanMergeWith (const UndoAction &) const override |
Public Member Functions inherited from yaze::editor::UndoAction | |
| virtual | ~UndoAction ()=default |
| virtual void | MergeWith (UndoAction &) |
Private Attributes | |
| SpriteSnapshot | before_ |
| SpriteSnapshot | after_ |
| RestoreFn | restore_ |
Undoable action for edits to a custom ZSprite.
Stores before and after snapshots of the sprite state and uses a restore callback to apply them back to the SpriteEditor. The callback is a std::function so the action doesn't need to know about the editor's internals directly.
Definition at line 40 of file sprite_undo_actions.h.
| using yaze::editor::SpriteEditAction::RestoreFn = std::function<void(const SpriteSnapshot&)> |
Definition at line 42 of file sprite_undo_actions.h.
|
inline |
Definition at line 44 of file sprite_undo_actions.h.
|
inlineoverridevirtual |
Implements yaze::editor::UndoAction.
Definition at line 50 of file sprite_undo_actions.h.
|
inlineoverridevirtual |
Implements yaze::editor::UndoAction.
Definition at line 58 of file sprite_undo_actions.h.
|
inlineoverridevirtual |
Human-readable description (e.g., "Paint 12 tiles on map 5")
Implements yaze::editor::UndoAction.
Definition at line 66 of file sprite_undo_actions.h.
References before_, yaze::editor::SpriteSnapshot::sprite_data, yaze::editor::SpriteSnapshot::sprite_index, and yaze::editor::zsprite::ZSprite::sprName.
|
inlineoverridevirtual |
Approximate memory footprint for budget enforcement.
Reimplemented from yaze::editor::UndoAction.
Definition at line 73 of file sprite_undo_actions.h.
References after_, before_, yaze::editor::zsprite::ZSprite::editor, yaze::editor::zsprite::SubEditor::Frames, and yaze::editor::SpriteSnapshot::sprite_data.
|
inlineoverridevirtual |
Whether this action can merge with the previous action on the stack. Called only when both actions have the same concrete type.
Reimplemented from yaze::editor::UndoAction.
Definition at line 86 of file sprite_undo_actions.h.
|
private |
Definition at line 89 of file sprite_undo_actions.h.
Referenced by Description(), MemoryUsage(), and Undo().
|
private |
Definition at line 90 of file sprite_undo_actions.h.
Referenced by MemoryUsage(), and Redo().
|
private |
Definition at line 91 of file sprite_undo_actions.h.