mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Fix no player interface swap on being attacked
This commit is contained in:
parent
e50efdc279
commit
54e6e42c46
@ -1602,6 +1602,29 @@ void CPlayerInterface::objectRemoved(const CGObjectInstance * obj)
|
||||
}
|
||||
}
|
||||
|
||||
void CPlayerInterface::playerBlocked(int reason, bool start)
|
||||
{
|
||||
if(reason == PlayerBlocked::EReason::UPCOMING_BATTLE)
|
||||
{
|
||||
if(CSH->howManyPlayerInterfaces() > 1 && LOCPLINT != this && LOCPLINT->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)
|
||||
boost::unique_lock<boost::mutex> lock(eventsM); //TODO: copied from yourTurn, no idea if it's needed
|
||||
LOCPLINT = this;
|
||||
GH.curInt = this;
|
||||
adventureInt->selection = nullptr;
|
||||
adventureInt->setPlayer(playerID);
|
||||
std::string msg = CGI->generaltexth->localizedTexts["adventureMap"]["playerAttacked"].String();
|
||||
boost::replace_first(msg, "%s", cb->getStartInfo()->playerInfos.find(playerID)->second.name);
|
||||
std::vector<std::shared_ptr<CComponent>> cmp;
|
||||
cmp.push_back(std::make_shared<CComponent>(CComponent::flag, playerID.getNum(), 0));
|
||||
makingTurn = true; //workaround for stiff showInfoDialog implementation
|
||||
showInfoDialog(msg, cmp);
|
||||
makingTurn = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CPlayerInterface::ctrlPressed() const
|
||||
{
|
||||
return isCtrlKeyDown();
|
||||
|
@ -167,6 +167,7 @@ public:
|
||||
void centerView (int3 pos, int focusTime) override;
|
||||
void objectPropertyChanged(const SetObjectProperty * sop) override;
|
||||
void objectRemoved(const CGObjectInstance *obj) override;
|
||||
void playerBlocked(int reason, bool start) override;
|
||||
void gameOver(PlayerColor player, const EVictoryLossCheckResult & victoryLossCheckResult) override;
|
||||
void playerStartsTurn(PlayerColor player) override; //called before yourTurn on active itnerface
|
||||
void showComp(const Component &comp, std::string message) override; //display component in the advmapint infobox
|
||||
|
@ -20,7 +20,8 @@
|
||||
"Deadly",
|
||||
"Impossible"
|
||||
]
|
||||
}
|
||||
},
|
||||
"playerAttacked" : "Player has been attacked: %s"
|
||||
},
|
||||
"systemOptions" :
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user