mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
Merge pull request #4355 from IvanSavenko/mp_fixes
Fix infinitely updating simultaneous turns slider
This commit is contained in:
commit
4acfa38d63
@ -340,10 +340,10 @@ void OptionsTabBase::recreate(bool campaign)
|
||||
|
||||
//Simultaneous turns
|
||||
if(auto turnSlider = widget<CSlider>("simturnsDurationMin"))
|
||||
turnSlider->setValue(SEL->getStartInfo()->simturnsInfo.requiredTurns);
|
||||
turnSlider->setValue(SEL->getStartInfo()->simturnsInfo.requiredTurns, false);
|
||||
|
||||
if(auto turnSlider = widget<CSlider>("simturnsDurationMax"))
|
||||
turnSlider->setValue(SEL->getStartInfo()->simturnsInfo.optionalTurns);
|
||||
turnSlider->setValue(SEL->getStartInfo()->simturnsInfo.optionalTurns, false);
|
||||
|
||||
if(auto w = widget<CLabel>("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<CLabel>("labelTurnDurationValue"))
|
||||
w->setText(CGI->generaltexth->turnDurations[idx]);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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<void(int)> & Moved, const std::vector<int> & values, int Value, Orientation orientation, EStyle style);
|
||||
|
Loading…
Reference in New Issue
Block a user