瀏覽代碼

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 年之前
父節點
當前提交
120301ecc8
共有 2 個文件被更改,包括 11 次插入2 次删除
  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]);
 	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)
 void CGarrisonSlot::clickRight(tribool down, bool previousState)
 {
 {
 	if(down && creature)
 	if(down && creature)
@@ -459,10 +467,10 @@ void CGarrisonInt::setSplittingMode(bool on)
 	if (inSplittingMode || on)
 	if (inSplittingMode || on)
 	{
 	{
 		for(CGarrisonSlot * slot : slotsUp)
 		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)
 		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;
 		inSplittingMode = on;
 	}
 	}
 }
 }

+ 1 - 0
client/widgets/CGarrisonInt.h

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