1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-25 21:38:59 +02:00

Block few more cases of access during another player turn in UI

This commit is contained in:
Ivan Savenko 2024-04-27 13:17:45 +03:00
parent 1775caa872
commit d53082e1c1
3 changed files with 9 additions and 5 deletions

View File

@ -625,7 +625,7 @@ void CCastleBuildings::recreate()
buildings.push_back(std::make_shared<CBuildingRect>(this, town, toAdd));
}
auto const & buildSorter = [] (const CIntObject * a, const CIntObject * b)
const auto & buildSorter = [](const CIntObject * a, const CIntObject * b)
{
auto b1 = dynamic_cast<const CBuildingRect *>(a);
auto b2 = dynamic_cast<const CBuildingRect *>(b);
@ -1564,7 +1564,7 @@ CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Buildin
buy = std::make_shared<CButton>(Point(45, 446), AnimationPath::builtin("IBUY30"), CButton::tooltip(tooltipYes.toString()), [&](){ buyFunc(); }, EShortcut::GLOBAL_ACCEPT);
buy->setBorderColor(Colors::METALLIC_GOLD);
buy->block(state!=EBuildingState::ALLOWED || LOCPLINT->playerID != town->tempOwner);
buy->block(state != EBuildingState::ALLOWED || LOCPLINT->playerID != town->tempOwner || !LOCPLINT->makingTurn);
cancel = std::make_shared<CButton>(Point(290, 445), AnimationPath::builtin("ICANCEL"), CButton::tooltip(tooltipNo.toString()), [&](){ close();}, EShortcut::GLOBAL_CANCEL);
cancel->setBorderColor(Colors::METALLIC_GOLD);

View File

@ -620,7 +620,7 @@ void CSpellWindow::SpellArea::clickPressed(const Point & cursorPosition)
const bool inCastle = owner->myInt->castleInt != nullptr;
//battle spell on adv map or adventure map spell during combat => display infowindow, not cast
if((combatSpell ^ inCombat) || inCastle)
if((combatSpell != inCombat) || inCastle || (!combatSpell && !LOCPLINT->makingTurn))
{
std::vector<std::shared_ptr<CComponent>> hlp(1, std::make_shared<CComponent>(ComponentType::SPELL, mySpell->id));
LOCPLINT->showInfoDialog(mySpell->getDescriptionTranslated(schoolLevel), hlp);

View File

@ -302,7 +302,7 @@ void CRecruitmentWindow::sliderMoved(int to)
if(!selected)
return;
buyButton->block(!to);
buyButton->block(!to || !LOCPLINT->makingTurn);
availableValue->setText(std::to_string(selected->amount - to));
toRecruitValue->setText(std::to_string(to));
@ -479,7 +479,11 @@ CTavernWindow::CTavernWindow(const CGObjectInstance * TavernObj, const std::func
recruit = std::make_shared<CButton>(Point(272, 355), AnimationPath::builtin("TPTAV01.DEF"), CButton::tooltip(), std::bind(&CTavernWindow::recruitb, this), EShortcut::GLOBAL_ACCEPT);
thiefGuild = std::make_shared<CButton>(Point(22, 428), AnimationPath::builtin("TPTAV02.DEF"), CButton::tooltip(CGI->generaltexth->tavernInfo[5]), std::bind(&CTavernWindow::thievesguildb, this), EShortcut::ADVENTURE_THIEVES_GUILD);
if(LOCPLINT->cb->getResourceAmount(EGameResID::GOLD) < GameConstants::HERO_GOLD_COST) //not enough gold
if(!LOCPLINT->makingTurn)
{
recruit->block(true);
}
else if(LOCPLINT->cb->getResourceAmount(EGameResID::GOLD) < GameConstants::HERO_GOLD_COST) //not enough gold
{
recruit->addHoverText(EButtonState::NORMAL, CGI->generaltexth->tavernInfo[0]); //Cannot afford a Hero
recruit->block(true);