#ifndef EDITSCENE_STARTUPMENUSYSTEM_HPP
#define EDITSCENE_STARTUPMENUSYSTEM_HPP
#pragma once

#include <flecs.h>
#include <Ogre.h>
#include <imgui.h>
#include <memory>

#include "../components/StartupMenu.hpp"

class EditorApp;

/**
 * System that renders the full-screen startup menu in game mode.
 * Only active when EditorApp is in GameMode::Game and GamePlayState::Menu.
 */
class StartupMenuSystem {
public:
	StartupMenuSystem(flecs::world &world, Ogre::SceneManager *sceneMgr,
			  EditorApp *editorApp);
	~StartupMenuSystem();

	void update(float deltaTime);

	/**
	 * Pre-load the menu font before ImGui NewFrame().
	 * Must be called outside an active ImGui frame (before NewFrame).
	 */
	void prepareFont();

private:
	void renderMenu(StartupMenuComponent &sm);
	void renderMissingMenuError();
	void ensureFontLoaded(const Ogre::String &fontName, float fontSize);

	flecs::world &m_world;
	Ogre::SceneManager *m_sceneMgr;
	EditorApp *m_editorApp;

	bool m_fontLoaded = false;
	Ogre::String m_currentFontName;
	float m_currentFontSize = 0.0f;
	ImFont *m_menuFont = nullptr;
};

#endif // EDITSCENE_STARTUPMENUSYSTEM_HPP
