#pragma once

#include <frostbite2D/event/event.h>
#include <frostbite2D/types/type_alias.h>
#include <vector>

namespace frostbite2D {

class Scene;
class UIScene;

class SceneManager {
public:
  static SceneManager& get();

  SceneManager(const SceneManager&) = delete;
  SceneManager& operator=(const SceneManager&) = delete;

  void PushScene(Ptr<Scene> scene);
  void PopScene();
  void ReplaceScene(Ptr<Scene> scene);

  void PushUIScene(Ptr<UIScene> scene);
  void PopUIScene();
  void ReplaceUIScene(Ptr<UIScene> scene);
  bool RemoveUIScene(UIScene* scene);
  void ClearUIScenes();
  void ClearAll();

  void Update(float deltaTime);
  void UpdateUI(float deltaTime);
  void Render();

  bool DispatchEvent(const Event& event);
  bool DispatchUIEvent(const Event& event);

  Scene* GetCurrentScene() const;
  UIScene* GetCurrentUIScene() const;
  bool HasActiveScene() const;
  bool HasActiveUIScene() const;

private:
  SceneManager() = default;

  std::vector<Ptr<Scene>> sceneStack_;
  std::vector<Ptr<UIScene>> uiSceneStack_;
};

} // namespace frostbite2D
