yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
dungeon_entrances_panel.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_DUNGEON_PANELS_DUNGEON_ENTRANCES_PANEL_H_
2#define YAZE_APP_EDITOR_DUNGEON_PANELS_DUNGEON_ENTRANCES_PANEL_H_
3
4#include <functional>
5#include <string>
6
10#include "app/gui/core/input.h"
11#include "imgui/imgui.h"
12#include "util/i18n/tr.h"
13#include "zelda3/common.h"
16
17namespace yaze {
18namespace editor {
19
30 public:
33 int* current_entrance_id,
34 std::function<void(int)> on_entrance_selected)
35 : entrances_(entrances),
36 current_entrance_id_(current_entrance_id),
37 on_entrance_selected_(std::move(on_entrance_selected)) {}
38
39 // ==========================================================================
40 // WindowContent Identity
41 // ==========================================================================
42
43 std::string GetId() const override { return "dungeon.entrance_properties"; }
44 std::string GetDisplayName() const override { return "Entrance Properties"; }
45 std::string GetIcon() const override { return ICON_MD_TUNE; }
46 std::string GetEditorCategory() const override { return "Dungeon"; }
47 int GetPriority() const override { return 26; }
48
49 // ==========================================================================
50 // WindowContent Drawing
51 // ==========================================================================
52
53 void Draw(bool* p_open) override {
55 return;
56 if (*current_entrance_id_ < 0 ||
57 *current_entrance_id_ >= static_cast<int>(entrances_->size())) {
59 }
60
61 auto& current_entrance = (*entrances_)[*current_entrance_id_];
62 const bool properties_editable =
64 bool changed = false;
65
66 // Entrance properties
67 ImGui::Text(tr("Entrance ID: %04X"), current_entrance.entrance_id_);
68 if (!properties_editable) {
69 ImGui::TextWrapped(tr(kDungeonSpawnReadOnlyReason));
70 }
71 ImGui::BeginDisabled(!properties_editable);
72 changed |= gui::InputHexWord("Room ID", &current_entrance.room_);
73 ImGui::SameLine();
74 changed |= gui::InputHexByte("Dungeon ID", &current_entrance.dungeon_id_,
75 50.f, true);
76
77 changed |=
78 gui::InputHexByte("Blockset", &current_entrance.blockset_, 50.f, true);
79 ImGui::SameLine();
80 changed |= gui::InputHexByte("Music", &current_entrance.music_, 50.f, true);
81 ImGui::SameLine();
82 changed |= gui::InputHexByte("Floor", &current_entrance.floor_);
83
84 ImGui::Separator();
85
86 changed |= gui::InputHexWord("Player X ", &current_entrance.x_position_);
87 ImGui::SameLine();
88 changed |= gui::InputHexWord("Player Y ", &current_entrance.y_position_);
89
90 changed |=
91 gui::InputHexWord("Camera X", &current_entrance.camera_trigger_x_);
92 ImGui::SameLine();
93 changed |=
94 gui::InputHexWord("Camera Y", &current_entrance.camera_trigger_y_);
95
96 changed |= gui::InputHexWord("Scroll X ", &current_entrance.camera_x_);
97 ImGui::SameLine();
98 changed |= gui::InputHexWord("Scroll Y ", &current_entrance.camera_y_);
99
100 changed |= gui::InputHexWord("Exit", &current_entrance.exit_, 50.f, true);
101
102 ImGui::Separator();
103 ImGui::Text(tr("Camera Boundaries"));
104 ImGui::Separator();
105 ImGui::Text(tr("\t\t\t\t\tNorth East South West"));
106
107 changed |= gui::InputHexByte(
108 "Quadrant", &current_entrance.camera_boundary_qn_, 50.f, true);
109 ImGui::SameLine();
110 changed |= gui::InputHexByte("##QE", &current_entrance.camera_boundary_qe_,
111 50.f, true);
112 ImGui::SameLine();
113 changed |= gui::InputHexByte("##QS", &current_entrance.camera_boundary_qs_,
114 50.f, true);
115 ImGui::SameLine();
116 changed |= gui::InputHexByte("##QW", &current_entrance.camera_boundary_qw_,
117 50.f, true);
118
119 changed |= gui::InputHexByte(
120 "Full room", &current_entrance.camera_boundary_fn_, 50.f, true);
121 ImGui::SameLine();
122 changed |= gui::InputHexByte("##FE", &current_entrance.camera_boundary_fe_,
123 50.f, true);
124 ImGui::SameLine();
125 changed |= gui::InputHexByte("##FS", &current_entrance.camera_boundary_fs_,
126 50.f, true);
127 ImGui::SameLine();
128 changed |= gui::InputHexByte("##FW", &current_entrance.camera_boundary_fw_,
129 50.f, true);
130 ImGui::EndDisabled();
131
133 changed);
134
135 ImGui::Separator();
136
137 // Entrance list
138 // Array layout (from LoadRoomEntrances):
139 // indices 0-6 (0x00-0x06): Spawn points (7 entries)
140 // indices 7-139 (0x07-0x8B): Regular entrances (133 entries)
141 constexpr int kNumSpawnPoints = zelda3::kNumDungeonSpawnPoints;
142 constexpr int kNumEntrances = zelda3::kNumRegularDungeonEntrances;
143 constexpr int kTotalEntries = zelda3::kNumDungeonEntranceSlots;
144
145 if (ImGui::BeginChild("##EntrancesList", ImVec2(0, 0), true,
146 ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
147 for (int i = 0; i < kTotalEntries; i++) {
148 std::string entrance_name;
149 if (i < kNumSpawnPoints) {
150 // Spawn points at indices 0-6
151 char buf[32];
152 snprintf(buf, sizeof(buf), "Spawn Point %d", i);
153 entrance_name = buf;
154 } else {
155 // Regular entrances at indices 7-139, mapped to kEntranceNames[0-132]
156 int entrance_id = i - kNumSpawnPoints;
157 if (entrance_id < kNumEntrances) {
158 // Use unified ResourceLabelProvider for entrance names
159 entrance_name = zelda3::GetEntranceLabel(entrance_id);
160 } else {
161 char buf[32];
162 snprintf(buf, sizeof(buf), "Unknown %d", i);
163 entrance_name = buf;
164 }
165 }
166
167 int room_id = (*entrances_)[i].room_;
168 // Use unified ResourceLabelProvider for room names
169 std::string room_name = zelda3::GetRoomLabel(room_id);
170
171 char label[256];
172 snprintf(label, sizeof(label), "[%02X] %s -> %s (%03X)", i,
173 entrance_name.c_str(), room_name.c_str(), room_id);
174
175 bool is_selected = (*current_entrance_id_ == i);
176 if (ImGui::Selectable(label, is_selected)) {
180 }
181 }
182 }
183 }
184 ImGui::EndChild();
185 }
186
187 private:
188 std::array<zelda3::RoomEntrance, zelda3::kNumDungeonEntranceSlots>*
189 entrances_ = nullptr;
190 int* current_entrance_id_ = nullptr;
191 std::function<void(int)> on_entrance_selected_;
192};
193
194} // namespace editor
195} // namespace yaze
196
197#endif // YAZE_APP_EDITOR_DUNGEON_PANELS_DUNGEON_ENTRANCES_PANEL_H_
WindowContent for displaying and editing dungeon entrances.
void Draw(bool *p_open) override
Draw the panel content.
std::function< void(int)> on_entrance_selected_
int GetPriority() const override
Get display priority for menu ordering.
std::string GetDisplayName() const override
Human-readable name shown in menus and title bars.
std::array< zelda3::RoomEntrance, zelda3::kNumDungeonEntranceSlots > * entrances_
std::string GetEditorCategory() const override
Editor category this panel belongs to.
std::string GetId() const override
Unique identifier for this panel.
std::string GetIcon() const override
Material Design icon for this panel.
DungeonEntrancesPanel(std::array< zelda3::RoomEntrance, zelda3::kNumDungeonEntranceSlots > *entrances, int *current_entrance_id, std::function< void(int)> on_entrance_selected)
Base interface for all logical window content components.
Dungeon Room Entrance or Spawn Point.
#define ICON_MD_TUNE
Definition icons.h:2022
bool CanEditDungeonEntrance(int slot_index, const zelda3::RoomEntrance &entrance)
constexpr char kDungeonSpawnReadOnlyReason[]
bool MarkDungeonEntranceDirtyIfEditable(int slot_index, zelda3::RoomEntrance &entrance, bool properties_changed)
bool InputHexWord(const char *label, uint16_t *data, float input_width, bool no_step)
Definition input.cc:355
bool InputHexByte(const char *label, uint8_t *data, float input_width, bool no_step)
Definition input.cc:376
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 kNumRegularDungeonEntrances
constexpr int kNumDungeonSpawnPoints
constexpr int kNumDungeonEntranceSlots