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