feat: Integrate Memory Editor functionality and remove enhanced version
- Added `memory_editor.cc` and `memory_editor.h` to implement core memory editing features. - Introduced a toolbar with options for jumping to addresses, searching patterns, and managing bookmarks. - Removed the `EnhancedMemoryEditor` class and its associated files, streamlining the memory editing process. - Updated `editor_library.cmake` and `editor_manager.h` to reflect the new structure and dependencies.
This commit is contained in:
92
src/app/editor/code/memory_editor.cc
Normal file
92
src/app/editor/code/memory_editor.cc
Normal file
@@ -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<int>(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
|
||||||
@@ -19,6 +19,8 @@ struct MemoryEditorWithDiffChecker {
|
|||||||
explicit MemoryEditorWithDiffChecker(Rom* rom = nullptr) : rom_(rom) {}
|
explicit MemoryEditorWithDiffChecker(Rom* rom = nullptr) : rom_(rom) {}
|
||||||
|
|
||||||
void Update(bool &show_memory_editor) {
|
void Update(bool &show_memory_editor) {
|
||||||
|
DrawToolbar();
|
||||||
|
ImGui::Separator();
|
||||||
static MemoryEditor mem_edit;
|
static MemoryEditor mem_edit;
|
||||||
static MemoryEditor comp_edit;
|
static MemoryEditor comp_edit;
|
||||||
static bool show_compare_rom = false;
|
static bool show_compare_rom = false;
|
||||||
@@ -66,7 +68,24 @@ struct MemoryEditorWithDiffChecker {
|
|||||||
Rom* rom() const { return rom_; }
|
Rom* rom() const { return rom_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void DrawToolbar();
|
||||||
|
void DrawJumpToAddressPopup();
|
||||||
|
void DrawSearchPopup();
|
||||||
|
void DrawBookmarksPopup();
|
||||||
|
|
||||||
Rom* rom_;
|
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<Bookmark> bookmarks_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace editor
|
} // namespace editor
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -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<MemoryBookmark> 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_
|
|
||||||
@@ -24,6 +24,7 @@ set(
|
|||||||
app/editor/message/message_data.cc
|
app/editor/message/message_data.cc
|
||||||
app/editor/message/message_preview.cc
|
app/editor/message/message_preview.cc
|
||||||
app/editor/code/assembly_editor.cc
|
app/editor/code/assembly_editor.cc
|
||||||
|
app/editor/code/memory_editor.cc
|
||||||
app/editor/code/project_file_editor.cc
|
app/editor/code/project_file_editor.cc
|
||||||
app/editor/graphics/screen_editor.cc
|
app/editor/graphics/screen_editor.cc
|
||||||
app/editor/graphics/graphics_editor.cc
|
app/editor/graphics/graphics_editor.cc
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
#include "app/core/project.h"
|
#include "app/core/project.h"
|
||||||
#include "app/editor/code/assembly_editor.h"
|
#include "app/editor/code/assembly_editor.h"
|
||||||
#include "app/editor/code/memory_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/code/project_file_editor.h"
|
||||||
#include "app/editor/dungeon/dungeon_editor_v2.h"
|
#include "app/editor/dungeon/dungeon_editor_v2.h"
|
||||||
#include "app/editor/graphics/graphics_editor.h"
|
#include "app/editor/graphics/graphics_editor.h"
|
||||||
|
|||||||
@@ -304,40 +304,70 @@ void OverworldEditor::DrawToolset() {
|
|||||||
gui::DrawTable(toolset_table_);
|
gui::DrawTable(toolset_table_);
|
||||||
|
|
||||||
if (show_tile16_editor_) {
|
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);
|
ImGuiWindowFlags_MenuBar);
|
||||||
|
|
||||||
|
// Use WidgetIdScope for test automation
|
||||||
|
gui::WidgetIdScope tile16_scope("Tile16Editor");
|
||||||
status_ = tile16_editor_.Update();
|
status_ = tile16_editor_.Update();
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show_gfx_group_editor_) {
|
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_);
|
&show_gfx_group_editor_);
|
||||||
status_ = gfx_group_editor_.Update();
|
status_ = gfx_group_editor_.Update();
|
||||||
gui::EndWindowWithDisplaySettings();
|
gui::EndWindowWithDisplaySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show_properties_editor_) {
|
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();
|
DrawOverworldProperties();
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show_custom_bg_color_editor_) {
|
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();
|
DrawCustomBackgroundColorEditor();
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show_overlay_editor_) {
|
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();
|
DrawOverlayEditor();
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show_map_properties_panel_) {
|
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();
|
DrawMapPropertiesPanel();
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user