1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-05-13 22:06:58 +02:00
vcmi/client/GameInstance.h
2025-03-12 13:33:12 +00:00

61 lines
1.4 KiB
C++

/*
* 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<CServerHandler> serverInstance;
std::unique_ptr<CMapHandler> mapInstance;
std::shared_ptr<CMainMenu> mainMenuInstance;
CPlayerInterface * interfaceInstance;
public:
GameInstance();
~GameInstance();
CServerHandler & server();
CMapHandler & map();
std::shared_ptr<CMainMenu> mainmenu();
CPlayerInterface * interface();
void setServerInstance(std::unique_ptr<CServerHandler> ptr);
void setMapInstance(std::unique_ptr<CMapHandler> ptr);
void setInterfaceInstance(CPlayerInterface * ptr);
void onGlobalLobbyInterfaceActivated() final;
void onUpdate() final;
bool capturedAllEvents() final;
void onShutdownRequested(bool askForConfirmation) final;
};
extern std::unique_ptr<GameInstance> GAME;