Preferences Dialog: avoid offset-by-one handling for accl speeds

Since the slider values started at 1, they needed to be adjusted for speed
index access. Less confusing to start at 0.
This commit is contained in:
Charles Dang 2018-02-24 18:57:06 +11:00
parent f722a09730
commit cc3d73621a
2 changed files with 4 additions and 3 deletions

View file

@ -82,7 +82,8 @@
{_GUI_PREFERENCES_MAIN_COMPOSITE_SLIDER
( _ "Speed:")
turbo_slider (
minimum_value,maximum_value=1,12
# Starts at 0 since the slider values are used for vector index access.
minimum_value,maximum_value=0,11
step_size=1
tooltip= _ "Units move and fight speed"
)

View file

@ -368,11 +368,11 @@ void preferences_dialog::post_build(window& window)
[&](widget& w) { disable_widget_on_toggle<slider>(window, w, "turbo_slider"); }, true);
const auto accl_load = [this]()->int {
return std::distance(accl_speeds_.begin(), std::find(accl_speeds_.begin(), accl_speeds_.end(), turbo_speed())) + 1;
return std::distance(accl_speeds_.begin(), std::find(accl_speeds_.begin(), accl_speeds_.end(), turbo_speed()));
};
const auto accl_save = [this](int i) {
set_turbo_speed(accl_speeds_[i - 1]);
set_turbo_speed(accl_speeds_[i]);
};
register_integer("turbo_slider", true,