yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
dungeon_room_selector.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_DUNGEON_DUNGEON_ROOM_SELECTOR_H
2#define YAZE_APP_EDITOR_DUNGEON_DUNGEON_ROOM_SELECTOR_H
3
4#include <cstdint>
5#include <functional>
6#include <string>
7#include <vector>
8
10#include "app/editor/editor.h"
11#include "imgui/imgui.h"
12#include "rom/rom.h"
13#include "zelda3/dungeon/room.h"
15#include "zelda3/game_data.h"
16
17namespace yaze {
18
19namespace project {
20struct YazeProject;
21} // namespace project
22
23namespace editor {
24
29 kFocusInWorkbench, // Default: navigate workbench to this room
30 kOpenStandalone, // Open as separate panel (even in workbench mode)
31 kPreview, // Update state only, don't show/focus panels
32};
33
38 public:
39 explicit DungeonRoomSelector(Rom* rom = nullptr) : rom_(rom) {}
40
41 void Draw();
42 void DrawRoomSelector(RoomSelectionIntent single_click_intent =
44 void DrawRoomBrowser(RoomSelectionIntent single_click_intent =
48
49 // Unified context setter (preferred)
51 rom_ = ctx.rom;
53 }
54 EditorContext context() const { return {rom_, game_data_}; }
55
56 // Individual setters for compatibility
57 void SetRom(Rom* rom) { rom_ = rom; }
58 Rom* rom() const { return rom_; }
61 void SetProject(const project::YazeProject* project) { project_ = project; }
62
63 // Room selection
64 void set_current_room_id(uint16_t room_id) {
65 if (current_room_id_ != room_id) {
67 }
68 current_room_id_ = room_id;
69 }
70 int current_room_id() const { return current_room_id_; }
71
72 void set_active_rooms(const ImVector<int>& rooms) { active_rooms_ = rooms; }
73 const ImVector<int>& active_rooms() const { return active_rooms_; }
74 ImVector<int>& mutable_active_rooms() { return active_rooms_; }
75
76 // Entrance selection
77 void set_current_entrance_id(int entrance_id) {
78 current_entrance_id_ = entrance_id;
79 }
81
82 // Room data access
83 void set_rooms(DungeonRoomStore* rooms) { rooms_ = rooms; }
86 entrances_ = entrances;
87 }
88
89 // Callback for room selection events (single-click / default)
90 void SetRoomSelectedCallback(std::function<void(int)> callback) {
91 room_selected_callback_ = std::move(callback);
92 }
93 [[deprecated("Use SetRoomSelectedCallback() instead")]] void
94 set_room_selected_callback(std::function<void(int)> callback) {
95 SetRoomSelectedCallback(std::move(callback));
96 }
97
98 // Intent-aware room selection callback (double-click, context menu)
100 std::function<void(int, RoomSelectionIntent)> callback) {
101 room_intent_callback_ = std::move(callback);
102 }
103
104 // Callback for entrance selection events (triggers room opening)
105 void SetEntranceSelectedCallback(std::function<void(int)> callback) {
106 entrance_selected_callback_ = std::move(callback);
107 }
108 [[deprecated("Use SetEntranceSelectedCallback() instead")]] void
109 set_entrance_selected_callback(std::function<void(int)> callback) {
110 SetEntranceSelectedCallback(std::move(callback));
111 }
112
113 // Get dungeon name from blockset value (public utility)
114 static const char* GetBlocksetGroupName(uint8_t blockset);
115
116 private:
117 Rom* rom_ = nullptr;
120 uint16_t current_room_id_ = 0;
123 ImVector<int> active_rooms_;
124
126 std::array<zelda3::RoomEntrance, zelda3::kNumDungeonEntranceSlots>*
127 entrances_ = nullptr;
128
129 // Callback for room selection events (single-click / default)
130 std::function<void(int)> room_selected_callback_;
131
132 // Intent-aware room selection callback (double-click, context menu)
134
135 // Callback for entrance selection events
136 std::function<void(int)> entrance_selected_callback_;
137
138 ImGuiTextFilter room_filter_;
139 ImGuiTextFilter entrance_filter_;
140
141 // View mode for room list
142 enum ViewMode : uint8_t {
143 kViewList = 0, // Flat list (original)
144 kViewGrouped = 1, // Grouped by dungeon/blockset
145 };
147
148 // Object-type filter for room list (especially useful on iOS)
149 // When enabled, only rooms containing the selected entity types are shown
157
158 // Cached filtered indices for virtualization
159 std::vector<int> filtered_room_indices_;
161 std::string last_room_filter_;
163
166 bool PassesEntityTypeFilter(int room_id) const;
167 void DrawRoomSelectorInternal(RoomSelectionIntent single_click_intent,
168 bool show_room_id_input);
169 void DrawEntranceSelectorInternal(bool show_properties);
170
171 // Draw the grouped-by-dungeon view
172 void DrawGroupedRoomList(RoomSelectionIntent single_click_intent);
173};
174
175} // namespace editor
176} // namespace yaze
177
178#endif
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
Handles room and entrance selection UI.
void DrawEntranceSelectorInternal(bool show_properties)
void SetRoomSelectedWithIntentCallback(std::function< void(int, RoomSelectionIntent)> callback)
void set_entrance_selected_callback(std::function< void(int)> callback)
void DrawGroupedRoomList(RoomSelectionIntent single_click_intent)
void SetGameData(zelda3::GameData *game_data)
void SetEntranceSelectedCallback(std::function< void(int)> callback)
const ImVector< int > & active_rooms() const
void DrawRoomSelectorInternal(RoomSelectionIntent single_click_intent, bool show_room_id_input)
void set_entrances(std::array< zelda3::RoomEntrance, zelda3::kNumDungeonEntranceSlots > *entrances)
void set_current_entrance_id(int entrance_id)
void set_rooms(DungeonRoomStore *rooms)
void set_room_selected_callback(std::function< void(int)> callback)
void DrawRoomSelector(RoomSelectionIntent single_click_intent=RoomSelectionIntent::kFocusInWorkbench)
std::array< zelda3::RoomEntrance, zelda3::kNumDungeonEntranceSlots > * entrances_
void DrawRoomBrowser(RoomSelectionIntent single_click_intent=RoomSelectionIntent::kFocusInWorkbench)
bool PassesEntityTypeFilter(int room_id) const
std::function< void(int)> room_selected_callback_
void SetRoomSelectedCallback(std::function< void(int)> callback)
std::function< void(int, RoomSelectionIntent)> room_intent_callback_
const project::YazeProject * project_
static const char * GetBlocksetGroupName(uint8_t blockset)
void SetProject(const project::YazeProject *project)
void set_active_rooms(const ImVector< int > &rooms)
zelda3::GameData * game_data() const
std::function< void(int)> entrance_selected_callback_
Dungeon Room Entrance or Spawn Point.
RoomSelectionIntent
Intent for room selection in the dungeon editor.
constexpr int kNumDungeonEntranceSlots
Lightweight view into the essential runtime context (Rom + GameData)
Definition editor.h:72
zelda3::GameData * game_data
Definition editor.h:74
Modern project structure with comprehensive settings consolidation.
Definition project.h:172