terom@185: #ifndef ENGINE_HH terom@185: #define ENGINE_HH terom@185: terom@218: // forward-declare terom@185: class Engine; terom@185: terom@185: #include "GameState.hh" terom@411: #include "Graphics/Graphics.hh" terom@186: #include "Network/Server.hh" terom@186: #include "Network/Client.hh" terom@185: terom@185: #include "Logger.hh" terom@185: terom@283: /** terom@283: * This is the core class that glues all the other components together and runs the main loop terom@283: */ terom@185: class Engine { terom@185: private: terom@185: // game state terom@408: Terrain *terrain; terom@408: GameState *game_state; terom@408: terom@185: // Graphics/Input terom@411: graphics::Graphics *graphics; terom@185: terom@185: // network server/client terom@185: NetworkServer *net_server; terom@408: NetworkClientConnect *net_client_connect; terom@408: // XXX: currently unused: NetworkClient *net_client; terom@185: terom@185: // to exit the mainloop terom@185: bool is_running; terom@218: terom@233: // ClanLib resources terom@233: CL_ResourceManager resources; terom@185: terom@185: public: terom@185: // default constructor terom@233: Engine (const std::string resource_xml_path = RESOURCE_XML_PATH); terom@185: terom@408: /** terom@408: * Setup game world using the given terrain, returning the new GameState terom@409: * terom@409: * XXX: fix to return void terom@408: */ terom@408: GameState& setupGame (Terrain *terrain); terom@408: terom@408: /** terom@409: * Setup game world using given terrain configuration terom@408: */ terom@409: void setupGame (const TerrainConfig &config); terom@408: terom@409: /** terom@409: * Enable graphics terom@409: */ terom@411: void setupGraphics (const graphics::DisplayConfig &config); terom@185: terom@409: /** terom@409: * Setup server, must call setupGame first terom@409: */ terom@185: void setupNetworkServer (const std::string &listen_port); terom@409: terom@409: /** terom@409: * Setup client, do *not* call setupGame, configuration comes from the server terom@409: */ terom@185: void setupNetworkClient (const std::string &connect_host, const std::string &connect_port); terom@409: terom@409: /** terom@409: * Setup singleplayer, must call setupGame first terom@409: */ terom@185: void setupSinglePlayer (void); terom@185: terom@408: /** terom@408: * Run the game main loop. This will not return until the game aborts due to an error, or someone calls stop(). terom@408: */ terom@185: void run (void); terom@408: terom@408: /** terom@408: * Terminate the main loop, causing run() to return once this loop iteration is finished terom@408: */ terom@408: void stop (void); terom@185: terom@408: private: terom@408: /** terom@408: * Actually start graphics, requires that game_state is now set terom@408: */ terom@408: void startGraphics (void); terom@185: terom@185: public: terom@233: // get a pointer to our resource manager terom@233: CL_ResourceManager* getResourceManager (void); terom@218: terom@185: // logging utility terom@185: static Logger log (enum LogLevel level, const char *type); terom@185: terom@185: }; terom@185: terom@185: #endif /* ENGINE_HH */