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

Undoable action for painting tiles on the overworld map. More...

#include <overworld_undo_actions.h>

Inheritance diagram for yaze::editor::OverworldTilePaintAction:
Collaboration diagram for yaze::editor::OverworldTilePaintAction:

Public Member Functions

 OverworldTilePaintAction (int map_id, int world, std::vector< OverworldTileChange > tile_changes, zelda3::Overworld *overworld, std::function< void()> refresh_fn)
 
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 &prev) const override
 
void MergeWith (UndoAction &prev) override
 
int map_id () const
 
int world () const
 
const std::vector< OverworldTileChange > & tile_changes () const
 
- Public Member Functions inherited from yaze::editor::UndoAction
virtual ~UndoAction ()=default
 

Static Public Attributes

static constexpr int kMergeWindowMs = 500
 Merge window: consecutive paints within this duration become one step.
 

Private Attributes

int map_id_
 
int world_
 
std::vector< OverworldTileChangetile_changes_
 
zelda3::Overworldoverworld_
 
std::function< void()> refresh_fn_
 
std::chrono::steady_clock::time_point timestamp_
 

Detailed Description

Undoable action for painting tiles on the overworld map.

Captures a batch of tile changes (from a single paint stroke or rectangle fill) with both old and new values so that Undo() and Redo() are fully self-contained.

Consecutive paint actions on the same map within kMergeWindowMs are merged into a single undo step via CanMergeWith/MergeWith.

Definition at line 41 of file overworld_undo_actions.h.

Constructor & Destructor Documentation

◆ OverworldTilePaintAction()

yaze::editor::OverworldTilePaintAction::OverworldTilePaintAction ( int map_id,
int world,
std::vector< OverworldTileChange > tile_changes,
zelda3::Overworld * overworld,
std::function< void()> refresh_fn )
inline
Parameters
map_idOverworld map index where painting occurred
worldWorld index (0=Light, 1=Dark, 2=Special)
tile_changesVector of individual tile changes with old+new values
overworldNon-owning pointer to the Overworld data layer
refresh_fnCallback to refresh map visuals after undo/redo

Definition at line 53 of file overworld_undo_actions.h.

Member Function Documentation

◆ Undo()

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

Implements yaze::editor::UndoAction.

Definition at line 65 of file overworld_undo_actions.h.

References yaze::zelda3::Overworld::GetMapTiles(), overworld_, refresh_fn_, tile_changes_, and world_.

Here is the call graph for this function:

◆ Redo()

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

Implements yaze::editor::UndoAction.

Definition at line 79 of file overworld_undo_actions.h.

References yaze::zelda3::Overworld::GetMapTiles(), overworld_, refresh_fn_, tile_changes_, and world_.

Here is the call graph for this function:

◆ Description()

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

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

Implements yaze::editor::UndoAction.

Definition at line 93 of file overworld_undo_actions.h.

References map_id_, and tile_changes_.

◆ MemoryUsage()

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

Approximate memory footprint for budget enforcement.

Reimplemented from yaze::editor::UndoAction.

Definition at line 100 of file overworld_undo_actions.h.

References tile_changes_.

◆ CanMergeWith()

bool yaze::editor::OverworldTilePaintAction::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 105 of file overworld_undo_actions.h.

References kMergeWindowMs, map_id_, timestamp_, and world_.

◆ MergeWith()

void yaze::editor::OverworldTilePaintAction::MergeWith ( UndoAction & )
inlineoverridevirtual

Absorb the previous action into this one. Precondition: CanMergeWith(prev) returned true.

Reimplemented from yaze::editor::UndoAction.

Definition at line 117 of file overworld_undo_actions.h.

References tile_changes_, and timestamp_.

◆ map_id()

int yaze::editor::OverworldTilePaintAction::map_id ( ) const
inline

Definition at line 148 of file overworld_undo_actions.h.

References map_id_.

◆ world()

int yaze::editor::OverworldTilePaintAction::world ( ) const
inline

Definition at line 149 of file overworld_undo_actions.h.

References world_.

◆ tile_changes()

const std::vector< OverworldTileChange > & yaze::editor::OverworldTilePaintAction::tile_changes ( ) const
inline

Definition at line 150 of file overworld_undo_actions.h.

References tile_changes_.

Member Data Documentation

◆ kMergeWindowMs

constexpr int yaze::editor::OverworldTilePaintAction::kMergeWindowMs = 500
staticconstexpr

Merge window: consecutive paints within this duration become one step.

Definition at line 44 of file overworld_undo_actions.h.

Referenced by CanMergeWith().

◆ map_id_

int yaze::editor::OverworldTilePaintAction::map_id_
private

Definition at line 155 of file overworld_undo_actions.h.

Referenced by CanMergeWith(), Description(), and map_id().

◆ world_

int yaze::editor::OverworldTilePaintAction::world_
private

Definition at line 156 of file overworld_undo_actions.h.

Referenced by CanMergeWith(), Redo(), Undo(), and world().

◆ tile_changes_

std::vector<OverworldTileChange> yaze::editor::OverworldTilePaintAction::tile_changes_
private

Definition at line 157 of file overworld_undo_actions.h.

Referenced by Description(), MemoryUsage(), MergeWith(), Redo(), tile_changes(), and Undo().

◆ overworld_

zelda3::Overworld* yaze::editor::OverworldTilePaintAction::overworld_
private

Definition at line 158 of file overworld_undo_actions.h.

Referenced by Redo(), and Undo().

◆ refresh_fn_

std::function<void()> yaze::editor::OverworldTilePaintAction::refresh_fn_
private

Definition at line 159 of file overworld_undo_actions.h.

Referenced by Redo(), and Undo().

◆ timestamp_

std::chrono::steady_clock::time_point yaze::editor::OverworldTilePaintAction::timestamp_
private

Definition at line 160 of file overworld_undo_actions.h.

Referenced by CanMergeWith(), and MergeWith().


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