24 #include "widgets/slider.hpp"
29 #define DBG_MP LOG_STREAM(debug, log_mp_create_options)
41 entry[
"id"] = comp[
"id"];
42 entry[
"name"] = comp[
"name"];
44 if (comp.has_child(
"options") && comp[
"allow_new_game"].to_bool(
true)) {
66 widgets_ordered_.clear();
69 if (comp.cfg.all_children_count() == 0 || !
is_active(comp.cfg[
"id"])) {
76 if (
c.key ==
"slider") {
78 }
else if (
c.key ==
"entry") {
80 }
else if (
c.key ==
"checkbox") {
82 }
else if (
c.key ==
"combo") {
122 DBG_MP <<
"Initializing the options manager" << std::endl;
184 od->layout(startx, ypos, w, border_size,
pane_);
202 i->second->hide_children(hide);
217 if (!value_cfg.
empty()) {
218 return const_cast<config&
>(value_cfg);
226 (*parent_cfg)[
"id"] = info.
cfg[
"id"];
232 value_cfg[
"id"] =
id;
239 static const config empty;
242 for (
const config& j :
i.cfg.child_range(
"option")) {
254 static const config empty;
260 if (j.cfg[
"id"] ==
id) {
271 static const config empty;
275 if (j.cfg[
"id"] ==
id) {
286 static const config empty;
307 if (!valcfg[
"value"].empty()) {
309 return valcfg[
"value"];
320 return optinfo[
"default"];
332 out[
"value"] =
widgets_[
c.cfg[
"id"]]->get_value();
352 return (key ==
"slider" || key ==
"entry" || key ==
"checkbox" || key ==
"combo") &&
353 (!option[
"id"].
empty());
363 entry_(new
gui::textbox(video, 150, cfg[
"default"])),
364 label_(new
gui::label(video, cfg[
"name"]))
401 slider_(new
gui::slider(video)),
403 last_value_(cfg[
"default"].to_int()),
404 label_text_(cfg[
"name"])
459 std::stringstream ss;
465 checkbox_(new
gui::button(video, cfg[
"name"],
gui::button::TYPE_CHECK))
510 ypos += 4*border_size;
521 label_(new
gui::label(video, cfg[
"name"])),
525 std::vector<std::string>
items;
527 items.push_back(item[
"name"]);
528 values_.push_back(item[
"value"]);
576 , button_(new
gui::button(video,
_(
"Defaults")))
static lg::log_domain log_mp_create_options("mp/create/options")
child_itors child_range(const std::string &key)
void restore_defaults(const std::string &component)
title_display(CVideo &video, const std::string &label)
void set_value(const config::attribute_value &val)
entry_display(CVideo &video, const config &cfg)
CVideo & video_
The screen to display the dialog on.
const std::string & set_text(const std::string &text)
gui::scrollpane * pane_
The scrollarea to put the widgets on.
virtual void hide_children(bool hide)
void set_value(int value)
std::string era_
The id of the selected era.
bool to_bool(bool def=false) const
void hide_children(bool hide=true)
void layout(int &xpos, int &ypos, int w, int border_size, gui::scrollpane *pane)
void set_scenario(const std::string &id)
Sets the selected scenario.
std::vector< std::string > modifications_
The ids of the selected modifications.
config options_info_
Stores needed info about each element and their configuration options.
void set_increment(int increment)
void layout(int &xpos, int &ypos, int w, int border_size, gui::scrollpane *pane)
GLuint const GLfloat * val
config values_
Stores the selected values for each option.
void set_text(const std::string &text, const SDL_Color &color=font::NORMAL_COLOR)
void set_modifications(const std::vector< std::string > &ids)
Sets the activated modifications.
const std::vector< std::string > items
const std::string text() const
reset_display(CVideo &video, const std::string &comp, manager &m)
void init_info(const config &cfg, const std::string &key)
Adds the necessary information about the specified component to options_info_.
std::string scenario_
The id of the selected [multiplayer] or [campaign].
Variant for storing WML attributes.
config::attribute_value get_value() const
GLboolean GLenum GLenum GLvoid * values
bool is_active(const std::string &id) const
This module controls the multiplayer lobby.
config::attribute_value get_default_value(const std::string &id) const
Retrieves the default value for a certain option.
static UNUSEDNOWARN std::string _(const char *str)
void layout(int &xpos, int &ypos, int w, int border_size, gui::scrollpane *pane)
void hide_children(bool hide)
const config & get_component_cfg(const std::string &id) const
virtual void hide_children(bool hide)
std::map< std::string, option_display * > widgets_
GLubyte GLubyte GLubyte GLubyte w
GLsizei const GLfloat * value
all_children_itors all_children_range() const
In-order iteration over all children.
const child_map::key_type & key
config & get_value_cfg(const std::string &id)
Returns the node which holds the selected value of an option.
void set_era(const std::string &id)
Sets the selected era.
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_...
void layout(int &xpos, int &ypos, int w, int border_size, gui::scrollpane *pane)
slider_display(CVideo &video, const config &cfg)
config & add_child(const std::string &key)
checkbox_display(CVideo &video, const config &cfg)
std::vector< std::string > values_
virtual void hide_children(bool hide)
const std::string label_text_
std::vector< option_display * > widgets_ordered_
void set_selected(int val)
void layout(int &xpos, int &ypos, int w, int border_size, gui::scrollpane *pane)
manager(const config &gamecfg, CVideo &video, gui::scrollpane *pane, const config &initial_value)
Constructor.
config::any_child get_option_parent(const std::string &id) const
Finds the parent node of an options.
void layout(int &xpos, int &ypos, int w, int border_size, gui::scrollpane *pane)
combo_display(CVideo &video, const config &cfg)
const SDL_Color LOBBY_COLOR
void set_items(const std::vector< std::string > &items)
config::attribute_value get_value() const
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.
void set_value(const config::attribute_value &val)
void set_value(const config::attribute_value &val)
virtual void hide_children(bool hide)
const config & get_option_info_cfg(const std::string &id) const
Returns the information about an option.
const std::vector< std::string > & modifications(bool mp)
bool find(E event, F functor)
Tests whether an event handler is available.
config & child(const std::string &key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
void set_campaign(const std::string &id)
Sets the selected campaign.
config & find_child(const std::string &key, const std::string &name, const std::string &value)
Returns the first child of tag key with a name attribute containing value.
config::attribute_value get_value() const
config::attribute_value get_value() const
const config & get_value_cfg_or_empty(const std::string &id) const
Returns the node which holds the selected value of an option.
int to_int(int def=0) const
const config & get_values()
Returns the the values for each option.
void hide_children(bool hide)
A config object defines a single node in a WML file, with access to child nodes.
static bool is_valid_option(const std::string &key, const config &option)
Decides whether a config is a sane option node or not.
GLsizei const GLcharARB ** string
void layout_widgets(int startx, int starty, int w)
void set_values(const config &values)
Set the current values the options.
void set_value(const config::attribute_value &val)