Refactor DungeonEditor and related components for improved object management and UI enhancements

- Replaced vertical separators with standard separators in the EditorManager's menu bar for consistency.
- Introduced a new room selection callback mechanism in DungeonRoomSelector to facilitate room selection events.
- Enhanced DungeonEditor with drag-and-select functionality for object placement, improving user interaction.
- Added an object browser in DungeonObjectSelector for better object management and preview capabilities.
- Streamlined object rendering and selection processes, ensuring a more intuitive editing experience.
This commit is contained in:
scawful
2025-09-25 18:56:30 -04:00
parent dd73ea080b
commit 1964d31930
10 changed files with 537 additions and 1485 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -85,16 +85,25 @@ class DungeonEditor : public Editor {
absl::Status UpdateDungeonRoomView(); absl::Status UpdateDungeonRoomView();
void DrawToolset(); void DrawToolset();
void DrawRoomSelector();
void DrawEntranceSelector();
void DrawDungeonTabView(); void DrawDungeonTabView();
void DrawDungeonCanvas(int room_id); void DrawDungeonCanvas(int room_id);
// Room selection management
void OnRoomSelected(int room_id);
void DrawRoomGraphics(); void DrawRoomGraphics();
void DrawTileSelector(); void DrawTileSelector();
void DrawObjectRenderer(); void DrawObjectRenderer();
// Object rendering methods
void RenderObjectInCanvas(const zelda3::RoomObject& object,
const gfx::SnesPalette& palette);
void DisplayObjectInfo(const zelda3::RoomObject& object, int canvas_x,
int canvas_y);
void RenderLayoutObjects(const zelda3::RoomLayout& layout,
const gfx::SnesPalette& palette);
// New editing mode interfaces // New editing mode interfaces
void DrawObjectEditor(); void DrawObjectEditor();
void DrawSpriteEditor(); void DrawSpriteEditor();
@@ -104,29 +113,19 @@ class DungeonEditor : public Editor {
void DrawChestEditor(); void DrawChestEditor();
void DrawPropertiesEditor(); void DrawPropertiesEditor();
// Integrated editing panels
void DrawIntegratedEditingPanels();
void DrawCompactObjectEditor();
void DrawCompactSpriteEditor();
void DrawCompactItemEditor();
void DrawCompactEntranceEditor();
void DrawCompactDoorEditor();
void DrawCompactChestEditor();
void DrawCompactPropertiesEditor();
// Object rendering methods
void RenderObjectInCanvas(const zelda3::RoomObject& object,
const gfx::SnesPalette& palette);
void DisplayObjectInfo(const zelda3::RoomObject& object, int canvas_x,
int canvas_y);
void RenderLayoutObjects(const zelda3::RoomLayout& layout,
const gfx::SnesPalette& palette);
// Coordinate conversion helpers // Coordinate conversion helpers
std::pair<int, int> RoomToCanvasCoordinates(int room_x, int room_y) const; std::pair<int, int> RoomToCanvasCoordinates(int room_x, int room_y) const;
std::pair<int, int> CanvasToRoomCoordinates(int canvas_x, int canvas_y) const; std::pair<int, int> CanvasToRoomCoordinates(int canvas_x, int canvas_y) const;
bool IsWithinCanvasBounds(int canvas_x, int canvas_y, int margin = 32) const; bool IsWithinCanvasBounds(int canvas_x, int canvas_y, int margin = 32) const;
// Drag and select box functionality
void HandleCanvasMouseInput();
void DrawSelectBox();
void DrawDragPreview();
void UpdateSelectedObjects();
bool IsObjectInSelectBox(const zelda3::RoomObject& object) const;
void PlaceObjectAtPosition(int room_x, int room_y);
// Room graphics management // Room graphics management
absl::Status LoadAndRenderRoomGraphics(int room_id); absl::Status LoadAndRenderRoomGraphics(int room_id);
absl::Status ReloadAllRoomGraphics(); absl::Status ReloadAllRoomGraphics();
@@ -183,6 +182,16 @@ class DungeonEditor : public Editor {
bool palette_showing_ = false; bool palette_showing_ = false;
bool refresh_graphics_ = false; bool refresh_graphics_ = false;
// Drag and select box infrastructure
bool is_dragging_ = false;
bool is_selecting_ = false;
ImVec2 drag_start_pos_;
ImVec2 drag_current_pos_;
ImVec2 select_start_pos_;
ImVec2 select_current_pos_;
std::vector<int> selected_objects_;
int current_layer_ = 0; // 0 = BG1, 1 = BG2, 2 = Both
// New editor system integration // New editor system integration
std::unique_ptr<zelda3::DungeonEditorSystem> dungeon_editor_system_; std::unique_ptr<zelda3::DungeonEditorSystem> dungeon_editor_system_;
std::shared_ptr<zelda3::DungeonObjectEditor> object_editor_; std::shared_ptr<zelda3::DungeonObjectEditor> object_editor_;

View File

@@ -1,34 +1,25 @@
#include "dungeon_object_selector.h" #include "dungeon_object_selector.h"
#include "absl/strings/str_format.h" #include <iterator>
#include "app/core/window.h" #include "app/core/window.h"
#include "app/gfx/arena.h" #include "app/gfx/arena.h"
#include "app/gfx/snes_palette.h" #include "app/gfx/snes_palette.h"
#include "app/gui/canvas.h" #include "app/gui/canvas.h"
#include "app/gui/color.h"
#include "app/gui/icons.h"
#include "app/gui/input.h"
#include "app/rom.h" #include "app/rom.h"
#include "app/zelda3/dungeon/object_renderer.h" #include "app/zelda3/dungeon/object_renderer.h"
#include "app/zelda3/dungeon/room.h" #include "app/zelda3/dungeon/room.h"
#include "app/zelda3/dungeon/dungeon_editor_system.h" #include "app/zelda3/dungeon/dungeon_editor_system.h"
#include "app/zelda3/dungeon/dungeon_object_editor.h" #include "app/zelda3/dungeon/dungeon_object_editor.h"
#include "imgui/imgui.h" #include "imgui/imgui.h"
#include "util/hex.h"
namespace yaze::editor { namespace yaze::editor {
using core::Renderer;
using ImGui::BeginChild; using ImGui::BeginChild;
using ImGui::BeginTabBar;
using ImGui::BeginTabItem;
using ImGui::Button;
using ImGui::EndChild; using ImGui::EndChild;
using ImGui::EndTabBar; using ImGui::EndTabBar;
using ImGui::EndTabItem; using ImGui::EndTabItem;
using ImGui::Separator; using ImGui::Separator;
using ImGui::Text;
void DungeonObjectSelector::DrawTileSelector() { void DungeonObjectSelector::DrawTileSelector() {
if (ImGui::BeginTabBar("##TabBar", ImGuiTabBarFlags_FittingPolicyScroll)) { if (ImGui::BeginTabBar("##TabBar", ImGuiTabBarFlags_FittingPolicyScroll)) {
@@ -51,55 +42,31 @@ void DungeonObjectSelector::DrawTileSelector() {
} }
void DungeonObjectSelector::DrawObjectRenderer() { void DungeonObjectSelector::DrawObjectRenderer() {
// Create a comprehensive object browser with previews
if (ImGui::BeginTable("DungeonObjectEditorTable", 2, ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV, ImVec2(0, 0))) { if (ImGui::BeginTable("DungeonObjectEditorTable", 2, ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV, ImVec2(0, 0))) {
ImGui::TableSetupColumn("Dungeon Objects", ImGuiTableColumnFlags_WidthStretch, ImGui::GetContentRegionAvail().x); ImGui::TableSetupColumn("Object Browser", ImGuiTableColumnFlags_WidthFixed, 280);
ImGui::TableSetupColumn("Canvas"); ImGui::TableSetupColumn("Preview Canvas", ImGuiTableColumnFlags_WidthStretch);
// Left column: Object browser with previews
ImGui::TableNextColumn(); ImGui::TableNextColumn();
BeginChild("DungeonObjectButtons", ImVec2(250, 0), true); BeginChild("ObjectBrowser", ImVec2(0, 0), true, ImGuiWindowFlags_AlwaysVerticalScrollbar);
static int selected_object = 0; DrawObjectBrowser();
int i = 0;
for (const auto object_name : zelda3::Type1RoomObjectNames) {
if (ImGui::Selectable(object_name.data(), selected_object == i)) {
selected_object = i;
// Create a test object and render it
auto test_object = zelda3::RoomObject(i, 8, 8, 0x12, 0); // Center in canvas
test_object.set_rom(rom_);
test_object.EnsureTilesLoaded();
// Get current palette
if (rom_ && rom_->is_loaded()) {
auto palette = rom_->palette_group().dungeon_main[current_palette_group_id_];
// Render object preview
auto result = object_renderer_.GetObjectPreview(test_object, palette);
if (result.ok()) {
object_loaded_ = true;
preview_object_ = test_object; // Store for rendering
preview_palette_ = palette;
}
}
}
i += 1;
}
EndChild(); EndChild();
// Right side of the table - Canvas // Right column: Large preview canvas
ImGui::TableNextColumn(); ImGui::TableNextColumn();
BeginChild("DungeonObjectCanvas", ImVec2(276, 0x10 * 0x40 + 1), true); BeginChild("PreviewCanvas", ImVec2(0, 0), true);
object_canvas_.DrawBackground(ImVec2(256 + 1, 0x10 * 0x40 + 1)); object_canvas_.DrawBackground(ImVec2(256 + 1, 0x10 * 0x40 + 1));
object_canvas_.DrawContextMenu(); object_canvas_.DrawContextMenu();
object_canvas_.DrawTileSelector(32); object_canvas_.DrawTileSelector(32);
object_canvas_.DrawGrid(32.0f); object_canvas_.DrawGrid(32.0f);
// Render object preview if available // Render selected object preview
if (object_loaded_ && preview_object_.id_ >= 0) { if (object_loaded_ && preview_object_.id_ >= 0) {
// Render preview object at center of canvas (object_canvas_ is 256x256) int preview_x = 128 - 16; // Center horizontally
int preview_x = 128 - 16; // Center horizontally (256/2 - 16 for 32x32 object)
int preview_y = 128 - 16; // Center vertically int preview_y = 128 - 16; // Center vertically
auto preview_result = object_renderer_.RenderObject(preview_object_, preview_palette_); auto preview_result = object_renderer_.RenderObject(preview_object_, preview_palette_);
@@ -112,21 +79,178 @@ void DungeonObjectSelector::DrawObjectRenderer() {
} }
object_canvas_.DrawOverlay(); object_canvas_.DrawOverlay();
EndChild(); EndChild();
ImGui::EndTable(); ImGui::EndTable();
} }
// Object details window
if (object_loaded_) { if (object_loaded_) {
ImGui::Begin("Object Preview", &object_loaded_, 0); ImGui::Begin("Object Details", &object_loaded_, 0);
ImGui::Text("Object ID: 0x%02X", preview_object_.id_); ImGui::Text("Object ID: 0x%02X", preview_object_.id_);
ImGui::Text("Position: (%d, %d)", preview_object_.x_, preview_object_.y_); ImGui::Text("Position: (%d, %d)", preview_object_.x_, preview_object_.y_);
ImGui::Text("Size: 0x%02X", preview_object_.size_); ImGui::Text("Size: 0x%02X", preview_object_.size_);
ImGui::Text("Layer: %d", static_cast<int>(preview_object_.layer_)); ImGui::Text("Layer: %d", static_cast<int>(preview_object_.layer_));
// Add object placement controls
ImGui::Separator();
ImGui::Text("Placement Controls:");
static int place_x = 0, place_y = 0;
ImGui::InputInt("X Position", &place_x);
ImGui::InputInt("Y Position", &place_y);
if (ImGui::Button("Place Object")) {
// TODO: Implement object placement in the main canvas
ImGui::Text("Object placed at (%d, %d)", place_x, place_y);
}
ImGui::End(); ImGui::End();
} }
} }
void DungeonObjectSelector::DrawObjectBrowser() {
static int selected_object_type = 0;
static int selected_object_id = 0;
// Object type selector
const char* object_types[] = {"Type 1 (0x00-0xFF)", "Type 2 (0x100-0x1FF)", "Type 3 (0x200+)"};
if (ImGui::Combo("Object Type", &selected_object_type, object_types, 3)) {
selected_object_id = 0; // Reset selection when changing type
}
ImGui::Separator();
// Object list with previews
const int preview_size = 32; // 32x32 pixel preview
const int items_per_row = 4; // 4 items per row
if (rom_ && rom_->is_loaded()) {
auto palette = rom_->palette_group().dungeon_main[current_palette_group_id_];
// Determine object range based on type
int start_id, end_id;
switch (selected_object_type) {
case 0: start_id = 0x00; end_id = 0xFF; break;
case 1: start_id = 0x100; end_id = 0x1FF; break;
case 2: start_id = 0x200; end_id = 0x2FF; break;
default: start_id = 0x00; end_id = 0xFF; break;
}
// Create a grid layout for object previews
int current_row = 0;
int current_col = 0;
for (int obj_id = start_id; obj_id <= end_id && obj_id <= start_id + 63; ++obj_id) { // Limit to 64 objects for performance
// Create object for preview
auto test_object = zelda3::RoomObject(obj_id, 0, 0, 0x12, 0);
test_object.set_rom(rom_);
test_object.EnsureTilesLoaded();
// Calculate position in grid
float item_width = (ImGui::GetContentRegionAvail().x - (items_per_row - 1) * ImGui::GetStyle().ItemSpacing.x) / items_per_row;
float item_height = preview_size + 40; // Preview + text
ImGui::PushID(obj_id);
// Create a selectable button with preview
bool is_selected = (selected_object_id == obj_id);
if (ImGui::Selectable("", is_selected, ImGuiSelectableFlags_None, ImVec2(item_width, item_height))) {
selected_object_id = obj_id;
// Update preview object
preview_object_ = test_object;
preview_palette_ = palette;
object_loaded_ = true;
}
// Draw preview image
ImVec2 cursor_pos = ImGui::GetCursorScreenPos();
ImVec2 preview_pos = ImVec2(cursor_pos.x + (item_width - preview_size) / 2,
cursor_pos.y - item_height + 5);
// Try to render object preview
auto preview_result = object_renderer_.GetObjectPreview(test_object, palette);
if (preview_result.ok()) {
auto preview_bitmap = std::move(preview_result.value());
preview_bitmap.SetPalette(palette);
core::Renderer::Get().RenderBitmap(&preview_bitmap);
// Draw preview using ImGui image
ImGui::SetCursorScreenPos(preview_pos);
ImGui::Image((ImTextureID)(intptr_t)preview_bitmap.texture(),
ImVec2(preview_size, preview_size));
} else {
// Draw placeholder if preview fails
ImGui::SetCursorScreenPos(preview_pos);
ImGui::GetWindowDrawList()->AddRectFilled(
preview_pos,
ImVec2(preview_pos.x + preview_size, preview_pos.y + preview_size),
IM_COL32(64, 64, 64, 255));
ImGui::GetWindowDrawList()->AddText(
ImVec2(preview_pos.x + 8, preview_pos.y + 12),
IM_COL32(255, 255, 255, 255),
"?");
}
// Draw object ID and name
ImGui::SetCursorScreenPos(ImVec2(cursor_pos.x + 2, cursor_pos.y - 25));
ImGui::Text("0x%03X", obj_id);
// Try to get object name
std::string object_name = "Unknown";
if (obj_id < 0x100) { // Type1RoomObjectNames has 248 elements (0-247, 0x00-0xF7)
if (obj_id < std::size(zelda3::Type1RoomObjectNames)) {
const char* name_ptr = zelda3::Type1RoomObjectNames[obj_id];
if (name_ptr != nullptr) {
object_name = std::string(name_ptr);
}
}
} else if (obj_id < 0x140) { // Type2RoomObjectNames has 64 elements (0x100-0x13F)
int type2_index = obj_id - 0x100;
if (type2_index >= 0 && type2_index < std::size(zelda3::Type2RoomObjectNames)) {
const char* name_ptr = zelda3::Type2RoomObjectNames[type2_index];
if (name_ptr != nullptr) {
object_name = std::string(name_ptr);
}
}
} else if (obj_id < 0x1C0) { // Type3RoomObjectNames has 128 elements (0x140-0x1BF)
int type3_index = obj_id - 0x140;
if (type3_index >= 0 && type3_index < std::size(zelda3::Type3RoomObjectNames)) {
const char* name_ptr = zelda3::Type3RoomObjectNames[type3_index];
if (name_ptr != nullptr) {
object_name = std::string(name_ptr);
}
}
}
ImGui::SetCursorScreenPos(ImVec2(cursor_pos.x + 2, cursor_pos.y - 10));
ImGui::Text("%s", object_name.c_str());
ImGui::PopID();
// Move to next position
current_col++;
if (current_col >= items_per_row) {
current_col = 0;
current_row++;
ImGui::NewLine();
} else {
ImGui::SameLine();
}
}
} else {
ImGui::Text("ROM not loaded");
}
ImGui::Separator();
// Selected object info
if (object_loaded_) {
ImGui::Text("Selected: 0x%03X", selected_object_id);
ImGui::Text("Layer: %d", static_cast<int>(preview_object_.layer_));
ImGui::Text("Size: 0x%02X", preview_object_.size_);
}
}
void DungeonObjectSelector::Draw() { void DungeonObjectSelector::Draw() {
if (ImGui::BeginTabBar("##ObjectEditorTabBar")) { if (ImGui::BeginTabBar("##ObjectEditorTabBar")) {
if (ImGui::BeginTabItem("Graphics")) { if (ImGui::BeginTabItem("Graphics")) {
@@ -312,11 +436,11 @@ void DungeonObjectSelector::DrawCompactObjectEditor() {
// Undo/Redo buttons // Undo/Redo buttons
Separator(); Separator();
if (ImGui::Button("Undo") && editor.CanUndo()) { if (ImGui::Button("Undo") && editor.CanUndo()) {
editor.Undo(); (void)editor.Undo();
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button("Redo") && editor.CanRedo()) { if (ImGui::Button("Redo") && editor.CanRedo()) {
editor.Redo(); (void)editor.Redo();
} }
} }

View File

@@ -53,6 +53,7 @@ class DungeonObjectSelector {
private: private:
void DrawRoomGraphics(); void DrawRoomGraphics();
void DrawObjectBrowser();
void DrawCompactObjectEditor(); void DrawCompactObjectEditor();
void DrawCompactSpriteEditor(); void DrawCompactSpriteEditor();
void DrawCompactItemEditor(); void DrawCompactItemEditor();

View File

@@ -1,6 +1,5 @@
#include "dungeon_room_selector.h" #include "dungeon_room_selector.h"
#include "absl/strings/str_format.h"
#include "app/gui/input.h" #include "app/gui/input.h"
#include "app/zelda3/dungeon/room.h" #include "app/zelda3/dungeon/room.h"
#include "app/zelda3/dungeon/room_entrance.h" #include "app/zelda3/dungeon/room_entrance.h"
@@ -10,14 +9,8 @@
namespace yaze::editor { namespace yaze::editor {
using ImGui::BeginChild; using ImGui::BeginChild;
using ImGui::BeginTabBar;
using ImGui::BeginTabItem;
using ImGui::EndChild; using ImGui::EndChild;
using ImGui::EndTabBar;
using ImGui::EndTabItem;
using ImGui::Separator;
using ImGui::SameLine; using ImGui::SameLine;
using ImGui::Text;
void DungeonRoomSelector::Draw() { void DungeonRoomSelector::Draw() {
if (ImGui::BeginTabBar("##DungeonRoomTabBar")) { if (ImGui::BeginTabBar("##DungeonRoomTabBar")) {
@@ -51,8 +44,9 @@ void DungeonRoomSelector::DrawRoomSelector() {
each_room_name.data()); each_room_name.data());
if (ImGui::IsItemClicked()) { if (ImGui::IsItemClicked()) {
current_room_id_ = i; current_room_id_ = i;
if (!active_rooms_.contains(i)) { // Notify the dungeon editor about room selection
active_rooms_.push_back(i); if (room_selected_callback_) {
room_selected_callback_(i);
} }
} }
i += 1; i += 1;
@@ -84,7 +78,7 @@ void DungeonRoomSelector::DrawEntranceSelector() {
gui::InputHexByte("Music", &current_entrance.music_, 50.f, true); gui::InputHexByte("Music", &current_entrance.music_, 50.f, true);
SameLine(); SameLine();
gui::InputHexByte("Floor", &current_entrance.floor_); gui::InputHexByte("Floor", &current_entrance.floor_);
Separator(); ImGui::Separator();
gui::InputHexWord("Player X ", &current_entrance.x_position_); gui::InputHexWord("Player X ", &current_entrance.x_position_);
SameLine(); SameLine();
@@ -100,9 +94,9 @@ void DungeonRoomSelector::DrawEntranceSelector() {
gui::InputHexWord("Exit", &current_entrance.exit_, 50.f, true); gui::InputHexWord("Exit", &current_entrance.exit_, 50.f, true);
Separator(); ImGui::Separator();
ImGui::Text("Camera Boundaries"); ImGui::Text("Camera Boundaries");
Separator(); ImGui::Separator();
ImGui::Text("\t\t\t\t\tNorth East South West"); ImGui::Text("\t\t\t\t\tNorth East South West");
gui::InputHexByte("Quadrant", &current_entrance.camera_boundary_qn_, 50.f, gui::InputHexByte("Quadrant", &current_entrance.camera_boundary_qn_, 50.f,
true); true);
@@ -124,15 +118,24 @@ void DungeonRoomSelector::DrawEntranceSelector() {
if (BeginChild("EntranceSelector", ImVec2(0, 0), true, if (BeginChild("EntranceSelector", ImVec2(0, 0), true,
ImGuiWindowFlags_AlwaysVerticalScrollbar)) { ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
for (int i = 0; i < 0x85 + 7; i++) { 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( rom_->resource_label()->SelectableLabelWithNameEdit(
current_entrance_id_ == i, "Dungeon Entrance Names", current_entrance_id_ == i, "Dungeon Entrance Names",
util::HexByte(i), zelda3::kEntranceNames[i].data()); util::HexByte(i), entrance_name);
if (ImGui::IsItemClicked()) { if (ImGui::IsItemClicked()) {
current_entrance_id_ = i; current_entrance_id_ = i;
if (!active_rooms_.contains(i)) { if (i < entrances_->size()) {
active_rooms_.push_back((*entrances_)[i].room_); int room_id = (*entrances_)[i].room_;
// Notify the dungeon editor about room selection
if (room_selected_callback_) {
room_selected_callback_(room_id);
}
} }
} }
} }

View File

@@ -1,9 +1,9 @@
#ifndef YAZE_APP_EDITOR_DUNGEON_DUNGEON_ROOM_SELECTOR_H #ifndef YAZE_APP_EDITOR_DUNGEON_DUNGEON_ROOM_SELECTOR_H
#define YAZE_APP_EDITOR_DUNGEON_DUNGEON_ROOM_SELECTOR_H #define YAZE_APP_EDITOR_DUNGEON_DUNGEON_ROOM_SELECTOR_H
#include <functional>
#include "imgui/imgui.h" #include "imgui/imgui.h"
#include "app/rom.h" #include "app/rom.h"
#include "app/gui/input.h"
#include "app/zelda3/dungeon/room_entrance.h" #include "app/zelda3/dungeon/room_entrance.h"
#include "zelda3/dungeon/room.h" #include "zelda3/dungeon/room.h"
@@ -40,6 +40,11 @@ class DungeonRoomSelector {
void set_rooms(std::array<zelda3::Room, 0x128>* rooms) { rooms_ = rooms; } void set_rooms(std::array<zelda3::Room, 0x128>* rooms) { rooms_ = rooms; }
void set_entrances(std::array<zelda3::RoomEntrance, 0x8C>* entrances) { entrances_ = entrances; } void set_entrances(std::array<zelda3::RoomEntrance, 0x8C>* entrances) { entrances_ = entrances; }
// Callback for room selection events
void set_room_selected_callback(std::function<void(int)> callback) {
room_selected_callback_ = callback;
}
private: private:
Rom* rom_ = nullptr; Rom* rom_ = nullptr;
uint16_t current_room_id_ = 0; uint16_t current_room_id_ = 0;
@@ -48,6 +53,9 @@ class DungeonRoomSelector {
std::array<zelda3::Room, 0x128>* rooms_ = nullptr; std::array<zelda3::Room, 0x128>* rooms_ = nullptr;
std::array<zelda3::RoomEntrance, 0x8C>* entrances_ = nullptr; std::array<zelda3::RoomEntrance, 0x8C>* entrances_ = nullptr;
// Callback for room selection events
std::function<void(int)> room_selected_callback_;
}; };
} // namespace editor } // namespace editor

View File

@@ -892,7 +892,7 @@ void EditorManager::DrawMenuBar() {
SetTooltip("Sessions: %zu active\nClick to switch between sessions", sessions_.size()); SetTooltip("Sessions: %zu active\nClick to switch between sessions", sessions_.size());
} }
SameLine(); SameLine();
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical); ImGui::Separator();
SameLine(); SameLine();
} }
@@ -927,7 +927,7 @@ void EditorManager::DrawMenuBar() {
// Settings and version (using pre-calculated positioning) // Settings and version (using pre-calculated positioning)
SameLine(GetWindowWidth() - total_right_width); SameLine(GetWindowWidth() - total_right_width);
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical); ImGui::Separator();
SameLine(); SameLine();
PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));

View File

@@ -2505,7 +2505,7 @@ absl::Status OverworldEditor::UpdateUsageStats() {
for (int i = 0; i < 0x81; i++) { for (int i = 0; i < 0x81; i++) {
auto entrance_name = rom_->resource_label()->CreateOrGetLabel( auto entrance_name = rom_->resource_label()->CreateOrGetLabel(
"Dungeon Entrance Names", util::HexByte(i), "Dungeon Entrance Names", util::HexByte(i),
zelda3::kEntranceNames[i].data()); zelda3::kEntranceNames[i]);
std::string str = absl::StrFormat("%#x - %s", i, entrance_name); std::string str = absl::StrFormat("%#x - %s", i, entrance_name);
if (Selectable(str.c_str(), selected_entrance_ == i, if (Selectable(str.c_str(), selected_entrance_ == i,
overworld_.entrances().at(i).deleted overworld_.entrances().at(i).deleted

View File

@@ -3,7 +3,6 @@
#include <cstdint> #include <cstdint>
#include <string> #include <string>
#include <string_view>
namespace yaze { namespace yaze {
@@ -45,7 +44,7 @@ class GameEntity {
virtual void UpdateMapProperties(uint16_t map_id) = 0; virtual void UpdateMapProperties(uint16_t map_id) = 0;
}; };
constexpr std::string_view kEntranceNames[] = { constexpr const char* kEntranceNames[] = {
"Link's House Intro", "Link's House Intro",
"Link's House Post-intro", "Link's House Post-intro",
"Sanctuary", "Sanctuary",

View File

@@ -5,7 +5,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "absl/strings/string_view.h"
#include "app/gfx/snes_tile.h" #include "app/gfx/snes_tile.h"
#include "app/rom.h" #include "app/rom.h"
#include "app/zelda3/dungeon/object_parser.h" #include "app/zelda3/dungeon/object_parser.h"
@@ -254,7 +253,7 @@ class Subtype3 : public RoomObject {
} }
}; };
constexpr static inline absl::string_view Type1RoomObjectNames[] = { constexpr static inline const char* Type1RoomObjectNames[] = {
"Ceiling ↔", "Ceiling ↔",
"Wall (top, north) ↔", "Wall (top, north) ↔",
"Wall (top, south) ↔", "Wall (top, south) ↔",
@@ -505,7 +504,7 @@ constexpr static inline absl::string_view Type1RoomObjectNames[] = {
"Nothing", "Nothing",
}; };
constexpr static inline absl::string_view Type2RoomObjectNames[] = { constexpr static inline const char* Type2RoomObjectNames[] = {
"Corner (top, concave) ▛", "Corner (top, concave) ▛",
"Corner (top, concave) ▙", "Corner (top, concave) ▙",
"Corner (top, concave) ▜", "Corner (top, concave) ▜",
@@ -572,7 +571,7 @@ constexpr static inline absl::string_view Type2RoomObjectNames[] = {
"Magic bat altar", "Magic bat altar",
}; };
constexpr static inline absl::string_view Type3RoomObjectNames[] = { constexpr static inline const char* Type3RoomObjectNames[] = {
"Waterfall face (empty)", "Waterfall face (empty)",
"Waterfall face (short)", "Waterfall face (short)",
"Waterfall face (long)", "Waterfall face (long)",