diff --git a/client/battle/BattleInterfaceClasses.cpp b/client/battle/BattleInterfaceClasses.cpp index 5ecbb2e70..b9a91b695 100644 --- a/client/battle/BattleInterfaceClasses.cpp +++ b/client/battle/BattleInterfaceClasses.cpp @@ -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 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); +} diff --git a/client/battle/BattleInterfaceClasses.h b/client/battle/BattleInterfaceClasses.h index ba6ebe4f8..b1fe272fa 100644 --- a/client/battle/BattleInterfaceClasses.h +++ b/client/battle/BattleInterfaceClasses.h @@ -197,15 +197,20 @@ class StackQueue : public CIntObject { StackQueue * owner; boost::optional boundUnitID; + bool highlighted = false; + public: std::shared_ptr background; std::shared_ptr icon; std::shared_ptr amount; std::shared_ptr 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 getBoundUnitID() const; + + void show(SDL_Surface * to) override; }; static const int QUEUE_SIZE = 10; diff --git a/client/battle/BattleStacksController.cpp b/client/battle/BattleStacksController.cpp index dabd2e6e3..3196c28c6 100644 --- a/client/battle/BattleStacksController.cpp +++ b/client/battle/BattleStacksController.cpp @@ -945,3 +945,14 @@ std::vector BattleStacksController::selectHoveredStacks() return {}; } + +const std::vector BattleStacksController::getHoveredStacksUnitIds() const +{ + auto result = std::vector(); + for (auto const * stack : mouseHoveredStacks) + { + result.push_back(stack->unitId()); + } + + return result; +} diff --git a/client/battle/BattleStacksController.h b/client/battle/BattleStacksController.h index 1ccf7ceef..82c95a7b6 100644 --- a/client/battle/BattleStacksController.h +++ b/client/battle/BattleStacksController.h @@ -144,6 +144,7 @@ public: const CStack* getActiveStack() const; const CStack* getSelectedStack() const; + const std::vector getHoveredStacksUnitIds() const; void update();