- Updated include paths for various GUI-related headers to improve organization and clarity. - Introduced new components for better modularity, including PaletteEditorWidget and EditorCardManager. - Refactored existing code to utilize the new components, ensuring consistency across the GUI subsystem. Benefits: - Enhances maintainability and readability of the GUI code. - Facilitates future enhancements and optimizations within the GUI subsystem.
147 lines
4.5 KiB
C++
147 lines
4.5 KiB
C++
#include "dungeon_room_selector.h"
|
|
|
|
#include "app/gui/core/input.h"
|
|
#include "zelda3/dungeon/room.h"
|
|
#include "zelda3/dungeon/room_entrance.h"
|
|
#include "imgui/imgui.h"
|
|
#include "util/hex.h"
|
|
|
|
namespace yaze::editor {
|
|
|
|
using ImGui::BeginChild;
|
|
using ImGui::EndChild;
|
|
using ImGui::SameLine;
|
|
|
|
void DungeonRoomSelector::Draw() {
|
|
if (ImGui::BeginTabBar("##DungeonRoomTabBar")) {
|
|
if (ImGui::BeginTabItem("Rooms")) {
|
|
DrawRoomSelector();
|
|
ImGui::EndTabItem();
|
|
}
|
|
if (ImGui::BeginTabItem("Entrances")) {
|
|
DrawEntranceSelector();
|
|
ImGui::EndTabItem();
|
|
}
|
|
ImGui::EndTabBar();
|
|
}
|
|
}
|
|
|
|
void DungeonRoomSelector::DrawRoomSelector() {
|
|
if (!rom_ || !rom_->is_loaded()) {
|
|
ImGui::Text("ROM not loaded");
|
|
return;
|
|
}
|
|
|
|
gui::InputHexWord("Room ID", ¤t_room_id_, 50.f, true);
|
|
|
|
if (ImGuiID child_id = ImGui::GetID((void *)(intptr_t)9);
|
|
BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
|
|
ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
|
|
int i = 0;
|
|
for (const auto each_room_name : zelda3::kRoomNames) {
|
|
rom_->resource_label()->SelectableLabelWithNameEdit(
|
|
current_room_id_ == i, "Dungeon Room Names", util::HexByte(i),
|
|
each_room_name.data());
|
|
if (ImGui::IsItemClicked()) {
|
|
current_room_id_ = i;
|
|
// Notify the dungeon editor about room selection
|
|
if (room_selected_callback_) {
|
|
room_selected_callback_(i);
|
|
}
|
|
}
|
|
i += 1;
|
|
}
|
|
}
|
|
EndChild();
|
|
}
|
|
|
|
void DungeonRoomSelector::DrawEntranceSelector() {
|
|
if (!rom_ || !rom_->is_loaded()) {
|
|
ImGui::Text("ROM not loaded");
|
|
return;
|
|
}
|
|
|
|
if (!entrances_) {
|
|
ImGui::Text("Entrances not loaded");
|
|
return;
|
|
}
|
|
|
|
auto current_entrance = (*entrances_)[current_entrance_id_];
|
|
gui::InputHexWord("Entrance ID", ¤t_entrance.entrance_id_);
|
|
gui::InputHexWord("Room ID", ¤t_entrance.room_);
|
|
SameLine();
|
|
|
|
gui::InputHexByte("Dungeon ID", ¤t_entrance.dungeon_id_, 50.f, true);
|
|
gui::InputHexByte("Blockset", ¤t_entrance.blockset_, 50.f, true);
|
|
SameLine();
|
|
|
|
gui::InputHexByte("Music", ¤t_entrance.music_, 50.f, true);
|
|
SameLine();
|
|
gui::InputHexByte("Floor", ¤t_entrance.floor_);
|
|
ImGui::Separator();
|
|
|
|
gui::InputHexWord("Player X ", ¤t_entrance.x_position_);
|
|
SameLine();
|
|
gui::InputHexWord("Player Y ", ¤t_entrance.y_position_);
|
|
|
|
gui::InputHexWord("Camera X", ¤t_entrance.camera_trigger_x_);
|
|
SameLine();
|
|
gui::InputHexWord("Camera Y", ¤t_entrance.camera_trigger_y_);
|
|
|
|
gui::InputHexWord("Scroll X ", ¤t_entrance.camera_x_);
|
|
SameLine();
|
|
gui::InputHexWord("Scroll Y ", ¤t_entrance.camera_y_);
|
|
|
|
gui::InputHexWord("Exit", ¤t_entrance.exit_, 50.f, true);
|
|
|
|
ImGui::Separator();
|
|
ImGui::Text("Camera Boundaries");
|
|
ImGui::Separator();
|
|
ImGui::Text("\t\t\t\t\tNorth East South West");
|
|
gui::InputHexByte("Quadrant", ¤t_entrance.camera_boundary_qn_, 50.f,
|
|
true);
|
|
SameLine();
|
|
gui::InputHexByte("", ¤t_entrance.camera_boundary_qe_, 50.f, true);
|
|
SameLine();
|
|
gui::InputHexByte("", ¤t_entrance.camera_boundary_qs_, 50.f, true);
|
|
SameLine();
|
|
gui::InputHexByte("", ¤t_entrance.camera_boundary_qw_, 50.f, true);
|
|
|
|
gui::InputHexByte("Full room", ¤t_entrance.camera_boundary_fn_, 50.f,
|
|
true);
|
|
SameLine();
|
|
gui::InputHexByte("", ¤t_entrance.camera_boundary_fe_, 50.f, true);
|
|
SameLine();
|
|
gui::InputHexByte("", ¤t_entrance.camera_boundary_fs_, 50.f, true);
|
|
SameLine();
|
|
gui::InputHexByte("", ¤t_entrance.camera_boundary_fw_, 50.f, true);
|
|
|
|
if (BeginChild("EntranceSelector", ImVec2(0, 0), true,
|
|
ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
|
|
for (int i = 0; i < 0x8C; i++) {
|
|
// The last seven are the spawn points
|
|
auto entrance_name = absl::StrFormat("Spawn Point %d", i - 0x85);
|
|
if (i < 0x85) {
|
|
entrance_name = std::string(zelda3::kEntranceNames[i]);
|
|
}
|
|
rom_->resource_label()->SelectableLabelWithNameEdit(
|
|
current_entrance_id_ == i, "Dungeon Entrance Names",
|
|
util::HexByte(i), entrance_name);
|
|
|
|
if (ImGui::IsItemClicked()) {
|
|
current_entrance_id_ = i;
|
|
if (i < entrances_->size()) {
|
|
int room_id = (*entrances_)[i].room_;
|
|
// Notify the dungeon editor about room selection
|
|
if (room_selected_callback_) {
|
|
room_selected_callback_(room_id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
EndChild();
|
|
}
|
|
|
|
} // namespace yaze::editor
|