#pragma region Copyright /* Toxid Game Copyright (C) 2002-2008 Nuclex Development Labs */ #pragma endregion #ifndef TOXID_MAIN_H #define TOXID_MAIN_H #include "Toxid.h" #include
#include #include #include #include #include #include #include #include #include #include namespace Toxid { // ------------------------------------------------------------------------------------------- // class UIServer; class MapServer; class GameServer; // ------------------------------------------------------------------------------------------- // /// Main game class that manages the game's major subsystems class Main { /// Signature of an event used to signal that a new time frame started public: typedef SigC::Signal1 TimeFrameSignal; /// Signature of an event used to signal that a frame is being rendered public: typedef SigC::Signal2< void, const shared_ptr &, const shared_ptr & > RenderFrameSignal; /// Event that is fired to update the game's state public: TimeFrameSignal onTimeFrame; /// Event that is fired to render a frame to the screen public: RenderFrameSignal onRenderFrame; /// Pseudo-Singleton accessor /// The global instance of the game's main class public: static Main &getInstance() { return *s_pInstance; } /// Initializes an instance of the main game class /// Informations about the application's environment /// /// Reads the settings from the default configuration file and initializes the /// game's subsystem servers /// public: Main(const Nuclex::Environment &Environment); /// Terminates an instance of the main game class /// /// The current settings are saved into the default configuration file and all /// subsystems are shut down /// public: ~Main(); // // Main implementation // /// Runs the game's main loop /// /// Responsible for keeping the entire application running, updating the game state /// and rendering frames until it is terminated /// public: void run(); /// Accesses the UI server /// The game's UI server public: UIServer &getUIServer() { return *m_spUIServer.get(); } /// Accesses the map server /// The game's map server public: MapServer &getMapServer() { return *m_spMapServer.get(); } /// Accesses the gameplay server /// The game's gameplay server public: GameServer &getGameServer() { return *m_spGameServer.get(); } /// Accesses the game's active video driver /// The game's active video driver public: const shared_ptr &getVideoDriver() { return m_spVideoDriver; } /// Accesses the game's active audio driver /// The game's active audio driver public: const shared_ptr &getAudioDriver() { return m_spAudioDriver; } /// Accesses the game's active video device /// The game's active video device public: const shared_ptr &getVideoDevice() { return m_spVideoDevice; } /// Accesses the game's active audio device /// The game's active audio device /// /// Unlike the video device, the audio device can be NULL, indicating that /// audio is not supported in the current system or the user decided not /// to enable audio playback. /// public: const shared_ptr &getAudioDevice() { return m_spAudioDevice; } /// Loads the application settings from a file /// File to load the application settings from public: void loadSettings(const string &sFilename = "toxid.settings.xml"); /// Saves the application settings into a file /// File to save the application settings into public: void saveSettings(const string &sFilename = "toxid.settings.xml"); /// Sets the display mode to use when the game starts up public: void setDefaultDisplayMode(const Video::VideoDriver::DisplayMode &DisplayMode) { m_DisplayMode = DisplayMode; } /// /// Contains informations telling the plugin loader how a Toxid plugin looks like /// private: struct PluginSettings { /// The name of the exported version query function in plugins public: static string VersionFunctionName; /// The name of the exported register function in plugins public: static string RegisterFunctionName; /// The name of the exported unregister function in plugins public: static string UnregisterFunctionName; /// Filename prefix used by this kind of plugin public: static string FilePrefix; }; /// Type of loadable a Toxid plugin private: typedef Plugin ToxidPlugin; /// Map storing Toxid plugins by their file names private: typedef std::map > PluginMap; /// The global main game class instance private: static Main *s_pInstance; /// Informations about the environment the game is executing in private: const Environment &m_Environment; /// Currently loaded toxid plugins private: PluginMap m_Plugins; /// Currently selected video driver private: shared_ptr m_spVideoDriver; /// Currently selected audio driver private: shared_ptr m_spAudioDriver; /// Selected video mode private: Video::VideoDriver::DisplayMode m_DisplayMode; /// UI subsystem server of the game private: std::auto_ptr m_spUIServer; /// Map subsystem server of the game private: std::auto_ptr m_spMapServer; /// Gameplay subsystem server of the game private: std::auto_ptr m_spGameServer; /// Video device being used for rendering private: shared_ptr m_spVideoDevice; /// Audio device being used for audio playback private: shared_ptr m_spAudioDevice; }; } // namespace Toxid #endif // TOXID_MAIN_H