Skip to content

Commit

Permalink
Preferences Dialog: avoid offset-by-one handling for accl speeds
Browse files Browse the repository at this point in the history
Since the slider values started at 1, they needed to be adjusted for speed
index access. Less confusing to start at 0.
  • Loading branch information
Vultraz committed Feb 24, 2018
1 parent f722a09 commit cc3d736
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion data/gui/window/preferences/01_general.cfg
Expand Up @@ -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"
)
Expand Down
4 changes: 2 additions & 2 deletions src/gui/dialogs/preferences_dialog.cpp
Expand Up @@ -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,
Expand Down

0 comments on commit cc3d736

Please sign in to comment.