Browse Source

Split army: dont highlight down garrison slots if there no visiting hero

Before UI always highlighted all slots in both town garrisons even if there no visiting here and you can't actually set army on these slots.
Now garrison slots only highlighted if they're owned by us or our ally. If there no visiting hero in town then only suitable upper garrison slots will be highlighted.
ArseniyShestakov 10 years ago
parent
commit
120301ecc8
2 changed files with 11 additions and 2 deletions
  1. 10 2
      client/widgets/CGarrisonInt.cpp
  2. 1 0
      client/widgets/CGarrisonInt.h

+ 10 - 2
client/widgets/CGarrisonInt.cpp

@@ -127,6 +127,14 @@ bool CGarrisonSlot::our() const
 	return 	upg?(owner->owned[1]):(owner->owned[0]);
 }
 
+bool CGarrisonSlot::ally() const
+{
+	if(!getObj())
+		return false;
+
+	return PlayerRelations::ALLIES == LOCPLINT->cb->getPlayerRelations(LOCPLINT->playerID, getObj()->tempOwner);
+}
+
 void CGarrisonSlot::clickRight(tribool down, bool previousState)
 {
 	if(down && creature)
@@ -459,10 +467,10 @@ void CGarrisonInt::setSplittingMode(bool on)
 	if (inSplittingMode || on)
 	{
 		for(CGarrisonSlot * slot : slotsUp)
-			slot->setHighlight( ( on && (slot->creature == nullptr || slot->creature == getSelection()->creature)));
+			slot->setHighlight( ( on && (slot->our() || slot->ally()) && (slot->creature == nullptr || slot->creature == getSelection()->creature)));
 
 		for(CGarrisonSlot * slot : slotsDown)
-			slot->setHighlight( ( on && (slot->creature == nullptr || slot->creature == getSelection()->creature)));
+			slot->setHighlight( ( on && (slot->our() || slot->ally()) && (slot->creature == nullptr || slot->creature == getSelection()->creature)));
 		inSplittingMode = on;
 	}
 }

+ 1 - 0
client/widgets/CGarrisonInt.h

@@ -39,6 +39,7 @@ public:
 	virtual void hover (bool on); //call-in
 	const CArmedInstance * getObj() const;
 	bool our() const;
+	bool ally() const;
 	void clickRight(tribool down, bool previousState);
 	void clickLeft(tribool down, bool previousState);
 	void update();