|
@@ -12,7 +12,6 @@
|
|
|
|
|
|
#include <vcmi/Artifact.h>
|
|
#include <vcmi/Artifact.h>
|
|
|
|
|
|
-#include "CGameInfo.h"
|
|
|
|
#include "CServerHandler.h"
|
|
#include "CServerHandler.h"
|
|
#include "HeroMovementController.h"
|
|
#include "HeroMovementController.h"
|
|
#include "PlayerLocalState.h"
|
|
#include "PlayerLocalState.h"
|
|
@@ -30,7 +29,8 @@
|
|
#include "eventsSDL/InputHandler.h"
|
|
#include "eventsSDL/InputHandler.h"
|
|
#include "eventsSDL/NotificationHandler.h"
|
|
#include "eventsSDL/NotificationHandler.h"
|
|
|
|
|
|
-#include "gui/CGuiHandler.h"
|
|
|
|
|
|
+#include "GameEngine.h"
|
|
|
|
+#include "GameInstance.h"
|
|
#include "gui/CursorHandler.h"
|
|
#include "gui/CursorHandler.h"
|
|
#include "gui/WindowHandler.h"
|
|
#include "gui/WindowHandler.h"
|
|
|
|
|
|
@@ -112,9 +112,7 @@
|
|
// They all assume that interface mutex is locked.
|
|
// They all assume that interface mutex is locked.
|
|
#define EVENT_HANDLER_CALLED_BY_CLIENT
|
|
#define EVENT_HANDLER_CALLED_BY_CLIENT
|
|
|
|
|
|
-#define BATTLE_EVENT_POSSIBLE_RETURN if (LOCPLINT != this) return; if (isAutoFightOn && !battleInt) return
|
|
|
|
-
|
|
|
|
-CPlayerInterface * LOCPLINT;
|
|
|
|
|
|
+#define BATTLE_EVENT_POSSIBLE_RETURN if (GAME->interface() != this) return; if (isAutoFightOn && !battleInt) return
|
|
|
|
|
|
std::shared_ptr<BattleInterface> CPlayerInterface::battleInt;
|
|
std::shared_ptr<BattleInterface> CPlayerInterface::battleInt;
|
|
|
|
|
|
@@ -137,7 +135,7 @@ CPlayerInterface::CPlayerInterface(PlayerColor Player):
|
|
|
|
|
|
{
|
|
{
|
|
logGlobal->trace("\tHuman player interface for player %s being constructed", Player.toString());
|
|
logGlobal->trace("\tHuman player interface for player %s being constructed", Player.toString());
|
|
- LOCPLINT = this;
|
|
|
|
|
|
+ GAME->setInterfaceInstance(this);
|
|
playerID=Player;
|
|
playerID=Player;
|
|
human=true;
|
|
human=true;
|
|
battleInt.reset();
|
|
battleInt.reset();
|
|
@@ -156,8 +154,8 @@ CPlayerInterface::~CPlayerInterface()
|
|
logGlobal->trace("\tHuman player interface for player %s being destructed", playerID.toString());
|
|
logGlobal->trace("\tHuman player interface for player %s being destructed", playerID.toString());
|
|
delete showingDialog;
|
|
delete showingDialog;
|
|
delete cingconsole;
|
|
delete cingconsole;
|
|
- if (LOCPLINT == this)
|
|
|
|
- LOCPLINT = nullptr;
|
|
|
|
|
|
+ if (GAME->interface() == this)
|
|
|
|
+ GAME->setInterfaceInstance(nullptr);
|
|
}
|
|
}
|
|
|
|
|
|
void CPlayerInterface::initGameInterface(std::shared_ptr<Environment> ENV, std::shared_ptr<CCallback> CB)
|
|
void CPlayerInterface::initGameInterface(std::shared_ptr<Environment> ENV, std::shared_ptr<CCallback> CB)
|
|
@@ -166,7 +164,7 @@ void CPlayerInterface::initGameInterface(std::shared_ptr<Environment> ENV, std::
|
|
env = ENV;
|
|
env = ENV;
|
|
|
|
|
|
pathfinderCache = std::make_unique<PathfinderCache>(cb.get(), PathfinderOptions(cb.get()));
|
|
pathfinderCache = std::make_unique<PathfinderCache>(cb.get(), PathfinderOptions(cb.get()));
|
|
- CCS->musich->loadTerrainMusicThemes();
|
|
|
|
|
|
+ ENGINE->music().loadTerrainMusicThemes();
|
|
initializeHeroTownList();
|
|
initializeHeroTownList();
|
|
|
|
|
|
adventureInt.reset(new AdventureMapInterface());
|
|
adventureInt.reset(new AdventureMapInterface());
|
|
@@ -187,10 +185,10 @@ void CPlayerInterface::closeAllDialogs()
|
|
// remove all active dialogs that do not expect query answer
|
|
// remove all active dialogs that do not expect query answer
|
|
while(true)
|
|
while(true)
|
|
{
|
|
{
|
|
- auto adventureWindow = GH.windows().topWindow<AdventureMapInterface>();
|
|
|
|
- auto settingsWindow = GH.windows().topWindow<SettingsMainWindow>();
|
|
|
|
- auto infoWindow = GH.windows().topWindow<CInfoWindow>();
|
|
|
|
- auto topWindow = GH.windows().topWindow<WindowBase>();
|
|
|
|
|
|
+ auto adventureWindow = ENGINE->windows().topWindow<AdventureMapInterface>();
|
|
|
|
+ auto settingsWindow = ENGINE->windows().topWindow<SettingsMainWindow>();
|
|
|
|
+ auto infoWindow = ENGINE->windows().topWindow<CInfoWindow>();
|
|
|
|
+ auto topWindow = ENGINE->windows().topWindow<WindowBase>();
|
|
|
|
|
|
if(adventureWindow != nullptr)
|
|
if(adventureWindow != nullptr)
|
|
break;
|
|
break;
|
|
@@ -207,7 +205,7 @@ void CPlayerInterface::closeAllDialogs()
|
|
if (topWindow)
|
|
if (topWindow)
|
|
topWindow->close();
|
|
topWindow->close();
|
|
else
|
|
else
|
|
- GH.windows().popWindows(1); // does not inherits from WindowBase, e.g. settings dialog
|
|
|
|
|
|
+ ENGINE->windows().popWindows(1); // does not inherits from WindowBase, e.g. settings dialog
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -228,15 +226,15 @@ void CPlayerInterface::playerEndsTurn(PlayerColor player)
|
|
|
|
|
|
void CPlayerInterface::playerStartsTurn(PlayerColor player)
|
|
void CPlayerInterface::playerStartsTurn(PlayerColor player)
|
|
{
|
|
{
|
|
- if(GH.windows().findWindows<AdventureMapInterface>().empty())
|
|
|
|
|
|
+ if(ENGINE->windows().findWindows<AdventureMapInterface>().empty())
|
|
{
|
|
{
|
|
// after map load - remove all active windows and replace them with adventure map
|
|
// after map load - remove all active windows and replace them with adventure map
|
|
- GH.windows().clear();
|
|
|
|
- GH.windows().pushWindow(adventureInt);
|
|
|
|
|
|
+ ENGINE->windows().clear();
|
|
|
|
+ ENGINE->windows().pushWindow(adventureInt);
|
|
}
|
|
}
|
|
|
|
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
- if (player != playerID && LOCPLINT == this)
|
|
|
|
|
|
+ if (player != playerID && GAME->interface() == this)
|
|
{
|
|
{
|
|
waitWhileDialog();
|
|
waitWhileDialog();
|
|
|
|
|
|
@@ -316,8 +314,8 @@ void CPlayerInterface::yourTurn(QueryID queryID)
|
|
|
|
|
|
bool hotseatWait = humanPlayersCount > 1;
|
|
bool hotseatWait = humanPlayersCount > 1;
|
|
|
|
|
|
- LOCPLINT = this;
|
|
|
|
- GH.curInt = this;
|
|
|
|
|
|
+ GAME->setInterfaceInstance(this);
|
|
|
|
+ ENGINE->curInt = this;
|
|
|
|
|
|
NotificationHandler::notify("Your turn");
|
|
NotificationHandler::notify("Your turn");
|
|
if(settings["general"]["startTurnAutosave"].Bool())
|
|
if(settings["general"]["startTurnAutosave"].Bool())
|
|
@@ -330,7 +328,7 @@ void CPlayerInterface::yourTurn(QueryID queryID)
|
|
adventureInt->onHotseatWaitStarted(playerID);
|
|
adventureInt->onHotseatWaitStarted(playerID);
|
|
|
|
|
|
makingTurn = true;
|
|
makingTurn = true;
|
|
- std::string msg = CGI->generaltexth->allTexts[13];
|
|
|
|
|
|
+ std::string msg = LIBRARY->generaltexth->allTexts[13];
|
|
boost::replace_first(msg, "%s", cb->getStartInfo()->playerInfos.find(playerID)->second.name);
|
|
boost::replace_first(msg, "%s", cb->getStartInfo()->playerInfos.find(playerID)->second.name);
|
|
std::vector<std::shared_ptr<CComponent>> cmp;
|
|
std::vector<std::shared_ptr<CComponent>> cmp;
|
|
cmp.push_back(std::make_shared<CComponent>(ComponentType::FLAG, playerID));
|
|
cmp.push_back(std::make_shared<CComponent>(ComponentType::FLAG, playerID));
|
|
@@ -349,7 +347,7 @@ void CPlayerInterface::acceptTurn(QueryID queryID, bool hotseatWait)
|
|
{
|
|
{
|
|
if (settings["session"]["autoSkip"].Bool())
|
|
if (settings["session"]["autoSkip"].Bool())
|
|
{
|
|
{
|
|
- while(auto iw = GH.windows().topWindow<CInfoWindow>())
|
|
|
|
|
|
+ while(auto iw = ENGINE->windows().topWindow<CInfoWindow>())
|
|
iw->close();
|
|
iw->close();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -400,7 +398,7 @@ void CPlayerInterface::heroMoved(const TryMoveHero & details, bool verbose)
|
|
{
|
|
{
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
waitWhileDialog();
|
|
waitWhileDialog();
|
|
- if(LOCPLINT != this)
|
|
|
|
|
|
+ if(GAME->interface() != this)
|
|
return;
|
|
return;
|
|
|
|
|
|
//FIXME: read once and store
|
|
//FIXME: read once and store
|
|
@@ -447,7 +445,7 @@ void CPlayerInterface::heroVisit(const CGHeroInstance * visitor, const CGObjectI
|
|
{
|
|
{
|
|
auto visitSound = visitedObj->getVisitSound(CRandomGenerator::getDefault());
|
|
auto visitSound = visitedObj->getVisitSound(CRandomGenerator::getDefault());
|
|
if (visitSound)
|
|
if (visitSound)
|
|
- CCS->soundh->playSound(visitSound.value());
|
|
|
|
|
|
+ ENGINE->sound().playSound(visitSound.value());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -457,7 +455,7 @@ void CPlayerInterface::heroCreated(const CGHeroInstance * hero)
|
|
localState->addWanderingHero(hero);
|
|
localState->addWanderingHero(hero);
|
|
adventureInt->onHeroChanged(hero);
|
|
adventureInt->onHeroChanged(hero);
|
|
if(castleInt)
|
|
if(castleInt)
|
|
- CCS->soundh->playSound(soundBase::newBuilding);
|
|
|
|
|
|
+ ENGINE->sound().playSound(soundBase::newBuilding);
|
|
}
|
|
}
|
|
void CPlayerInterface::openTownWindow(const CGTownInstance * town)
|
|
void CPlayerInterface::openTownWindow(const CGTownInstance * town)
|
|
{
|
|
{
|
|
@@ -467,7 +465,7 @@ void CPlayerInterface::openTownWindow(const CGTownInstance * town)
|
|
|
|
|
|
auto newCastleInt = std::make_shared<CCastleInterface>(town);
|
|
auto newCastleInt = std::make_shared<CCastleInterface>(town);
|
|
|
|
|
|
- GH.windows().pushWindow(newCastleInt);
|
|
|
|
|
|
+ ENGINE->windows().pushWindow(newCastleInt);
|
|
}
|
|
}
|
|
|
|
|
|
void CPlayerInterface::heroPrimarySkillChanged(const CGHeroInstance * hero, PrimarySkill which, si64 val)
|
|
void CPlayerInterface::heroPrimarySkillChanged(const CGHeroInstance * hero, PrimarySkill which, si64 val)
|
|
@@ -475,7 +473,7 @@ void CPlayerInterface::heroPrimarySkillChanged(const CGHeroInstance * hero, Prim
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
if (which == PrimarySkill::EXPERIENCE)
|
|
if (which == PrimarySkill::EXPERIENCE)
|
|
{
|
|
{
|
|
- for(auto ctw : GH.windows().findWindows<IMarketHolder>())
|
|
|
|
|
|
+ for(auto ctw : ENGINE->windows().findWindows<IMarketHolder>())
|
|
ctw->updateExperience();
|
|
ctw->updateExperience();
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -487,7 +485,7 @@ void CPlayerInterface::heroPrimarySkillChanged(const CGHeroInstance * hero, Prim
|
|
void CPlayerInterface::heroSecondarySkillChanged(const CGHeroInstance * hero, int which, int val)
|
|
void CPlayerInterface::heroSecondarySkillChanged(const CGHeroInstance * hero, int which, int val)
|
|
{
|
|
{
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
- for (auto cuw : GH.windows().findWindows<IMarketHolder>())
|
|
|
|
|
|
+ for (auto cuw : ENGINE->windows().findWindows<IMarketHolder>())
|
|
cuw->updateSecondarySkills();
|
|
cuw->updateSecondarySkills();
|
|
|
|
|
|
localState->verifyPath(hero);
|
|
localState->verifyPath(hero);
|
|
@@ -511,18 +509,18 @@ void CPlayerInterface::heroMovePointsChanged(const CGHeroInstance * hero)
|
|
void CPlayerInterface::receivedResource()
|
|
void CPlayerInterface::receivedResource()
|
|
{
|
|
{
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
- for (auto mw : GH.windows().findWindows<IMarketHolder>())
|
|
|
|
|
|
+ for (auto mw : ENGINE->windows().findWindows<IMarketHolder>())
|
|
mw->updateResources();
|
|
mw->updateResources();
|
|
|
|
|
|
- GH.windows().totalRedraw();
|
|
|
|
|
|
+ ENGINE->windows().totalRedraw();
|
|
}
|
|
}
|
|
|
|
|
|
void CPlayerInterface::heroGotLevel(const CGHeroInstance *hero, PrimarySkill pskill, std::vector<SecondarySkill>& skills, QueryID queryID)
|
|
void CPlayerInterface::heroGotLevel(const CGHeroInstance *hero, PrimarySkill pskill, std::vector<SecondarySkill>& skills, QueryID queryID)
|
|
{
|
|
{
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
waitWhileDialog();
|
|
waitWhileDialog();
|
|
- CCS->soundh->playSound(soundBase::heroNewLevel);
|
|
|
|
- GH.windows().createAndPushWindow<CLevelWindow>(hero, pskill, skills, [=](ui32 selection)
|
|
|
|
|
|
+ ENGINE->sound().playSound(soundBase::heroNewLevel);
|
|
|
|
+ ENGINE->windows().createAndPushWindow<CLevelWindow>(hero, pskill, skills, [=](ui32 selection)
|
|
{
|
|
{
|
|
cb->selectionMade(selection, queryID);
|
|
cb->selectionMade(selection, queryID);
|
|
});
|
|
});
|
|
@@ -532,8 +530,8 @@ void CPlayerInterface::commanderGotLevel (const CCommanderInstance * commander,
|
|
{
|
|
{
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
waitWhileDialog();
|
|
waitWhileDialog();
|
|
- CCS->soundh->playSound(soundBase::heroNewLevel);
|
|
|
|
- GH.windows().createAndPushWindow<CStackWindow>(commander, skills, [=](ui32 selection)
|
|
|
|
|
|
+ ENGINE->sound().playSound(soundBase::heroNewLevel);
|
|
|
|
+ ENGINE->windows().createAndPushWindow<CStackWindow>(commander, skills, [=](ui32 selection)
|
|
{
|
|
{
|
|
cb->selectionMade(selection, queryID);
|
|
cb->selectionMade(selection, queryID);
|
|
});
|
|
});
|
|
@@ -559,15 +557,15 @@ void CPlayerInterface::heroInGarrisonChange(const CGTownInstance *town)
|
|
adventureInt->onHeroChanged(nullptr);
|
|
adventureInt->onHeroChanged(nullptr);
|
|
adventureInt->onTownChanged(town);
|
|
adventureInt->onTownChanged(town);
|
|
|
|
|
|
- for (auto cgh : GH.windows().findWindows<IGarrisonHolder>())
|
|
|
|
|
|
+ for (auto cgh : ENGINE->windows().findWindows<IGarrisonHolder>())
|
|
if (cgh->holdsGarrison(town))
|
|
if (cgh->holdsGarrison(town))
|
|
cgh->updateGarrisons();
|
|
cgh->updateGarrisons();
|
|
|
|
|
|
- for (auto ki : GH.windows().findWindows<CKingdomInterface>())
|
|
|
|
|
|
+ for (auto ki : ENGINE->windows().findWindows<CKingdomInterface>())
|
|
ki->townChanged(town);
|
|
ki->townChanged(town);
|
|
|
|
|
|
// Perform totalRedraw to update hero list on adventure map, if any dialogs are open
|
|
// Perform totalRedraw to update hero list on adventure map, if any dialogs are open
|
|
- GH.windows().totalRedraw();
|
|
|
|
|
|
+ ENGINE->windows().totalRedraw();
|
|
}
|
|
}
|
|
|
|
|
|
void CPlayerInterface::heroVisitsTown(const CGHeroInstance* hero, const CGTownInstance * town)
|
|
void CPlayerInterface::heroVisitsTown(const CGHeroInstance* hero, const CGTownInstance * town)
|
|
@@ -617,11 +615,11 @@ void CPlayerInterface::garrisonsChanged(std::vector<const CArmedInstance *> objs
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- for (auto cgh : GH.windows().findWindows<IGarrisonHolder>())
|
|
|
|
|
|
+ for (auto cgh : ENGINE->windows().findWindows<IGarrisonHolder>())
|
|
if (cgh->holdsGarrisons(objs))
|
|
if (cgh->holdsGarrisons(objs))
|
|
cgh->updateGarrisons();
|
|
cgh->updateGarrisons();
|
|
|
|
|
|
- GH.windows().totalRedraw();
|
|
|
|
|
|
+ ENGINE->windows().totalRedraw();
|
|
}
|
|
}
|
|
|
|
|
|
void CPlayerInterface::buildChanged(const CGTownInstance *town, BuildingID buildingID, int what) //what: 1 - built, 2 - demolished
|
|
void CPlayerInterface::buildChanged(const CGTownInstance *town, BuildingID buildingID, int what) //what: 1 - built, 2 - demolished
|
|
@@ -647,10 +645,10 @@ void CPlayerInterface::buildChanged(const CGTownInstance *town, BuildingID build
|
|
}
|
|
}
|
|
|
|
|
|
// Perform totalRedraw in order to force redraw of updated town list icon from adventure map
|
|
// Perform totalRedraw in order to force redraw of updated town list icon from adventure map
|
|
- GH.windows().totalRedraw();
|
|
|
|
|
|
+ ENGINE->windows().totalRedraw();
|
|
}
|
|
}
|
|
|
|
|
|
- for (auto cgh : GH.windows().findWindows<ITownHolder>())
|
|
|
|
|
|
+ for (auto cgh : ENGINE->windows().findWindows<ITownHolder>())
|
|
cgh->buildChanged();
|
|
cgh->buildChanged();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -811,7 +809,7 @@ void CPlayerInterface::activeStack(const BattleID & battleID, const CStack * sta
|
|
{
|
|
{
|
|
//FIXME: we want client rendering to proceed while AI is making actions
|
|
//FIXME: we want client rendering to proceed while AI is making actions
|
|
// so unlock mutex while AI is busy since this might take quite a while, especially if hero has many spells
|
|
// so unlock mutex while AI is busy since this might take quite a while, especially if hero has many spells
|
|
- auto unlockInterface = vstd::makeUnlockGuard(GH.interfaceMutex);
|
|
|
|
|
|
+ auto unlockInterface = vstd::makeUnlockGuard(ENGINE->interfaceMutex);
|
|
autofightingAI->activeStack(battleID, stack);
|
|
autofightingAI->activeStack(battleID, stack);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -855,7 +853,7 @@ void CPlayerInterface::battleEnd(const BattleID & battleID, const BattleResult *
|
|
|
|
|
|
isAutoFightEndBattle = false;
|
|
isAutoFightEndBattle = false;
|
|
|
|
|
|
- GH.windows().pushWindow(wnd);
|
|
|
|
|
|
+ ENGINE->windows().pushWindow(wnd);
|
|
// #1490 - during AI turn when quick combat is on, we need to display the message and wait for user to close it.
|
|
// #1490 - during AI turn when quick combat is on, we need to display the message and wait for user to close it.
|
|
// Otherwise NewTurn causes freeze.
|
|
// Otherwise NewTurn causes freeze.
|
|
waitWhileDialog();
|
|
waitWhileDialog();
|
|
@@ -906,7 +904,7 @@ void CPlayerInterface::battleTriggerEffect(const BattleID & battleID, const Batt
|
|
|
|
|
|
if(bte.effect == vstd::to_underlying(BonusType::MANA_DRAIN))
|
|
if(bte.effect == vstd::to_underlying(BonusType::MANA_DRAIN))
|
|
{
|
|
{
|
|
- const CGHeroInstance * manaDrainedHero = LOCPLINT->cb->getHero(ObjectInstanceID(bte.additionalInfo));
|
|
|
|
|
|
+ const CGHeroInstance * manaDrainedHero = GAME->interface()->cb->getHero(ObjectInstanceID(bte.additionalInfo));
|
|
battleInt->windowObject->heroManaPointsChanged(manaDrainedHero);
|
|
battleInt->windowObject->heroManaPointsChanged(manaDrainedHero);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1007,12 +1005,12 @@ void CPlayerInterface::showInfoDialog(EInfoWindowMode type, const std::string &t
|
|
// abort movement, if any. Strictly speaking unnecessary, but prevents some edge cases, like movement sound on visiting Magi Hut with "show messages in status window" on
|
|
// abort movement, if any. Strictly speaking unnecessary, but prevents some edge cases, like movement sound on visiting Magi Hut with "show messages in status window" on
|
|
movementController->requestMovementAbort();
|
|
movementController->requestMovementAbort();
|
|
|
|
|
|
- if (makingTurn && GH.windows().count() > 0 && LOCPLINT == this)
|
|
|
|
- CCS->soundh->playSound(static_cast<soundBase::soundID>(soundID));
|
|
|
|
|
|
+ if (makingTurn && ENGINE->windows().count() > 0 && GAME->interface() == this)
|
|
|
|
+ ENGINE->sound().playSound(static_cast<soundBase::soundID>(soundID));
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- if (settings["session"]["autoSkip"].Bool() && !GH.isKeyboardShiftDown())
|
|
|
|
|
|
+ if (settings["session"]["autoSkip"].Bool() && !ENGINE->isKeyboardShiftDown())
|
|
{
|
|
{
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -1039,21 +1037,21 @@ void CPlayerInterface::showInfoDialog(const std::string & text, std::shared_ptr<
|
|
|
|
|
|
void CPlayerInterface::showInfoDialog(const std::string &text, const std::vector<std::shared_ptr<CComponent>> & components, int soundID)
|
|
void CPlayerInterface::showInfoDialog(const std::string &text, const std::vector<std::shared_ptr<CComponent>> & components, int soundID)
|
|
{
|
|
{
|
|
- LOG_TRACE_PARAMS(logGlobal, "player=%s, text=%s, is LOCPLINT=%d", playerID % text % (this==LOCPLINT));
|
|
|
|
|
|
+ LOG_TRACE_PARAMS(logGlobal, "player=%s, text=%s, is GAME->interface()=%d", playerID % text % (this==GAME->interface()));
|
|
waitWhileDialog();
|
|
waitWhileDialog();
|
|
|
|
|
|
- if (settings["session"]["autoSkip"].Bool() && !GH.isKeyboardShiftDown())
|
|
|
|
|
|
+ if (settings["session"]["autoSkip"].Bool() && !ENGINE->isKeyboardShiftDown())
|
|
{
|
|
{
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
std::shared_ptr<CInfoWindow> temp = CInfoWindow::create(text, playerID, components);
|
|
std::shared_ptr<CInfoWindow> temp = CInfoWindow::create(text, playerID, components);
|
|
|
|
|
|
- if ((makingTurn || (battleInt && battleInt->curInt && battleInt->curInt.get() == this)) && GH.windows().count() > 0 && LOCPLINT == this)
|
|
|
|
|
|
+ if ((makingTurn || (battleInt && battleInt->curInt && battleInt->curInt.get() == this)) && ENGINE->windows().count() > 0 && GAME->interface() == this)
|
|
{
|
|
{
|
|
- CCS->soundh->playSound(static_cast<soundBase::soundID>(soundID));
|
|
|
|
|
|
+ ENGINE->sound().playSound(static_cast<soundBase::soundID>(soundID));
|
|
showingDialog->setBusy();
|
|
showingDialog->setBusy();
|
|
movementController->requestMovementAbort(); // interrupt movement to show dialog
|
|
movementController->requestMovementAbort(); // interrupt movement to show dialog
|
|
- GH.windows().pushWindow(temp);
|
|
|
|
|
|
+ ENGINE->windows().pushWindow(temp);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -1074,7 +1072,7 @@ void CPlayerInterface::showInfoDialogAndWait(std::vector<Component> & components
|
|
void CPlayerInterface::showYesNoDialog(const std::string &text, CFunctionList<void()> onYes, CFunctionList<void()> onNo, const std::vector<std::shared_ptr<CComponent>> & components)
|
|
void CPlayerInterface::showYesNoDialog(const std::string &text, CFunctionList<void()> onYes, CFunctionList<void()> onNo, const std::vector<std::shared_ptr<CComponent>> & components)
|
|
{
|
|
{
|
|
movementController->requestMovementAbort();
|
|
movementController->requestMovementAbort();
|
|
- LOCPLINT->showingDialog->setBusy();
|
|
|
|
|
|
+ GAME->interface()->showingDialog->setBusy();
|
|
CInfoWindow::showYesNoDialog(text, components, onYes, onNo, playerID);
|
|
CInfoWindow::showYesNoDialog(text, components, onYes, onNo, playerID);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1084,7 +1082,7 @@ void CPlayerInterface::showBlockingDialog(const std::string &text, const std::ve
|
|
waitWhileDialog();
|
|
waitWhileDialog();
|
|
|
|
|
|
movementController->requestMovementAbort();
|
|
movementController->requestMovementAbort();
|
|
- CCS->soundh->playSound(static_cast<soundBase::soundID>(soundID));
|
|
|
|
|
|
+ ENGINE->sound().playSound(static_cast<soundBase::soundID>(soundID));
|
|
|
|
|
|
if (!selection && cancel) //simple yes/no dialog
|
|
if (!selection && cancel) //simple yes/no dialog
|
|
{
|
|
{
|
|
@@ -1116,9 +1114,9 @@ void CPlayerInterface::showBlockingDialog(const std::string &text, const std::ve
|
|
int charperline = 35;
|
|
int charperline = 35;
|
|
if (pom.size() > 1)
|
|
if (pom.size() > 1)
|
|
charperline = 50;
|
|
charperline = 50;
|
|
- GH.windows().createAndPushWindow<CSelWindow>(text, playerID, charperline, intComps, pom, askID);
|
|
|
|
- intComps[0]->clickPressed(GH.getCursorPosition());
|
|
|
|
- intComps[0]->clickReleased(GH.getCursorPosition());
|
|
|
|
|
|
+ ENGINE->windows().createAndPushWindow<CSelWindow>(text, playerID, charperline, intComps, pom, askID);
|
|
|
|
+ intComps[0]->clickPressed(ENGINE->getCursorPosition());
|
|
|
|
+ intComps[0]->clickReleased(ENGINE->getCursorPosition());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1179,7 +1177,7 @@ void CPlayerInterface::showMapObjectSelectDialog(QueryID askID, const Component
|
|
const CGTownInstance * t = dynamic_cast<const CGTownInstance *>(cb->getObj(obj));
|
|
const CGTownInstance * t = dynamic_cast<const CGTownInstance *>(cb->getObj(obj));
|
|
if(t)
|
|
if(t)
|
|
{
|
|
{
|
|
- auto image = GH.renderHandler().loadImage(AnimationPath::builtin("ITPA"), t->getTown()->clientInfo.icons[t->hasFort()][false] + 2, 0, EImageBlitMode::OPAQUE);
|
|
|
|
|
|
+ auto image = ENGINE->renderHandler().loadImage(AnimationPath::builtin("ITPA"), t->getTown()->clientInfo.icons[t->hasFort()][false] + 2, 0, EImageBlitMode::OPAQUE);
|
|
image->scaleTo(Point(35, 23), EScalingAlgorithm::NEAREST);
|
|
image->scaleTo(Point(35, 23), EScalingAlgorithm::NEAREST);
|
|
images.push_back(image);
|
|
images.push_back(image);
|
|
}
|
|
}
|
|
@@ -1187,9 +1185,9 @@ void CPlayerInterface::showMapObjectSelectDialog(QueryID askID, const Component
|
|
|
|
|
|
auto wnd = std::make_shared<CObjectListWindow>(tempList, localIcon, localTitle, localDescription, selectCallback, 0, images);
|
|
auto wnd = std::make_shared<CObjectListWindow>(tempList, localIcon, localTitle, localDescription, selectCallback, 0, images);
|
|
wnd->onExit = cancelCallback;
|
|
wnd->onExit = cancelCallback;
|
|
- wnd->onPopup = [this, objectGuiOrdered](int index) { CRClickPopup::createAndPush(cb->getObj(objectGuiOrdered[index]), GH.getCursorPosition()); };
|
|
|
|
- wnd->onClicked = [this, objectGuiOrdered](int index) { adventureInt->centerOnObject(cb->getObj(objectGuiOrdered[index])); GH.windows().totalRedraw(); };
|
|
|
|
- GH.windows().pushWindow(wnd);
|
|
|
|
|
|
+ wnd->onPopup = [this, objectGuiOrdered](int index) { CRClickPopup::createAndPush(cb->getObj(objectGuiOrdered[index]), ENGINE->getCursorPosition()); };
|
|
|
|
+ wnd->onClicked = [this, objectGuiOrdered](int index) { adventureInt->centerOnObject(cb->getObj(objectGuiOrdered[index])); ENGINE->windows().totalRedraw(); };
|
|
|
|
+ ENGINE->windows().pushWindow(wnd);
|
|
}
|
|
}
|
|
|
|
|
|
void CPlayerInterface::tileRevealed(const std::unordered_set<int3> &pos)
|
|
void CPlayerInterface::tileRevealed(const std::unordered_set<int3> &pos)
|
|
@@ -1207,7 +1205,7 @@ void CPlayerInterface::tileHidden(const std::unordered_set<int3> &pos)
|
|
|
|
|
|
void CPlayerInterface::openHeroWindow(const CGHeroInstance *hero)
|
|
void CPlayerInterface::openHeroWindow(const CGHeroInstance *hero)
|
|
{
|
|
{
|
|
- GH.windows().createAndPushWindow<CHeroWindow>(hero);
|
|
|
|
|
|
+ ENGINE->windows().createAndPushWindow<CHeroWindow>(hero);
|
|
}
|
|
}
|
|
|
|
|
|
void CPlayerInterface::availableCreaturesChanged( const CGDwelling *town )
|
|
void CPlayerInterface::availableCreaturesChanged( const CGDwelling *town )
|
|
@@ -1215,21 +1213,21 @@ void CPlayerInterface::availableCreaturesChanged( const CGDwelling *town )
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
if (const CGTownInstance * townObj = dynamic_cast<const CGTownInstance*>(town))
|
|
if (const CGTownInstance * townObj = dynamic_cast<const CGTownInstance*>(town))
|
|
{
|
|
{
|
|
- for (auto fortScreen : GH.windows().findWindows<CFortScreen>())
|
|
|
|
|
|
+ for (auto fortScreen : ENGINE->windows().findWindows<CFortScreen>())
|
|
fortScreen->creaturesChangedEventHandler();
|
|
fortScreen->creaturesChangedEventHandler();
|
|
|
|
|
|
- for (auto castleInterface : GH.windows().findWindows<CCastleInterface>())
|
|
|
|
|
|
+ for (auto castleInterface : ENGINE->windows().findWindows<CCastleInterface>())
|
|
if(castleInterface->town == town)
|
|
if(castleInterface->town == town)
|
|
castleInterface->creaturesChangedEventHandler();
|
|
castleInterface->creaturesChangedEventHandler();
|
|
|
|
|
|
if (townObj)
|
|
if (townObj)
|
|
- for (auto ki : GH.windows().findWindows<CKingdomInterface>())
|
|
|
|
|
|
+ for (auto ki : ENGINE->windows().findWindows<CKingdomInterface>())
|
|
ki->townChanged(townObj);
|
|
ki->townChanged(townObj);
|
|
}
|
|
}
|
|
- else if(town && GH.windows().count() > 0 && (town->ID == Obj::CREATURE_GENERATOR1
|
|
|
|
|
|
+ else if(town && ENGINE->windows().count() > 0 && (town->ID == Obj::CREATURE_GENERATOR1
|
|
|| town->ID == Obj::CREATURE_GENERATOR4 || town->ID == Obj::WAR_MACHINE_FACTORY))
|
|
|| town->ID == Obj::CREATURE_GENERATOR4 || town->ID == Obj::WAR_MACHINE_FACTORY))
|
|
{
|
|
{
|
|
- for (auto crw : GH.windows().findWindows<CRecruitmentWindow>())
|
|
|
|
|
|
+ for (auto crw : ENGINE->windows().findWindows<CRecruitmentWindow>())
|
|
if (crw->dwelling == town)
|
|
if (crw->dwelling == town)
|
|
crw->availableCreaturesChanged();
|
|
crw->availableCreaturesChanged();
|
|
}
|
|
}
|
|
@@ -1252,7 +1250,7 @@ void CPlayerInterface::heroBonusChanged( const CGHeroInstance *hero, const Bonus
|
|
void CPlayerInterface::moveHero( const CGHeroInstance *h, const CGPath& path )
|
|
void CPlayerInterface::moveHero( const CGHeroInstance *h, const CGPath& path )
|
|
{
|
|
{
|
|
LOG_TRACE(logGlobal);
|
|
LOG_TRACE(logGlobal);
|
|
- if (!LOCPLINT->makingTurn)
|
|
|
|
|
|
+ if (!GAME->interface()->makingTurn)
|
|
return;
|
|
return;
|
|
|
|
|
|
assert(h);
|
|
assert(h);
|
|
@@ -1287,7 +1285,7 @@ void CPlayerInterface::showGarrisonDialog( const CArmedInstance *up, const CGHer
|
|
|
|
|
|
auto cgw = std::make_shared<CGarrisonWindow>(up, down, removableUnits);
|
|
auto cgw = std::make_shared<CGarrisonWindow>(up, down, removableUnits);
|
|
cgw->quit->addCallback(onEnd);
|
|
cgw->quit->addCallback(onEnd);
|
|
- GH.windows().pushWindow(cgw);
|
|
|
|
|
|
+ ENGINE->windows().pushWindow(cgw);
|
|
}
|
|
}
|
|
|
|
|
|
void CPlayerInterface::requestRealized( PackageApplied *pa )
|
|
void CPlayerInterface::requestRealized( PackageApplied *pa )
|
|
@@ -1307,7 +1305,7 @@ void CPlayerInterface::showHeroExchange(ObjectInstanceID hero1, ObjectInstanceID
|
|
void CPlayerInterface::heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID hero2, QueryID query)
|
|
void CPlayerInterface::heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID hero2, QueryID query)
|
|
{
|
|
{
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
- GH.windows().createAndPushWindow<CExchangeWindow>(hero1, hero2, query);
|
|
|
|
|
|
+ ENGINE->windows().createAndPushWindow<CExchangeWindow>(hero1, hero2, query);
|
|
}
|
|
}
|
|
|
|
|
|
void CPlayerInterface::beforeObjectPropertyChanged(const SetObjectProperty * sop)
|
|
void CPlayerInterface::beforeObjectPropertyChanged(const SetObjectProperty * sop)
|
|
@@ -1392,18 +1390,18 @@ void CPlayerInterface::showRecruitmentDialog(const CGDwelling *dwelling, const C
|
|
{
|
|
{
|
|
cb->selectionMade(0, queryID);
|
|
cb->selectionMade(0, queryID);
|
|
};
|
|
};
|
|
- GH.windows().createAndPushWindow<CRecruitmentWindow>(dwelling, level, dst, recruitCb, closeCb);
|
|
|
|
|
|
+ ENGINE->windows().createAndPushWindow<CRecruitmentWindow>(dwelling, level, dst, recruitCb, closeCb);
|
|
}
|
|
}
|
|
|
|
|
|
void CPlayerInterface::waitWhileDialog()
|
|
void CPlayerInterface::waitWhileDialog()
|
|
{
|
|
{
|
|
- if (GH.amIGuiThread())
|
|
|
|
|
|
+ if (ENGINE->amIGuiThread())
|
|
{
|
|
{
|
|
logGlobal->warn("Cannot wait for dialogs in gui thread (deadlock risk)!");
|
|
logGlobal->warn("Cannot wait for dialogs in gui thread (deadlock risk)!");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- auto unlockInterface = vstd::makeUnlockGuard(GH.interfaceMutex);
|
|
|
|
|
|
+ auto unlockInterface = vstd::makeUnlockGuard(ENGINE->interfaceMutex);
|
|
showingDialog->waitWhileBusy();
|
|
showingDialog->waitWhileBusy();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1413,7 +1411,7 @@ void CPlayerInterface::showShipyardDialog(const IShipyard *obj)
|
|
auto state = obj->shipyardStatus();
|
|
auto state = obj->shipyardStatus();
|
|
TResources cost;
|
|
TResources cost;
|
|
obj->getBoatCost(cost);
|
|
obj->getBoatCost(cost);
|
|
- GH.windows().createAndPushWindow<CShipyardWindow>(cost, state, obj->getBoatType(), [=](){ cb->buildBoat(obj); });
|
|
|
|
|
|
+ ENGINE->windows().createAndPushWindow<CShipyardWindow>(cost, state, obj->getBoatType(), [=](){ cb->buildBoat(obj); });
|
|
}
|
|
}
|
|
|
|
|
|
void CPlayerInterface::newObject( const CGObjectInstance * obj )
|
|
void CPlayerInterface::newObject( const CGObjectInstance * obj )
|
|
@@ -1421,10 +1419,10 @@ void CPlayerInterface::newObject( const CGObjectInstance * obj )
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
//we might have built a boat in shipyard in opened town screen
|
|
//we might have built a boat in shipyard in opened town screen
|
|
if (obj->ID == Obj::BOAT
|
|
if (obj->ID == Obj::BOAT
|
|
- && LOCPLINT->castleInt
|
|
|
|
- && obj->visitablePos() == LOCPLINT->castleInt->town->bestLocation())
|
|
|
|
|
|
+ && GAME->interface()->castleInt
|
|
|
|
+ && obj->visitablePos() == GAME->interface()->castleInt->town->bestLocation())
|
|
{
|
|
{
|
|
- LOCPLINT->castleInt->addBuilding(BuildingID::SHIP);
|
|
|
|
|
|
+ GAME->interface()->castleInt->addBuilding(BuildingID::SHIP);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1432,18 +1430,18 @@ void CPlayerInterface::centerView (int3 pos, int focusTime)
|
|
{
|
|
{
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
waitWhileDialog();
|
|
waitWhileDialog();
|
|
- CCS->curh->hide();
|
|
|
|
|
|
+ ENGINE->cursor().hide();
|
|
adventureInt->centerOnTile(pos);
|
|
adventureInt->centerOnTile(pos);
|
|
if (focusTime)
|
|
if (focusTime)
|
|
{
|
|
{
|
|
- GH.windows().totalRedraw();
|
|
|
|
|
|
+ ENGINE->windows().totalRedraw();
|
|
{
|
|
{
|
|
IgnoreEvents ignore(*this);
|
|
IgnoreEvents ignore(*this);
|
|
- auto unlockInterface = vstd::makeUnlockGuard(GH.interfaceMutex);
|
|
|
|
|
|
+ auto unlockInterface = vstd::makeUnlockGuard(ENGINE->interfaceMutex);
|
|
boost::this_thread::sleep_for(boost::chrono::milliseconds(focusTime));
|
|
boost::this_thread::sleep_for(boost::chrono::milliseconds(focusTime));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- CCS->curh->show();
|
|
|
|
|
|
+ ENGINE->cursor().show();
|
|
}
|
|
}
|
|
|
|
|
|
void CPlayerInterface::objectRemoved(const CGObjectInstance * obj, const PlayerColor & initiator)
|
|
void CPlayerInterface::objectRemoved(const CGObjectInstance * obj, const PlayerColor & initiator)
|
|
@@ -1455,10 +1453,10 @@ void CPlayerInterface::objectRemoved(const CGObjectInstance * obj, const PlayerC
|
|
if (removalSound)
|
|
if (removalSound)
|
|
{
|
|
{
|
|
waitWhileDialog();
|
|
waitWhileDialog();
|
|
- CCS->soundh->playSound(removalSound.value());
|
|
|
|
|
|
+ ENGINE->sound().playSound(removalSound.value());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- CGI->mh->waitForOngoingAnimations();
|
|
|
|
|
|
+ GAME->map().waitForOngoingAnimations();
|
|
|
|
|
|
if(obj->ID == Obj::HERO && obj->tempOwner == playerID)
|
|
if(obj->ID == Obj::HERO && obj->tempOwner == playerID)
|
|
{
|
|
{
|
|
@@ -1471,7 +1469,7 @@ void CPlayerInterface::objectRemoved(const CGObjectInstance * obj, const PlayerC
|
|
const CGTownInstance * t = static_cast<const CGTownInstance *>(obj);
|
|
const CGTownInstance * t = static_cast<const CGTownInstance *>(obj);
|
|
townRemoved(t);
|
|
townRemoved(t);
|
|
}
|
|
}
|
|
- GH.fakeMouseMove();
|
|
|
|
|
|
+ ENGINE->fakeMouseMove();
|
|
}
|
|
}
|
|
|
|
|
|
void CPlayerInterface::objectRemovedAfter()
|
|
void CPlayerInterface::objectRemovedAfter()
|
|
@@ -1483,7 +1481,7 @@ void CPlayerInterface::objectRemovedAfter()
|
|
if (castleInt)
|
|
if (castleInt)
|
|
castleInt->updateGarrisons();
|
|
castleInt->updateGarrisons();
|
|
|
|
|
|
- for (auto ki : GH.windows().findWindows<CKingdomInterface>())
|
|
|
|
|
|
+ for (auto ki : ENGINE->windows().findWindows<CKingdomInterface>())
|
|
ki->heroRemoved();
|
|
ki->heroRemoved();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1491,13 +1489,13 @@ void CPlayerInterface::playerBlocked(int reason, bool start)
|
|
{
|
|
{
|
|
if(reason == PlayerBlocked::EReason::UPCOMING_BATTLE)
|
|
if(reason == PlayerBlocked::EReason::UPCOMING_BATTLE)
|
|
{
|
|
{
|
|
- if(CSH->howManyPlayerInterfaces() > 1 && LOCPLINT != this && LOCPLINT->makingTurn == false)
|
|
|
|
|
|
+ if(GAME->server().howManyPlayerInterfaces() > 1 && GAME->interface() != this && GAME->interface()->makingTurn == false)
|
|
{
|
|
{
|
|
//one of our players who isn't last in order got attacked not by our another player (happens for example in hotseat mode)
|
|
//one of our players who isn't last in order got attacked not by our another player (happens for example in hotseat mode)
|
|
- LOCPLINT = this;
|
|
|
|
- GH.curInt = this;
|
|
|
|
|
|
+ GAME->setInterfaceInstance(this);
|
|
|
|
+ ENGINE->curInt = this;
|
|
adventureInt->onCurrentPlayerChanged(playerID);
|
|
adventureInt->onCurrentPlayerChanged(playerID);
|
|
- std::string msg = CGI->generaltexth->translate("vcmi.adventureMap.playerAttacked");
|
|
|
|
|
|
+ std::string msg = LIBRARY->generaltexth->translate("vcmi.adventureMap.playerAttacked");
|
|
boost::replace_first(msg, "%s", cb->getStartInfo()->playerInfos.find(playerID)->second.name);
|
|
boost::replace_first(msg, "%s", cb->getStartInfo()->playerInfos.find(playerID)->second.name);
|
|
std::vector<std::shared_ptr<CComponent>> cmp;
|
|
std::vector<std::shared_ptr<CComponent>> cmp;
|
|
cmp.push_back(std::make_shared<CComponent>(ComponentType::FLAG, playerID));
|
|
cmp.push_back(std::make_shared<CComponent>(ComponentType::FLAG, playerID));
|
|
@@ -1515,22 +1513,22 @@ void CPlayerInterface::update()
|
|
boost::shared_lock gsLock(CGameState::mutex);
|
|
boost::shared_lock gsLock(CGameState::mutex);
|
|
|
|
|
|
// While mutexes were locked away we may be have stopped being the active interface
|
|
// While mutexes were locked away we may be have stopped being the active interface
|
|
- if (LOCPLINT != this)
|
|
|
|
|
|
+ if (GAME->interface() != this)
|
|
return;
|
|
return;
|
|
|
|
|
|
//if there are any waiting dialogs, show them
|
|
//if there are any waiting dialogs, show them
|
|
if (makingTurn && !dialogs.empty() && !showingDialog->isBusy())
|
|
if (makingTurn && !dialogs.empty() && !showingDialog->isBusy())
|
|
{
|
|
{
|
|
showingDialog->setBusy();
|
|
showingDialog->setBusy();
|
|
- GH.windows().pushWindow(dialogs.front());
|
|
|
|
|
|
+ ENGINE->windows().pushWindow(dialogs.front());
|
|
dialogs.pop_front();
|
|
dialogs.pop_front();
|
|
}
|
|
}
|
|
|
|
|
|
assert(adventureInt);
|
|
assert(adventureInt);
|
|
|
|
|
|
// Handles mouse and key input
|
|
// Handles mouse and key input
|
|
- GH.handleEvents();
|
|
|
|
- GH.windows().simpleRedraw();
|
|
|
|
|
|
+ ENGINE->handleEvents();
|
|
|
|
+ ENGINE->windows().simpleRedraw();
|
|
}
|
|
}
|
|
|
|
|
|
void CPlayerInterface::endNetwork()
|
|
void CPlayerInterface::endNetwork()
|
|
@@ -1576,13 +1574,13 @@ void CPlayerInterface::gameOver(PlayerColor player, const EVictoryLossCheckResul
|
|
if (player == playerID)
|
|
if (player == playerID)
|
|
{
|
|
{
|
|
if (victoryLossCheckResult.loss())
|
|
if (victoryLossCheckResult.loss())
|
|
- showInfoDialog(CGI->generaltexth->allTexts[95]);
|
|
|
|
|
|
+ showInfoDialog(LIBRARY->generaltexth->allTexts[95]);
|
|
|
|
|
|
- assert(GH.curInt == LOCPLINT);
|
|
|
|
- auto previousInterface = LOCPLINT; //without multiple player interfaces some of lines below are useless, but for hotseat we wanna swap player interface temporarily
|
|
|
|
|
|
+ assert(ENGINE->curInt == GAME->interface());
|
|
|
|
+ auto previousInterface = GAME->interface(); //without multiple player interfaces some of lines below are useless, but for hotseat we wanna swap player interface temporarily
|
|
|
|
|
|
- LOCPLINT = this; //this is needed for dialog to show and avoid freeze, dialog showing logic should be reworked someday
|
|
|
|
- GH.curInt = this; //waiting for dialogs requires this to get events
|
|
|
|
|
|
+ GAME->setInterfaceInstance(this); //this is needed for dialog to show and avoid freeze, dialog showing logic should be reworked someday
|
|
|
|
+ ENGINE->curInt = this; //waiting for dialogs requires this to get events
|
|
|
|
|
|
if(!makingTurn)
|
|
if(!makingTurn)
|
|
{
|
|
{
|
|
@@ -1593,8 +1591,8 @@ void CPlayerInterface::gameOver(PlayerColor player, const EVictoryLossCheckResul
|
|
else
|
|
else
|
|
waitForAllDialogs();
|
|
waitForAllDialogs();
|
|
|
|
|
|
- GH.curInt = previousInterface;
|
|
|
|
- LOCPLINT = previousInterface;
|
|
|
|
|
|
+ ENGINE->curInt = previousInterface;
|
|
|
|
+ GAME->setInterfaceInstance(previousInterface);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1612,7 +1610,7 @@ void CPlayerInterface::showPuzzleMap()
|
|
double ratio = 0;
|
|
double ratio = 0;
|
|
int3 grailPos = cb->getGrailPos(&ratio);
|
|
int3 grailPos = cb->getGrailPos(&ratio);
|
|
|
|
|
|
- GH.windows().createAndPushWindow<CPuzzleWindow>(grailPos, ratio);
|
|
|
|
|
|
+ ENGINE->windows().createAndPushWindow<CPuzzleWindow>(grailPos, ratio);
|
|
}
|
|
}
|
|
|
|
|
|
void CPlayerInterface::viewWorldMap()
|
|
void CPlayerInterface::viewWorldMap()
|
|
@@ -1624,15 +1622,15 @@ void CPlayerInterface::advmapSpellCast(const CGHeroInstance * caster, SpellID sp
|
|
{
|
|
{
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
|
|
|
|
- if(GH.windows().topWindow<CSpellWindow>())
|
|
|
|
- GH.windows().popWindows(1);
|
|
|
|
|
|
+ if(ENGINE->windows().topWindow<CSpellWindow>())
|
|
|
|
+ ENGINE->windows().popWindows(1);
|
|
|
|
|
|
if(spellID == SpellID::FLY || spellID == SpellID::WATER_WALK)
|
|
if(spellID == SpellID::FLY || spellID == SpellID::WATER_WALK)
|
|
localState->erasePath(caster);
|
|
localState->erasePath(caster);
|
|
|
|
|
|
auto castSoundPath = spellID.toSpell()->getCastSound();
|
|
auto castSoundPath = spellID.toSpell()->getCastSound();
|
|
if(!castSoundPath.empty())
|
|
if(!castSoundPath.empty())
|
|
- CCS->soundh->playSound(castSoundPath);
|
|
|
|
|
|
+ ENGINE->sound().playSound(castSoundPath);
|
|
}
|
|
}
|
|
|
|
|
|
void CPlayerInterface::tryDigging(const CGHeroInstance * h)
|
|
void CPlayerInterface::tryDigging(const CGHeroInstance * h)
|
|
@@ -1664,7 +1662,7 @@ void CPlayerInterface::tryDigging(const CGHeroInstance * h)
|
|
if(msgToShow < 0)
|
|
if(msgToShow < 0)
|
|
cb->dig(h);
|
|
cb->dig(h);
|
|
else
|
|
else
|
|
- showInfoDialog(CGI->generaltexth->allTexts[msgToShow]);
|
|
|
|
|
|
+ showInfoDialog(LIBRARY->generaltexth->allTexts[msgToShow]);
|
|
}
|
|
}
|
|
|
|
|
|
void CPlayerInterface::battleNewRoundFirst(const BattleID & battleID)
|
|
void CPlayerInterface::battleNewRoundFirst(const BattleID & battleID)
|
|
@@ -1683,17 +1681,17 @@ void CPlayerInterface::showMarketWindow(const IMarket * market, const CGHeroInst
|
|
};
|
|
};
|
|
|
|
|
|
if(market->allowsTrade(EMarketMode::ARTIFACT_EXP) && visitor->getAlignment() != EAlignment::EVIL)
|
|
if(market->allowsTrade(EMarketMode::ARTIFACT_EXP) && visitor->getAlignment() != EAlignment::EVIL)
|
|
- GH.windows().createAndPushWindow<CMarketWindow>(market, visitor, onWindowClosed, EMarketMode::ARTIFACT_EXP);
|
|
|
|
|
|
+ ENGINE->windows().createAndPushWindow<CMarketWindow>(market, visitor, onWindowClosed, EMarketMode::ARTIFACT_EXP);
|
|
else if(market->allowsTrade(EMarketMode::CREATURE_EXP) && visitor->getAlignment() != EAlignment::GOOD)
|
|
else if(market->allowsTrade(EMarketMode::CREATURE_EXP) && visitor->getAlignment() != EAlignment::GOOD)
|
|
- GH.windows().createAndPushWindow<CMarketWindow>(market, visitor, onWindowClosed, EMarketMode::CREATURE_EXP);
|
|
|
|
|
|
+ ENGINE->windows().createAndPushWindow<CMarketWindow>(market, visitor, onWindowClosed, EMarketMode::CREATURE_EXP);
|
|
else if(market->allowsTrade(EMarketMode::CREATURE_UNDEAD))
|
|
else if(market->allowsTrade(EMarketMode::CREATURE_UNDEAD))
|
|
- GH.windows().createAndPushWindow<CTransformerWindow>(market, visitor, onWindowClosed);
|
|
|
|
|
|
+ ENGINE->windows().createAndPushWindow<CTransformerWindow>(market, visitor, onWindowClosed);
|
|
else if (!market->availableModes().empty())
|
|
else if (!market->availableModes().empty())
|
|
for(auto mode = EMarketMode::RESOURCE_RESOURCE; mode != EMarketMode::MARKET_AFTER_LAST_PLACEHOLDER; mode = vstd::next(mode, 1))
|
|
for(auto mode = EMarketMode::RESOURCE_RESOURCE; mode != EMarketMode::MARKET_AFTER_LAST_PLACEHOLDER; mode = vstd::next(mode, 1))
|
|
{
|
|
{
|
|
if(vstd::contains(market->availableModes(), mode))
|
|
if(vstd::contains(market->availableModes(), mode))
|
|
{
|
|
{
|
|
- GH.windows().createAndPushWindow<CMarketWindow>(market, visitor, onWindowClosed, mode);
|
|
|
|
|
|
+ ENGINE->windows().createAndPushWindow<CMarketWindow>(market, visitor, onWindowClosed, mode);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1707,19 +1705,19 @@ void CPlayerInterface::showUniversityWindow(const IMarket *market, const CGHeroI
|
|
auto onWindowClosed = [this, queryID](){
|
|
auto onWindowClosed = [this, queryID](){
|
|
cb->selectionMade(0, queryID);
|
|
cb->selectionMade(0, queryID);
|
|
};
|
|
};
|
|
- GH.windows().createAndPushWindow<CUniversityWindow>(visitor, BuildingID::NONE, market, onWindowClosed);
|
|
|
|
|
|
+ ENGINE->windows().createAndPushWindow<CUniversityWindow>(visitor, BuildingID::NONE, market, onWindowClosed);
|
|
}
|
|
}
|
|
|
|
|
|
void CPlayerInterface::showHillFortWindow(const CGObjectInstance *object, const CGHeroInstance *visitor)
|
|
void CPlayerInterface::showHillFortWindow(const CGObjectInstance *object, const CGHeroInstance *visitor)
|
|
{
|
|
{
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
- GH.windows().createAndPushWindow<CHillFortWindow>(visitor, object);
|
|
|
|
|
|
+ ENGINE->windows().createAndPushWindow<CHillFortWindow>(visitor, object);
|
|
}
|
|
}
|
|
|
|
|
|
void CPlayerInterface::availableArtifactsChanged(const CGBlackMarket * bm)
|
|
void CPlayerInterface::availableArtifactsChanged(const CGBlackMarket * bm)
|
|
{
|
|
{
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
- for (auto cmw : GH.windows().findWindows<IMarketHolder>())
|
|
|
|
|
|
+ for (auto cmw : ENGINE->windows().findWindows<IMarketHolder>())
|
|
cmw->updateArtifacts();
|
|
cmw->updateArtifacts();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1730,19 +1728,19 @@ void CPlayerInterface::showTavernWindow(const CGObjectInstance * object, const C
|
|
if (queryID != QueryID::NONE)
|
|
if (queryID != QueryID::NONE)
|
|
cb->selectionMade(0, queryID);
|
|
cb->selectionMade(0, queryID);
|
|
};
|
|
};
|
|
- GH.windows().createAndPushWindow<CTavernWindow>(object, onWindowClosed);
|
|
|
|
|
|
+ ENGINE->windows().createAndPushWindow<CTavernWindow>(object, onWindowClosed);
|
|
}
|
|
}
|
|
|
|
|
|
void CPlayerInterface::showThievesGuildWindow (const CGObjectInstance * obj)
|
|
void CPlayerInterface::showThievesGuildWindow (const CGObjectInstance * obj)
|
|
{
|
|
{
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
- GH.windows().createAndPushWindow<CThievesGuildWindow>(obj);
|
|
|
|
|
|
+ ENGINE->windows().createAndPushWindow<CThievesGuildWindow>(obj);
|
|
}
|
|
}
|
|
|
|
|
|
void CPlayerInterface::showQuestLog()
|
|
void CPlayerInterface::showQuestLog()
|
|
{
|
|
{
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
EVENT_HANDLER_CALLED_BY_CLIENT;
|
|
- GH.windows().createAndPushWindow<CQuestLog>(LOCPLINT->cb->getMyQuests());
|
|
|
|
|
|
+ ENGINE->windows().createAndPushWindow<CQuestLog>(GAME->interface()->cb->getMyQuests());
|
|
}
|
|
}
|
|
|
|
|
|
void CPlayerInterface::showShipyardDialogOrProblemPopup(const IShipyard *obj)
|
|
void CPlayerInterface::showShipyardDialogOrProblemPopup(const IShipyard *obj)
|
|
@@ -1808,7 +1806,7 @@ void CPlayerInterface::waitForAllDialogs()
|
|
|
|
|
|
while(!dialogs.empty())
|
|
while(!dialogs.empty())
|
|
{
|
|
{
|
|
- auto unlockInterface = vstd::makeUnlockGuard(GH.interfaceMutex);
|
|
|
|
|
|
+ auto unlockInterface = vstd::makeUnlockGuard(ENGINE->interfaceMutex);
|
|
boost::this_thread::sleep_for(boost::chrono::milliseconds(5));
|
|
boost::this_thread::sleep_for(boost::chrono::milliseconds(5));
|
|
}
|
|
}
|
|
waitWhileDialog();
|
|
waitWhileDialog();
|
|
@@ -1817,10 +1815,10 @@ void CPlayerInterface::waitForAllDialogs()
|
|
void CPlayerInterface::proposeLoadingGame()
|
|
void CPlayerInterface::proposeLoadingGame()
|
|
{
|
|
{
|
|
showYesNoDialog(
|
|
showYesNoDialog(
|
|
- CGI->generaltexth->allTexts[68],
|
|
|
|
|
|
+ LIBRARY->generaltexth->allTexts[68],
|
|
[]()
|
|
[]()
|
|
{
|
|
{
|
|
- CSH->endGameplay();
|
|
|
|
|
|
+ GAME->server().endGameplay();
|
|
CMM->menu->switchToTab("load");
|
|
CMM->menu->switchToTab("load");
|
|
},
|
|
},
|
|
nullptr
|
|
nullptr
|
|
@@ -1835,12 +1833,12 @@ bool CPlayerInterface::capturedAllEvents()
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
- bool needToLockAdventureMap = adventureInt && adventureInt->isActive() && CGI->mh->hasOngoingAnimations();
|
|
|
|
|
|
+ bool needToLockAdventureMap = adventureInt && adventureInt->isActive() && GAME->map().hasOngoingAnimations();
|
|
bool quickCombatOngoing = isAutoFightOn && !battleInt;
|
|
bool quickCombatOngoing = isAutoFightOn && !battleInt;
|
|
|
|
|
|
if (ignoreEvents || needToLockAdventureMap || quickCombatOngoing )
|
|
if (ignoreEvents || needToLockAdventureMap || quickCombatOngoing )
|
|
{
|
|
{
|
|
- GH.input().ignoreEventsUntilInput();
|
|
|
|
|
|
+ ENGINE->input().ignoreEventsUntilInput();
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|