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) {}
|
||||
|
||||
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<Bookmark> bookmarks_;
|
||||
};
|
||||
|
||||
} // 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_
|
||||
Reference in New Issue
Block a user