Browse Source

Merge pull request #3625 from IvanSavenko/exchange_in_town

Better hero exchange in town
Ivan Savenko 1 year ago
parent
commit
83eb0ea28f
2 changed files with 6 additions and 16 deletions
  1. 6 14
      client/windows/CCastleInterface.cpp
  2. 0 2
      client/windows/CCastleInterface.h

+ 6 - 14
client/windows/CCastleInterface.cpp

@@ -427,7 +427,11 @@ void CHeroGSlot::clickPressed(const Point & cursorPosition)
 	if(hero && isSelected())
 	if(hero && isSelected())
 	{
 	{
 		setHighlight(false);
 		setHighlight(false);
-		LOCPLINT->openHeroWindow(hero);
+
+		if(other->hero)
+			LOCPLINT->showHeroExchange(hero->id, other->hero->id);
+		else
+			LOCPLINT->openHeroWindow(hero);
 	}
 	}
 	else if(other->hero && other->isSelected())
 	else if(other->hero && other->isSelected())
 	{
 	{
@@ -515,14 +519,6 @@ void HeroSlots::update()
 	visitingHero->set(town->visitingHero);
 	visitingHero->set(town->visitingHero);
 }
 }
 
 
-void HeroSlots::splitClicked()
-{
-	if(!!town->visitingHero && town->garrisonHero && (visitingHero->isSelected() || garrisonedHero->isSelected()))
-	{
-		LOCPLINT->showHeroExchange(town->visitingHero->id, town->garrisonHero->id);
-	}
-}
-
 void HeroSlots::swapArmies()
 void HeroSlots::swapArmies()
 {
 {
 	bool allow = true;
 	bool allow = true;
@@ -1217,11 +1213,7 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, const CGTownInst
 	exit = std::make_shared<CButton>(Point(744, 544), AnimationPath::builtin("TSBTNS"), CButton::tooltip(CGI->generaltexth->tcommands[8]), [&](){close();}, EShortcut::GLOBAL_RETURN);
 	exit = std::make_shared<CButton>(Point(744, 544), AnimationPath::builtin("TSBTNS"), CButton::tooltip(CGI->generaltexth->tcommands[8]), [&](){close();}, EShortcut::GLOBAL_RETURN);
 	exit->setImageOrder(4, 5, 6, 7);
 	exit->setImageOrder(4, 5, 6, 7);
 
 
-	auto split = std::make_shared<CButton>(Point(744, 382), AnimationPath::builtin("TSBTNS"), CButton::tooltip(CGI->generaltexth->tcommands[3]), [&]()
-	{
-		garr->splitClick();
-		heroes->splitClicked();
-	});
+	auto split = std::make_shared<CButton>(Point(744, 382), AnimationPath::builtin("TSBTNS"), CButton::tooltip(CGI->generaltexth->tcommands[3]), [this]() { garr->splitClick(); });
 	garr->addSplitBtn(split);
 	garr->addSplitBtn(split);
 
 
 	Rect barRect(9, 182, 732, 18);
 	Rect barRect(9, 182, 732, 18);

+ 0 - 2
client/windows/CCastleInterface.h

@@ -133,7 +133,6 @@ public:
 	HeroSlots(const CGTownInstance * town, Point garrPos, Point visitPos, std::shared_ptr<CGarrisonInt> Garrison, bool ShowEmpty);
 	HeroSlots(const CGTownInstance * town, Point garrPos, Point visitPos, std::shared_ptr<CGarrisonInt> Garrison, bool ShowEmpty);
 	~HeroSlots();
 	~HeroSlots();
 
 
-	void splitClicked(); //for hero meeting only (splitting stacks is handled by garrison int)
 	void update();
 	void update();
 	void swapArmies(); //exchange garrisoned and visiting heroes or move hero to\from garrison
 	void swapArmies(); //exchange garrisoned and visiting heroes or move hero to\from garrison
 };
 };
@@ -227,7 +226,6 @@ class CCastleInterface : public CStatusbarWindow, public IGarrisonHolder
 	std::shared_ptr<CTownInfo> fort;
 	std::shared_ptr<CTownInfo> fort;
 
 
 	std::shared_ptr<CButton> exit;
 	std::shared_ptr<CButton> exit;
-	std::shared_ptr<CButton> split;
 	std::shared_ptr<CButton> fastTownHall;
 	std::shared_ptr<CButton> fastTownHall;
 	std::shared_ptr<CButton> fastArmyPurchase;
 	std::shared_ptr<CButton> fastArmyPurchase;
 	std::shared_ptr<LRClickableArea> fastMarket;
 	std::shared_ptr<LRClickableArea> fastMarket;