1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

CHeroArea fix

This commit is contained in:
SoundSSGood
2023-09-03 21:42:22 +03:00
parent 3675d88730
commit f1a6116088
4 changed files with 31 additions and 14 deletions

View File

@@ -114,9 +114,10 @@ void LRClickableAreaWTextComp::showPopupWindow(const Point & cursorPosition)
LRClickableAreaWText::showPopupWindow(cursorPosition); //only if with-component variant not occurred
}
CHeroArea::CHeroArea(int x, int y, const CGHeroInstance * _hero)
CHeroArea::CHeroArea(int x, int y, const CGHeroInstance * hero)
: CIntObject(LCLICK | HOVER),
hero(_hero)
hero(hero),
clickFunctor(nullptr)
{
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
@@ -126,13 +127,24 @@ CHeroArea::CHeroArea(int x, int y, const CGHeroInstance * _hero)
pos.h = 64;
if(hero)
{
portrait = std::make_shared<CAnimImage>(AnimationPath::builtin("PortraitsLarge"), hero->portrait);
clickFunctor = [hero]() -> void
{
LOCPLINT->openHeroWindow(hero);
};
}
}
void CHeroArea::addClickCallback(ClickFunctor callback)
{
clickFunctor = callback;
}
void CHeroArea::clickPressed(const Point & cursorPosition)
{
if(hero)
LOCPLINT->openHeroWindow(hero);
if(clickFunctor)
clickFunctor();
}
void CHeroArea::hover(bool on)