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

Replaced clickRight event with showPopupWindow/closePopupWindow

This commit is contained in:
Ivan Savenko
2023-06-11 18:20:10 +03:00
parent 02ea798c97
commit d4aa778547
49 changed files with 125 additions and 194 deletions

View File

@@ -57,9 +57,9 @@ void LRClickableAreaWText::clickLeft(tribool down, bool previousState)
LOCPLINT->showInfoDialog(text);
}
}
void LRClickableAreaWText::clickRight(tribool down, bool previousState)
void LRClickableAreaWText::showPopupWindow()
{
if (down && !text.empty())
if (!text.empty())
CRClickPopup::createAndPush(text);
}
@@ -108,22 +108,19 @@ std::shared_ptr<CComponent> LRClickableAreaWTextComp::createComponent() const
return std::shared_ptr<CComponent>();
}
void LRClickableAreaWTextComp::clickRight(tribool down, bool previousState)
void LRClickableAreaWTextComp::showPopupWindow()
{
if(down)
if(auto comp = createComponent())
{
if(auto comp = createComponent())
{
CRClickPopup::createAndPush(text, CInfoWindow::TCompsInfo(1, comp));
return;
}
CRClickPopup::createAndPush(text, CInfoWindow::TCompsInfo(1, comp));
return;
}
LRClickableAreaWText::clickRight(down, previousState); //only if with-component variant not occurred
LRClickableAreaWText::showPopupWindow(); //only if with-component variant not occurred
}
CHeroArea::CHeroArea(int x, int y, const CGHeroInstance * _hero)
: CIntObject(LCLICK | RCLICK | HOVER),
: CIntObject(LCLICK | HOVER),
hero(_hero)
{
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
@@ -143,12 +140,6 @@ void CHeroArea::clickLeft(tribool down, bool previousState)
LOCPLINT->openHeroWindow(hero);
}
void CHeroArea::clickRight(tribool down, bool previousState)
{
if(hero && (!down) && previousState)
LOCPLINT->openHeroWindow(hero);
}
void CHeroArea::hover(bool on)
{
if (on && hero)
@@ -169,12 +160,6 @@ void LRClickableAreaOpenTown::clickLeft(tribool down, bool previousState)
}
}
void LRClickableAreaOpenTown::clickRight(tribool down, bool previousState)
{
if(town && (!down) && previousState)
LOCPLINT->openTownWindow(town);//TODO: popup?
}
LRClickableAreaOpenTown::LRClickableAreaOpenTown(const Rect & Pos, const CGTownInstance * Town)
: LRClickableAreaWTextComp(Pos, -1), town(Town)
{