mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-23 00:28:08 +02:00
using CHeroArea
This commit is contained in:
@ -121,9 +121,10 @@ void LRClickableAreaWTextComp::showPopupWindow(const Point & cursorPosition)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CHeroArea::CHeroArea(int x, int y, const CGHeroInstance * hero)
|
CHeroArea::CHeroArea(int x, int y, const CGHeroInstance * hero)
|
||||||
: CIntObject(LCLICK | HOVER),
|
: CIntObject(LCLICK | SHOW_POPUP | HOVER),
|
||||||
hero(hero),
|
hero(hero),
|
||||||
clickFunctor(nullptr)
|
clickFunctor(nullptr),
|
||||||
|
clickRFunctor(nullptr)
|
||||||
{
|
{
|
||||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||||
|
|
||||||
@ -147,12 +148,23 @@ void CHeroArea::addClickCallback(ClickFunctor callback)
|
|||||||
clickFunctor = callback;
|
clickFunctor = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CHeroArea::addRClickCallback(ClickFunctor callback)
|
||||||
|
{
|
||||||
|
clickRFunctor = callback;
|
||||||
|
}
|
||||||
|
|
||||||
void CHeroArea::clickPressed(const Point & cursorPosition)
|
void CHeroArea::clickPressed(const Point & cursorPosition)
|
||||||
{
|
{
|
||||||
if(clickFunctor)
|
if(clickFunctor)
|
||||||
clickFunctor();
|
clickFunctor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CHeroArea::showPopupWindow(const Point & cursorPosition)
|
||||||
|
{
|
||||||
|
if(clickRFunctor)
|
||||||
|
clickRFunctor();
|
||||||
|
}
|
||||||
|
|
||||||
void CHeroArea::hover(bool on)
|
void CHeroArea::hover(bool on)
|
||||||
{
|
{
|
||||||
if (on && hero)
|
if (on && hero)
|
||||||
|
@ -190,12 +190,15 @@ public:
|
|||||||
|
|
||||||
CHeroArea(int x, int y, const CGHeroInstance * hero);
|
CHeroArea(int x, int y, const CGHeroInstance * hero);
|
||||||
void addClickCallback(ClickFunctor callback);
|
void addClickCallback(ClickFunctor callback);
|
||||||
|
void addRClickCallback(ClickFunctor callback);
|
||||||
void clickPressed(const Point & cursorPosition) override;
|
void clickPressed(const Point & cursorPosition) override;
|
||||||
|
void showPopupWindow(const Point & cursorPosition) override;
|
||||||
void hover(bool on) override;
|
void hover(bool on) override;
|
||||||
private:
|
private:
|
||||||
const CGHeroInstance * hero;
|
const CGHeroInstance * hero;
|
||||||
std::shared_ptr<CAnimImage> portrait;
|
std::shared_ptr<CAnimImage> portrait;
|
||||||
ClickFunctor clickFunctor;
|
ClickFunctor clickFunctor;
|
||||||
|
ClickFunctor clickRFunctor;
|
||||||
ClickFunctor showPopupHandler;
|
ClickFunctor showPopupHandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
#include "../widgets/Slider.h"
|
#include "../widgets/Slider.h"
|
||||||
#include "../widgets/TextControls.h"
|
#include "../widgets/TextControls.h"
|
||||||
#include "../widgets/ObjectLists.h"
|
#include "../widgets/ObjectLists.h"
|
||||||
#include "../widgets/MiscWidgets.h"
|
|
||||||
|
|
||||||
#include "../render/Canvas.h"
|
#include "../render/Canvas.h"
|
||||||
#include "../render/CAnimation.h"
|
#include "../render/CAnimation.h"
|
||||||
@ -410,8 +409,9 @@ CLevelWindow::CLevelWindow(const CGHeroInstance * hero, PrimarySkill pskill, std
|
|||||||
box = std::make_shared<CComponentBox>(comps, Rect(75, 300, pos.w - 150, 100));
|
box = std::make_shared<CComponentBox>(comps, Rect(75, 300, pos.w - 150, 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
portrait = std::make_shared<CAnimImage>(AnimationPath::builtin("PortraitsLarge"), hero->getIconIndex(), 0, 170, 66);
|
portrait = std::make_shared<CHeroArea>(170, 66, hero);
|
||||||
portraitArea = std::make_shared<LRClickableArea>(Rect(170, 66, 58, 64), nullptr, [hero](){ GH.windows().createAndPushWindow<CRClickPopupInt>(std::make_shared<CHeroWindow>(hero)); });
|
portrait->addClickCallback(nullptr);
|
||||||
|
portrait->addRClickCallback([hero](){ GH.windows().createAndPushWindow<CRClickPopupInt>(std::make_shared<CHeroWindow>(hero)); });
|
||||||
ok = std::make_shared<CButton>(Point(297, 413), AnimationPath::builtin("IOKAY"), CButton::tooltip(), std::bind(&CLevelWindow::close, this), EShortcut::GLOBAL_ACCEPT);
|
ok = std::make_shared<CButton>(Point(297, 413), AnimationPath::builtin("IOKAY"), CButton::tooltip(), std::bind(&CLevelWindow::close, this), EShortcut::GLOBAL_ACCEPT);
|
||||||
|
|
||||||
//%s has gained a level.
|
//%s has gained a level.
|
||||||
|
@ -35,7 +35,7 @@ class CGStatusBar;
|
|||||||
class CTextBox;
|
class CTextBox;
|
||||||
class CGarrisonInt;
|
class CGarrisonInt;
|
||||||
class CGarrisonSlot;
|
class CGarrisonSlot;
|
||||||
class LRClickableArea;
|
class CHeroArea;
|
||||||
|
|
||||||
enum class EUserEvent;
|
enum class EUserEvent;
|
||||||
|
|
||||||
@ -130,8 +130,7 @@ public:
|
|||||||
/// Raised up level window where you can select one out of two skills
|
/// Raised up level window where you can select one out of two skills
|
||||||
class CLevelWindow : public CWindowObject
|
class CLevelWindow : public CWindowObject
|
||||||
{
|
{
|
||||||
std::shared_ptr<CAnimImage> portrait;
|
std::shared_ptr<CHeroArea> portrait;
|
||||||
std::shared_ptr<LRClickableArea> portraitArea;
|
|
||||||
std::shared_ptr<CButton> ok;
|
std::shared_ptr<CButton> ok;
|
||||||
std::shared_ptr<CLabel> mainTitle;
|
std::shared_ptr<CLabel> mainTitle;
|
||||||
std::shared_ptr<CLabel> levelTitle;
|
std::shared_ptr<CLabel> levelTitle;
|
||||||
|
Reference in New Issue
Block a user