/* * GameInstance.h, part of VCMI engine * * Authors: listed in file AUTHORS in main folder * * License: GNU General Public License v2.0 or later * Full text of license available in license.txt file, in main folder * */ #pragma once #include "GameEngineUser.h" class CServerHandler; class GlobalLobbyClient; class CPlayerInterface; class CMapHandler; class CMainMenu; VCMI_LIB_NAMESPACE_BEGIN class INetworkHandler; VCMI_LIB_NAMESPACE_END class GameShutdownException final : public std::exception { public: const char* what() const noexcept final { return "Game shutdown has been requested"; } }; class GameInstance final : boost::noncopyable, public IGameEngineUser { std::unique_ptr serverInstance; std::unique_ptr mapInstance; std::shared_ptr mainMenuInstance; CPlayerInterface * interfaceInstance; public: GameInstance(); ~GameInstance(); CServerHandler & server(); CMapHandler & map(); std::shared_ptr mainmenu(); CPlayerInterface * interface(); void setServerInstance(std::unique_ptr ptr); void setMapInstance(std::unique_ptr ptr); void setInterfaceInstance(CPlayerInterface * ptr); void onGlobalLobbyInterfaceActivated() final; void onUpdate() final; bool capturedAllEvents() final; void onShutdownRequested(bool askForConfirmation) final; }; extern std::unique_ptr GAME;