//
// Created by sebastian on 06.08.26.
//

#ifndef COLORRACE_MAINMENUUILAYER_H
#define COLORRACE_MAINMENUUILAYER_H
#include <utility>

#include "layer/Layer.h"
#include "loader/assets/AssetManager.h"
#include "renderer/GuiRenderer.h"
#include "renderer/ui/GUITexture.h"


class MainMenuUiLayer : public engine::Layer {
public:
    MainMenuUiLayer(engine::Keyboard &keyboard, engine::Mouse &mouse, engine::EventBus<engine::animation::AnimationMarkerEvent> &animationEventBus, std::shared_ptr<engine::EventBus<ApplicationEvents>> applicationEventbus, engine::AssetManager& assetManager)
    : Layer(keyboard, mouse, animationEventBus, std::move(applicationEventbus)), m_assetManager(assetManager) {
    }

    void onRender() override;
    void onUpdate(float deltaTime) override;

protected:
    void onAttachImpl() override;
    void onDetachImpl() override;

private:
    engine::AssetManager& m_assetManager;
    std::unique_ptr<engine::GUITexture> backgroundImage;
    engine::renderer::GuiRenderer m_guiRenderer;

    char m_hostBuffer[64] = "127.0.0.1";
    int m_port = 7777;
    bool m_connectionError = false;
    std::string m_errorMessage;

    void renderConnectDialog();
};


#endif //COLORRACE_MAINMENUUILAYER_H
