diff --git a/client/lobby/OptionsTabBase.cpp b/client/lobby/OptionsTabBase.cpp index c4d728d00..17936a6d0 100644 --- a/client/lobby/OptionsTabBase.cpp +++ b/client/lobby/OptionsTabBase.cpp @@ -340,10 +340,10 @@ void OptionsTabBase::recreate(bool campaign) //Simultaneous turns if(auto turnSlider = widget("simturnsDurationMin")) - turnSlider->setValue(SEL->getStartInfo()->simturnsInfo.requiredTurns); + turnSlider->setValue(SEL->getStartInfo()->simturnsInfo.requiredTurns, false); if(auto turnSlider = widget("simturnsDurationMax")) - turnSlider->setValue(SEL->getStartInfo()->simturnsInfo.optionalTurns); + turnSlider->setValue(SEL->getStartInfo()->simturnsInfo.optionalTurns, false); if(auto w = widget("labelSimturnsDurationValueMin")) w->setText(generateSimturnsDurationText(SEL->getStartInfo()->simturnsInfo.requiredTurns)); @@ -388,7 +388,7 @@ void OptionsTabBase::recreate(bool campaign) auto & tpreset = variables["timerPresets"].Vector()[idx]; if(tpreset.Vector().at(1).Integer() == turnTimerRemote.turnTimer / 1000) { - turnSlider->scrollTo(idx); + turnSlider->scrollTo(idx, false); if(auto w = widget("labelTurnDurationValue")) w->setText(CGI->generaltexth->turnDurations[idx]); } diff --git a/client/widgets/Slider.cpp b/client/widgets/Slider.cpp index 2c866ff47..e51896cdc 100644 --- a/client/widgets/Slider.cpp +++ b/client/widgets/Slider.cpp @@ -70,7 +70,7 @@ int CSlider::getValue() const return value; } -void CSlider::setValue(int to) +void CSlider::setValue(int to, bool callCallbacks) { scrollTo(value); } @@ -113,7 +113,7 @@ void CSlider::updateSliderPos() } } -void CSlider::scrollTo(int to) +void CSlider::scrollTo(int to, bool callCallbacks) { vstd::amax(to, 0); vstd::amin(to, positions); @@ -125,7 +125,8 @@ void CSlider::scrollTo(int to) updateSliderPos(); - moved(getValue()); + if (callCallbacks) + moved(getValue()); } void CSlider::clickPressed(const Point & cursorPosition) @@ -321,7 +322,7 @@ int SliderNonlinear::getValue() const return scaledValues.at(CSlider::getValue()); } -void SliderNonlinear::setValue(int to) +void SliderNonlinear::setValue(int to, bool callCallbacks) { size_t nearest = 0; @@ -334,5 +335,5 @@ void SliderNonlinear::setValue(int to) nearest = i; } - scrollTo(nearest); + scrollTo(nearest, callCallbacks); } diff --git a/client/widgets/Slider.h b/client/widgets/Slider.h index 88a580187..6cbba6823 100644 --- a/client/widgets/Slider.h +++ b/client/widgets/Slider.h @@ -52,14 +52,14 @@ public: void clearScrollBounds(); /// Value modifiers - void scrollTo(int value); + void scrollTo(int value, bool callCallbacks = true); void scrollBy(int amount) override; void scrollToMin(); void scrollToMax(); /// Amount modifier void setAmount(int to); - virtual void setValue(int to); + virtual void setValue(int to, bool callCallbacks = true); /// Accessors int getAmount() const; @@ -95,7 +95,7 @@ class SliderNonlinear : public CSlider using CSlider::setAmount; // make private public: - void setValue(int to) override; + void setValue(int to, bool callCallbacks) override; int getValue() const override; SliderNonlinear(Point position, int length, const std::function & Moved, const std::vector & values, int Value, Orientation orientation, EStyle style);