1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Show town-specific tower icon in battle queue, if such icon exists

This commit is contained in:
Ivan Savenko
2022-11-29 14:59:50 +02:00
parent 861a6849f9
commit 178cd0226f
4 changed files with 22 additions and 4 deletions

View File

@@ -156,7 +156,6 @@ CBattleInterface::CBattleInterface(const CCreatureSet *army1, const CCreatureSet
queue->moveTo(Point(pos.x, pos.y - queue->pos.h)); queue->moveTo(Point(pos.x, pos.y - queue->pos.h));
} }
queue->update();
//preparing siege info //preparing siege info
const CGTownInstance *town = curInt->cb->battleGetDefendedTown(); const CGTownInstance *town = curInt->cb->battleGetDefendedTown();
@@ -423,6 +422,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet *army1, const CCreatureSet
currentAction = PossiblePlayerBattleAction::INVALID; currentAction = PossiblePlayerBattleAction::INVALID;
selectedAction = PossiblePlayerBattleAction::INVALID; selectedAction = PossiblePlayerBattleAction::INVALID;
addUsedEvents(RCLICK | MOVE | KEYBOARD); addUsedEvents(RCLICK | MOVE | KEYBOARD);
queue->update();
blockUI(true); blockUI(true);
} }

View File

@@ -59,6 +59,7 @@ struct ProjectileInfo;
class CClickableHex; class CClickableHex;
class CAnimation; class CAnimation;
class IImage; class IImage;
class CStackQueue;
/// Small struct which contains information about the id of the attacked stack, the damage dealt,... /// Small struct which contains information about the id of the attacked stack, the damage dealt,...
struct StackAttackedInfo struct StackAttackedInfo
@@ -396,7 +397,7 @@ public:
friend class CPlayerInterface; friend class CPlayerInterface;
friend class CButton; friend class CButton;
friend class CInGameConsole; friend class CInGameConsole;
friend class CStackQueue;
friend class CBattleResultWindow; friend class CBattleResultWindow;
friend class CBattleHero; friend class CBattleHero;
friend class CEffectAnimation; friend class CEffectAnimation;

View File

@@ -763,7 +763,13 @@ void CStackQueue::update()
stackBoxes[boxIndex]->setUnit(nullptr); 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); OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
background = std::make_shared<CPicture>(owner->embedded ? "StackQueueSmall" : "StackQueueLarge"); background = std::make_shared<CPicture>(owner->embedded ? "StackQueueSmall" : "StackQueueLarge");
@@ -795,7 +801,16 @@ void CStackQueue::StackBox::setUnit(const battle::Unit * unit, size_t turn)
{ {
background->colorize(unit->unitOwner()); background->colorize(unit->unitOwner());
icon->visible = true; 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())); amount->setText(makeNumberShort(unit->getCount()));
if(stateIcon) if(stateIcon)

View File

@@ -157,6 +157,7 @@ class CStackQueue : public CIntObject
{ {
class StackBox : public CIntObject class StackBox : public CIntObject
{ {
CStackQueue * owner;
public: public:
std::shared_ptr<CPicture> background; std::shared_ptr<CPicture> background;
std::shared_ptr<CAnimImage> icon; std::shared_ptr<CAnimImage> icon;
@@ -175,6 +176,7 @@ class CStackQueue : public CIntObject
std::shared_ptr<CAnimation> icons; std::shared_ptr<CAnimation> icons;
std::shared_ptr<CAnimation> stateIcons; std::shared_ptr<CAnimation> stateIcons;
int32_t getSiegeShooterIconID();
public: public:
const bool embedded; const bool embedded;