#include "../Menu.h"
#include "../../Backend/Font/FontManager.h"
#include "../../Initialization/Initialization.h"
#include "../../Backend/Injector/Injector.h"
#include <iostream>


menu::Injector* menu::Injector::Get() {
    static Injector instance;
    return &instance;
}

void menu::Injector::DrawInjectorMenu() {
    auto* font = Font::Get();
    RLVector2 Win_size = Initialization::Get()->Get_WinSize();

    if (!m_connecting) {
        m_connecting = true;
        m_startTime = RLGetTime();
    }

    double elapsed = RLGetTime() - m_startTime;

    float alpha = 25 + (float)((sin(elapsed * 2.5) + 1.0) * 0.5 * 195.0f);

    auto size = font->MeasureText("Injector", 18);
    font->DrawTextEX("Injector...", { (Win_size.x - size.x) / 2, (Win_size.y - size.y) / 2 }, 18, { 250, 250, 250, (unsigned char)alpha }, 2);
    bool injectorReady = (elapsed >= 3.0); // 模拟注入准备时间
    if (injectorReady && !m_injectionDone) {
        m_injectionDone = true;
        injector::Get()->Launch();  // 新线程启动 SkeetInjector
    }
}