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

Undoable action for edits to a single Tile16. More...

#include <tile16_undo_actions.h>

Inheritance diagram for yaze::editor::Tile16EditAction:
Collaboration diagram for yaze::editor::Tile16EditAction:

Public Types

using RestoreFn = std::function<void(const Tile16Snapshot&)>
 

Public Member Functions

 Tile16EditAction (Tile16Snapshot before, Tile16Snapshot 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

Tile16Snapshot before_
 
Tile16Snapshot after_
 
RestoreFn restore_
 

Detailed Description

Undoable action for edits to a single Tile16.

Stores before and after snapshots of the tile state and uses a restore callback to apply them back to the Tile16Editor. The callback is a std::function so the action doesn't need to know about the editor's internals directly.

Definition at line 45 of file tile16_undo_actions.h.

Member Typedef Documentation

◆ RestoreFn

using yaze::editor::Tile16EditAction::RestoreFn = std::function<void(const Tile16Snapshot&)>

Definition at line 47 of file tile16_undo_actions.h.

Constructor & Destructor Documentation

◆ Tile16EditAction()

yaze::editor::Tile16EditAction::Tile16EditAction ( Tile16Snapshot before,
Tile16Snapshot after,
RestoreFn restore )
inline

Definition at line 49 of file tile16_undo_actions.h.

Member Function Documentation

◆ Undo()

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

Implements yaze::editor::UndoAction.

Definition at line 55 of file tile16_undo_actions.h.

References before_, and restore_.

◆ Redo()

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

Implements yaze::editor::UndoAction.

Definition at line 60 of file tile16_undo_actions.h.

References after_, and restore_.

◆ Description()

std::string yaze::editor::Tile16EditAction::Description ( ) const
inlineoverridevirtual

Human-readable description (e.g., "Paint 12 tiles on map 5")

Implements yaze::editor::UndoAction.

Definition at line 65 of file tile16_undo_actions.h.

References before_, and yaze::editor::Tile16Snapshot::tile_id.

◆ MemoryUsage()

size_t yaze::editor::Tile16EditAction::MemoryUsage ( ) const
inlineoverridevirtual

Approximate memory footprint for budget enforcement.

Reimplemented from yaze::editor::UndoAction.

Definition at line 69 of file tile16_undo_actions.h.

References after_, before_, and yaze::editor::Tile16Snapshot::bitmap_data.

◆ CanMergeWith()

bool yaze::editor::Tile16EditAction::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 73 of file tile16_undo_actions.h.

Member Data Documentation

◆ before_

Tile16Snapshot yaze::editor::Tile16EditAction::before_
private

Definition at line 78 of file tile16_undo_actions.h.

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

◆ after_

Tile16Snapshot yaze::editor::Tile16EditAction::after_
private

Definition at line 79 of file tile16_undo_actions.h.

Referenced by MemoryUsage(), and Redo().

◆ restore_

RestoreFn yaze::editor::Tile16EditAction::restore_
private

Definition at line 80 of file tile16_undo_actions.h.

Referenced by Redo(), and Undo().


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