1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

Fixed UI locking in simturns

This commit is contained in:
Ivan Savenko
2023-09-18 22:09:35 +03:00
parent b2f30f78fa
commit 64c82c9133

View File

@@ -170,6 +170,13 @@ void CPlayerInterface::initGameInterface(std::shared_ptr<Environment> ENV, std::
// always recreate advmap interface to avoid possible memory-corruption bugs // always recreate advmap interface to avoid possible memory-corruption bugs
adventureInt.reset(new AdventureMapInterface()); adventureInt.reset(new AdventureMapInterface());
if(GH.windows().findWindows<AdventureMapInterface>().empty())
{
// after map load - remove all active windows and replace them with adventure map
GH.windows().clear();
GH.windows().pushWindow(adventureInt);
}
} }
void CPlayerInterface::playerEndsTurn(PlayerColor player) void CPlayerInterface::playerEndsTurn(PlayerColor player)
@@ -182,31 +189,13 @@ void CPlayerInterface::playerEndsTurn(PlayerColor player)
void CPlayerInterface::playerStartsTurn(PlayerColor player) void CPlayerInterface::playerStartsTurn(PlayerColor player)
{ {
EVENT_HANDLER_CALLED_BY_CLIENT; EVENT_HANDLER_CALLED_BY_CLIENT;
movementController->onPlayerTurnStarted();
if(GH.windows().findWindows<AdventureMapInterface>().empty())
{
// after map load - remove all active windows and replace them with adventure map
GH.windows().clear();
GH.windows().pushWindow(adventureInt);
}
// close window from another player
if(auto w = GH.windows().topWindow<CInfoWindow>())
if(w->ID == QueryID::NONE && player != playerID)
w->close();
// remove all dialogs that do not expect query answer
while (!GH.windows().topWindow<AdventureMapInterface>() && !GH.windows().topWindow<CInfoWindow>())
GH.windows().popWindows(1);
if (player != playerID && LOCPLINT == this) if (player != playerID && LOCPLINT == this)
{ {
waitWhileDialog(); waitWhileDialog();
bool isHuman = cb->getStartInfo()->playerInfos.count(player) && cb->getStartInfo()->playerInfos.at(player).isControlledByHuman(); bool isHuman = cb->getStartInfo()->playerInfos.count(player) && cb->getStartInfo()->playerInfos.at(player).isControlledByHuman();
if (makingTurn == false)
adventureInt->onEnemyTurnStarted(player, isHuman); adventureInt->onEnemyTurnStarted(player, isHuman);
} }
} }
@@ -261,6 +250,21 @@ void CPlayerInterface::yourTurn(QueryID queryID)
LOCPLINT = this; LOCPLINT = this;
GH.curInt = this; GH.curInt = this;
// close window from another player
if(auto w = GH.windows().topWindow<CInfoWindow>())
{
assert(0);// what is this?
if(w->ID == QueryID::NONE)
w->close();
}
// remove all dialogs that do not expect query answer
while (!GH.windows().topWindow<AdventureMapInterface>() && !GH.windows().topWindow<CInfoWindow>())
{
assert(0);// what is this?
GH.windows().popWindows(1);
}
NotificationHandler::notify("Your turn"); NotificationHandler::notify("Your turn");
if(settings["general"]["startTurnAutosave"].Bool()) if(settings["general"]["startTurnAutosave"].Bool())
{ {
@@ -335,6 +339,7 @@ void CPlayerInterface::acceptTurn(QueryID queryID)
} }
cb->selectionMade(0, queryID); cb->selectionMade(0, queryID);
movementController->onPlayerTurnStarted();
} }
void CPlayerInterface::heroMoved(const TryMoveHero & details, bool verbose) void CPlayerInterface::heroMoved(const TryMoveHero & details, bool verbose)