From 8b60275a6e7c75f034d20377439f88ce01ae9672 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sun, 18 Feb 2024 21:02:24 +0200 Subject: [PATCH 1/2] Hero exchange in town is now activated by clicking on hero portrait --- client/windows/CCastleInterface.cpp | 20 ++++++-------------- client/windows/CCastleInterface.h | 1 - 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/client/windows/CCastleInterface.cpp b/client/windows/CCastleInterface.cpp index 16fdd2365..a07fa29bd 100644 --- a/client/windows/CCastleInterface.cpp +++ b/client/windows/CCastleInterface.cpp @@ -427,7 +427,11 @@ void CHeroGSlot::clickPressed(const Point & cursorPosition) if(hero && isSelected()) { 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()) { @@ -515,14 +519,6 @@ void HeroSlots::update() 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() { bool allow = true; @@ -1217,11 +1213,7 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, const CGTownInst exit = std::make_shared(Point(744, 544), AnimationPath::builtin("TSBTNS"), CButton::tooltip(CGI->generaltexth->tcommands[8]), [&](){close();}, EShortcut::GLOBAL_RETURN); exit->setImageOrder(4, 5, 6, 7); - auto split = std::make_shared(Point(744, 382), AnimationPath::builtin("TSBTNS"), CButton::tooltip(CGI->generaltexth->tcommands[3]), [&]() - { - garr->splitClick(); - heroes->splitClicked(); - }); + auto split = std::make_shared(Point(744, 382), AnimationPath::builtin("TSBTNS"), CButton::tooltip(CGI->generaltexth->tcommands[3]), [this]() { garr->splitClick(); }); garr->addSplitBtn(split); Rect barRect(9, 182, 732, 18); diff --git a/client/windows/CCastleInterface.h b/client/windows/CCastleInterface.h index 1b7884737..f883c62dd 100644 --- a/client/windows/CCastleInterface.h +++ b/client/windows/CCastleInterface.h @@ -133,7 +133,6 @@ public: HeroSlots(const CGTownInstance * town, Point garrPos, Point visitPos, std::shared_ptr Garrison, bool ShowEmpty); ~HeroSlots(); - void splitClicked(); //for hero meeting only (splitting stacks is handled by garrison int) void update(); void swapArmies(); //exchange garrisoned and visiting heroes or move hero to\from garrison }; From 82eea1abc162f75d99250bad72add29c71e46045 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Mon, 19 Feb 2024 16:49:59 +0200 Subject: [PATCH 2/2] Remove unused variable --- client/windows/CCastleInterface.h | 1 - 1 file changed, 1 deletion(-) diff --git a/client/windows/CCastleInterface.h b/client/windows/CCastleInterface.h index f883c62dd..32c1d426c 100644 --- a/client/windows/CCastleInterface.h +++ b/client/windows/CCastleInterface.h @@ -226,7 +226,6 @@ class CCastleInterface : public CStatusbarWindow, public IGarrisonHolder std::shared_ptr fort; std::shared_ptr exit; - std::shared_ptr split; std::shared_ptr fastTownHall; std::shared_ptr fastArmyPurchase; std::shared_ptr fastMarket;