1
0
mirror of https://github.com/vcmi/vcmi.git synced 2026-05-22 09:55:17 +02:00
Files
vcmi/client/GameInstance.h
T

64 lines
1.4 KiB
C++
Raw Normal View History

2025-02-11 15:23:33 +00:00
/*
* 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
2025-02-27 22:18:31 +00:00
#include "GameEngineUser.h"
2025-02-11 15:23:33 +00:00
class CServerHandler;
class GlobalLobbyClient;
class CPlayerInterface;
class CMapHandler;
class CMainMenu;
2025-02-11 15:23:33 +00:00
2025-02-21 16:00:59 +00:00
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";
}
};
2025-02-27 22:18:31 +00:00
class GameInstance final : boost::noncopyable, public IGameEngineUser
2025-02-11 15:23:33 +00:00
{
std::unique_ptr<CServerHandler> serverInstance;
std::unique_ptr<CMapHandler> mapInstance;
std::shared_ptr<CMainMenu> mainMenuInstance;
2025-02-11 15:23:33 +00:00
CPlayerInterface * interfaceInstance;
void pauseAutoSave();
2025-02-11 15:23:33 +00:00
public:
GameInstance();
~GameInstance();
CServerHandler & server();
CMapHandler & map();
std::shared_ptr<CMainMenu> mainmenu();
2025-02-11 15:23:33 +00:00
CPlayerInterface * interface();
void setServerInstance(std::unique_ptr<CServerHandler> ptr);
void setMapInstance(std::unique_ptr<CMapHandler> ptr);
void setInterfaceInstance(CPlayerInterface * ptr);
2025-02-27 22:18:31 +00:00
void onGlobalLobbyInterfaceActivated() final;
void onUpdate() final;
bool capturedAllEvents() final;
void onShutdownRequested(bool askForConfirmation) final;
void onAppPaused() final;
2025-02-11 15:23:33 +00:00
};
extern std::unique_ptr<GameInstance> GAME;