#include "SceneView.hpp"

TSE::EDITOR::SceneView::SceneView(TSE::IRenderTexture *frameBuffer) : GuiWindow("Scene", ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar)
{ 
    fb = frameBuffer;
}

int selected = 0;

void TSE::EDITOR::SceneView::Define()
{
    ImGuiWindowFlags flags2 = ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar;
    if(ImGui::BeginChild("##SceneChild", {0,0}, ImGuiChildFlags_None, flags2))
    {
        ImGui::Image(fb->GetTextureId(selected), {fb->Width(), fb->Height()},{0,1}, {1,0});
        auto vec2 = ImGui::GetWindowSize();
        if(fb->Width() != vec2.x || fb->Height() != vec2.y)
        {
            fb->SetSize({vec2.x, vec2.y});
        }


        static const char* items[] = {
            "0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15",
            "16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"
        };

        ImGui::SetCursorPos(ImVec2(6.0f, 6.0f));

        ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0,0,0,0.6f));
        ImGui::PushStyleColor(ImGuiCol_PopupBg, ImVec4(0,0,0,0.9f));

        ImGui::SetNextItemWidth(80.0f);
        ImGui::Combo("##SceneDropdown", &selected, items, IM_ARRAYSIZE(items));

        ImGui::PopStyleColor(2);

        IsHovered = ImGui::IsWindowFocused();
    }
    ImGui::EndChild();
}
