yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
tile16_undo_actions.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_OVERWORLD_TILE16_UNDO_ACTIONS_H_
2#define YAZE_APP_EDITOR_OVERWORLD_TILE16_UNDO_ACTIONS_H_
3
4#include <cstdint>
5#include <functional>
6#include <string>
7#include <utility>
8#include <vector>
9
10#include "absl/status/status.h"
11#include "absl/strings/str_format.h"
15
16namespace yaze {
17namespace editor {
18
26 int tile_id = 0;
27 std::vector<uint8_t> bitmap_data;
30 uint8_t palette = 0;
31 bool x_flip = false;
32 bool y_flip = false;
33 bool priority = false;
34};
35
46 public:
47 using RestoreFn = std::function<void(const Tile16Snapshot&)>;
48
50 RestoreFn restore)
51 : before_(std::move(before)),
52 after_(std::move(after)),
53 restore_(std::move(restore)) {}
54
55 absl::Status Undo() override {
57 return absl::OkStatus();
58 }
59
60 absl::Status Redo() override {
62 return absl::OkStatus();
63 }
64
65 std::string Description() const override {
66 return absl::StrFormat("Edit tile16 #%d", before_.tile_id);
67 }
68
69 size_t MemoryUsage() const override {
70 return before_.bitmap_data.size() + after_.bitmap_data.size();
71 }
72
73 bool CanMergeWith(const UndoAction& /*prev*/) const override {
74 return false;
75 }
76
77 private:
81};
82
83} // namespace editor
84} // namespace yaze
85
86#endif // YAZE_APP_EDITOR_OVERWORLD_TILE16_UNDO_ACTIONS_H_
Undoable action for edits to a single Tile16.
bool CanMergeWith(const UndoAction &) const override
std::string Description() const override
Human-readable description (e.g., "Paint 12 tiles on map 5")
Tile16EditAction(Tile16Snapshot before, Tile16Snapshot after, RestoreFn restore)
size_t MemoryUsage() const override
Approximate memory footprint for budget enforcement.
std::function< void(const Tile16Snapshot &)> RestoreFn
Abstract base for all undoable actions (Command pattern)
Definition undo_action.h:20
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
Tile composition of four 8x8 tiles.
Definition snes_tile.h:142
Snapshot of a Tile16's editable state for undo/redo.
std::vector< uint8_t > bitmap_data