yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
dungeon_room_selector.cc
Go to the documentation of this file.
2
4#include "imgui/imgui.h"
5#include "util/hex.h"
10
11namespace yaze::editor {
12
13using ImGui::BeginChild;
14using ImGui::EndChild;
15using ImGui::SameLine;
16
18 // Legacy combined view - prefer using DrawRoomSelector() and
19 // DrawEntranceSelector() separately via their own EditorPanels
21}
22
24 if (!rom_ || !rom_->is_loaded()) {
25 ImGui::Text("ROM not loaded");
26 return;
27 }
28
29 gui::InputHexWord("Room ID", &current_room_id_, 50.f, true);
30 ImGui::Separator();
31
32 room_filter_.Draw("Filter", ImGui::GetContentRegionAvail().x);
33
34 if (ImGui::BeginTable("RoomList", 2,
35 ImGuiTableFlags_ScrollY | ImGuiTableFlags_Borders |
36 ImGuiTableFlags_RowBg | ImGuiTableFlags_Resizable)) {
37 ImGui::TableSetupColumn("ID", ImGuiTableColumnFlags_WidthFixed, 40.0f);
38 ImGui::TableSetupColumn("Name");
39 ImGui::TableHeadersRow();
40
41 // Use kNumberOfRooms (296) as limit - rooms_ array is 0x128 elements
42 for (int i = 0; i < zelda3::kNumberOfRooms; ++i) {
43 // Use unified ResourceLabelProvider for room names
44 std::string display_name = zelda3::GetRoomLabel(i);
45
46 if (room_filter_.PassFilter(display_name.c_str())) {
47 ImGui::TableNextRow();
48 ImGui::TableNextColumn();
49
50 char label[32];
51 snprintf(label, sizeof(label), "%03X", i);
52 if (ImGui::Selectable(label, current_room_id_ == i,
53 ImGuiSelectableFlags_SpanAllColumns)) {
57 }
58 }
59
60 ImGui::TableNextColumn();
61 ImGui::TextUnformatted(display_name.c_str());
62 }
63 }
64 ImGui::EndTable();
65 }
66}
67
69 if (!rom_ || !rom_->is_loaded()) {
70 ImGui::Text("ROM not loaded");
71 return;
72 }
73
74 if (!entrances_) {
75 ImGui::Text("Entrances not loaded");
76 return;
77 }
78
79 auto current_entrance = (*entrances_)[current_entrance_id_];
80
81 // Organized Properties Table
82 if (ImGui::BeginTable("EntranceProps", 4, ImGuiTableFlags_Borders)) {
83 ImGui::TableSetupColumn("Core", ImGuiTableColumnFlags_WidthStretch);
84 ImGui::TableSetupColumn("Position", ImGuiTableColumnFlags_WidthStretch);
85 ImGui::TableSetupColumn("Camera", ImGuiTableColumnFlags_WidthStretch);
86 ImGui::TableSetupColumn("Scroll", ImGuiTableColumnFlags_WidthStretch);
87 ImGui::TableHeadersRow();
88
89 ImGui::TableNextRow();
90 ImGui::TableNextColumn();
91 gui::InputHexWord("Entr ID", &current_entrance.entrance_id_);
92 gui::InputHexWord("Room ID", &current_entrance.room_);
93 gui::InputHexByte("Dungeon", &current_entrance.dungeon_id_);
94 gui::InputHexByte("Music", &current_entrance.music_);
95
96 ImGui::TableNextColumn();
97 gui::InputHexWord("Player X", &current_entrance.x_position_);
98 gui::InputHexWord("Player Y", &current_entrance.y_position_);
99 gui::InputHexByte("Blockset", &current_entrance.blockset_);
100 gui::InputHexByte("Floor", &current_entrance.floor_);
101
102 ImGui::TableNextColumn();
103 gui::InputHexWord("Cam Trg X", &current_entrance.camera_trigger_x_);
104 gui::InputHexWord("Cam Trg Y", &current_entrance.camera_trigger_y_);
105 gui::InputHexWord("Exit", &current_entrance.exit_);
106
107 ImGui::TableNextColumn();
108 gui::InputHexWord("Scroll X", &current_entrance.camera_x_);
109 gui::InputHexWord("Scroll Y", &current_entrance.camera_y_);
110
111 ImGui::EndTable();
112 }
113
114 ImGui::Separator();
115 if (ImGui::CollapsingHeader("Camera Boundaries")) {
116 ImGui::Text(" North East South West");
117 ImGui::Text("Quadrant ");
118 SameLine();
119 gui::InputHexByte("##QN", &current_entrance.camera_boundary_qn_, 40.f);
120 SameLine();
121 gui::InputHexByte("##QE", &current_entrance.camera_boundary_qe_, 40.f);
122 SameLine();
123 gui::InputHexByte("##QS", &current_entrance.camera_boundary_qs_, 40.f);
124 SameLine();
125 gui::InputHexByte("##QW", &current_entrance.camera_boundary_qw_, 40.f);
126
127 ImGui::Text("Full Room ");
128 SameLine();
129 gui::InputHexByte("##FN", &current_entrance.camera_boundary_fn_, 40.f);
130 SameLine();
131 gui::InputHexByte("##FE", &current_entrance.camera_boundary_fe_, 40.f);
132 SameLine();
133 gui::InputHexByte("##FS", &current_entrance.camera_boundary_fs_, 40.f);
134 SameLine();
135 gui::InputHexByte("##FW", &current_entrance.camera_boundary_fw_, 40.f);
136 }
137 ImGui::Separator();
138
139 entrance_filter_.Draw("Filter", ImGui::GetContentRegionAvail().x);
140
141 // Entrance array layout (from LoadRoomEntrances):
142 // indices 0-6 (0x00-0x06): Spawn points (7 entries)
143 // indices 7-139 (0x07-0x8B): Regular entrances (133 entries, IDs 0x00-0x84)
144 constexpr int kNumSpawnPoints = 7; // 0x07
145 constexpr int kNumEntrances = 133; // 0x85
146 constexpr int kTotalEntries = 140; // 0x8C
147
148 if (ImGui::BeginTable("EntranceList", 3,
149 ImGuiTableFlags_ScrollY | ImGuiTableFlags_Borders |
150 ImGuiTableFlags_RowBg | ImGuiTableFlags_Resizable)) {
151 ImGui::TableSetupColumn("ID", ImGuiTableColumnFlags_WidthFixed, 40.0f);
152 ImGui::TableSetupColumn("Room", ImGuiTableColumnFlags_WidthFixed, 50.0f);
153 ImGui::TableSetupColumn("Name");
154 ImGui::TableHeadersRow();
155
156 for (int i = 0; i < kTotalEntries; i++) {
157 std::string display_name;
158
159 if (i < kNumSpawnPoints) {
160 // Spawn points are at indices 0-6
161 display_name = absl::StrFormat("Spawn Point %d", i);
162 } else {
163 // Regular entrances are at indices 7-139, mapped to entrance IDs 0-132
164 int entrance_id = i - kNumSpawnPoints;
165 if (entrance_id < kNumEntrances) {
166 // Use unified ResourceLabelProvider for entrance names
167 display_name = zelda3::GetEntranceLabel(entrance_id);
168 } else {
169 display_name = absl::StrFormat("Unknown Entrance %d", i);
170 }
171 }
172
173 // Get room ID for this entrance
174 int room_id = (i < static_cast<int>(entrances_->size()))
175 ? (*entrances_)[i].room_ : 0;
176
177 // Include room ID in filter matching
178 char filter_text[256];
179 snprintf(filter_text, sizeof(filter_text), "%s %03X",
180 display_name.c_str(), room_id);
181
182 if (entrance_filter_.PassFilter(filter_text)) {
183 ImGui::TableNextRow();
184 ImGui::TableNextColumn();
185
186 char label[32];
187 snprintf(label, sizeof(label), "%02X", i);
188 if (ImGui::Selectable(label, current_entrance_id_ == i,
189 ImGuiSelectableFlags_SpanAllColumns)) {
191 if (i < static_cast<int>(entrances_->size())) {
192 // Use entrance callback if set, otherwise fall back to room callback
195 } else if (room_selected_callback_) {
197 }
198 }
199 }
200
201 ImGui::TableNextColumn();
202 ImGui::Text("%03X", room_id);
203
204 ImGui::TableNextColumn();
205 ImGui::TextUnformatted(display_name.c_str());
206 }
207 }
208 ImGui::EndTable();
209 }
210}
211
212} // namespace yaze::editor
bool is_loaded() const
Definition rom.h:128
std::array< zelda3::RoomEntrance, 0x8C > * entrances_
std::function< void(int)> room_selected_callback_
std::function< void(int)> entrance_selected_callback_
Editors are the view controllers for the application.
Definition agent_chat.cc:23
bool InputHexWord(const char *label, uint16_t *data, float input_width, bool no_step)
Definition input.cc:344
bool InputHexByte(const char *label, uint8_t *data, float input_width, bool no_step)
Definition input.cc:370
std::string GetEntranceLabel(int id)
Convenience function to get an entrance label.
std::string GetRoomLabel(int id)
Convenience function to get a room label.
constexpr int kNumberOfRooms