Skip to content

Commit

Permalink
MP Options Helper: fixed choice options saving indexes instead of values
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Oct 23, 2016
1 parent e7c2105 commit b1d886b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/gui/dialogs/multiplayer/mp_options_helper.cpp
Expand Up @@ -78,6 +78,11 @@ void tmp_options_helper::update_options_data_map(ttoggle_button* widget, const o
options_data_[source][widget->id()] = widget->get_value_bool();
}

void tmp_options_helper::update_options_data_map_menu_button(tmenu_button* widget, const option_source& source, const config& cfg)
{
options_data_[source][widget->id()] = cfg.child_range("item")[widget->get_value()]["value"].str();
}

void tmp_options_helper::reset_options_data(const option_source& source, bool& handled, bool& halt)
{
options_data_[source].clear();
Expand Down Expand Up @@ -193,7 +198,7 @@ void tmp_options_helper::display_custom_options(std::string&& type, const config
}

menu_button->connect_click_handler(
std::bind(&tmp_options_helper::update_options_data_map<tmenu_button>, this, menu_button, visible_options_.back()));
std::bind(&tmp_options_helper::update_options_data_map_menu_button, this, menu_button, visible_options_.back(), option_cfg));

} else if(opt.key == "slider") {
add_name("slider_label");
Expand Down
4 changes: 4 additions & 0 deletions src/gui/dialogs/multiplayer/mp_options_helper.hpp
Expand Up @@ -23,6 +23,7 @@ namespace gui2
{

class tcontrol;
class tmenu_button;
class ttoggle_button;
class ttree_view;
class ttree_view_node;
Expand Down Expand Up @@ -58,6 +59,9 @@ class tmp_options_helper
void update_options_data_map(T* widget, const option_source& source);
void update_options_data_map(ttoggle_button* widget, const option_source& source);

// NOTE: this cannot be an overload of update_options_data_map since that's a templated function
void update_options_data_map_menu_button(tmenu_button* widget, const option_source& source, const config& cfg);

void reset_options_data(const option_source& source, bool& handled, bool& halt);

ttree_view& options_tree_;
Expand Down

0 comments on commit b1d886b

Please sign in to comment.