#ifndef EDITSCENE_GAMEMODE_HPP
#define EDITSCENE_GAMEMODE_HPP
#pragma once

/**
 * @file GameMode.hpp
 *
 * Global game mode query functions for the editScene feature.
 *
 * These functions allow any code in the editScene feature to query
 * whether the application is currently in editor mode or game mode,
 * and what the current gameplay state is, without needing a direct
 * pointer to EditorApp.
 *
 * The EditorApp sets the current mode via setEditSceneGameMode()
 * during its lifetime.  Code outside the editScene feature should
 * continue to use EditorApp::getGameMode() / getGamePlayState()
 * directly.
 */

namespace editScene
{

/**
 * Application mode: editor or game.
 */
enum class GameMode { Editor, Game };

/**
 * Play state when in game mode.
 */
enum class GamePlayState { Menu, Playing, Paused };

// ---------------------------------------------------------------------------
// Global state management (called by EditorApp)
// ---------------------------------------------------------------------------

/**
 * Set the current game mode.  Called by EditorApp on mode changes.
 */
void setEditSceneGameMode(GameMode mode) noexcept;

/**
 * Set the current gameplay state.  Called by EditorApp on state changes.
 */
void setEditSceneGamePlayState(GamePlayState state) noexcept;

// ---------------------------------------------------------------------------
// Query functions
// ---------------------------------------------------------------------------

/**
 * Return the current application mode.
 */
GameMode getGameMode() noexcept;

/**
 * Return the current gameplay state (only meaningful in game mode).
 */
GamePlayState getGamePlayState() noexcept;

// ---------------------------------------------------------------------------
// Predicates
// ---------------------------------------------------------------------------

/** True when the application is in editor mode. */
inline bool isEditorMode() noexcept
{
	return getGameMode() == GameMode::Editor;
}

/** True when the application is in game mode (any play state). */
inline bool isGameMode() noexcept
{
	return getGameMode() == GameMode::Game;
}

/** True when in game mode and the gameplay state is Playing. */
inline bool isGamePlaying() noexcept
{
	return getGameMode() == GameMode::Game &&
	       getGamePlayState() == GamePlayState::Playing;
}

/** True when in game mode and the gameplay state is Menu. */
inline bool isGameMenu() noexcept
{
	return getGameMode() == GameMode::Game &&
	       getGamePlayState() == GamePlayState::Menu;
}

/** True when in game mode and the gameplay state is Paused. */
inline bool isGamePaused() noexcept
{
	return getGameMode() == GameMode::Game &&
	       getGamePlayState() == GamePlayState::Paused;
}

} // namespace editScene

#endif // EDITSCENE_GAMEMODE_HPP
