3#include "absl/strings/str_format.h"
9#include "imgui/imgui.h"
16 return absl::OkStatus();
22 ImGui::Begin(
"Hex Editor", &
active_);
23 if (ImGui::Button(
"Compare Rom")) {
29 static uint64_t convert_address = 0;
30 gui::InputHex(
"SNES to PC", (
int*)&convert_address, 6, 200.f);
32 Text(
"%x",
SnesToPc(convert_address));
34 BEGIN_TABLE(
"Memory Comparison", 2, ImGuiTableFlags_Resizable);
39 Text(
"%s",
rom()->filename().data());
46 ImGui::BeginChild(
"Comparison ROM");
57 return absl::OkStatus();
65 {{ImGuiStyleVar_FramePadding, ImVec2(pad, pad * 0.67f)},
66 {ImGuiStyleVar_ItemSpacing, ImVec2(pad * 0.67f, pad * 0.67f)}});
69 ImGui::OpenPopup(
"JumpToAddress");
71 if (ImGui::IsItemHovered()) {
72 ImGui::SetTooltip(
"Jump to specific address");
77 ImGui::OpenPopup(
"SearchPattern");
79 if (ImGui::IsItemHovered()) {
80 ImGui::SetTooltip(
"Search for hex pattern");
85 ImGui::OpenPopup(
"Bookmarks");
87 if (ImGui::IsItemHovered()) {
88 ImGui::SetTooltip(
"Manage address bookmarks");
110 if (ImGui::BeginPopupModal(
"JumpToAddress",
nullptr,
111 ImGuiWindowFlags_AlwaysAutoResize)) {
117 ImGui::SetNextItemWidth(200);
120 ImGuiInputTextFlags_CharsHexadecimal |
121 ImGuiInputTextFlags_EnterReturnsTrue)) {
127 ImGui::CloseCurrentPopup();
130 ImGui::TextDisabled(
"Format: 0x1C800 or 1C800");
142 ImGui::CloseCurrentPopup();
146 ImGui::CloseCurrentPopup();
153 if (ImGui::BeginPopupModal(
"SearchPattern",
nullptr,
154 ImGuiWindowFlags_AlwaysAutoResize)) {
160 ImGui::SetNextItemWidth(300);
163 ImGuiInputTextFlags_EnterReturnsTrue)) {
165 ImGui::CloseCurrentPopup();
167 ImGui::TextDisabled(
"Use ?? for wildcard (e.g. FF 00 ?? 12)");
172 if (ImGui::SmallButton(
"LDA")) {
176 if (ImGui::SmallButton(
"STA")) {
180 if (ImGui::SmallButton(
"JSR")) {
190 ImGui::CloseCurrentPopup();
194 ImGui::CloseCurrentPopup();
201 if (ImGui::BeginPopupModal(
"Bookmarks",
nullptr,
202 ImGuiWindowFlags_AlwaysAutoResize)) {
214 if (ImGui::Button(
ICON_MD_ADD " Add Current Address", ImVec2(250, 0))) {
218 absl::StrFormat(
"Bookmark %zu",
bookmarks_.size() + 1);
219 new_bookmark.
description =
"User-defined bookmark";
224 ImGui::BeginChild(
"##bookmarks_list", ImVec2(0, 300),
true);
225 if (ImGui::BeginTable(
"##bookmarks_table", 3,
226 ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg |
227 ImGuiTableFlags_Resizable)) {
228 ImGui::TableSetupColumn(
"Name", ImGuiTableColumnFlags_WidthFixed, 150);
229 ImGui::TableSetupColumn(
"Address", ImGuiTableColumnFlags_WidthFixed,
231 ImGui::TableSetupColumn(
"Description",
232 ImGuiTableColumnFlags_WidthStretch);
233 ImGui::TableHeadersRow();
235 for (
size_t i = 0; i <
bookmarks_.size(); ++i) {
237 ImGui::PushID(
static_cast<int>(i));
239 ImGui::TableNextRow();
240 ImGui::TableNextColumn();
241 if (ImGui::Selectable(bm.name.c_str(),
false,
242 ImGuiSelectableFlags_SpanAllColumns)) {
245 ImGui::CloseCurrentPopup();
248 ImGui::TableNextColumn();
252 ImGui::TableNextColumn();
253 ImGui::TextDisabled(
"%s", bm.description.c_str());
262 if (ImGui::Button(
ICON_MD_ADD " Add Bookmark", ImVec2(150, 0))) {
266 absl::StrFormat(
"Bookmark %zu",
bookmarks_.size() + 1);
267 new_bookmark.
description =
"User-defined bookmark";
281 ImGui::CloseCurrentPopup();
absl::Status LoadFromFile(const std::string &filename, const LoadOptions &options=LoadOptions::Defaults())
char search_pattern_[256]
std::vector< Bookmark > bookmarks_
gui::MemoryEditorWidget memory_widget_
uint32_t current_address_
absl::Status Update() override
void DrawBookmarksPopup()
gui::MemoryEditorWidget comparison_widget_
void DrawJumpToAddressPopup()
static float GetButtonPadding()
RAII guard for ImGui style vars.
static std::string ShowOpenFileDialog()
ShowOpenFileDialog opens a file dialog and returns the selected filepath. Uses global feature flag to...
#define ICON_MD_LOCATION_ON
#define ICON_MD_LOCATION_SEARCHING
#define ICON_MD_MORE_VERT
#define ICON_MD_CLEAR_ALL
#define BEGIN_TABLE(l, n, f)
#define PRINT_IF_ERROR(expression)
bool InputHex(const char *label, uint64_t *data)
uint32_t SnesToPc(uint32_t addr) noexcept