1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Highlight logic for queue icon on stack hover, lacks visual representation

This commit is contained in:
Dydzio 2023-01-22 20:06:10 +01:00
parent 92754e22f0
commit bd1bd5064a
4 changed files with 45 additions and 1 deletions

View File

@ -779,6 +779,14 @@ StackQueue::StackQueue(bool Embedded, BattleInterface & owner)
void StackQueue::show(SDL_Surface * to)
{
auto unitIdsToHighlight = owner.stacksController->getHoveredStacksUnitIds();
for(auto & stackBox : stackBoxes)
{
bool isBoundUnitCurrentlyHovered = vstd::contains(unitIdsToHighlight, stackBox->getBoundUnitID());
stackBox->toggleHighlight(isBoundUnitCurrentlyHovered);
}
if (embedded)
showAll(to);
CIntObject::show(to);
@ -901,3 +909,22 @@ boost::optional<uint32_t> StackQueue::StackBox::getBoundUnitID() const
{
return boundUnitID;
}
void StackQueue::StackBox::toggleHighlight(bool value)
{
highlighted = value;
}
void StackQueue::StackBox::show(SDL_Surface *to)
{
if(highlighted)
{
//TODO: logic to perform on image that changes it visually when unit highlighted
}
else
{
//TODO: logic to perform on image that changes it visually when unit loses highlight
}
CIntObject::show(to);
}

View File

@ -197,15 +197,20 @@ class StackQueue : public CIntObject
{
StackQueue * owner;
boost::optional<uint32_t> boundUnitID;
bool highlighted = false;
public:
std::shared_ptr<CPicture> background;
std::shared_ptr<CAnimImage> icon;
std::shared_ptr<CLabel> amount;
std::shared_ptr<CAnimImage> stateIcon;
void setUnit(const battle::Unit * unit, size_t turn = 0);
StackBox(StackQueue * owner);
void setUnit(const battle::Unit * unit, size_t turn = 0);
void toggleHighlight(bool value);
boost::optional<uint32_t> getBoundUnitID() const;
void show(SDL_Surface * to) override;
};
static const int QUEUE_SIZE = 10;

View File

@ -945,3 +945,14 @@ std::vector<const CStack *> BattleStacksController::selectHoveredStacks()
return {};
}
const std::vector<uint32_t> BattleStacksController::getHoveredStacksUnitIds() const
{
auto result = std::vector<uint32_t>();
for (auto const * stack : mouseHoveredStacks)
{
result.push_back(stack->unitId());
}
return result;
}

View File

@ -144,6 +144,7 @@ public:
const CStack* getActiveStack() const;
const CStack* getSelectedStack() const;
const std::vector<uint32_t> getHoveredStacksUnitIds() const;
void update();