diff --git a/client/lobby/CBonusSelection.cpp b/client/lobby/CBonusSelection.cpp index e6de278b1..94cd19834 100644 --- a/client/lobby/CBonusSelection.cpp +++ b/client/lobby/CBonusSelection.cpp @@ -350,7 +350,10 @@ void CBonusSelection::createBonusesIcons() break; } - std::shared_ptr bonusButton = std::make_shared(Point(475 + i * 68, 455), AnimationPath::builtin("campaignBonusSelection"), CButton::tooltip(desc.toString(), desc.toString())); + std::shared_ptr bonusButton = std::make_shared(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(AnimationPath::builtin(picName), picNumber)); diff --git a/client/widgets/Buttons.cpp b/client/widgets/Buttons.cpp index 00063a770..2284e3764 100644 --- a/client/widgets/Buttons.cpp +++ b/client/widgets/Buttons.cpp @@ -446,10 +446,13 @@ void CToggleBase::setAllowDeselection(bool on) } CToggleButton::CToggleButton(Point position, const AnimationPath &defName, const std::pair &help, - CFunctionList callback, EShortcut key, bool playerColoredButton): + CFunctionList callback, EShortcut key, bool playerColoredButton, + CFunctionList 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 & callback) { onChange += callback; diff --git a/client/widgets/Buttons.h b/client/widgets/Buttons.h index 34d97ec83..f369473f8 100644 --- a/client/widgets/Buttons.h +++ b/client/widgets/Buttons.h @@ -166,13 +166,17 @@ class CToggleButton : public CButton, public CToggleBase void doSelect(bool on) override; void setEnabled(bool enabled) override; + CFunctionList callbackSelected; + public: CToggleButton(Point position, const AnimationPath &defName, const std::pair &help, - CFunctionList Callback = 0, EShortcut key = {}, bool playerColoredButton = false ); + CFunctionList Callback = nullptr, EShortcut key = {}, bool playerColoredButton = false, + CFunctionList 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;