diff --git a/src/app/editor/code/memory_editor.cc b/src/app/editor/code/memory_editor.cc new file mode 100644 index 00000000..f64ab2ba --- /dev/null +++ b/src/app/editor/code/memory_editor.cc @@ -0,0 +1,92 @@ +#include "app/editor/code/memory_editor.h" +#include "app/gui/icons.h" + +namespace yaze { +namespace editor { + +void MemoryEditorWithDiffChecker::DrawToolbar() { + if (ImGui::Button(ICON_MD_LOCATION_SEARCHING " Jump")) { + ImGui::OpenPopup("JumpToAddress"); + } + + ImGui::SameLine(); + if (ImGui::Button(ICON_MD_SEARCH " Search")) { + ImGui::OpenPopup("SearchPattern"); + } + + ImGui::SameLine(); + if (ImGui::Button(ICON_MD_BOOKMARK " Bookmarks")) { + ImGui::OpenPopup("Bookmarks"); + } + + DrawJumpToAddressPopup(); + DrawSearchPopup(); + DrawBookmarksPopup(); +} + +void MemoryEditorWithDiffChecker::DrawJumpToAddressPopup() { + if (ImGui::BeginPopup("JumpToAddress")) { + ImGui::Text(ICON_MD_LOCATION_SEARCHING " Jump to Address"); + ImGui::Separator(); + ImGui::InputText("Address (hex)", jump_address_, IM_ARRAYSIZE(jump_address_)); + ImGui::TextDisabled("Format: 0x1C800 or 1C800"); + if (ImGui::Button("Go", ImVec2(120, 0))) { + // TODO: Parse address and scroll to it + ImGui::CloseCurrentPopup(); + } + ImGui::SameLine(); + if (ImGui::Button("Cancel", ImVec2(120, 0))) { + ImGui::CloseCurrentPopup(); + } + ImGui::EndPopup(); + } +} + +void MemoryEditorWithDiffChecker::DrawSearchPopup() { + if (ImGui::BeginPopup("SearchPattern")) { + ImGui::Text(ICON_MD_SEARCH " Search Hex Pattern"); + ImGui::Separator(); + ImGui::InputText("Pattern", search_pattern_, IM_ARRAYSIZE(search_pattern_)); + ImGui::TextDisabled("Use ?? for wildcard (e.g. FF 00 ?? 12)"); + if (ImGui::Button("Search", ImVec2(120, 0))) { + // TODO: Implement search using hex-search handler + ImGui::CloseCurrentPopup(); + } + ImGui::SameLine(); + if (ImGui::Button("Cancel", ImVec2(120, 0))) { + ImGui::CloseCurrentPopup(); + } + ImGui::EndPopup(); + } +} + +void MemoryEditorWithDiffChecker::DrawBookmarksPopup() { + if (ImGui::BeginPopup("Bookmarks")) { + ImGui::Text(ICON_MD_BOOKMARK " Memory Bookmarks"); + ImGui::Separator(); + + if (bookmarks_.empty()) { + ImGui::TextDisabled("No bookmarks yet"); + ImGui::Separator(); + if (ImGui::Button("Add Current Address")) { + // TODO: Add bookmark at current address + } + } else { + for (size_t i = 0; i < bookmarks_.size(); ++i) { + const auto& bm = bookmarks_[i]; + ImGui::PushID(static_cast(i)); + if (ImGui::Selectable(bm.name.c_str())) { + current_address_ = bm.address; + // TODO: Jump to this address + } + ImGui::TextDisabled(" 0x%06X - %s", bm.address, bm.description.c_str()); + ImGui::PopID(); + } + } + + ImGui::EndPopup(); + } +} + +} // namespace editor +} // namespace yaze diff --git a/src/app/editor/code/memory_editor.h b/src/app/editor/code/memory_editor.h index b5c33c30..a717ffa8 100644 --- a/src/app/editor/code/memory_editor.h +++ b/src/app/editor/code/memory_editor.h @@ -19,6 +19,8 @@ struct MemoryEditorWithDiffChecker { explicit MemoryEditorWithDiffChecker(Rom* rom = nullptr) : rom_(rom) {} void Update(bool &show_memory_editor) { + DrawToolbar(); + ImGui::Separator(); static MemoryEditor mem_edit; static MemoryEditor comp_edit; static bool show_compare_rom = false; @@ -66,7 +68,24 @@ struct MemoryEditorWithDiffChecker { Rom* rom() const { return rom_; } private: + void DrawToolbar(); + void DrawJumpToAddressPopup(); + void DrawSearchPopup(); + void DrawBookmarksPopup(); + Rom* rom_; + + // Toolbar state + char jump_address_[16] = "0x000000"; + char search_pattern_[256] = ""; + uint32_t current_address_ = 0; + + struct Bookmark { + uint32_t address; + std::string name; + std::string description; + }; + std::vector bookmarks_; }; } // namespace editor diff --git a/src/app/editor/code/memory_editor_enhanced.cc b/src/app/editor/code/memory_editor_enhanced.cc deleted file mode 100644 index 08dfd3f5..00000000 --- a/src/app/editor/code/memory_editor_enhanced.cc +++ /dev/null @@ -1,89 +0,0 @@ -#include "app/editor/code/memory_editor_enhanced.h" -#include "app/gui/icons.h" -#include "imgui/imgui.h" - -namespace yaze { -namespace editor { - -void EnhancedMemoryEditor::UpdateEnhanced(bool& show) { - ImGui::SetNextWindowSize(ImVec2(1000, 700), ImGuiCond_FirstUseEver); - if (!ImGui::Begin(ICON_MD_DATA_ARRAY " Enhanced Hex Editor", &show)) { - ImGui::End(); - return; - } - - DrawToolbar(); - ImGui::Separator(); - - // Call base memory editor - static MemoryEditor mem_edit; - mem_edit.DrawContents((void*)&(*rom()), rom()->size()); - - ImGui::End(); -} - -void EnhancedMemoryEditor::DrawToolbar() { - if (ImGui::Button(ICON_MD_LOCATION_SEARCHING " Jump to Address")) { - ImGui::OpenPopup("JumpToAddress"); - } - - ImGui::SameLine(); - if (ImGui::Button(ICON_MD_SEARCH " Search Pattern")) { - ImGui::OpenPopup("SearchPattern"); - } - - ImGui::SameLine(); - if (ImGui::Button(ICON_MD_BOOKMARK " Bookmarks")) { - ImGui::OpenPopup("Bookmarks"); - } - - ImGui::SameLine(); - if (ImGui::Button(ICON_MD_COMPARE " Diff View")) { - // TODO: Show diff - } - - // Jump to address popup - if (ImGui::BeginPopup("JumpToAddress")) { - ImGui::Text("Jump to Address"); - ImGui::Separator(); - ImGui::InputText("Address (hex)", jump_address_, IM_ARRAYSIZE(jump_address_)); - if (ImGui::Button("Go")) { - // TODO: Parse and jump - ImGui::CloseCurrentPopup(); - } - ImGui::EndPopup(); - } - - // Search popup - if (ImGui::BeginPopup("SearchPattern")) { - ImGui::Text("Search Hex Pattern"); - ImGui::Separator(); - ImGui::InputText("Pattern", search_pattern_, IM_ARRAYSIZE(search_pattern_)); - ImGui::TextDisabled("Use ?? for wildcard (e.g. FF 00 ?? 12)"); - if (ImGui::Button("Search")) { - // TODO: Implement search - ImGui::CloseCurrentPopup(); - } - ImGui::EndPopup(); - } - - // Bookmarks popup - if (ImGui::BeginPopup("Bookmarks")) { - ImGui::Text("Memory Bookmarks"); - ImGui::Separator(); - for (const auto& bm : bookmarks_) { - if (ImGui::Selectable(bm.name.c_str())) { - current_address_ = bm.address; - } - ImGui::TextDisabled(" 0x%06X - %s", bm.address, bm.description.c_str()); - } - ImGui::EndPopup(); - } -} - -void EnhancedMemoryEditor::DrawJumpToAddress() {} -void EnhancedMemoryEditor::DrawSearch() {} -void EnhancedMemoryEditor::DrawBookmarks() {} - -} // namespace editor -} // namespace yaze diff --git a/src/app/editor/code/memory_editor_enhanced.h b/src/app/editor/code/memory_editor_enhanced.h deleted file mode 100644 index 3ccb7724..00000000 --- a/src/app/editor/code/memory_editor_enhanced.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef YAZE_APP_EDITOR_CODE_MEMORY_EDITOR_ENHANCED_H_ -#define YAZE_APP_EDITOR_CODE_MEMORY_EDITOR_ENHANCED_H_ - -#include "app/editor/code/memory_editor.h" -#include "app/gui/icons.h" - -namespace yaze { -namespace editor { - -struct MemoryBookmark { - uint32_t address; - std::string name; - std::string description; -}; - -class EnhancedMemoryEditor : public MemoryEditorWithDiffChecker { - public: - explicit EnhancedMemoryEditor(Rom* rom) : MemoryEditorWithDiffChecker(rom) {} - - void UpdateEnhanced(bool& show); - - private: - void DrawToolbar(); - void DrawJumpToAddress(); - void DrawSearch(); - void DrawBookmarks(); - - std::vector bookmarks_; - char jump_address_[16] = "0x000000"; - char search_pattern_[256] = ""; - uint32_t current_address_ = 0; -}; - -} // namespace editor -} // namespace yaze - -#endif // YAZE_APP_EDITOR_CODE_MEMORY_EDITOR_ENHANCED_H_ diff --git a/src/app/editor/editor_library.cmake b/src/app/editor/editor_library.cmake index a12bb9d6..e97fa044 100644 --- a/src/app/editor/editor_library.cmake +++ b/src/app/editor/editor_library.cmake @@ -24,6 +24,7 @@ set( app/editor/message/message_data.cc app/editor/message/message_preview.cc app/editor/code/assembly_editor.cc + app/editor/code/memory_editor.cc app/editor/code/project_file_editor.cc app/editor/graphics/screen_editor.cc app/editor/graphics/graphics_editor.cc diff --git a/src/app/editor/editor_manager.h b/src/app/editor/editor_manager.h index 0b0e4342..10d3adbd 100644 --- a/src/app/editor/editor_manager.h +++ b/src/app/editor/editor_manager.h @@ -13,7 +13,6 @@ #include "app/core/project.h" #include "app/editor/code/assembly_editor.h" #include "app/editor/code/memory_editor.h" -#include "app/editor/code/memory_editor_enhanced.h" #include "app/editor/code/project_file_editor.h" #include "app/editor/dungeon/dungeon_editor_v2.h" #include "app/editor/graphics/graphics_editor.h" diff --git a/src/app/editor/overworld/overworld_editor.cc b/src/app/editor/overworld/overworld_editor.cc index 1a2ee2d3..0d9b8986 100644 --- a/src/app/editor/overworld/overworld_editor.cc +++ b/src/app/editor/overworld/overworld_editor.cc @@ -304,40 +304,70 @@ void OverworldEditor::DrawToolset() { gui::DrawTable(toolset_table_); if (show_tile16_editor_) { - ImGui::Begin("Tile16 Editor", &show_tile16_editor_, + // Create unique window name using session ID from context + std::string tile16_window_name = context_ + ? absl::StrFormat("Tile16 Editor###Tile16_S%zu", context_->session_id) + : "Tile16 Editor"; + + ImGui::Begin(tile16_window_name.c_str(), &show_tile16_editor_, ImGuiWindowFlags_MenuBar); + + // Use WidgetIdScope for test automation + gui::WidgetIdScope tile16_scope("Tile16Editor"); status_ = tile16_editor_.Update(); + ImGui::End(); } if (show_gfx_group_editor_) { - gui::BeginWindowWithDisplaySettings("Gfx Group Editor", + std::string gfx_window_name = context_ + ? absl::StrFormat("Gfx Group Editor###GfxGroup_S%zu", context_->session_id) + : "Gfx Group Editor"; + gui::BeginWindowWithDisplaySettings(gfx_window_name.c_str(), &show_gfx_group_editor_); status_ = gfx_group_editor_.Update(); gui::EndWindowWithDisplaySettings(); } if (show_properties_editor_) { - ImGui::Begin("Properties", &show_properties_editor_); + std::string props_window_name = context_ + ? absl::StrFormat("Properties###Props_S%zu", context_->session_id) + : "Properties"; + ImGui::Begin(props_window_name.c_str(), &show_properties_editor_); DrawOverworldProperties(); ImGui::End(); } if (show_custom_bg_color_editor_) { - ImGui::Begin("Custom Background Colors", &show_custom_bg_color_editor_); + std::string bg_window_name = context_ + ? absl::StrFormat("Custom Background Colors###BG_S%zu", context_->session_id) + : "Custom Background Colors"; + ImGui::Begin(bg_window_name.c_str(), &show_custom_bg_color_editor_); DrawCustomBackgroundColorEditor(); ImGui::End(); } if (show_overlay_editor_) { - ImGui::Begin("Overlay Editor", &show_overlay_editor_); + std::string overlay_window_name = context_ + ? absl::StrFormat("Overlay Editor###Overlay_S%zu", context_->session_id) + : "Overlay Editor"; + ImGui::Begin(overlay_window_name.c_str(), &show_overlay_editor_); DrawOverlayEditor(); ImGui::End(); } if (show_map_properties_panel_) { - ImGui::Begin("Map Properties Panel", &show_map_properties_panel_); + // Create unique window name using session ID from context + std::string map_props_window_name = context_ + ? absl::StrFormat("Map Properties###MapProps_S%zu", context_->session_id) + : "Map Properties"; + + ImGui::Begin(map_props_window_name.c_str(), &show_map_properties_panel_); + + // Use WidgetIdScope for test automation + gui::WidgetIdScope map_props_scope("MapProperties"); DrawMapPropertiesPanel(); + ImGui::End(); }