5#include "absl/strings/ascii.h"
6#include "absl/strings/str_format.h"
18 if (!project->code_folder.empty()) {
19 return project->GetAbsolutePath(project->code_folder);
21 if (!project->filepath.empty()) {
22 return std::filesystem::path(project->filepath).parent_path().string();
25 return std::filesystem::current_path().string();
43 if (!registry_or.ok()) {
45 last_error_ = std::string(registry_or.status().message());
52 registry_ = std::move(registry_or.value());
56 "Loaded %zu asm files, %zu bins, %zu draw routines, %zu components.",
65 const std::string& filter)
const {
69 const std::string value_lower = absl::AsciiStrToLower(value);
70 const std::string filter_lower = absl::AsciiStrToLower(filter);
71 return value_lower.find(filter_lower) != std::string::npos;
77 if (ImGui::Button(
"Auto Detect")) {
81 if (ImGui::Button(
"Refresh")) {
91 "ASM: %zu Bins: %zu Draw: %zu Components: %zu Warnings: %zu",
101 if (ImGui::BeginTable(
"oracle_menu_bins_table", 6,
102 ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg |
103 ImGuiTableFlags_Resizable | ImGuiTableFlags_ScrollY,
105 ImGui::TableSetupColumn(
"Label");
106 ImGui::TableSetupColumn(
"Bin Path");
107 ImGui::TableSetupColumn(
"Bytes", ImGuiTableColumnFlags_WidthFixed, 70.0f);
108 ImGui::TableSetupColumn(
"Status", ImGuiTableColumnFlags_WidthFixed, 70.0f);
109 ImGui::TableSetupColumn(
"ASM");
110 ImGui::TableSetupColumn(
"Line", ImGuiTableColumnFlags_WidthFixed, 55.0f);
111 ImGui::TableHeadersRow();
113 for (
const auto& entry :
registry_.bins) {
118 ImGui::TableNextRow();
119 ImGui::TableSetColumnIndex(0);
120 ImGui::TextUnformatted(entry.label.empty() ?
"(unlabeled)"
121 : entry.label.c_str());
122 ImGui::TableSetColumnIndex(1);
123 ImGui::TextUnformatted(entry.resolved_bin_path.c_str());
124 ImGui::TableSetColumnIndex(2);
125 ImGui::Text(
"%llu",
static_cast<unsigned long long>(entry.size_bytes));
126 ImGui::TableSetColumnIndex(3);
128 entry.exists ? theme.status_success : theme.status_error,
"%s",
129 entry.exists ?
"OK" :
"MISSING");
130 ImGui::TableSetColumnIndex(4);
131 ImGui::TextUnformatted(entry.asm_path.c_str());
132 ImGui::TableSetColumnIndex(5);
133 ImGui::Text(
"%d", entry.line);
143 if (ImGui::BeginTable(
"oracle_menu_draw_table", 5,
144 ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg |
145 ImGuiTableFlags_Resizable | ImGuiTableFlags_ScrollY,
147 ImGui::TableSetupColumn(
"Routine");
148 ImGui::TableSetupColumn(
"ASM");
149 ImGui::TableSetupColumn(
"Line", ImGuiTableColumnFlags_WidthFixed, 55.0f);
150 ImGui::TableSetupColumn(
"Refs", ImGuiTableColumnFlags_WidthFixed, 50.0f);
151 ImGui::TableSetupColumn(
"Kind", ImGuiTableColumnFlags_WidthFixed, 60.0f);
152 ImGui::TableHeadersRow();
154 for (
const auto& routine :
registry_.draw_routines) {
159 ImGui::TableNextRow();
160 ImGui::TableSetColumnIndex(0);
161 ImGui::TextUnformatted(routine.label.c_str());
162 ImGui::TableSetColumnIndex(1);
163 ImGui::TextUnformatted(routine.asm_path.c_str());
164 ImGui::TableSetColumnIndex(2);
165 ImGui::Text(
"%d", routine.line);
166 ImGui::TableSetColumnIndex(3);
167 ImGui::Text(
"%d", routine.references);
168 ImGui::TableSetColumnIndex(4);
169 ImGui::TextUnformatted(routine.local ?
"local" :
"global");
181 for (
const auto& component :
registry_.components) {
193 const float left_width = ImGui::GetContentRegionAvail().x * 0.58f;
194 ImGui::BeginChild(
"oracle_menu_components_list", ImVec2(left_width, 340.0f),
195 ImGuiChildFlags_Borders);
196 if (ImGui::BeginTable(
"oracle_menu_components_table", 5,
197 ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg |
198 ImGuiTableFlags_Resizable |
199 ImGuiTableFlags_ScrollY)) {
200 ImGui::TableSetupColumn(
"Table");
201 ImGui::TableSetupColumn(
"Index", ImGuiTableColumnFlags_WidthFixed, 55.0f);
202 ImGui::TableSetupColumn(
"Row", ImGuiTableColumnFlags_WidthFixed, 50.0f);
203 ImGui::TableSetupColumn(
"Col", ImGuiTableColumnFlags_WidthFixed, 50.0f);
204 ImGui::TableSetupColumn(
"Ref");
205 ImGui::TableHeadersRow();
209 ImGui::TableNextRow();
211 ImGui::TableSetColumnIndex(0);
213 std::string row_label =
214 absl::StrFormat(
"%s##oracle_component_%d", component->table_label, i);
215 if (ImGui::Selectable(row_label.c_str(), selected,
216 ImGuiSelectableFlags_SpanAllColumns)) {
222 ImGui::TableSetColumnIndex(1);
223 ImGui::Text(
"%d", component->index);
224 ImGui::TableSetColumnIndex(2);
225 ImGui::Text(
"%d", component->row);
226 ImGui::TableSetColumnIndex(3);
227 ImGui::Text(
"%d", component->col);
228 ImGui::TableSetColumnIndex(4);
229 ImGui::Text(
"%s:%d", component->asm_path.c_str(), component->line);
237 ImGui::BeginChild(
"oracle_menu_component_editor", ImVec2(0, 340.0f),
238 ImGuiChildFlags_Borders);
242 ImGui::TextDisabled(
"Select a component row to preview/apply edits.");
248 ImGui::Text(
"Table: %s", component->table_label.c_str());
249 ImGui::Text(
"Index: %d", component->index);
250 ImGui::Text(
"ASM: %s:%d", component->asm_path.c_str(), component->line);
251 if (!component->note.empty()) {
252 ImGui::TextDisabled(
"Note: %s", component->note.c_str());
265 if (ImGui::Button(
"Preview")) {
271 absl::StrFormat(
"Preview failed: %s", edit_or.status().message());
273 const auto& edit = edit_or.value();
275 "Preview %s[%d] (%d,%d) -> (%d,%d)", edit.table_label, edit.index,
276 edit.old_row, edit.old_col, edit.new_row, edit.new_col);
280 if (ImGui::Button(
"Apply")) {
286 absl::StrFormat(
"Apply failed: %s", edit_or.status().message());
288 const auto& edit = edit_or.value();
290 "Applied %s[%d] (%d,%d) -> (%d,%d)", edit.table_label, edit.index,
291 edit.old_row, edit.old_col, edit.new_row, edit.new_col);
305 ImGui::TextColored(theme.status_error,
"%s",
last_error_.c_str());
315 ImGui::TextDisabled(
"No menu registry data loaded.");
320 if (ImGui::BeginTabItem(
"Bins")) {
324 if (ImGui::BeginTabItem(
"Draw Routines")) {
328 if (ImGui::BeginTabItem(
"Components")) {
332 if (ImGui::BeginTabItem(
"Warnings")) {
334 ImGui::TextDisabled(
"No warnings.");
336 for (
const auto& warning :
registry_.warnings) {
337 ImGui::BulletText(
"%s", warning.c_str());
absl::StatusOr< OracleMenuRegistry > BuildOracleMenuRegistry(const std::filesystem::path &project_root)
absl::StatusOr< OracleMenuComponentEditResult > SetOracleMenuComponentOffset(const std::filesystem::path &project_root, const std::string &asm_relative_path, const std::string &table_label, int index, int row, int col, bool write_changes)
const AgentUITheme & GetTheme()
::yaze::project::YazeProject * current_project()
Get the current project instance.
Editors are the view controllers for the application.
bool BeginThemedTabBar(const char *id, ImGuiTabBarFlags flags)
A stylized tab bar with "Mission Control" branding.
#define REGISTER_PANEL(PanelClass)
Auto-registration macro for panels with default constructors.