1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

using CHeroArea

This commit is contained in:
Laserlicht
2023-12-22 01:30:41 +01:00
committed by GitHub
parent f75ccc308b
commit c20f0bdc3e
4 changed files with 22 additions and 8 deletions

View File

@@ -121,9 +121,10 @@ void LRClickableAreaWTextComp::showPopupWindow(const Point & cursorPosition)
}
CHeroArea::CHeroArea(int x, int y, const CGHeroInstance * hero)
: CIntObject(LCLICK | HOVER),
: CIntObject(LCLICK | SHOW_POPUP | HOVER),
hero(hero),
clickFunctor(nullptr)
clickFunctor(nullptr),
clickRFunctor(nullptr)
{
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
@@ -147,12 +148,23 @@ void CHeroArea::addClickCallback(ClickFunctor callback)
clickFunctor = callback;
}
void CHeroArea::addRClickCallback(ClickFunctor callback)
{
clickRFunctor = callback;
}
void CHeroArea::clickPressed(const Point & cursorPosition)
{
if(clickFunctor)
clickFunctor();
}
void CHeroArea::showPopupWindow(const Point & cursorPosition)
{
if(clickRFunctor)
clickRFunctor();
}
void CHeroArea::hover(bool on)
{
if (on && hero)