mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
enable doubleclick
This commit is contained in:
parent
c473e65b0f
commit
1fb2a026ec
@ -459,8 +459,8 @@ CTavernWindow::CTavernWindow(const CGObjectInstance * TavernObj, const std::func
|
||||
|
||||
oldSelected = -1;
|
||||
|
||||
h1 = std::make_shared<HeroPortrait>(selected, 0, 72, 299, h[0]);
|
||||
h2 = std::make_shared<HeroPortrait>(selected, 1, 162, 299, h[1]);
|
||||
h1 = std::make_shared<HeroPortrait>(selected, 0, 72, 299, h[0], [&]() { if(!recruit->isBlocked()) recruitb(); });
|
||||
h2 = std::make_shared<HeroPortrait>(selected, 1, 162, 299, h[1], [&]() { if(!recruit->isBlocked()) recruitb(); });
|
||||
|
||||
title = std::make_shared<CLabel>(197, 32, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[37]);
|
||||
cost = std::make_shared<CLabel>(320, 328, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE, std::to_string(GameConstants::HERO_GOLD_COST));
|
||||
@ -569,15 +569,23 @@ void CTavernWindow::HeroPortrait::clickPressed(const Point & cursorPosition)
|
||||
*_sel = _id;
|
||||
}
|
||||
|
||||
void CTavernWindow::HeroPortrait::clickDouble(const Point & cursorPosition)
|
||||
{
|
||||
clickPressed(cursorPosition);
|
||||
|
||||
if(onChoose)
|
||||
onChoose();
|
||||
}
|
||||
|
||||
void CTavernWindow::HeroPortrait::showPopupWindow(const Point & cursorPosition)
|
||||
{
|
||||
if(h)
|
||||
GH.windows().createAndPushWindow<CRClickPopupInt>(std::make_shared<CHeroWindow>(h));
|
||||
}
|
||||
|
||||
CTavernWindow::HeroPortrait::HeroPortrait(int & sel, int id, int x, int y, const CGHeroInstance * H)
|
||||
: CIntObject(LCLICK | SHOW_POPUP | HOVER),
|
||||
h(H), _sel(&sel), _id(id)
|
||||
CTavernWindow::HeroPortrait::HeroPortrait(int & sel, int id, int x, int y, const CGHeroInstance * H, std::function<void()> OnChoose)
|
||||
: CIntObject(LCLICK | DOUBLECLICK | SHOW_POPUP | HOVER),
|
||||
h(H), _sel(&sel), _id(id), onChoose(OnChoose)
|
||||
{
|
||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||
h = H;
|
||||
|
@ -206,10 +206,13 @@ public:
|
||||
std::string description; // "XXX is a level Y ZZZ with N artifacts"
|
||||
const CGHeroInstance * h;
|
||||
|
||||
std::function<void()> onChoose;
|
||||
|
||||
void clickPressed(const Point & cursorPosition) override;
|
||||
void clickDouble(const Point & cursorPosition) override;
|
||||
void showPopupWindow(const Point & cursorPosition) override;
|
||||
void hover (bool on) override;
|
||||
HeroPortrait(int & sel, int id, int x, int y, const CGHeroInstance * H);
|
||||
HeroPortrait(int & sel, int id, int x, int y, const CGHeroInstance * H, std::function<void()> OnChoose = nullptr);
|
||||
|
||||
private:
|
||||
int *_sel;
|
||||
|
Loading…
Reference in New Issue
Block a user