1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Added block for several more actions outside of our turn

This commit is contained in:
Ivan Savenko 2024-04-28 15:58:54 +03:00
parent d53082e1c1
commit 74d3b4ab43
9 changed files with 20 additions and 12 deletions

View File

@ -171,7 +171,7 @@ void CAltarArtifacts::updateAltarSlots()
} }
calcExpAltarForHero(); calcExpAltarForHero();
deal->block(tradeSlotsMap.empty()); deal->block(tradeSlotsMap.empty() || !LOCPLINT->makingTurn);
} }
void CAltarArtifacts::putBackArtifacts() void CAltarArtifacts::putBackArtifacts()
@ -205,7 +205,7 @@ void CAltarArtifacts::onSlotClickPressed(const std::shared_ptr<CTradeableItem> &
{ {
if(altarSlot->id == -1) if(altarSlot->id == -1)
tradeSlotsMap.try_emplace(altarSlot, pickedArtInst); tradeSlotsMap.try_emplace(altarSlot, pickedArtInst);
deal->block(false); deal->block(!LOCPLINT->makingTurn);
LOCPLINT->cb->swapArtifacts(ArtifactLocation(heroArts->getHero()->id, ArtifactPosition::TRANSITION_POS), LOCPLINT->cb->swapArtifacts(ArtifactLocation(heroArts->getHero()->id, ArtifactPosition::TRANSITION_POS),
ArtifactLocation(altarId, ArtifactPosition::ALTAR)); ArtifactLocation(altarId, ArtifactPosition::ALTAR));

View File

@ -205,7 +205,7 @@ void CAltarCreatures::sacrificeAll()
offerTradePanel->update(); offerTradePanel->update();
updateShowcases(); updateShowcases();
deal->block(calcExpAltarForHero() == 0); deal->block(calcExpAltarForHero() == 0 || !LOCPLINT->makingTurn);
} }
void CAltarCreatures::updateAltarSlot(const std::shared_ptr<CTradeableItem> & slot) void CAltarCreatures::updateAltarSlot(const std::shared_ptr<CTradeableItem> & slot)
@ -222,7 +222,7 @@ void CAltarCreatures::onOfferSliderMoved(int newVal)
unitsOnAltar[bidTradePanel->highlightedSlot->serial] = newVal; unitsOnAltar[bidTradePanel->highlightedSlot->serial] = newVal;
if(offerTradePanel->isHighlighted()) if(offerTradePanel->isHighlighted())
updateAltarSlot(offerTradePanel->highlightedSlot); updateAltarSlot(offerTradePanel->highlightedSlot);
deal->block(calcExpAltarForHero() == 0); deal->block(calcExpAltarForHero() == 0 || !LOCPLINT->makingTurn);
highlightingChanged(); highlightingChanged();
redraw(); redraw();
} }

View File

@ -102,7 +102,7 @@ void CArtifactsBuying::highlightingChanged()
if(bidTradePanel->isHighlighted() && offerTradePanel->isHighlighted()) if(bidTradePanel->isHighlighted() && offerTradePanel->isHighlighted())
{ {
market->getOffer(bidTradePanel->getSelectedItemId(), offerTradePanel->getSelectedItemId(), bidQty, offerQty, EMarketMode::RESOURCE_ARTIFACT); market->getOffer(bidTradePanel->getSelectedItemId(), offerTradePanel->getSelectedItemId(), bidQty, offerQty, EMarketMode::RESOURCE_ARTIFACT);
deal->block(LOCPLINT->cb->getResourceAmount(GameResID(bidTradePanel->getSelectedItemId())) >= bidQty ? false : true); deal->block(LOCPLINT->cb->getResourceAmount(GameResID(bidTradePanel->getSelectedItemId())) < bidQty || !LOCPLINT->makingTurn);
} }
CMarketBase::highlightingChanged(); CMarketBase::highlightingChanged();
CMarketTraderText::highlightingChanged(); CMarketTraderText::highlightingChanged();

View File

@ -149,7 +149,7 @@ void CArtifactsSelling::highlightingChanged()
if(art && offerTradePanel->isHighlighted()) if(art && offerTradePanel->isHighlighted())
{ {
market->getOffer(art->getTypeId(), offerTradePanel->getSelectedItemId(), bidQty, offerQty, EMarketMode::ARTIFACT_RESOURCE); market->getOffer(art->getTypeId(), offerTradePanel->getSelectedItemId(), bidQty, offerQty, EMarketMode::ARTIFACT_RESOURCE);
deal->block(false); deal->block(!LOCPLINT->makingTurn);
} }
CMarketBase::highlightingChanged(); CMarketBase::highlightingChanged();
CMarketTraderText::highlightingChanged(); CMarketTraderText::highlightingChanged();

View File

@ -96,7 +96,7 @@ void CFreelancerGuild::highlightingChanged()
offerSlider->scrollTo(0); offerSlider->scrollTo(0);
offerSlider->block(false); offerSlider->block(false);
maxAmount->block(false); maxAmount->block(false);
deal->block(false); deal->block(!LOCPLINT->makingTurn);
} }
CMarketBase::highlightingChanged(); CMarketBase::highlightingChanged();
CMarketTraderText::highlightingChanged(); CMarketTraderText::highlightingChanged();

View File

@ -89,7 +89,7 @@ void CMarketResources::highlightingChanged()
const bool isControlsBlocked = bidTradePanel->getSelectedItemId() != offerTradePanel->getSelectedItemId() ? false : true; const bool isControlsBlocked = bidTradePanel->getSelectedItemId() != offerTradePanel->getSelectedItemId() ? false : true;
offerSlider->block(isControlsBlocked); offerSlider->block(isControlsBlocked);
maxAmount->block(isControlsBlocked); maxAmount->block(isControlsBlocked);
deal->block(isControlsBlocked); deal->block(isControlsBlocked || !LOCPLINT->makingTurn);
} }
CMarketBase::highlightingChanged(); CMarketBase::highlightingChanged();
CMarketTraderText::highlightingChanged(); CMarketTraderText::highlightingChanged();

View File

@ -89,7 +89,7 @@ void CTransferResources::highlightingChanged()
offerSlider->scrollTo(0); offerSlider->scrollTo(0);
offerSlider->block(false); offerSlider->block(false);
maxAmount->block(false); maxAmount->block(false);
deal->block(false); deal->block(!LOCPLINT->makingTurn);
} }
CMarketBase::highlightingChanged(); CMarketBase::highlightingChanged();
CMarketTraderText::highlightingChanged(); CMarketTraderText::highlightingChanged();

View File

@ -783,11 +783,14 @@ void CCastleBuildings::buildingClicked(BuildingID building, BuildingSubID::EBuil
if(upgrades == BuildingID::TAVERN) if(upgrades == BuildingID::TAVERN)
LOCPLINT->showTavernWindow(town, nullptr, QueryID::NONE); LOCPLINT->showTavernWindow(town, nullptr, QueryID::NONE);
else else
enterBuilding(building); enterBuilding(building);
break; break;
case BuildingSubID::CASTLE_GATE: case BuildingSubID::CASTLE_GATE:
enterCastleGate(); if (LOCPLINT->makingTurn)
enterCastleGate();
else
enterBuilding(building);
break; break;
case BuildingSubID::CREATURE_TRANSFORMER: //Skeleton Transformer case BuildingSubID::CREATURE_TRANSFORMER: //Skeleton Transformer
@ -966,7 +969,9 @@ void CCastleBuildings::enterMagesGuild()
{ {
const CGHeroInstance *hero = getHero(); const CGHeroInstance *hero = getHero();
if(hero && !hero->hasSpellbook()) //hero doesn't have spellbok // hero doesn't have spellbok
// or it is not our turn and we can't make actions
if(hero && !hero->hasSpellbook() && LOCPLINT->makingTurn)
{ {
if(hero->isCampaignYog()) if(hero->isCampaignYog())
{ {

View File

@ -89,6 +89,9 @@ void CWindowWithArtifacts::clickPressedArtPlaceHero(const CArtifactsOfHeroBase &
if(artPlace.isLocked()) if(artPlace.isLocked())
return; return;
if (!LOCPLINT->makingTurn)
return;
std::visit( std::visit(
[this, &artPlace](auto artSetWeak) -> void [this, &artPlace](auto artSetWeak) -> void
{ {