#pragma once
// -------------------------------------------------------------------------
// MenuBridge — the seam between the vendored Lumin ImGui menu (external/lumin)
// and this project's overlay state (GameOverlay).
//
// GameOverlay fills one of these every frame (pointers into its own members
// for the editable values, plain values for the read-only info panels) and
// the menu's render() reads/writes through the global pointer below.  This
// keeps all the actual ESP state owned by GameOverlay while letting Lumin's
// widgets drive it.
// -------------------------------------------------------------------------
#include <cstddef>
#include <functional>
#include <map>
#include <string>
#include <vector>

struct MenuBridge {
    // ---- ESP visibility toggles (point at GameOverlay members) ----
    bool* showPlayers      = nullptr;
    bool* showAnimals      = nullptr;
    bool* showZombies      = nullptr;
    bool* showItems        = nullptr;
    bool* showBox          = nullptr;
    bool* showSkeleton     = nullptr;
    bool* showHeadDot      = nullptr;
    bool* showWeapon         = nullptr;
    bool* showHealthBar      = nullptr;
    bool* showHealthNumber   = nullptr;
    bool* showCorpses        = nullptr;
    bool* debugSkeleton      = nullptr;
    bool* showBallisticDot   = nullptr;
    bool* showBulletTrails   = nullptr;

    // ---- ESP draw-distance limits ----
    float* playerMaxDist = nullptr;
    float* animalMaxDist = nullptr;
    float* zombieMaxDist = nullptr;
    float* itemMaxDist   = nullptr;

    // ---- Per-category loot toggles (key = filterKey) ----
    std::map<std::string, bool>* itemCategories = nullptr;

    // ---- Read-only info (refreshed each frame) ----
    bool        connected = false;
    std::string serverName;
    std::string mapName;
    std::string status;
    bool        hasPos = false;
    float       px = 0.f, py = 0.f, pz = 0.f;
    std::size_t nPlayers = 0, nAnimals = 0, nZombies = 0,
                nVehicles = 0, nItems = 0, nBullets = 0;

    // ---- DMA handle stats (read-only, refreshed each frame) ----
    bool  dmaAttached    = false;
    float dmaReadMBps    = 0.f;   // MB/s rolling 1 s
    float dmaScatterOps  = 0.f;   // scatter calls/s rolling 1 s
    float dmaTotalGB     = 0.f;   // cumulative GB read since attach
    uint64_t dmaTotalOps = 0;     // cumulative scatter calls since attach

    // ---- Web radar ----
    int                      webPort = 7777;
    std::vector<std::string> webUrls;

    // ---- Resolution settings (point at GameOverlay members) ----
    int*  pendingW       = nullptr;
    int*  pendingH       = nullptr;
    int*  pendingRW      = nullptr;
    int*  pendingRH      = nullptr;
    bool* stretchToFill  = nullptr;

    // ---- Actions ----
    std::function<void()> onApplyDisplayRes;  // applies pendingW/H + resize
    std::function<void()> onApplyRenderRes;   // applies pendingRW/RH + stretch
    std::function<void()> onSaveConfig;
    std::function<void()> onExit;
};

// Set by GameOverlay before each gui->render() call; read by the menu.
extern MenuBridge* g_menu;

// Thin shim implemented in external/lumin/framework/gui.cpp.  Lets GameOverlay
// drive the Lumin menu without pulling the whole framework header (and its
// `using namespace ImGui`) into GameOverlay's translation unit.  Must be called
// between ImGui::NewFrame() and ImGui::Render().
void RenderLuminMenu();
