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
11#include "app/editor/editor.h"
12#include "imgui/imgui.h"
13#include "rom/rom.h"
15#include "zelda3/dungeon/room.h"
17#include "zelda3/game_data.h"
18
19namespace yaze {
20
21namespace project {
22struct YazeProject;
23} // namespace project
24
25namespace editor {
26
31 kFocusInWorkbench, // Default: navigate workbench to this room
32 kOpenStandalone, // Open as separate panel (even in workbench mode)
33 kPreview, // Update state only, don't show/focus panels
34};
35
40 public:
41 explicit DungeonRoomSelector(Rom* rom = nullptr) : rom_(rom) {}
42
43 void Draw();
44 void DrawRoomSelector(RoomSelectionIntent single_click_intent =
46 void DrawRoomBrowser(RoomSelectionIntent single_click_intent =
50
51 // Unified context setter (preferred)
53 rom_ = ctx.rom;
55 }
56 EditorContext context() const { return {rom_, game_data_}; }
57
58 // Individual setters for compatibility
59 void SetRom(Rom* rom) { rom_ = rom; }
60 Rom* rom() const { return rom_; }
63 void SetProject(const project::YazeProject* project) { project_ = project; }
64
65 // Room selection
66 void set_current_room_id(uint16_t room_id) {
67 if (current_room_id_ != room_id) {
69 }
70 current_room_id_ = room_id;
71 }
72 int current_room_id() const { return current_room_id_; }
73
74 void set_active_rooms(const ImVector<int>& rooms) { active_rooms_ = rooms; }
75 const ImVector<int>& active_rooms() const { return active_rooms_; }
76 ImVector<int>& mutable_active_rooms() { return active_rooms_; }
77
78 // Entrance selection
79 void set_current_entrance_id(int entrance_id) {
80 current_entrance_id_ = entrance_id;
81 }
83
84 // Room data access
85 void set_rooms(DungeonRoomStore* rooms) { rooms_ = rooms; }
88 entrances_ = entrances;
89 }
91 std::array<zelda3::DungeonSpawnPoint, zelda3::kNumDungeonSpawnPoints>*
92 spawn_points) {
93 spawn_points_ = spawn_points;
94 }
95
96 // Callback for room selection events (single-click / default)
97 void SetRoomSelectedCallback(std::function<void(int)> callback) {
98 room_selected_callback_ = std::move(callback);
99 }
100 [[deprecated("Use SetRoomSelectedCallback() instead")]] void
101 set_room_selected_callback(std::function<void(int)> callback) {
102 SetRoomSelectedCallback(std::move(callback));
103 }
104
105 // Intent-aware room selection callback (double-click, context menu)
107 std::function<void(int, RoomSelectionIntent)> callback) {
108 room_intent_callback_ = std::move(callback);
109 }
110
111 // Callback for entrance selection events (triggers room opening)
112 void SetEntranceSelectedCallback(std::function<void(int)> callback) {
113 entrance_selected_callback_ = std::move(callback);
114 }
115 [[deprecated("Use SetEntranceSelectedCallback() instead")]] void
116 set_entrance_selected_callback(std::function<void(int)> callback) {
117 SetEntranceSelectedCallback(std::move(callback));
118 }
119
120 // Get dungeon name from blockset value (public utility)
121 static const char* GetBlocksetGroupName(uint8_t blockset);
122
123 private:
124 Rom* rom_ = nullptr;
127 uint16_t current_room_id_ = 0;
130 ImVector<int> active_rooms_;
131
133 std::array<zelda3::RoomEntrance, zelda3::kNumDungeonEntranceSlots>*
134 entrances_ = nullptr;
135 std::array<zelda3::DungeonSpawnPoint, zelda3::kNumDungeonSpawnPoints>*
136 spawn_points_ = nullptr;
137
138 // Callback for room selection events (single-click / default)
139 std::function<void(int)> room_selected_callback_;
140
141 // Intent-aware room selection callback (double-click, context menu)
143
144 // Callback for entrance selection events
145 std::function<void(int)> entrance_selected_callback_;
146
147 ImGuiTextFilter room_filter_;
148 ImGuiTextFilter entrance_filter_;
149
150 // View mode for room list
151 enum ViewMode : uint8_t {
152 kViewList = 0, // Flat list (original)
153 kViewGrouped = 1, // Grouped by dungeon/blockset
154 };
156
157 // Object-type filter for room list (especially useful on iOS)
158 // When enabled, only rooms containing the selected entity types are shown
166
167 // Cached filtered indices for virtualization
168 std::vector<int> filtered_room_indices_;
170 std::string last_room_filter_;
173
176 bool PassesEntityTypeFilter(int room_id) const;
177 void DrawRoomSelectorInternal(RoomSelectionIntent single_click_intent,
178 bool show_room_id_input);
179 void DrawEntranceSelectorInternal(bool show_properties);
180
181 // Draw the grouped-by-dungeon view
182 void DrawGroupedRoomList(RoomSelectionIntent single_click_intent);
183};
184
185} // namespace editor
186} // namespace yaze
187
188#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.
std::array< zelda3::DungeonSpawnPoint, zelda3::kNumDungeonSpawnPoints > * spawn_points_
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_
void set_spawn_points(std::array< zelda3::DungeonSpawnPoint, zelda3::kNumDungeonSpawnPoints > *spawn_points)
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