diff --git a/client/battle/CBattleInterface.cpp b/client/battle/CBattleInterface.cpp index 478bd4eba..6eb574173 100644 --- a/client/battle/CBattleInterface.cpp +++ b/client/battle/CBattleInterface.cpp @@ -156,7 +156,6 @@ CBattleInterface::CBattleInterface(const CCreatureSet *army1, const CCreatureSet queue->moveTo(Point(pos.x, pos.y - queue->pos.h)); } - queue->update(); //preparing siege info const CGTownInstance *town = curInt->cb->battleGetDefendedTown(); @@ -423,6 +422,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet *army1, const CCreatureSet currentAction = PossiblePlayerBattleAction::INVALID; selectedAction = PossiblePlayerBattleAction::INVALID; addUsedEvents(RCLICK | MOVE | KEYBOARD); + queue->update(); blockUI(true); } diff --git a/client/battle/CBattleInterface.h b/client/battle/CBattleInterface.h index 4a7e50d57..96983880c 100644 --- a/client/battle/CBattleInterface.h +++ b/client/battle/CBattleInterface.h @@ -59,6 +59,7 @@ struct ProjectileInfo; class CClickableHex; class CAnimation; class IImage; +class CStackQueue; /// Small struct which contains information about the id of the attacked stack, the damage dealt,... struct StackAttackedInfo @@ -396,7 +397,7 @@ public: friend class CPlayerInterface; friend class CButton; friend class CInGameConsole; - + friend class CStackQueue; friend class CBattleResultWindow; friend class CBattleHero; friend class CEffectAnimation; diff --git a/client/battle/CBattleInterfaceClasses.cpp b/client/battle/CBattleInterfaceClasses.cpp index 7bf3d8f1d..88c5ba103 100644 --- a/client/battle/CBattleInterfaceClasses.cpp +++ b/client/battle/CBattleInterfaceClasses.cpp @@ -763,7 +763,13 @@ void CStackQueue::update() stackBoxes[boxIndex]->setUnit(nullptr); } -CStackQueue::StackBox::StackBox(CStackQueue * owner) +int32_t CStackQueue::getSiegeShooterIconID() +{ + return owner->siegeH->town->town->faction->index; +} + +CStackQueue::StackBox::StackBox(CStackQueue * owner): + owner(owner) { OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); background = std::make_shared(owner->embedded ? "StackQueueSmall" : "StackQueueLarge"); @@ -795,7 +801,16 @@ void CStackQueue::StackBox::setUnit(const battle::Unit * unit, size_t turn) { background->colorize(unit->unitOwner()); icon->visible = true; - icon->setFrame(unit->creatureIconIndex()); + + // temporary code for mod compatibility: + // first, set icon that should definitely exist (arrow tower icon in base vcmi mod) + // second, try to switch to icon that should be provided by mod + // if mod is not up to date and does have arrow tower icon yet - second setFrame call will fail and retain previously set image + // for 1.2 release & later next line should be moved into 'else' block + icon->setFrame(unit->creatureIconIndex(), 0); + if (unit->unitType()->idNumber == CreatureID::ARROW_TOWERS) + icon->setFrame(owner->getSiegeShooterIconID(), 1); + amount->setText(makeNumberShort(unit->getCount())); if(stateIcon) diff --git a/client/battle/CBattleInterfaceClasses.h b/client/battle/CBattleInterfaceClasses.h index c0b657d27..9ee2bed6a 100644 --- a/client/battle/CBattleInterfaceClasses.h +++ b/client/battle/CBattleInterfaceClasses.h @@ -157,6 +157,7 @@ class CStackQueue : public CIntObject { class StackBox : public CIntObject { + CStackQueue * owner; public: std::shared_ptr background; std::shared_ptr icon; @@ -175,6 +176,7 @@ class CStackQueue : public CIntObject std::shared_ptr icons; std::shared_ptr stateIcons; + int32_t getSiegeShooterIconID(); public: const bool embedded;