ソースを参照

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

Dydzio 2 年 前
コミット
bd1bd5064a

+ 27 - 0
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<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);
+}

+ 6 - 1
client/battle/BattleInterfaceClasses.h

@@ -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;

+ 11 - 0
client/battle/BattleStacksController.cpp

@@ -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;
+}

+ 1 - 0
client/battle/BattleStacksController.h

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