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 "imgui/imgui.h"
11#include "zelda3/common.h"
14
15namespace yaze {
16namespace editor {
17
28 public:
30 std::array<zelda3::RoomEntrance, 0x8C>* entrances,
31 int* current_entrance_id,
32 std::function<void(int)> on_entrance_selected)
33 : entrances_(entrances),
34 current_entrance_id_(current_entrance_id),
35 on_entrance_selected_(std::move(on_entrance_selected)) {}
36
37 // ==========================================================================
38 // EditorPanel Identity
39 // ==========================================================================
40
41 std::string GetId() const override { return "dungeon.entrance_properties"; }
42 std::string GetDisplayName() const override { return "Entrance Properties"; }
43 std::string GetIcon() const override { return ICON_MD_TUNE; }
44 std::string GetEditorCategory() const override { return "Dungeon"; }
45 int GetPriority() const override { return 26; }
46
47 // ==========================================================================
48 // EditorPanel Drawing
49 // ==========================================================================
50
51 void Draw(bool* p_open) override {
52 if (!entrances_ || !current_entrance_id_) return;
53
54 auto& current_entrance = (*entrances_)[*current_entrance_id_];
55
56 // Entrance properties
57 gui::InputHexWord("Entrance ID", &current_entrance.entrance_id_);
58 gui::InputHexWord("Room ID",
59 reinterpret_cast<uint16_t*>(&current_entrance.room_));
60 ImGui::SameLine();
61 gui::InputHexByte("Dungeon ID", &current_entrance.dungeon_id_, 50.f, true);
62
63 gui::InputHexByte("Blockset", &current_entrance.blockset_, 50.f, true);
64 ImGui::SameLine();
65 gui::InputHexByte("Music", &current_entrance.music_, 50.f, true);
66 ImGui::SameLine();
67 gui::InputHexByte("Floor", &current_entrance.floor_);
68
69 ImGui::Separator();
70
71 gui::InputHexWord("Player X ", &current_entrance.x_position_);
72 ImGui::SameLine();
73 gui::InputHexWord("Player Y ", &current_entrance.y_position_);
74
75 gui::InputHexWord("Camera X", &current_entrance.camera_trigger_x_);
76 ImGui::SameLine();
77 gui::InputHexWord("Camera Y", &current_entrance.camera_trigger_y_);
78
79 gui::InputHexWord("Scroll X ", &current_entrance.camera_x_);
80 ImGui::SameLine();
81 gui::InputHexWord("Scroll Y ", &current_entrance.camera_y_);
82
83 gui::InputHexWord("Exit",
84 reinterpret_cast<uint16_t*>(&current_entrance.exit_),
85 50.f, true);
86
87 ImGui::Separator();
88 ImGui::Text("Camera Boundaries");
89 ImGui::Separator();
90 ImGui::Text("\t\t\t\t\tNorth East South West");
91
92 gui::InputHexByte("Quadrant", &current_entrance.camera_boundary_qn_, 50.f,
93 true);
94 ImGui::SameLine();
95 gui::InputHexByte("##QE", &current_entrance.camera_boundary_qe_, 50.f, true);
96 ImGui::SameLine();
97 gui::InputHexByte("##QS", &current_entrance.camera_boundary_qs_, 50.f, true);
98 ImGui::SameLine();
99 gui::InputHexByte("##QW", &current_entrance.camera_boundary_qw_, 50.f, true);
100
101 gui::InputHexByte("Full room", &current_entrance.camera_boundary_fn_, 50.f,
102 true);
103 ImGui::SameLine();
104 gui::InputHexByte("##FE", &current_entrance.camera_boundary_fe_, 50.f, true);
105 ImGui::SameLine();
106 gui::InputHexByte("##FS", &current_entrance.camera_boundary_fs_, 50.f, true);
107 ImGui::SameLine();
108 gui::InputHexByte("##FW", &current_entrance.camera_boundary_fw_, 50.f, true);
109
110 ImGui::Separator();
111
112 // Entrance list
113 // Array layout (from LoadRoomEntrances):
114 // indices 0-6 (0x00-0x06): Spawn points (7 entries)
115 // indices 7-139 (0x07-0x8B): Regular entrances (133 entries)
116 constexpr int kNumSpawnPoints = 7;
117 constexpr int kNumEntrances = 133;
118 constexpr int kTotalEntries = 140;
119
120 if (ImGui::BeginChild("##EntrancesList", ImVec2(0, 0), true,
121 ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
122 for (int i = 0; i < kTotalEntries; i++) {
123 std::string entrance_name;
124 if (i < kNumSpawnPoints) {
125 // Spawn points at indices 0-6
126 char buf[32];
127 snprintf(buf, sizeof(buf), "Spawn Point %d", i);
128 entrance_name = buf;
129 } else {
130 // Regular entrances at indices 7-139, mapped to kEntranceNames[0-132]
131 int entrance_id = i - kNumSpawnPoints;
132 if (entrance_id < kNumEntrances) {
133 // Use unified ResourceLabelProvider for entrance names
134 entrance_name = zelda3::GetEntranceLabel(entrance_id);
135 } else {
136 char buf[32];
137 snprintf(buf, sizeof(buf), "Unknown %d", i);
138 entrance_name = buf;
139 }
140 }
141
142 int room_id = (*entrances_)[i].room_;
143 // Use unified ResourceLabelProvider for room names
144 std::string room_name = zelda3::GetRoomLabel(room_id);
145
146 char label[256];
147 snprintf(label, sizeof(label), "[%02X] %s -> %s (%03X)", i,
148 entrance_name.c_str(), room_name.c_str(), room_id);
149
150 bool is_selected = (*current_entrance_id_ == i);
151 if (ImGui::Selectable(label, is_selected)) {
155 }
156 }
157 }
158 }
159 ImGui::EndChild();
160 }
161
162 private:
163 std::array<zelda3::RoomEntrance, 0x8C>* entrances_ = nullptr;
164 int* current_entrance_id_ = nullptr;
165 std::function<void(int)> on_entrance_selected_;
166};
167
168} // namespace editor
169} // namespace yaze
170
171#endif // YAZE_APP_EDITOR_DUNGEON_PANELS_DUNGEON_ENTRANCES_PANEL_H_
EditorPanel 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.
DungeonEntrancesPanel(std::array< zelda3::RoomEntrance, 0x8C > *entrances, int *current_entrance_id, std::function< void(int)> on_entrance_selected)
std::array< zelda3::RoomEntrance, 0x8C > * 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.
Base interface for all logical panel components.
#define ICON_MD_TUNE
Definition icons.h:2022
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.