mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
Highlight logic for queue icon on stack hover, lacks visual representation
This commit is contained in:
@@ -779,6 +779,14 @@ StackQueue::StackQueue(bool Embedded, BattleInterface & owner)
|
|||||||
|
|
||||||
void StackQueue::show(SDL_Surface * to)
|
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)
|
if (embedded)
|
||||||
showAll(to);
|
showAll(to);
|
||||||
CIntObject::show(to);
|
CIntObject::show(to);
|
||||||
@@ -901,3 +909,22 @@ boost::optional<uint32_t> StackQueue::StackBox::getBoundUnitID() const
|
|||||||
{
|
{
|
||||||
return boundUnitID;
|
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);
|
||||||
|
}
|
||||||
|
|||||||
@@ -197,15 +197,20 @@ class StackQueue : public CIntObject
|
|||||||
{
|
{
|
||||||
StackQueue * owner;
|
StackQueue * owner;
|
||||||
boost::optional<uint32_t> boundUnitID;
|
boost::optional<uint32_t> boundUnitID;
|
||||||
|
bool highlighted = false;
|
||||||
|
|
||||||
public:
|
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 setUnit(const battle::Unit * unit, size_t turn = 0);
|
|
||||||
StackBox(StackQueue * owner);
|
StackBox(StackQueue * owner);
|
||||||
|
void setUnit(const battle::Unit * unit, size_t turn = 0);
|
||||||
|
void toggleHighlight(bool value);
|
||||||
boost::optional<uint32_t> getBoundUnitID() const;
|
boost::optional<uint32_t> getBoundUnitID() const;
|
||||||
|
|
||||||
|
void show(SDL_Surface * to) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int QUEUE_SIZE = 10;
|
static const int QUEUE_SIZE = 10;
|
||||||
|
|||||||
@@ -945,3 +945,14 @@ std::vector<const CStack *> BattleStacksController::selectHoveredStacks()
|
|||||||
|
|
||||||
return {};
|
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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ public:
|
|||||||
|
|
||||||
const CStack* getActiveStack() const;
|
const CStack* getActiveStack() const;
|
||||||
const CStack* getSelectedStack() const;
|
const CStack* getSelectedStack() const;
|
||||||
|
const std::vector<uint32_t> getHoveredStacksUnitIds() const;
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user