fix(editor): update overworld exit properties and popup handling
- Changed `x_camera_` and `y_camera_` in `OverworldExit` from `uint8_t` to `uint16_t` for consistency and to accommodate larger values. - Updated the `DrawExitEditorPopup` function to use `InputHexWord` for camera positions, reflecting the new data type. - Added `ImGui::PushID` and `ImGui::PopID` calls in various popup functions to resolve duplicate ID warnings, enhancing the stability of the UI. Benefits: - Ensures proper handling of camera coordinates in the overworld editor. - Improves UI robustness by addressing ID conflicts in popups.
This commit is contained in:
@@ -192,9 +192,9 @@ bool DrawExitEditorPopup(zelda3::OverworldExit &exit) {
|
||||
SameLine();
|
||||
gui::InputHex("Y Position", &exit.y_);
|
||||
|
||||
gui::InputHexByte("X Camera", &exit.x_camera_);
|
||||
gui::InputHexWord("X Camera", &exit.x_camera_);
|
||||
SameLine();
|
||||
gui::InputHexByte("Y Camera", &exit.y_camera_);
|
||||
gui::InputHexWord("Y Camera", &exit.y_camera_);
|
||||
|
||||
gui::InputHexWord("X Scroll", &exit.x_scroll_);
|
||||
SameLine();
|
||||
|
||||
@@ -540,6 +540,8 @@ void MapPropertiesSystem::SetupCanvasContextMenu(
|
||||
// Private method implementations
|
||||
void MapPropertiesSystem::DrawGraphicsPopup(int current_map, int game_state) {
|
||||
if (ImGui::BeginPopup("GraphicsPopup")) {
|
||||
ImGui::PushID("GraphicsPopup"); // Fix ImGui duplicate ID warnings
|
||||
|
||||
// Use theme-aware spacing instead of hardcoded constants
|
||||
float spacing = gui::LayoutHelpers::GetStandardSpacing();
|
||||
float padding = gui::LayoutHelpers::GetButtonPadding();
|
||||
@@ -639,6 +641,7 @@ void MapPropertiesSystem::DrawGraphicsPopup(int current_map, int game_state) {
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar(2); // Pop the 2 style variables we pushed
|
||||
ImGui::PopID(); // Pop GraphicsPopup ID scope
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
@@ -646,6 +649,8 @@ void MapPropertiesSystem::DrawGraphicsPopup(int current_map, int game_state) {
|
||||
void MapPropertiesSystem::DrawPalettesPopup(int current_map, int game_state,
|
||||
bool& show_custom_bg_color_editor) {
|
||||
if (ImGui::BeginPopup("PalettesPopup")) {
|
||||
ImGui::PushID("PalettesPopup"); // Fix ImGui duplicate ID warnings
|
||||
|
||||
// Use theme-aware spacing instead of hardcoded constants
|
||||
float spacing = gui::LayoutHelpers::GetStandardSpacing();
|
||||
float padding = gui::LayoutHelpers::GetButtonPadding();
|
||||
@@ -700,6 +705,7 @@ void MapPropertiesSystem::DrawPalettesPopup(int current_map, int game_state,
|
||||
HOVER_HINT("Open custom background color editor (v2+)");
|
||||
|
||||
ImGui::PopStyleVar(2); // Pop the 2 style variables we pushed
|
||||
ImGui::PopID(); // Pop PalettesPopup ID scope
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
@@ -709,6 +715,8 @@ void MapPropertiesSystem::DrawPropertiesPopup(int current_map,
|
||||
bool& show_overlay_preview,
|
||||
int& game_state) {
|
||||
if (ImGui::BeginPopup("ConfigPopup")) {
|
||||
ImGui::PushID("ConfigPopup"); // Fix ImGui duplicate ID warnings
|
||||
|
||||
// Use theme-aware spacing instead of hardcoded constants
|
||||
float spacing = gui::LayoutHelpers::GetStandardSpacing();
|
||||
float padding = gui::LayoutHelpers::GetButtonPadding();
|
||||
@@ -811,6 +819,7 @@ void MapPropertiesSystem::DrawPropertiesPopup(int current_map,
|
||||
HOVER_HINT("Open detailed area configuration with all settings tabs");
|
||||
|
||||
ImGui::PopStyleVar(2); // Pop the 2 style variables we pushed
|
||||
ImGui::PopID(); // Pop ConfigPopup ID scope
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
@@ -1649,6 +1658,8 @@ void MapPropertiesSystem::DrawOverlayPreviewOnMap(int current_map,
|
||||
|
||||
void MapPropertiesSystem::DrawViewPopup() {
|
||||
if (ImGui::BeginPopup("ViewPopup")) {
|
||||
ImGui::PushID("ViewPopup"); // Fix ImGui duplicate ID warnings
|
||||
|
||||
// Use theme-aware spacing instead of hardcoded constants
|
||||
float spacing = gui::LayoutHelpers::GetStandardSpacing();
|
||||
float padding = gui::LayoutHelpers::GetButtonPadding();
|
||||
@@ -1678,12 +1689,15 @@ void MapPropertiesSystem::DrawViewPopup() {
|
||||
HOVER_HINT("Toggle fullscreen canvas (F11)");
|
||||
|
||||
ImGui::PopStyleVar(2); // Pop the 2 style variables we pushed
|
||||
ImGui::PopID(); // Pop ViewPopup ID scope
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
|
||||
void MapPropertiesSystem::DrawQuickAccessPopup() {
|
||||
if (ImGui::BeginPopup("QuickPopup")) {
|
||||
ImGui::PushID("QuickPopup"); // Fix ImGui duplicate ID warnings
|
||||
|
||||
// Use theme-aware spacing instead of hardcoded constants
|
||||
float spacing = gui::LayoutHelpers::GetStandardSpacing();
|
||||
float padding = gui::LayoutHelpers::GetButtonPadding();
|
||||
@@ -1715,6 +1729,7 @@ void MapPropertiesSystem::DrawQuickAccessPopup() {
|
||||
HOVER_HINT("Lock/unlock current map (Ctrl+L)");
|
||||
|
||||
ImGui::PopStyleVar(2); // Pop the 2 style variables we pushed
|
||||
ImGui::PopID(); // Pop QuickPopup ID scope
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -912,8 +912,8 @@ void OverworldEditor::RenderUpdatedMapBitmap(
|
||||
current_bitmap.set_modified(true);
|
||||
|
||||
// Immediately update the texture to reflect changes
|
||||
// TODO: Queue texture for later rendering.
|
||||
// core::Renderer::Get().UpdateBitmap(¤t_bitmap);
|
||||
gfx::Arena::Get().QueueTextureCommand(
|
||||
gfx::Arena::TextureCommandType::UPDATE, ¤t_bitmap);
|
||||
}
|
||||
|
||||
void OverworldEditor::CheckForOverworldEdits() {
|
||||
@@ -3012,7 +3012,7 @@ void OverworldEditor::HandleEntityInsertion(const std::string& entity_type) {
|
||||
// Get mouse position from canvas (in world coordinates)
|
||||
ImVec2 mouse_pos = ow_map_canvas_.hover_mouse_pos();
|
||||
|
||||
LOG_DEBUG("OverworldEditor", "Inserting entity type='%s' at pos=(%f,%f) map=%d",
|
||||
LOG_DEBUG("OverworldEditor", "HandleEntityInsertion called: type='%s' at pos=(%.0f,%.0f) map=%d",
|
||||
entity_type.c_str(), mouse_pos.x, mouse_pos.y, current_map_);
|
||||
|
||||
if (entity_type == "entrance") {
|
||||
@@ -3022,6 +3022,7 @@ void OverworldEditor::HandleEntityInsertion(const std::string& entity_type) {
|
||||
current_entity_ = *result;
|
||||
ImGui::OpenPopup("Entrance Editor");
|
||||
rom_->set_dirty(true);
|
||||
LOG_DEBUG("OverworldEditor", "Entrance inserted successfully at map=%d", current_map_);
|
||||
} else {
|
||||
LOG_ERROR("OverworldEditor", "Failed to insert entrance: %s",
|
||||
result.status().message().data());
|
||||
@@ -3034,6 +3035,7 @@ void OverworldEditor::HandleEntityInsertion(const std::string& entity_type) {
|
||||
current_entity_ = *result;
|
||||
ImGui::OpenPopup("Entrance Editor");
|
||||
rom_->set_dirty(true);
|
||||
LOG_DEBUG("OverworldEditor", "Hole inserted successfully at map=%d", current_map_);
|
||||
} else {
|
||||
LOG_ERROR("OverworldEditor", "Failed to insert hole: %s",
|
||||
result.status().message().data());
|
||||
@@ -3046,6 +3048,7 @@ void OverworldEditor::HandleEntityInsertion(const std::string& entity_type) {
|
||||
current_entity_ = *result;
|
||||
ImGui::OpenPopup("Exit editor");
|
||||
rom_->set_dirty(true);
|
||||
LOG_DEBUG("OverworldEditor", "Exit inserted successfully at map=%d", current_map_);
|
||||
} else {
|
||||
LOG_ERROR("OverworldEditor", "Failed to insert exit: %s",
|
||||
result.status().message().data());
|
||||
@@ -3058,6 +3061,7 @@ void OverworldEditor::HandleEntityInsertion(const std::string& entity_type) {
|
||||
current_entity_ = *result;
|
||||
ImGui::OpenPopup("Item editor");
|
||||
rom_->set_dirty(true);
|
||||
LOG_DEBUG("OverworldEditor", "Item inserted successfully at map=%d", current_map_);
|
||||
} else {
|
||||
LOG_ERROR("OverworldEditor", "Failed to insert item: %s",
|
||||
result.status().message().data());
|
||||
@@ -3070,6 +3074,7 @@ void OverworldEditor::HandleEntityInsertion(const std::string& entity_type) {
|
||||
current_entity_ = *result;
|
||||
ImGui::OpenPopup("Sprite editor");
|
||||
rom_->set_dirty(true);
|
||||
LOG_DEBUG("OverworldEditor", "Sprite inserted successfully at map=%d", current_map_);
|
||||
} else {
|
||||
LOG_ERROR("OverworldEditor", "Failed to insert sprite: %s",
|
||||
result.status().message().data());
|
||||
|
||||
Reference in New Issue
Block a user