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
3#include "app/gui/input.h"
6#include "imgui/imgui.h"
7#include "util/hex.h"
8
9namespace yaze::editor {
10
11using ImGui::BeginChild;
12using ImGui::EndChild;
13using ImGui::SameLine;
14
16 if (ImGui::BeginTabBar("##DungeonRoomTabBar")) {
17 if (ImGui::BeginTabItem("Rooms")) {
19 ImGui::EndTabItem();
20 }
21 if (ImGui::BeginTabItem("Entrances")) {
23 ImGui::EndTabItem();
24 }
25 ImGui::EndTabBar();
26 }
27}
28
30 if (!rom_ || !rom_->is_loaded()) {
31 ImGui::Text("ROM not loaded");
32 return;
33 }
34
35 gui::InputHexWord("Room ID", &current_room_id_, 50.f, true);
36
37 if (ImGuiID child_id = ImGui::GetID((void *)(intptr_t)9);
38 BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
39 ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
40 int i = 0;
41 for (const auto each_room_name : zelda3::kRoomNames) {
43 current_room_id_ == i, "Dungeon Room Names", util::HexByte(i),
44 each_room_name.data());
45 if (ImGui::IsItemClicked()) {
47 // Notify the dungeon editor about room selection
50 }
51 }
52 i += 1;
53 }
54 }
55 EndChild();
56}
57
59 if (!rom_ || !rom_->is_loaded()) {
60 ImGui::Text("ROM not loaded");
61 return;
62 }
63
64 if (!entrances_) {
65 ImGui::Text("Entrances not loaded");
66 return;
67 }
68
69 auto current_entrance = (*entrances_)[current_entrance_id_];
70 gui::InputHexWord("Entrance ID", &current_entrance.entrance_id_);
71 gui::InputHexWord("Room ID", &current_entrance.room_);
72 SameLine();
73
74 gui::InputHexByte("Dungeon ID", &current_entrance.dungeon_id_, 50.f, true);
75 gui::InputHexByte("Blockset", &current_entrance.blockset_, 50.f, true);
76 SameLine();
77
78 gui::InputHexByte("Music", &current_entrance.music_, 50.f, true);
79 SameLine();
80 gui::InputHexByte("Floor", &current_entrance.floor_);
81 ImGui::Separator();
82
83 gui::InputHexWord("Player X ", &current_entrance.x_position_);
84 SameLine();
85 gui::InputHexWord("Player Y ", &current_entrance.y_position_);
86
87 gui::InputHexWord("Camera X", &current_entrance.camera_trigger_x_);
88 SameLine();
89 gui::InputHexWord("Camera Y", &current_entrance.camera_trigger_y_);
90
91 gui::InputHexWord("Scroll X ", &current_entrance.camera_x_);
92 SameLine();
93 gui::InputHexWord("Scroll Y ", &current_entrance.camera_y_);
94
95 gui::InputHexWord("Exit", &current_entrance.exit_, 50.f, true);
96
97 ImGui::Separator();
98 ImGui::Text("Camera Boundaries");
99 ImGui::Separator();
100 ImGui::Text("\t\t\t\t\tNorth East South West");
101 gui::InputHexByte("Quadrant", &current_entrance.camera_boundary_qn_, 50.f,
102 true);
103 SameLine();
104 gui::InputHexByte("", &current_entrance.camera_boundary_qe_, 50.f, true);
105 SameLine();
106 gui::InputHexByte("", &current_entrance.camera_boundary_qs_, 50.f, true);
107 SameLine();
108 gui::InputHexByte("", &current_entrance.camera_boundary_qw_, 50.f, true);
109
110 gui::InputHexByte("Full room", &current_entrance.camera_boundary_fn_, 50.f,
111 true);
112 SameLine();
113 gui::InputHexByte("", &current_entrance.camera_boundary_fe_, 50.f, true);
114 SameLine();
115 gui::InputHexByte("", &current_entrance.camera_boundary_fs_, 50.f, true);
116 SameLine();
117 gui::InputHexByte("", &current_entrance.camera_boundary_fw_, 50.f, true);
118
119 if (BeginChild("EntranceSelector", ImVec2(0, 0), true,
120 ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
121 for (int i = 0; i < 0x8C; i++) {
122 // The last seven are the spawn points
123 auto entrance_name = absl::StrFormat("Spawn Point %d", i - 0x85);
124 if (i < 0x85) {
125 entrance_name = std::string(zelda3::kEntranceNames[i]);
126 }
128 current_entrance_id_ == i, "Dungeon Entrance Names",
129 util::HexByte(i), entrance_name);
130
131 if (ImGui::IsItemClicked()) {
133 if (i < entrances_->size()) {
134 int room_id = (*entrances_)[i].room_;
135 // Notify the dungeon editor about room selection
138 }
139 }
140 }
141 }
142 }
143 EndChild();
144}
145
146} // namespace yaze::editor
core::ResourceLabelManager * resource_label()
Definition rom.h:220
bool is_loaded() const
Definition rom.h:197
std::array< zelda3::RoomEntrance, 0x8C > * entrances_
std::function< void(int)> room_selected_callback_
Editors are the view controllers for the application.
bool InputHexWord(const char *label, uint16_t *data, float input_width, bool no_step)
Definition input.cc:175
bool InputHexByte(const char *label, uint8_t *data, float input_width, bool no_step)
Definition input.cc:189
std::string HexByte(uint8_t byte, HexStringParams params)
Definition hex.cc:30
constexpr std::string_view kRoomNames[]
Definition room.h:484
constexpr const char * kEntranceNames[]
Definition common.h:47
void SelectableLabelWithNameEdit(bool selected, const std::string &type, const std::string &key, const std::string &defaultValue)
Definition project.cc:855