#include "mainMenu.hpp"

#include <imgui/imgui.h>

#include "game.h"

namespace game {

MainMenu::MainMenu()
{
    this->fxCollection.load("data/fx/menu.fx.xml");
    this->bgEffect = this->fxCollection.createEffect("e1");
    this->bgEffect->pos = vec2f{15, 0};
}

MainMenu::~MainMenu()
{
    delete this->bgEffect;
}

void MainMenu::Show() noexcept
{
    this->bgEffect->start();
}

void MainMenu::Hide() noexcept
{
    this->bgEffect->stop();
}

void MainMenu::Update() noexcept
{
    this->bgEffect->update();

    ImGui::SetNextWindowPos(ImVec2());
    ImGui::Begin("main", nullptr, ImVec2(300, 544), -1, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoBackground);

    ImGui::BeginGroup();
        if (ImGui::Button("start", ImVec2(300, 100))) {
            game::setState(1);
        }
        ImGui::Button("settings", ImVec2(300, 100));
        ImGui::Button("exit", ImVec2(300, 100));
    ImGui::EndGroup();

    ImGui::End();
}


void MainMenu::Render() const noexcept
{
    this->bgEffect->draw();
}

}
