mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
allow double click for bonus selection
This commit is contained in:
parent
6179521364
commit
7ae8514657
@ -350,7 +350,10 @@ void CBonusSelection::createBonusesIcons()
|
||||
break;
|
||||
}
|
||||
|
||||
std::shared_ptr<CToggleButton> bonusButton = std::make_shared<CToggleButton>(Point(475 + i * 68, 455), AnimationPath::builtin("campaignBonusSelection"), CButton::tooltip(desc.toString(), desc.toString()));
|
||||
std::shared_ptr<CToggleButton> bonusButton = std::make_shared<CToggleButton>(Point(475 + i * 68, 455), AnimationPath::builtin("campaignBonusSelection"), CButton::tooltip(desc.toString(), desc.toString()), nullptr, EShortcut::NONE, false, [this](){
|
||||
if(buttonStart->isActive() && !buttonStart->isBlocked())
|
||||
CBonusSelection::startMap();
|
||||
});
|
||||
|
||||
if(picNumber != -1)
|
||||
bonusButton->setOverlay(std::make_shared<CAnimImage>(AnimationPath::builtin(picName), picNumber));
|
||||
|
@ -446,10 +446,13 @@ void CToggleBase::setAllowDeselection(bool on)
|
||||
}
|
||||
|
||||
CToggleButton::CToggleButton(Point position, const AnimationPath &defName, const std::pair<std::string, std::string> &help,
|
||||
CFunctionList<void(bool)> callback, EShortcut key, bool playerColoredButton):
|
||||
CFunctionList<void(bool)> callback, EShortcut key, bool playerColoredButton,
|
||||
CFunctionList<void()> callbackSelected):
|
||||
CButton(position, defName, help, 0, key, playerColoredButton),
|
||||
CToggleBase(callback)
|
||||
CToggleBase(callback),
|
||||
callbackSelected(callbackSelected)
|
||||
{
|
||||
addUsedEvents(DOUBLECLICK);
|
||||
}
|
||||
|
||||
void CToggleButton::doSelect(bool on)
|
||||
@ -516,6 +519,12 @@ void CToggleButton::clickCancel(const Point & cursorPosition)
|
||||
doSelect(isSelected());
|
||||
}
|
||||
|
||||
void CToggleButton::clickDouble(const Point & cursorPosition)
|
||||
{
|
||||
if(callbackSelected)
|
||||
callbackSelected();
|
||||
}
|
||||
|
||||
void CToggleGroup::addCallback(const std::function<void(int)> & callback)
|
||||
{
|
||||
onChange += callback;
|
||||
|
@ -166,13 +166,17 @@ class CToggleButton : public CButton, public CToggleBase
|
||||
void doSelect(bool on) override;
|
||||
void setEnabled(bool enabled) override;
|
||||
|
||||
CFunctionList<void()> callbackSelected;
|
||||
|
||||
public:
|
||||
CToggleButton(Point position, const AnimationPath &defName, const std::pair<std::string, std::string> &help,
|
||||
CFunctionList<void(bool)> Callback = 0, EShortcut key = {}, bool playerColoredButton = false );
|
||||
CFunctionList<void(bool)> Callback = nullptr, EShortcut key = {}, bool playerColoredButton = false,
|
||||
CFunctionList<void()> CallbackSelected = nullptr );
|
||||
|
||||
void clickPressed(const Point & cursorPosition) override;
|
||||
void clickReleased(const Point & cursorPosition) override;
|
||||
void clickCancel(const Point & cursorPosition) override;
|
||||
void clickDouble(const Point & cursorPosition) override;
|
||||
|
||||
// bring overrides into scope
|
||||
//using CButton::addCallback;
|
||||
|
Loading…
Reference in New Issue
Block a user