1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-03 13:01:33 +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

@ -284,10 +284,9 @@ void CInfoBar::clickLeft(tribool down, bool previousState)
}
}
void CInfoBar::clickRight(tribool down, bool previousState)
void CInfoBar::showPopupWindow()
{
if (down)
CRClickPopup::createAndPush(CGI->generaltexth->allTexts[109]);
CRClickPopup::createAndPush(CGI->generaltexth->allTexts[109]);
}
void CInfoBar::hover(bool on)

View File

@ -155,7 +155,7 @@ private:
void tick(uint32_t msPassed) override;
void clickLeft(tribool down, bool previousState) override;
void clickRight(tribool down, bool previousState) override;
void showPopupWindow() override;
void hover(bool on) override;
void playNewDaySound();

View File

@ -40,10 +40,9 @@ CList::CListItem::CListItem(CList * Parent)
CList::CListItem::~CListItem() = default;
void CList::CListItem::clickRight(tribool down, bool previousState)
void CList::CListItem::showPopupWindow()
{
if (down == true)
showTooltip();
showTooltip();
}
void CList::CListItem::clickLeft(tribool down, bool previousState)

View File

@ -35,7 +35,7 @@ protected:
CListItem(CList * parent);
~CListItem();
void clickRight(tribool down, bool previousState) override;
void showPopupWindow() override;
void clickLeft(tribool down, bool previousState) override;
void hover(bool on) override;
void onSelect(bool on);

View File

@ -149,10 +149,9 @@ void CMinimap::clickLeft(tribool down, bool previousState)
moveAdvMapSelection(GH.getCursorPosition());
}
void CMinimap::clickRight(tribool down, bool previousState)
void CMinimap::showPopupWindow()
{
if (down)
CRClickPopup::createAndPush(CGI->generaltexth->zelp[291].second);
CRClickPopup::createAndPush(CGI->generaltexth->zelp[291].second);
}
void CMinimap::hover(bool on)

View File

@ -45,7 +45,7 @@ class CMinimap : public CIntObject
void gesturePanning(const Point & initialPosition, const Point & currentPosition, const Point & lastUpdateDistance) override;
void clickLeft(tribool down, bool previousState) override;
void clickRight(tribool down, bool previousState) override;
void showPopupWindow() override;
void hover (bool on) override;
void mouseMoved (const Point & cursorPosition) override;

View File

@ -219,16 +219,12 @@ void BattleFieldController::clickLeft(tribool down, bool previousState)
}
}
void BattleFieldController::clickRight(tribool down, bool previousState)
void BattleFieldController::showPopupWindow()
{
if(down)
{
BattleHex selectedHex = getHoveredHex();
BattleHex selectedHex = getHoveredHex();
if (selectedHex != BattleHex::INVALID)
owner.actionsController->onHexRightClicked(selectedHex);
}
if (selectedHex != BattleHex::INVALID)
owner.actionsController->onHexRightClicked(selectedHex);
}
void BattleFieldController::renderBattlefield(Canvas & canvas)

View File

@ -92,7 +92,7 @@ class BattleFieldController : public CIntObject
void gesturePanning(const Point & initialPosition, const Point & currentPosition, const Point & lastUpdateDistance) override;
void mouseMoved(const Point & cursorPosition) override;
void clickLeft(tribool down, bool previousState) override;
void clickRight(tribool down, bool previousState) override;
void showPopupWindow() override;
void activate() override;
void showAll(Canvas & to) override;

View File

@ -178,14 +178,18 @@ void EventDispatcher::handleMouseButtonClick(EventReceiversList & interestedObjs
{
if(isPressed)
i->currentMouseState[btn] = isPressed;
i->clickRight(isPressed, prev);
if (isPressed)
i->showPopupWindow();
else
i->closePopupWindow();
}
else if(!isPressed)
{
if (btn == MouseButton::LEFT)
i->clickLeft(boost::logic::indeterminate, prev);
if (btn == MouseButton::RIGHT)
i->clickRight(boost::logic::indeterminate, prev);
i->closePopupWindow();
}
}
}

View File

@ -36,7 +36,8 @@ protected:
void deactivateEvents(ui16 what);
virtual void clickLeft(tribool down, bool previousState) {}
virtual void clickRight(tribool down, bool previousState) {}
virtual void showPopupWindow() {}
virtual void closePopupWindow() {}
virtual void clickDouble() {}
/// Called when user pans screen by specified distance

View File

@ -507,7 +507,7 @@ void CBonusSelection::CRegion::clickLeft(tribool down, bool previousState)
}
}
void CBonusSelection::CRegion::clickRight(tribool down, bool previousState)
void CBonusSelection::CRegion::showPopupWindow()
{
// FIXME: For some reason "down" is only ever contain indeterminate_value
auto text = CSH->si->campState->camp->scenarios[idOfMapAndRegion].regionText;

View File

@ -46,7 +46,7 @@ public:
CRegion(int id, bool accessible, bool selectable, const CampaignRegions & campDsc);
void updateState();
void clickLeft(tribool down, bool previousState) override;
void clickRight(tribool down, bool previousState) override;
void showPopupWindow() override;
};
void createBonusesIcons();

View File

@ -378,9 +378,9 @@ void CFlagBox::recreate()
}
}
void CFlagBox::clickRight(tribool down, bool previousState)
void CFlagBox::showPopupWindow()
{
if(down && SEL->getMapInfo())
if(SEL->getMapInfo())
GH.windows().createAndPushWindow<CFlagBoxTooltipBox>(iconsTeamFlags);
}

View File

@ -135,7 +135,7 @@ class CFlagBox : public CIntObject
public:
CFlagBox(const Rect & rect);
void recreate();
void clickRight(tribool down, bool previousState) override;
void showPopupWindow() override;
void showTeamsPopup();
class CFlagBoxTooltipBox : public CWindowObject

View File

@ -432,18 +432,15 @@ void OptionsTab::SelectedBox::update()
subtitle->setText(getName());
}
void OptionsTab::SelectedBox::clickRight(tribool down, bool previousState)
void OptionsTab::SelectedBox::showPopupWindow()
{
if(down)
{
// cases when we do not need to display a message
if(settings.castle == -2 && CPlayerSettingsHelper::type == TOWN)
return;
if(settings.hero == -2 && !SEL->getPlayerInfo(settings.color.getNum()).hasCustomMainHero() && CPlayerSettingsHelper::type == HERO)
return;
// cases when we do not need to display a message
if(settings.castle == -2 && CPlayerSettingsHelper::type == TOWN)
return;
if(settings.hero == -2 && !SEL->getPlayerInfo(settings.color.getNum()).hasCustomMainHero() && CPlayerSettingsHelper::type == HERO)
return;
GH.windows().createAndPushWindow<CPlayerOptionTooltipBox>(*this);
}
GH.windows().createAndPushWindow<CPlayerOptionTooltipBox>(*this);
}
void OptionsTab::SelectedBox::scrollBy(int distance)

View File

@ -101,7 +101,7 @@ public:
std::shared_ptr<CLabel> subtitle;
SelectedBox(Point position, PlayerSettings & settings, SelType type);
void clickRight(tribool down, bool previousState) override;
void showPopupWindow() override;
void scrollBy(int distance) override;
void update();

View File

@ -20,7 +20,7 @@
#include "../../lib/filesystem/Filesystem.h"
CreditsScreen::CreditsScreen(Rect rect)
: CIntObject(LCLICK | RCLICK), positionCounter(0)
: CIntObject(LCLICK), positionCounter(0)
{
pos.w = rect.w;
pos.h = rect.h;
@ -43,15 +43,10 @@ void CreditsScreen::show(Canvas & to)
//end of credits, close this screen
if(credits->textSize.y + 600 < positionCounter / 2)
clickRight(false, false);
clickLeft(false, false);
}
void CreditsScreen::clickLeft(tribool down, bool previousState)
{
clickRight(down, previousState);
}
void CreditsScreen::clickRight(tribool down, bool previousState)
{
CTabbedInt * menu = dynamic_cast<CTabbedInt *>(parent);
assert(menu);

View File

@ -22,5 +22,4 @@ public:
CreditsScreen(Rect rect);
void show(Canvas & to) override;
void clickLeft(tribool down, bool previousState) override;
void clickRight(tribool down, bool previousState) override;
};

View File

@ -55,11 +55,11 @@ void MapViewActions::clickLeft(tribool down, bool previousState)
adventureInt->onTileLeftClicked(tile);
}
void MapViewActions::clickRight(tribool down, bool previousState)
void MapViewActions::showPopupWindow()
{
int3 tile = model->getTileAtPoint(GH.getCursorPosition() - pos.topLeft());
if(down && context->isInMap(tile))
if(context->isInMap(tile))
adventureInt->onTileRightClicked(tile);
}

View File

@ -32,7 +32,7 @@ public:
void setContext(const std::shared_ptr<IMapRendererContext> & context);
void clickLeft(tribool down, bool previousState) override;
void clickRight(tribool down, bool previousState) override;
void showPopupWindow() override;
void gesturePanning(const Point & initialPosition, const Point & currentPosition, const Point & lastUpdateDistance) override;
void gesturePinch(const Point & centerPosition, double lastUpdateFactor) override;
void hover(bool on) override;

View File

@ -199,9 +199,9 @@ void CButton::clickLeft(tribool down, bool previousState)
}
}
void CButton::clickRight(tribool down, bool previousState)
void CButton::showPopupWindow()
{
if(down && helpBox.size()) //there is no point to show window with nothing inside...
if(helpBox.size()) //there is no point to show window with nothing inside...
CRClickPopup::createAndPush(helpBox);
}

View File

@ -102,7 +102,7 @@ public:
void setPlayerColor(PlayerColor player);
/// CIntObject overrides
void clickRight(tribool down, bool previousState) override;
void showPopupWindow() override;
void clickLeft(tribool down, bool previousState) override;
void hover (bool on) override;
void showAll(Canvas & to) override;

View File

@ -72,11 +72,6 @@ void CArtPlace::clickLeft(tribool down, bool previousState)
LRClickableAreaWTextComp::clickLeft(down, previousState);
}
void CArtPlace::clickRight(tribool down, bool previousState)
{
LRClickableAreaWTextComp::clickRight(down, previousState);
}
const CArtifactInstance * CArtPlace::getArt()
{
return ourArt;
@ -132,10 +127,10 @@ void CCommanderArtPlace::clickLeft(tribool down, bool previousState)
LOCPLINT->showYesNoDialog(CGI->generaltexth->translate("vcmi.commanderWindow.artifactMessage"), [this]() { returnArtToHeroCallback(); }, []() {});
}
void CCommanderArtPlace::clickRight(tribool down, bool previousState)
void CCommanderArtPlace::showPopupWindow()
{
if(ourArt && text.size() && down)
CArtPlace::clickRight(down, previousState);
if(ourArt && text.size())
CArtPlace::showPopupWindow();
}
void CCommanderArtPlace::setArtifact(const CArtifactInstance * art)
@ -197,13 +192,10 @@ void CHeroArtPlace::clickLeft(tribool down, bool previousState)
leftClickCallback(*this);
}
void CHeroArtPlace::clickRight(tribool down, bool previousState)
void CHeroArtPlace::showPopupWindow()
{
if(down)
{
if(rightClickCallback)
rightClickCallback(*this);
}
if(rightClickCallback)
rightClickCallback(*this);
}
void CHeroArtPlace::showAll(Canvas & to)

View File

@ -42,7 +42,6 @@ protected:
public:
CArtPlace(Point position, const CArtifactInstance * Art = nullptr);
void clickLeft(tribool down, bool previousState) override;
void clickRight(tribool down, bool previousState) override;
const CArtifactInstance * getArt();
virtual void setArtifact(const CArtifactInstance * art)=0;
@ -60,7 +59,7 @@ protected:
public:
CCommanderArtPlace(Point position, const CGHeroInstance * commanderOwner, ArtifactPosition artSlot, const CArtifactInstance * Art = nullptr);
void clickLeft(tribool down, bool previousState) override;
void clickRight(tribool down, bool previousState) override;
void showPopupWindow() override;
void setArtifact(const CArtifactInstance * art) override;
};
@ -79,7 +78,7 @@ public:
void selectSlot(bool on);
bool isMarked() const;
void clickLeft(tribool down, bool previousState) override;
void clickRight(tribool down, bool previousState) override;
void showPopupWindow() override;
void showAll(Canvas & to) override;
void setArtifact(const CArtifactInstance * art) override;
void addCombinedArtInfo(std::map<const CArtifact*, int> & arts);

View File

@ -258,9 +258,9 @@ void CComponent::setSurface(std::string defName, int imgPos)
image = std::make_shared<CAnimImage>(defName, imgPos);
}
void CComponent::clickRight(tribool down, bool previousState)
void CComponent::showPopupWindow()
{
if(down && !getDescription().empty())
if(!getDescription().empty())
CRClickPopup::createAndPush(getDescription());
}

View File

@ -65,7 +65,7 @@ public:
CComponent(Etype Type, int Subtype, int Val = 0, ESize imageSize=large, EFonts font = FONT_SMALL);
CComponent(const Component &c, ESize imageSize=large, EFonts font = FONT_SMALL);
void clickRight(tribool down, bool previousState) override; //call-in
void showPopupWindow() override; //call-in
};
/// component that can be selected or deselected

View File

@ -286,9 +286,9 @@ bool CGarrisonSlot::mustForceReselection() const
return false;
}
void CGarrisonSlot::clickRight(tribool down, bool previousState)
void CGarrisonSlot::showPopupWindow()
{
if(creature && down)
if(creature)
{
GH.windows().createAndPushWindow<CStackWindow>(myStack, true);
}

View File

@ -58,7 +58,7 @@ public:
bool our() const;
SlotID getSlot() const { return ID; }
bool ally() const;
void clickRight(tribool down, bool previousState) override;
void showPopupWindow() override;
void clickLeft(tribool down, bool previousState) override;
void update();
CGarrisonSlot(CGarrisonInt *Owner, int x, int y, SlotID IID, EGarrisonType Upg=EGarrisonType::UP, const CStackInstance * creature_ = nullptr);

View File

@ -200,7 +200,7 @@ void CWindowWithArtifacts::rightClickArtPlaceHero(CArtifactsOfHeroBase & artsIns
return;
}
if(artPlace.text.size())
artPlace.LRClickableAreaWTextComp::clickRight(boost::logic::tribool::true_value, false);
artPlace.LRClickableAreaWTextComp::showPopupWindow();
}
}
// Altar window, Market window right click handler
@ -209,7 +209,7 @@ void CWindowWithArtifacts::rightClickArtPlaceHero(CArtifactsOfHeroBase & artsIns
std::is_same_v<decltype(artSetWeak), std::weak_ptr<CArtifactsOfHeroMarket>>)
{
if(artPlace.getArt() && artPlace.text.size())
artPlace.LRClickableAreaWTextComp::clickRight(boost::logic::tribool::true_value, false);
artPlace.LRClickableAreaWTextComp::showPopupWindow();
}
}, artSetWeak.value());
}

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)
{

View File

@ -49,7 +49,7 @@ public:
void init();
virtual void clickLeft(tribool down, bool previousState) override;
virtual void clickRight(tribool down, bool previousState) override;
virtual void showPopupWindow() override;
};
/// base class for hero/town/garrison tooltips
@ -136,7 +136,6 @@ public:
CHeroArea(int x, int y, const CGHeroInstance * _hero);
void clickLeft(tribool down, bool previousState) override;
void clickRight(tribool down, bool previousState) override;
void hover(bool on) override;
};
@ -147,7 +146,7 @@ public:
int baseType;
int bonusValue;
virtual void clickLeft(tribool down, bool previousState) override;
virtual void clickRight(tribool down, bool previousState) override;
virtual void showPopupWindow() override;
LRClickableAreaWTextComp(const Rect &Pos = Rect(0,0,0,0), int BaseType = -1);
std::shared_ptr<CComponent> createComponent() const;
@ -159,7 +158,6 @@ class LRClickableAreaOpenTown: public LRClickableAreaWTextComp
public:
const CGTownInstance * town;
void clickLeft(tribool down, bool previousState) override;
void clickRight(tribool down, bool previousState) override;
LRClickableAreaOpenTown(const Rect & Pos, const CGTownInstance * Town);
};

View File

@ -141,9 +141,9 @@ void CBuildingRect::clickLeft(tribool down, bool previousState)
}
}
void CBuildingRect::clickRight(tribool down, bool previousState)
void CBuildingRect::showPopupWindow()
{
if((!area) || (!((bool)down)) || (this!=parent->selectedBuilding) || getBuilding() == nullptr)
if((!area) || (this!=parent->selectedBuilding) || getBuilding() == nullptr)
return;
if( !area->isTransparent(GH.getCursorPosition() - pos.topLeft()) ) //inside building image
{
@ -415,9 +415,9 @@ void CHeroGSlot::clickLeft(tribool down, bool previousState)
}
}
void CHeroGSlot::clickRight(tribool down, bool previousState)
void CHeroGSlot::showPopupWindow()
{
if(hero && down)
if(hero)
{
GH.windows().createAndPushWindow<CInfoBoxPopup>(Point(pos.x + 175, pos.y + 100), hero);
}
@ -1089,15 +1089,12 @@ std::string CCreaInfo::genGrowthText()
return descr;
}
void CCreaInfo::clickRight(tribool down, bool previousState)
void CCreaInfo::showPopupWindow()
{
if(down)
{
if (showAvailable)
GH.windows().createAndPushWindow<CDwellingInfoBox>(GH.screenDimensions().x / 2, GH.screenDimensions().y / 2, town, level);
else
CRClickPopup::createAndPush(genGrowthText(), std::make_shared<CComponent>(CComponent::creature, creature->getId()));
}
if (showAvailable)
GH.windows().createAndPushWindow<CDwellingInfoBox>(GH.screenDimensions().x / 2, GH.screenDimensions().y / 2, town, level);
else
CRClickPopup::createAndPush(genGrowthText(), std::make_shared<CComponent>(CComponent::creature, creature->getId()));
}
bool CCreaInfo::getShowAvailable()
@ -1144,9 +1141,9 @@ void CTownInfo::hover(bool on)
}
}
void CTownInfo::clickRight(tribool down, bool previousState)
void CTownInfo::showPopupWindow()
{
if(building && down)
if(building)
{
auto c = std::make_shared<CComponent>(CComponent::building, building->town->faction->getIndex(), building->bid);
CRClickPopup::createAndPush(CInfoWindow::genText(building->getNameTranslated(), building->getDescriptionTranslated()), c);
@ -1396,10 +1393,9 @@ void CHallInterface::CBuildingBox::clickLeft(tribool down, bool previousState)
GH.windows().createAndPushWindow<CBuildWindow>(town,building,state,0);
}
void CHallInterface::CBuildingBox::clickRight(tribool down, bool previousState)
void CHallInterface::CBuildingBox::showPopupWindow()
{
if(down)
GH.windows().createAndPushWindow<CBuildWindow>(town,building,state,1);
GH.windows().createAndPushWindow<CBuildWindow>(town,building,state,1);
}
CHallInterface::CHallInterface(const CGTownInstance * Town):
@ -1668,7 +1664,7 @@ CFortScreen::RecruitArea::RecruitArea(int posX, int posY, const CGTownInstance *
pos.h = 126;
if(!town->creatures[level].second.empty())
addUsedEvents(LCLICK | RCLICK | HOVER);//Activate only if dwelling is present
addUsedEvents(LCLICK | HOVER);//Activate only if dwelling is present
icons = std::make_shared<CPicture>("TPCAINFO", 261, 3);
@ -1758,11 +1754,6 @@ void CFortScreen::RecruitArea::clickLeft(tribool down, bool previousState)
LOCPLINT->castleInt->builds->enterDwelling(level);
}
void CFortScreen::RecruitArea::clickRight(tribool down, bool previousState)
{
clickLeft(down, false); //r-click does same as l-click - opens recr. window
}
CMageGuildScreen::CMageGuildScreen(CCastleInterface * owner,std::string imagem)
: CStatusbarWindow(BORDERED, imagem)
{
@ -1819,10 +1810,9 @@ void CMageGuildScreen::Scroll::clickLeft(tribool down, bool previousState)
LOCPLINT->showInfoDialog(spell->getDescriptionTranslated(0), std::make_shared<CComponent>(CComponent::spell, spell->id));
}
void CMageGuildScreen::Scroll::clickRight(tribool down, bool previousState)
void CMageGuildScreen::Scroll::showPopupWindow()
{
if(down)
CRClickPopup::createAndPush(spell->getDescriptionTranslated(0), std::make_shared<CComponent>(CComponent::spell, spell->id));
CRClickPopup::createAndPush(spell->getDescriptionTranslated(0), std::make_shared<CComponent>(CComponent::spell, spell->id));
}
void CMageGuildScreen::Scroll::hover(bool on)

View File

@ -67,7 +67,7 @@ public:
bool operator<(const CBuildingRect & p2) const;
void hover(bool on) override;
void clickLeft(tribool down, bool previousState) override;
void clickRight(tribool down, bool previousState) override;
void showPopupWindow() override;
void mouseMoved (const Point & cursorPosition) override;
void tick(uint32_t msPassed) override;
void show(Canvas & to) override;
@ -112,7 +112,7 @@ public:
void hover (bool on) override;
void clickLeft(tribool down, bool previousState) override;
void clickRight(tribool down, bool previousState) override;
void showPopupWindow() override;
void deactivate() override;
};
@ -192,7 +192,7 @@ public:
void update();
void hover(bool on) override;
void clickLeft(tribool down, bool previousState) override;
void clickRight(tribool down, bool previousState) override;
void showPopupWindow() override;
bool getShowAvailable();
};
@ -207,7 +207,7 @@ public:
CTownInfo(int posX, int posY, const CGTownInstance * town, bool townHall);
void hover(bool on) override;
void clickRight(tribool down, bool previousState) override;
void showPopupWindow() override;
};
/// Class which manages the castle window
@ -274,7 +274,7 @@ class CHallInterface : public CStatusbarWindow
CBuildingBox(int x, int y, const CGTownInstance * Town, const CBuilding * Building);
void hover(bool on) override;
void clickLeft(tribool down, bool previousState) override;
void clickRight(tribool down, bool previousState) override;
void showPopupWindow() override;
};
const CGTownInstance * town;
@ -346,7 +346,6 @@ class CFortScreen : public CStatusbarWindow
void creaturesChangedEventHandler();
void hover(bool on) override;
void clickLeft(tribool down, bool previousState) override;
void clickRight(tribool down, bool previousState) override;
};
std::shared_ptr<CLabel> title;
std::vector<std::shared_ptr<RecruitArea>> recAreas;
@ -372,7 +371,7 @@ class CMageGuildScreen : public CStatusbarWindow
public:
Scroll(Point position, const CSpell *Spell);
void clickLeft(tribool down, bool previousState) override;
void clickRight(tribool down, bool previousState) override;
void showPopupWindow() override;
void hover(bool on) override;
};
std::shared_ptr<CPicture> window;

View File

@ -120,12 +120,6 @@ void CCommanderSkillIcon::clickLeft(tribool down, bool previousState)
callback();
}
void CCommanderSkillIcon::clickRight(tribool down, bool previousState)
{
if(down)
LRClickableAreaWText::clickRight(down, previousState);
}
static std::string skillToFile(int skill, int level, bool selected)
{
// FIXME: is this a correct hadling?

View File

@ -38,7 +38,6 @@ public:
std::function<void()> callback;
void clickLeft(tribool down, bool previousState) override;
void clickRight(tribool down, bool previousState) override;
void setObject(std::shared_ptr<CIntObject> object);
};

View File

@ -90,18 +90,15 @@ InfoBox::InfoBox(Point position, InfoPos Pos, InfoSize Size, std::shared_ptr<IIn
InfoBox::~InfoBox() = default;
void InfoBox::clickRight(tribool down, bool previousState)
void InfoBox::showPopupWindow()
{
if (down)
{
std::shared_ptr<CComponent> comp;
std::string text;
data->prepareMessage(text, comp);
if (comp)
CRClickPopup::createAndPush(text, CInfoWindow::TCompsInfo(1, comp));
else if (!text.empty())
CRClickPopup::createAndPush(text);
}
std::shared_ptr<CComponent> comp;
std::string text;
data->prepareMessage(text, comp);
if (comp)
CRClickPopup::createAndPush(text, CInfoWindow::TCompsInfo(1, comp));
else if (!text.empty())
CRClickPopup::createAndPush(text);
}
void InfoBox::clickLeft(tribool down, bool previousState)

View File

@ -73,7 +73,7 @@ public:
InfoBox(Point position, InfoPos Pos, InfoSize Size, std::shared_ptr<IInfoBoxData> Data);
~InfoBox();
void clickRight(tribool down, bool previousState) override;
void showPopupWindow() override;
void clickLeft(tribool down, bool previousState) override;
//Update object if data may have changed

View File

@ -57,10 +57,9 @@ void CSpellWindow::InteractiveArea::clickLeft(tribool down, bool previousState)
onLeft();
}
void CSpellWindow::InteractiveArea::clickRight(tribool down, bool previousState)
void CSpellWindow::InteractiveArea::showPopupWindow()
{
if (down)
CRClickPopup::createAndPush(helpText);
CRClickPopup::createAndPush(helpText);
}
void CSpellWindow::InteractiveArea::hover(bool on)
@ -541,9 +540,9 @@ void CSpellWindow::SpellArea::clickLeft(tribool down, bool previousState)
}
}
void CSpellWindow::SpellArea::clickRight(tribool down, bool previousState)
void CSpellWindow::SpellArea::showPopupWindow()
{
if(mySpell && down)
if(mySpell)
{
std::string dmgInfo;
auto causedDmg = owner->myInt->cb->estimateSpellDamage(mySpell, owner->myHero);

View File

@ -45,7 +45,7 @@ class CSpellWindow : public CWindowObject
void setSpell(const CSpell * spell);
void clickLeft(tribool down, bool previousState) override;
void clickRight(tribool down, bool previousState) override;
void showPopupWindow() override;
void hover(bool on) override;
};
@ -58,7 +58,7 @@ class CSpellWindow : public CWindowObject
std::string helpText;
public:
void clickLeft(tribool down, bool previousState) override;
void clickRight(tribool down, bool previousState) override;
void showPopupWindow() override;
void hover(bool on) override;
InteractiveArea(const Rect &myRect, std::function<void()> funcL, int helpTextId, CSpellWindow * _owner);

View File

@ -263,12 +263,10 @@ void CTradeWindow::CTradeableItem::hover(bool on)
}
}
void CTradeWindow::CTradeableItem::clickRight(tribool down, bool previousState)
void CTradeWindow::CTradeableItem::showPopupWindow()
{
if(down)
switch(type)
{
switch(type)
{
case CREATURE:
case CREATURE_PLACEHOLDER:
//GH.statusbar->print(boost::str(boost::format(CGI->generaltexth->allTexts[481]) % CGI->creh->objects[id]->namePl));
@ -279,7 +277,6 @@ void CTradeWindow::CTradeableItem::clickRight(tribool down, bool previousState)
if(id >= 0)
CRClickPopup::createAndPush(CGI->artifacts()->getByIndex(id)->getDescriptionTranslated());
break;
}
}
}

View File

@ -56,7 +56,7 @@ public:
void showAllAt(const Point & dstPos, const std::string & customSub, Canvas & to);
void clickRight(tribool down, bool previousState) override;
void showPopupWindow() override;
void hover(bool on) override;
void showAll(Canvas & to) override;
void clickLeft(tribool down, bool previousState) override;

View File

@ -235,7 +235,7 @@ void CWindowObject::showAll(Canvas & to)
CMessage::drawBorder(color, to.getInternalSurface(), pos.w+28, pos.h+29, pos.x-14, pos.y-15);
}
void CWindowObject::clickRight(tribool down, bool previousState)
void CWindowObject::closePopupWindow()
{
close();
CCS->curh->show();

View File

@ -28,7 +28,7 @@ protected:
std::shared_ptr<CPicture> background;
//Used only if RCLICK_POPUP was set
void clickRight(tribool down, bool previousState) override;
void closePopupWindow() override;
//To display border
void updateShadow();
void setBackground(std::string filename);

View File

@ -123,8 +123,7 @@ CreaturePurchaseCard::CCreatureClickArea::CCreatureClickArea(const Point & posit
pos.h = CREATURE_HEIGHT;
}
void CreaturePurchaseCard::CCreatureClickArea::clickRight(tribool down, bool previousState)
void CreaturePurchaseCard::CCreatureClickArea::showPopupWindow()
{
if (down)
GH.windows().createAndPushWindow<CStackWindow>(creatureOnTheCard, true);
GH.windows().createAndPushWindow<CStackWindow>(creatureOnTheCard, true);
}

View File

@ -49,7 +49,7 @@ private:
{
public:
CCreatureClickArea(const Point & pos, const std::shared_ptr<CCreaturePic> creaturePic, const CCreature * creatureOnTheCard);
void clickRight(tribool down, bool previousState) override;
void showPopupWindow() override;
const CCreature * creatureOnTheCard;
// These are obtained by guessing and checking. I'm not sure how the other numbers

View File

@ -100,10 +100,9 @@ void CRecruitmentWindow::CCreatureCard::clickLeft(tribool down, bool previousSta
parent->select(this->shared_from_this());
}
void CRecruitmentWindow::CCreatureCard::clickRight(tribool down, bool previousState)
void CRecruitmentWindow::CCreatureCard::showPopupWindow()
{
if(down)
GH.windows().createAndPushWindow<CStackWindow>(creature, true);
GH.windows().createAndPushWindow<CStackWindow>(creature, true);
}
void CRecruitmentWindow::CCreatureCard::showAll(Canvas & to)
@ -557,9 +556,9 @@ void CTavernWindow::HeroPortrait::clickLeft(tribool down, bool previousState)
*_sel = _id;
}
void CTavernWindow::HeroPortrait::clickRight(tribool down, bool previousState)
void CTavernWindow::HeroPortrait::showPopupWindow()
{
if(h && down)
if(h)
GH.windows().createAndPushWindow<CRClickPopupInt>(std::make_shared<CHeroWindow>(h));
}
@ -1266,12 +1265,9 @@ void CUniversityWindow::CItem::clickLeft(tribool down, bool previousState)
}
}
void CUniversityWindow::CItem::clickRight(tribool down, bool previousState)
void CUniversityWindow::CItem::showPopupWindow()
{
if(down)
{
CRClickPopup::createAndPush(CGI->skillh->getByIndex(ID)->getDescriptionTranslated(1), std::make_shared<CComponent>(CComponent::secskill, ID, 1));
}
CRClickPopup::createAndPush(CGI->skillh->getByIndex(ID)->getDescriptionTranslated(1), std::make_shared<CComponent>(CComponent::secskill, ID, 1));
}
void CUniversityWindow::CItem::hover(bool on)

View File

@ -60,7 +60,7 @@ class CRecruitmentWindow : public CStatusbarWindow
CCreatureCard(CRecruitmentWindow * window, const CCreature * crea, int totalAmount);
void clickLeft(tribool down, bool previousState) override;
void clickRight(tribool down, bool previousState) override;
void showPopupWindow() override;
void showAll(Canvas & to) override;
};
@ -206,7 +206,7 @@ public:
const CGHeroInstance * h;
void clickLeft(tribool down, bool previousState) override;
void clickRight(tribool down, bool previousState) override;
void showPopupWindow() override;
void hover (bool on) override;
HeroPortrait(int & sel, int id, int x, int y, const CGHeroInstance * H);
@ -418,7 +418,7 @@ class CUniversityWindow : public CStatusbarWindow
void showAll(Canvas & to) override;
void clickLeft(tribool down, bool previousState) override;
void clickRight(tribool down, bool previousState) override;
void showPopupWindow() override;
void hover(bool on) override;
int state();//0=can't learn, 1=learned, 2=can learn
CItem(CUniversityWindow * _parent, int _ID, int X, int Y);

View File

@ -289,10 +289,8 @@ void CInfoPopup::init(int x, int y)
}
void CRClickPopup::clickRight(tribool down, bool previousState)
void CRClickPopup::closePopupWindow()
{
if(down)
return;
close();
}

View File

@ -76,7 +76,7 @@ class CRClickPopup : public WindowBase
{
public:
virtual void close();
void clickRight(tribool down, bool previousState) override;
void closePopupWindow() override;
CRClickPopup();
virtual ~CRClickPopup();