#ifndef APPLICATION_HPP
#define APPLICATION_HPP

#include "core.hpp"

#include "events/application_event.hpp"
#include "imgui/imgui_layer.hpp"
#include "layer.hpp"
#include "layer_stack.hpp"
#include "window/window.hpp"
#include <memory>

namespace OpenEngine {
    class OE_API Application
    {
        public:
            Application();
            virtual ~Application() = default;

            void Run();

            virtual void OnEvent(Event& event);

            void PushLayer(Layer* layer);
            void PushOverlay(Layer* overlay);

            inline static Application& Get() { return *instance; }

            inline Window& GetWindow() { return *window; }
            inline void StopRunning() { running = false; }

        private:
            bool OnWindowClose(WindowCloseEvent& event);
            bool OnWindowResize(WindowResizeEvent& event);

            inline static Application* instance;

            bool running = true;
            std::unique_ptr<Window> window;

            ImGuiLayer* imgui_layer;
            LayerStack layer_stack;
    };

    // Is defined by client
    Application* CreateApplication();
}

#endif // APPLICATION_HPP
