yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::editor::SpriteEditAction Class Reference

Undoable action for edits to a custom ZSprite. More...

#include <sprite_undo_actions.h>

Inheritance diagram for yaze::editor::SpriteEditAction:
Collaboration diagram for yaze::editor::SpriteEditAction:

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_
 

Detailed Description

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.

Member Typedef Documentation

◆ RestoreFn

using yaze::editor::SpriteEditAction::RestoreFn = std::function<void(const SpriteSnapshot&)>

Definition at line 42 of file sprite_undo_actions.h.

Constructor & Destructor Documentation

◆ SpriteEditAction()

yaze::editor::SpriteEditAction::SpriteEditAction ( SpriteSnapshot before,
SpriteSnapshot after,
RestoreFn restore )
inline

Definition at line 44 of file sprite_undo_actions.h.

Member Function Documentation

◆ Undo()

absl::Status yaze::editor::SpriteEditAction::Undo ( )
inlineoverridevirtual

Implements yaze::editor::UndoAction.

Definition at line 50 of file sprite_undo_actions.h.

References before_, and restore_.

◆ Redo()

absl::Status yaze::editor::SpriteEditAction::Redo ( )
inlineoverridevirtual

Implements yaze::editor::UndoAction.

Definition at line 58 of file sprite_undo_actions.h.

References after_, and restore_.

◆ Description()

std::string yaze::editor::SpriteEditAction::Description ( ) const
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.

◆ MemoryUsage()

size_t yaze::editor::SpriteEditAction::MemoryUsage ( ) const
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.

◆ CanMergeWith()

bool yaze::editor::SpriteEditAction::CanMergeWith ( const UndoAction & ) const
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.

Member Data Documentation

◆ before_

SpriteSnapshot yaze::editor::SpriteEditAction::before_
private

Definition at line 89 of file sprite_undo_actions.h.

Referenced by Description(), MemoryUsage(), and Undo().

◆ after_

SpriteSnapshot yaze::editor::SpriteEditAction::after_
private

Definition at line 90 of file sprite_undo_actions.h.

Referenced by MemoryUsage(), and Redo().

◆ restore_

RestoreFn yaze::editor::SpriteEditAction::restore_
private

Definition at line 91 of file sprite_undo_actions.h.

Referenced by Redo(), and Undo().


The documentation for this class was generated from the following file: