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
11#include "rom/rom.h"
12#include "zelda3/dungeon/room.h"
13
14namespace yaze {
15namespace editor {
16
17class ObjectSelection;
18
22enum class EntityType {
23 None,
24 Object, // Room tile objects
25 Door, // Door entities
26 Sprite, // Enemy/NPC sprites
27 Item // Pot items
28};
29
37enum class MutationDomain : uint8_t {
38 kUnknown = 0,
40 kDoors,
42 kItems,
45};
46
52 size_t index = 0; // Index into the respective container
53
54 bool operator==(const SelectedEntity& other) const {
55 return type == other.type && index == other.index;
56 }
57};
58
76 // Core dependencies (required)
77 gui::Canvas* canvas = nullptr;
78 Rom* rom = nullptr;
79 std::array<zelda3::Room, dungeon_coords::kRoomCount>* rooms = nullptr;
82
83 // Palette for rendering previews
85
86 // Unified callbacks
87 // Called before any state modification (for undo snapshots)
88 std::function<void()> on_mutation;
89
90 // Called after rendering changes require cache refresh
91 std::function<void()> on_invalidate_cache;
92
93 // Called when selection state changes
94 std::function<void()> on_selection_changed;
95
96 // Called when entity (door/sprite/item) changes
97 std::function<void()> on_entity_changed;
98
99 // Last mutation/invalidation domain (best-effort). Set by Notify* helpers so
100 // the editor can route undo capture and expensive rerenders appropriately.
103
107 bool IsValid() const { return canvas != nullptr && rooms != nullptr; }
108
115 return nullptr;
116 }
117 return &(*rooms)[current_room_id];
118 }
119
126 return nullptr;
127 }
128 return &(*rooms)[current_room_id];
129 }
130
141
152
159
166};
167
168} // namespace editor
169} // namespace yaze
170
171#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.
std::array< zelda3::Room, dungeon_coords::kRoomCount > * rooms
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.