feat: Add Enhanced Memory Editor with toolbar functionality

- Introduced `EnhancedMemoryEditor` class for advanced memory editing capabilities.
- Implemented a toolbar with buttons for jumping to addresses, searching patterns, and managing bookmarks.
- Added popups for address jumping and pattern searching, enhancing user interaction.
- Removed unnecessary style variable pop from `AgentChatWidget` for cleaner UI management.
This commit is contained in:
scawful
2025-10-05 01:50:53 -04:00
parent 9f119abba7
commit a4103e8e5c
3 changed files with 126 additions and 1 deletions

View File

@@ -671,7 +671,6 @@ void AgentChatWidget::Draw() {
ImGui::EndTabBar();
}
ImGui::PopStyleVar(4); // Pop the 4 style vars we pushed
ImGui::End();
}

View File

@@ -0,0 +1,89 @@
#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

View File

@@ -0,0 +1,37 @@
#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_