mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-03 13:01:33 +02:00
Fix battle queue stack highlighting
This commit is contained in:
parent
108688389e
commit
0be9aff99f
@ -652,14 +652,6 @@ StackQueue::StackQueue(bool Embedded, BattleInterface & owner)
|
|||||||
|
|
||||||
void StackQueue::show(Canvas & to)
|
void StackQueue::show(Canvas & to)
|
||||||
{
|
{
|
||||||
auto unitIdsToHighlight = owner.stacksController->getHoveredStacksUnitIds();
|
|
||||||
|
|
||||||
for(auto & stackBox : stackBoxes)
|
|
||||||
{
|
|
||||||
bool isBoundUnitCurrentlyHovered = vstd::contains(unitIdsToHighlight, stackBox->getBoundUnitID());
|
|
||||||
stackBox->toggleHighlight(isBoundUnitCurrentlyHovered);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (embedded)
|
if (embedded)
|
||||||
showAll(to);
|
showAll(to);
|
||||||
CIntObject::show(to);
|
CIntObject::show(to);
|
||||||
@ -783,15 +775,24 @@ std::optional<uint32_t> StackQueue::StackBox::getBoundUnitID() const
|
|||||||
return boundUnitID;
|
return boundUnitID;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StackQueue::StackBox::toggleHighlight(bool value)
|
bool StackQueue::StackBox::isBoundUnitHighlighted() const
|
||||||
{
|
{
|
||||||
highlighted = value;
|
auto unitIdsToHighlight = owner->owner.stacksController->getHoveredStacksUnitIds();
|
||||||
|
return vstd::contains(unitIdsToHighlight, getBoundUnitID());
|
||||||
|
}
|
||||||
|
|
||||||
|
void StackQueue::StackBox::showAll(Canvas & to)
|
||||||
|
{
|
||||||
|
CIntObject::showAll(to);
|
||||||
|
|
||||||
|
if(isBoundUnitHighlighted())
|
||||||
|
to.drawBorder(background->pos, Colors::CYAN, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StackQueue::StackBox::show(Canvas & to)
|
void StackQueue::StackBox::show(Canvas & to)
|
||||||
{
|
{
|
||||||
if(highlighted)
|
|
||||||
to.drawBorder(background->pos, Colors::CYAN, 2);
|
|
||||||
|
|
||||||
CIntObject::show(to);
|
CIntObject::show(to);
|
||||||
|
|
||||||
|
if(isBoundUnitHighlighted())
|
||||||
|
to.drawBorder(background->pos, Colors::CYAN, 2);
|
||||||
}
|
}
|
||||||
|
@ -167,20 +167,21 @@ class StackQueue : public CIntObject
|
|||||||
{
|
{
|
||||||
StackQueue * owner;
|
StackQueue * owner;
|
||||||
std::optional<uint32_t> boundUnitID;
|
std::optional<uint32_t> boundUnitID;
|
||||||
bool highlighted = false;
|
|
||||||
|
|
||||||
public:
|
|
||||||
std::shared_ptr<CPicture> background;
|
std::shared_ptr<CPicture> background;
|
||||||
std::shared_ptr<CAnimImage> icon;
|
std::shared_ptr<CAnimImage> icon;
|
||||||
std::shared_ptr<CLabel> amount;
|
std::shared_ptr<CLabel> amount;
|
||||||
std::shared_ptr<CAnimImage> stateIcon;
|
std::shared_ptr<CAnimImage> stateIcon;
|
||||||
|
|
||||||
|
void show(Canvas & to) override;
|
||||||
|
void showAll(Canvas & to) override;
|
||||||
|
|
||||||
|
bool isBoundUnitHighlighted() const;
|
||||||
|
public:
|
||||||
StackBox(StackQueue * owner);
|
StackBox(StackQueue * owner);
|
||||||
void setUnit(const battle::Unit * unit, size_t turn = 0);
|
void setUnit(const battle::Unit * unit, size_t turn = 0);
|
||||||
void toggleHighlight(bool value);
|
|
||||||
std::optional<uint32_t> getBoundUnitID() const;
|
std::optional<uint32_t> getBoundUnitID() const;
|
||||||
|
|
||||||
void show(Canvas & to) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int QUEUE_SIZE = 10;
|
static const int QUEUE_SIZE = 10;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user