/******************************************************************************
*	File		-	worldTree.cpp
*	Author		-	Joey Pollack
*	Date		-	2021/11/04 (y/m/d)
*	Mod Date	-	2021/11/04 (y/m/d)
*	Description	-	The tree view listing all objects in the world
******************************************************************************/

#include "world_tree.h"
#include <world/world.h>
#include <dearimgui/imgui.h>
#include <editor/editor.h>

namespace lunarium
{
namespace editor
{
    WorldTree::WorldTree()
        : Panel("World Tree", gui::PanelDockZone::DDZ_LEFT, true), mpWorld(nullptr)
    {
        
    }

    void WorldTree::SetWorld(lunarium::World* pWorld)
    {
        mpWorld = pWorld;
    }

    lunarium::World* WorldTree::GetWorld()
    {
        return mpWorld;
    }

    bool WorldTree::DoFrame()
    {
        if (!mIsOpen)
            return false;

        if (!ImGui::Begin(GetName(), &mIsOpen, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar))
        {
            ImGui::End();
            return false;
        }

        if (ImGui::TreeNode("World Root"))
        {
            // TODO: Build tree of world contents

            ImGui::TreePop();
        }

        if (ImGui::BeginPopupContextWindow(0, ImGuiPopupFlags_MouseButtonRight))
        {
            
            ImGui::EndPopup();
        }

        ImGui::End();
        return true;
    }
}
}