/******************************************************************************
*	File		-	editor_console.h
*	Author		-	Joey Pollack
*	Date		-	2022/10/26 (y/m/d)
*	Mod Date	-	2022/10/26 (y/m/d)
*	Description	-	The console log for the game editor
******************************************************************************/

#include "editor_console.h"
#include <core/core.h>
#include <gui/gui.h>
#include <gui/imgui_ext.h>

namespace lunarium { namespace editor
{
    EditorConsole::EditorConsole()
        : Console("Console", PanelDockZone::DDZ_BOTTOM, true, (ImGuiWindowFlags)ImGuiWindowFlags_NoCollapse),
        mGraphicsDebug(false), mInfoVerbose(false)
    {

    }

    EditorConsole::~EditorConsole()
    {
        
    }

    void EditorConsole::DoFrame()
    {
        ImVec2 window_size = ImGui::GetWindowSize();

        float child_height = ImGui::GetFrameHeight() * 1.75;
        ImGui::BeginChild("World View Toolbar", ImVec2(ImGui::GetContentRegionAvailWidth(), child_height), true);
        DoToolBar();
        ImGui::EndChild();;

        ImGui::PushFont(Core::GUI().GetFont(GuiFont::FONT_ROBO_SMALL));
        //ImVec2 region = ImGui::GetContentRegionAvail();
//        ImGui::SetNextWindowSize(ImVec2(ImGui::GetContentRegionAvailWidth(), ImGui::GetContentRegionAvail().y - 750), ImGuiCond_Always);
        Console::DoFrame();
        ImGui::PopFont();
    }

    void EditorConsole::PreBegin()
    {

    }

    void EditorConsole::DoToolBar()
    {
        if (ImGuiExt::CheckBoxLeft("Graphics Debug", &mGraphicsDebug))
        {
            SetOGLDebugFlag(mGraphicsDebug);
        }

        ImGui::SameLine();

        if (ImGuiExt::CheckBoxLeft("Info Verbose", &mInfoVerbose))
        {
            SetVerboseFlag(mInfoVerbose);
        }

        ImGui::SameLine();

        if (ImGui::Button("Clear"))
        {
            ClearMessageHistory();
        }
    }
}}