Initial commit: registry_dashboard — Dashboard ImGui para fn_registry

This commit is contained in:
Egutierrez
2026-04-08 00:42:29 +02:00
commit 303b6d476d
9 changed files with 722 additions and 0 deletions
+78
View File
@@ -0,0 +1,78 @@
#include "app_base.h"
#include "imgui.h"
#include "core/fullscreen_window.h"
#include "data.h"
#include "views.h"
#include <cstdio>
#include <cstdlib>
#include <string>
#include <fstream>
static RegistryData g_data;
static std::string g_db_path;
static bool g_loaded = false;
static void reload_data() {
g_data = RegistryData{};
g_loaded = load_registry_data(g_db_path.c_str(), g_data);
if (!g_loaded) {
fprintf(stderr, "Failed to load registry data from: %s\n", g_db_path.c_str());
}
}
static void render() {
if (ImGui::GetIO().UserData != nullptr) {
ImGui::GetIO().UserData = nullptr;
reload_data();
}
if (!g_loaded) {
fullscreen_window_begin("##error");
ImGui::TextColored(ImVec4(1, 0.3f, 0.3f, 1),
"Could not open registry.db");
ImGui::Spacing();
ImGui::Text("Tried: %s", g_db_path.c_str());
ImGui::Spacing();
ImGui::TextWrapped("Usage: registry_dashboard <path1> [path2] [path3] ...");
ImGui::Spacing();
if (ImGui::Button("Retry")) {
reload_data();
}
fullscreen_window_end();
return;
}
draw_dashboard(g_data);
}
int main(int argc, char** argv) {
if (argc < 2) {
fprintf(stderr, "Usage: registry_dashboard <db_path> [fallback_path ...]\n");
fprintf(stderr, " Tries each path in order until one opens successfully.\n");
return 1;
}
// Try each argument in order
for (int i = 1; i < argc; i++) {
std::string candidate = argv[i];
if (std::ifstream(candidate).good()) {
g_db_path = candidate;
fprintf(stdout, "Using: %s\n", g_db_path.c_str());
break;
}
fprintf(stderr, "Not found: %s\n", candidate);
}
if (g_db_path.empty()) {
// None found, use last arg so error screen shows something useful
g_db_path = argv[argc - 1];
}
reload_data();
return fn::run_app(
{.title = "fn_registry Dashboard", .width = 1600, .height = 1000, .viewports = true},
render
);
}