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

Undoable action for dungeon room object edits. More...

#include <dungeon_undo_actions.h>

Inheritance diagram for yaze::editor::DungeonObjectsAction:
Collaboration diagram for yaze::editor::DungeonObjectsAction:

Public Types

using RestoreFn
 

Public Member Functions

 DungeonObjectsAction (int room_id, std::vector< zelda3::RoomObject > before, std::vector< size_t > before_selection, std::vector< zelda3::RoomObject > after, std::vector< size_t > after_selection, 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

int room_id_
 
std::vector< zelda3::RoomObjectbefore_
 
std::vector< size_t > before_selection_
 
std::vector< zelda3::RoomObjectafter_
 
std::vector< size_t > after_selection_
 
RestoreFn restore_
 

Detailed Description

Undoable action for dungeon room object edits.

Captures a full snapshot of a room's tile objects and object selection before and after an editing operation. Undo restores the before-state, Redo restores the after-state, using a caller-provided restore callback that applies the snapshot back into the room.

Definition at line 29 of file dungeon_undo_actions.h.

Member Typedef Documentation

◆ RestoreFn

Initial value:
std::function<void(int room_id, const std::vector<zelda3::RoomObject>&,
const std::vector<size_t>& selected_indices)>

Definition at line 31 of file dungeon_undo_actions.h.

Constructor & Destructor Documentation

◆ DungeonObjectsAction()

yaze::editor::DungeonObjectsAction::DungeonObjectsAction ( int room_id,
std::vector< zelda3::RoomObject > before,
std::vector< size_t > before_selection,
std::vector< zelda3::RoomObject > after,
std::vector< size_t > after_selection,
RestoreFn restore )
inline

Definition at line 35 of file dungeon_undo_actions.h.

Member Function Documentation

◆ Undo()

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

Implements yaze::editor::UndoAction.

Definition at line 46 of file dungeon_undo_actions.h.

References before_, before_selection_, restore_, and room_id_.

◆ Redo()

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

Implements yaze::editor::UndoAction.

Definition at line 54 of file dungeon_undo_actions.h.

References after_, after_selection_, restore_, and room_id_.

◆ Description()

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

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

Implements yaze::editor::UndoAction.

Definition at line 62 of file dungeon_undo_actions.h.

References room_id_.

◆ MemoryUsage()

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

Approximate memory footprint for budget enforcement.

Reimplemented from yaze::editor::UndoAction.

Definition at line 66 of file dungeon_undo_actions.h.

References after_, after_selection_, before_, and before_selection_.

◆ CanMergeWith()

bool yaze::editor::DungeonObjectsAction::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 dungeon_undo_actions.h.

Member Data Documentation

◆ room_id_

int yaze::editor::DungeonObjectsAction::room_id_
private

Definition at line 80 of file dungeon_undo_actions.h.

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

◆ before_

std::vector<zelda3::RoomObject> yaze::editor::DungeonObjectsAction::before_
private

Definition at line 81 of file dungeon_undo_actions.h.

Referenced by MemoryUsage(), and Undo().

◆ before_selection_

std::vector<size_t> yaze::editor::DungeonObjectsAction::before_selection_
private

Definition at line 82 of file dungeon_undo_actions.h.

Referenced by MemoryUsage(), and Undo().

◆ after_

std::vector<zelda3::RoomObject> yaze::editor::DungeonObjectsAction::after_
private

Definition at line 83 of file dungeon_undo_actions.h.

Referenced by MemoryUsage(), and Redo().

◆ after_selection_

std::vector<size_t> yaze::editor::DungeonObjectsAction::after_selection_
private

Definition at line 84 of file dungeon_undo_actions.h.

Referenced by MemoryUsage(), and Redo().

◆ restore_

RestoreFn yaze::editor::DungeonObjectsAction::restore_
private

Definition at line 85 of file dungeon_undo_actions.h.

Referenced by Redo(), and Undo().


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