1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-25 21:38:59 +02:00

Hero exchange in town is now activated by clicking on hero portrait

This commit is contained in:
Ivan Savenko 2024-02-18 21:02:24 +02:00
parent 868b41c8ee
commit 8b60275a6e
2 changed files with 6 additions and 15 deletions

View File

@ -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<CButton>(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<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);
Rect barRect(9, 182, 732, 18);

View File

@ -133,7 +133,6 @@ public:
HeroSlots(const CGTownInstance * town, Point garrPos, Point visitPos, std::shared_ptr<CGarrisonInt> 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
};