1#ifndef YAZE_APP_EDITOR_DUNGEON_UNDO_ACTIONS_H_
2#define YAZE_APP_EDITOR_DUNGEON_UNDO_ACTIONS_H_
11#include "absl/status/status.h"
12#include "absl/strings/str_format.h"
34 int room_id,
const std::vector<zelda3::RoomObject>&,
35 const std::vector<size_t>& selected_indices,
36 const std::vector<chest_data>& chests)>;
39 std::vector<size_t> before_selection,
40 std::vector<zelda3::RoomObject> after,
41 std::vector<size_t> after_selection,
42 std::vector<chest_data> before_chests,
43 std::vector<chest_data> after_chests,
RestoreFn restore)
53 absl::Status
Undo()
override {
55 return absl::InternalError(
"DungeonObjectsAction: no restore callback");
60 absl::Status
Redo()
override {
62 return absl::InternalError(
"DungeonObjectsAction: no restore callback");
68 return absl::StrFormat(
"Edit room %03X objects",
room_id_);
89 std::vector<zelda3::RoomObject>
after_;
98 std::vector<zelda3::Room::Door>
doors;
99 std::vector<DungeonSpriteSnapshot>
sprites;
119 : absl::InternalError(
120 "DungeonEntitiesAction: no restore callback");
124 : absl::InternalError(
125 "DungeonEntitiesAction: no restore callback");
131 return absl::StrFormat(
"Edit room %03X %s",
room_id_, label);
139 state.objects.size() *
sizeof(size_t);
172 return absl::InternalError(
173 "DungeonCustomCollisionAction: no restore callback");
176 return absl::OkStatus();
181 return absl::InternalError(
182 "DungeonCustomCollisionAction: no restore callback");
185 return absl::OkStatus();
189 return absl::StrFormat(
"Edit room %03X custom collision",
room_id_);
213 const std::vector<DungeonCustomCollisionSnapshot>&)>;
216 std::vector<DungeonCustomCollisionSnapshot> before,
217 std::vector<DungeonCustomCollisionSnapshot> after,
RestoreFn restore)
224 return absl::InternalError(
225 "DungeonCustomCollisionBatchAction: no restore callback");
232 return absl::InternalError(
233 "DungeonCustomCollisionBatchAction: no restore callback");
239 return absl::StrFormat(
"Generate minecart collision for %d rooms",
240 static_cast<int>(
after_.size()));
251 std::vector<DungeonCustomCollisionSnapshot>
before_;
252 std::vector<DungeonCustomCollisionSnapshot>
after_;
269 return absl::InternalError(
"DungeonWaterFillAction: no restore callback");
272 return absl::OkStatus();
277 return absl::InternalError(
"DungeonWaterFillAction: no restore callback");
280 return absl::OkStatus();
284 return absl::StrFormat(
"Edit room %03X water fill",
room_id_);
size_t MemoryUsage() const override
Approximate memory footprint for budget enforcement.
zelda3::CustomCollisionMap before_
std::string Description() const override
Human-readable description (e.g., "Paint 12 tiles on map 5")
absl::Status Undo() override
std::function< void(int room_id, const zelda3::CustomCollisionMap &)> RestoreFn
DungeonCustomCollisionAction(int room_id, zelda3::CustomCollisionMap before, zelda3::CustomCollisionMap after, RestoreFn restore)
absl::Status Redo() override
bool CanMergeWith(const UndoAction &) const override
zelda3::CustomCollisionMap after_
size_t MemoryUsage() const override
Approximate memory footprint for budget enforcement.
std::string Description() const override
Human-readable description (e.g., "Paint 12 tiles on map 5")
std::vector< DungeonCustomCollisionSnapshot > after_
absl::Status Redo() override
bool CanMergeWith(const UndoAction &) const override
std::vector< DungeonCustomCollisionSnapshot > before_
absl::Status Undo() override
std::function< absl::Status( const std::vector< DungeonCustomCollisionSnapshot > &)> RestoreFn
DungeonCustomCollisionBatchAction(std::vector< DungeonCustomCollisionSnapshot > before, std::vector< DungeonCustomCollisionSnapshot > after, RestoreFn restore)
std::string Description() const override
Human-readable description (e.g., "Paint 12 tiles on map 5")
DungeonEntitySnapshot before_
absl::Status Redo() override
std::function< absl::Status(int, MutationDomain, const DungeonEntitySnapshot &)> RestoreFn
bool CanMergeWith(const UndoAction &) const override
DungeonEntitiesAction(int room_id, MutationDomain domain, DungeonEntitySnapshot before, DungeonEntitySnapshot after, RestoreFn restore)
DungeonEntitySnapshot after_
absl::Status Undo() override
size_t MemoryUsage() const override
Approximate memory footprint for budget enforcement.
Undoable action for dungeon room object edits.
std::vector< zelda3::RoomObject > after_
std::vector< chest_data > before_chests_
std::vector< zelda3::RoomObject > before_
std::vector< size_t > before_selection_
std::function< absl::Status( int room_id, const std::vector< zelda3::RoomObject > &, const std::vector< size_t > &selected_indices, const std::vector< chest_data > &chests)> RestoreFn
bool CanMergeWith(const UndoAction &) const override
size_t MemoryUsage() const override
Approximate memory footprint for budget enforcement.
std::vector< size_t > after_selection_
absl::Status Undo() override
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, std::vector< chest_data > before_chests, std::vector< chest_data > after_chests, RestoreFn restore)
std::string Description() const override
Human-readable description (e.g., "Paint 12 tiles on map 5")
std::vector< chest_data > after_chests_
absl::Status Redo() override
std::string Description() const override
Human-readable description (e.g., "Paint 12 tiles on map 5")
std::function< void(int room_id, const WaterFillSnapshot &)> RestoreFn
bool CanMergeWith(const UndoAction &) const override
absl::Status Undo() override
size_t MemoryUsage() const override
Approximate memory footprint for budget enforcement.
DungeonWaterFillAction(int room_id, WaterFillSnapshot before, WaterFillSnapshot after, RestoreFn restore)
WaterFillSnapshot before_
absl::Status Redo() override
Abstract base for all undoable actions (Command pattern)
MutationDomain
Domain/type of mutation for undo + invalidation routing.
Legacy chest data structure.
zelda3::CustomCollisionMap map
std::vector< DungeonSpriteSnapshot > sprites
std::vector< size_t > objects
std::vector< zelda3::PotItem > items
std::vector< SelectedEntity > entities
std::vector< zelda3::Room::Door > doors
Represents a selected entity in the dungeon editor.
std::vector< uint16_t > offsets
Represents a door in a dungeon room.