#include <mp_options.hpp>
Public Member Functions | |
manager (const config &gamecfg, CVideo &video, gui::scrollpane *pane, const config &initial_value) | |
Constructor. More... | |
~manager () | |
void | set_values (const config &values) |
Set the current values the options. More... | |
void | set_era (const std::string &id) |
Sets the selected era. More... | |
void | set_scenario (const std::string &id) |
Sets the selected scenario. More... | |
void | set_campaign (const std::string &id) |
Sets the selected campaign. More... | |
void | set_modifications (const std::vector< std::string > &ids) |
Sets the activated modifications. More... | |
void | layout_widgets (int startx, int starty, int w) |
void | process_event () |
void | hide_children (bool hide=true) |
const config & | get_values () |
Returns the the values for each option. More... | |
void | init_widgets () |
void | restore_defaults (const std::string &component) |
bool | has_options () const |
Private Member Functions | |
void | init_info (const config &cfg, const std::string &key) |
Adds the necessary information about the specified component to options_info_. More... | |
config & | get_value_cfg (const std::string &id) |
Returns the node which holds the selected value of an option. More... | |
const config & | get_value_cfg_or_empty (const std::string &id) const |
Returns the node which holds the selected value of an option. More... | |
const config & | get_option_info_cfg (const std::string &id) const |
Returns the information about an option. More... | |
const config & | get_component_cfg (const std::string &id) const |
config::any_child | get_option_parent (const std::string &id) const |
Finds the parent node of an options. More... | |
config::attribute_value | get_stored_value (const std::string &id) const |
Retrieves the saved value for a certain option, or the default, if there's no such. More... | |
config::attribute_value | get_default_value (const std::string &id) const |
Retrieves the default value for a certain option. More... | |
void | extract_values (const std::string &key, const std::string &id) |
Writes all the values for the options of a certain component from a specified window into values_. More... | |
void | update_values () |
bool | is_active (const std::string &id) const |
Static Private Member Functions | |
static bool | is_valid_option (const std::string &key, const config &option) |
Decides whether a config is a sane option node or not. More... | |
Private Attributes | |
config | options_info_ |
Stores needed info about each element and their configuration options. More... | |
config | values_ |
Stores the selected values for each option. More... | |
CVideo & | video_ |
The screen to display the dialog on. More... | |
gui::scrollpane * | pane_ |
The scrollarea to put the widgets on. More... | |
std::string | era_ |
The id of the selected era. More... | |
std::string | scenario_ |
The id of the selected [multiplayer] or [campaign]. More... | |
bool | is_campaign_ |
std::vector< std::string > | modifications_ |
The ids of the selected modifications. More... | |
std::map< std::string, option_display * > | widgets_ |
std::vector< option_display * > | widgets_ordered_ |
Definition at line 150 of file mp_options.hpp.
mp::options::manager::manager | ( | const config & | gamecfg, |
CVideo & | video, | ||
gui::scrollpane * | pane, | ||
const config & | initial_value | ||
) |
Constructor.
gamecfg | The config object holding all eras, scenarios and modifications. |
display | The screen to display the dialog on. |
initial_value | The initial values for each option. |
Definition at line 110 of file mp_options.cpp.
References config::all_children_range(), DBG_MP, get_stored_value(), get_value_cfg(), i, init_info(), init_widgets(), is_valid_option(), and options_info_.
mp::options::manager::~manager | ( | ) |
Definition at line 142 of file mp_options.cpp.
References widgets_ordered_.
|
private |
Writes all the values for the options of a certain component from a specified window into values_.
key | The component's type. |
id | The component's id. |
Definition at line 323 of file mp_options.cpp.
References config::all_children_range(), config::find_child(), get_value_cfg(), is_valid_option(), options_info_, and widgets_.
Referenced by update_values().
|
private |
Definition at line 284 of file mp_options.cpp.
References e, config::find_child(), and options_info_.
Referenced by restore_defaults().
|
private |
Retrieves the default value for a certain option.
id | The id of the option. |
Definition at line 316 of file mp_options.cpp.
References get_option_info_cfg().
Referenced by get_stored_value(), and restore_defaults().
|
private |
Returns the information about an option.
id | The id of the option. |
Definition at line 269 of file mp_options.cpp.
References config::all_children_range(), i, and options_info_.
Referenced by get_default_value().
|
private |
Finds the parent node of an options.
id | The id of the option. |
Definition at line 252 of file mp_options.cpp.
References config::all_children_range(), i, and options_info_.
Referenced by get_value_cfg().
|
private |
Retrieves the saved value for a certain option, or the default, if there's no such.
id | The id of the option. |
Definition at line 303 of file mp_options.cpp.
References get_default_value(), and get_value_cfg_or_empty().
Referenced by init_widgets(), and manager().
|
private |
Returns the node which holds the selected value of an option.
If that node is not yet created, the function creates it.
id | The id of the option. |
Definition at line 213 of file mp_options.cpp.
References config::add_child(), config::any_child::cfg, config::empty(), config::find_child(), get_option_parent(), get_value_cfg_or_empty(), lg::info(), config::any_child::key, and values_.
Referenced by extract_values(), and manager().
|
private |
Returns the node which holds the selected value of an option.
If that node is not yet created, the function returns an empty config.
id | The id of the option. |
Definition at line 237 of file mp_options.cpp.
References config::all_children_range(), i, and values_.
Referenced by get_stored_value(), and get_value_cfg().
const config & mp::options::manager::get_values | ( | ) |
Returns the the values for each option.
Definition at line 207 of file mp_options.cpp.
References update_values(), and values_.
Referenced by mp::configure::get_parameters().
bool mp::options::manager::has_options | ( | ) | const |
Definition at line 105 of file mp_options.cpp.
References widgets_.
Referenced by mp::configure::configure().
void mp::options::manager::hide_children | ( | bool | hide = true | ) |
Definition at line 197 of file mp_options.cpp.
Referenced by mp::configure::hide_children().
|
private |
Adds the necessary information about the specified component to options_info_.
cfg | The component's data. |
key | The component's type. |
Definition at line 37 of file mp_options.cpp.
References config::add_child(), config::all_children_range(), config::child(), config::child_range(), preferences::options(), and options_info_.
Referenced by manager().
void mp::options::manager::init_widgets | ( | ) |
Definition at line 59 of file mp_options.cpp.
References config::all_children_range(), config::any_child::cfg, get_stored_value(), is_active(), options_info_, video_, widgets_, and widgets_ordered_.
Referenced by mp::configure::configure(), and manager().
|
private |
Definition at line 356 of file mp_options.cpp.
References era_, gui2::event::find(), modifications_, and scenario_.
Referenced by init_widgets().
|
staticprivate |
Decides whether a config is a sane option node or not.
A valid option node:
key | The option's key. |
option | The option's data. |
Definition at line 350 of file mp_options.cpp.
References config::empty().
Referenced by extract_values(), manager(), and restore_defaults().
Definition at line 178 of file mp_options.cpp.
References pane_, and widgets_ordered_.
Referenced by mp::configure::layout_children().
void mp::options::manager::process_event | ( | ) |
Definition at line 189 of file mp_options.cpp.
References i, and widgets_ordered_.
Referenced by mp::configure::process_event_impl().
void mp::options::manager::restore_defaults | ( | const std::string & | component | ) |
Definition at line 92 of file mp_options.cpp.
References get_component_cfg(), get_default_value(), i, is_valid_option(), and widgets_.
Referenced by mp::options::reset_display::process_event().
void mp::options::manager::set_campaign | ( | const std::string & | id | ) |
Sets the selected campaign.
Whenever show_dialog is called, only options for the campaign scenario will be displayed.
id | The campaign's id. |
Definition at line 167 of file mp_options.cpp.
References is_campaign_, and scenario_.
Referenced by mp::configure::configure().
void mp::options::manager::set_era | ( | const std::string & | id | ) |
Sets the selected era.
Whenever show_dialog is called, only options for the selected era will be displayed.
id | The era's id. |
Definition at line 156 of file mp_options.cpp.
References preferences::era(), and era_.
Referenced by mp::configure::configure().
void mp::options::manager::set_modifications | ( | const std::vector< std::string > & | ids | ) |
Sets the activated modifications.
Whenever show_dialog is called, only options for the activated modifications will be displayed.
ids | The ids of the modifications |
Definition at line 173 of file mp_options.cpp.
References preferences::modifications(), and modifications_.
Referenced by mp::configure::configure().
void mp::options::manager::set_scenario | ( | const std::string & | id | ) |
Sets the selected scenario.
Whenever show_dialog is called, only options for the selected scenario will be displayed.
id | The scenario's id. |
Definition at line 161 of file mp_options.cpp.
References is_campaign_, and scenario_.
Referenced by mp::configure::configure().
Set the current values the options.
This overrides ALL previously set values, even if a not all options are provided a new value for.
values | The new values for each option. |
Definition at line 151 of file mp_options.cpp.
|
private |
Definition at line 336 of file mp_options.cpp.
References era_, extract_values(), is_campaign_, modifications_, and scenario_.
Referenced by get_values().
|
private |
The id of the selected era.
Definition at line 239 of file mp_options.hpp.
Referenced by is_active(), set_era(), and update_values().
|
private |
Definition at line 243 of file mp_options.hpp.
Referenced by set_campaign(), set_scenario(), and update_values().
|
private |
The ids of the selected modifications.
Definition at line 245 of file mp_options.hpp.
Referenced by is_active(), set_modifications(), and update_values().
|
private |
Stores needed info about each element and their configuration options.
Definition at line 227 of file mp_options.hpp.
Referenced by extract_values(), get_component_cfg(), get_option_info_cfg(), get_option_parent(), init_info(), init_widgets(), and manager().
|
private |
The scrollarea to put the widgets on.
Definition at line 236 of file mp_options.hpp.
Referenced by layout_widgets().
|
private |
The id of the selected [multiplayer] or [campaign].
Definition at line 242 of file mp_options.hpp.
Referenced by is_active(), set_campaign(), set_scenario(), and update_values().
|
private |
Stores the selected values for each option.
Definition at line 230 of file mp_options.hpp.
Referenced by get_value_cfg(), get_value_cfg_or_empty(), get_values(), and set_values().
|
private |
The screen to display the dialog on.
Definition at line 233 of file mp_options.hpp.
Referenced by init_widgets().
|
private |
Definition at line 247 of file mp_options.hpp.
Referenced by extract_values(), has_options(), hide_children(), init_widgets(), and restore_defaults().
|
private |
Definition at line 248 of file mp_options.hpp.
Referenced by init_widgets(), layout_widgets(), process_event(), and ~manager().