#include "IWindow.hpp"
#include "Debug.hpp"
#include "LuaStateHandler.hpp"
#include "utils/Time.hpp"
#include "version.h"
#include "IInputManager.hpp"
#include "elements/AudioEngine.hpp"
#include "IdGenerator.hpp"

#define FREEIMAGE_LIB
#include "FI/FreeImage.h"

TSE::IWindow* TSE::IWindow::lastWindow = nullptr;

bool TSE::IWindow::BaseInit() const
{
    LuaStateHandler::InitLuaState();
    Debug::Init();
    Debug::Log("TSE:" + TSE_VERSION_STRING);
    AudioEngine::Init();
    FreeImage_Initialise(true);
    return true;
}

void TSE::IWindow::BaseUpdate() const
{
    Time::Update();
}

TSE::Vector2 TSE::IWindow::GetSize() const
{
    return Vector2({width, height});
}

TSE::IWindow::~IWindow()
{
    FreeImage_DeInitialise();
    AudioEngine::Destroy();
    IInputManager::instance()->Delete();
    Time::Destroy();
    Debug::Close();
}
