yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
interaction_context.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_DUNGEON_INTERACTION_INTERACTION_CONTEXT_H_
2#define YAZE_APP_EDITOR_DUNGEON_INTERACTION_INTERACTION_CONTEXT_H_
3
4#include <array>
5#include <cstdint>
6#include <functional>
7
12#include "rom/rom.h"
13#include "zelda3/dungeon/room.h"
14
15namespace yaze {
16namespace editor {
17
18class ObjectSelection;
19
23enum class EntityType {
24 None,
25 Object, // Room tile objects
26 Door, // Door entities
27 Sprite, // Enemy/NPC sprites
28 Item // Pot items
29};
30
38enum class MutationDomain : uint8_t {
39 kUnknown = 0,
41 kDoors,
43 kItems,
46};
47
53 size_t index = 0; // Index into the respective container
54
55 bool operator==(const SelectedEntity& other) const {
56 return type == other.type && index == other.index;
57 }
58};
59
77 // Core dependencies (required)
78 gui::Canvas* canvas = nullptr;
79 Rom* rom = nullptr;
83
84 // Palette for rendering previews
86
87 // Unified callbacks
88 // Called before any state modification (for undo snapshots)
89 std::function<void()> on_mutation;
90
91 // Called after rendering changes require cache refresh
92 std::function<void()> on_invalidate_cache;
93
94 // Called when selection state changes
95 std::function<void()> on_selection_changed;
96
97 // Called when entity (door/sprite/item) changes
98 std::function<void()> on_entity_changed;
99
100 // Last mutation/invalidation domain (best-effort). Set by Notify* helpers so
101 // the editor can route undo capture and expensive rerenders appropriately.
104
108 bool IsValid() const { return canvas != nullptr && rooms != nullptr; }
109
116 return nullptr;
117 }
118 return &(*rooms)[current_room_id];
119 }
120
127 return nullptr;
128 }
129 return &(*rooms)[current_room_id];
130 }
131
139 last_mutation_domain = domain;
140 if (on_mutation)
141 on_mutation();
142 }
143
155
163
167 void NotifyEntityChanged() const {
170 }
171};
172
173} // namespace editor
174} // namespace yaze
175
176#endif // YAZE_APP_EDITOR_DUNGEON_INTERACTION_INTERACTION_CONTEXT_H_
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:28
Manages object selection state and operations for the dungeon editor.
Modern, robust canvas for drawing and manipulating graphics.
Definition canvas.h:150
bool IsValidRoomId(int room_id)
Validate room ID is within valid range.
MutationDomain
Domain/type of mutation for undo + invalidation routing.
EntityType
Type of entity that can be selected in the dungeon editor.
Shared context for all interaction handlers.
std::function< void()> on_invalidate_cache
const zelda3::Room * GetCurrentRoomConst() const
Get const pointer to current room.
void NotifyEntityChanged() const
Notify that entity has changed.
void NotifyInvalidateCache(MutationDomain domain=MutationDomain::kUnknown) const
Notify that cache invalidation is needed.
bool IsValid() const
Check if context has required dependencies.
void NotifySelectionChanged() const
Notify that selection has changed.
void NotifyMutation(MutationDomain domain=MutationDomain::kUnknown) const
Notify that a mutation is about to happen.
zelda3::Room * GetCurrentRoom() const
Get pointer to current room.
std::function< void()> on_entity_changed
std::function< void()> on_selection_changed
Represents a selected entity in the dungeon editor.
bool operator==(const SelectedEntity &other) const
Represents a group of palettes.