The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
edit_side.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2016 by Fabian Müller <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #define GETTEXT_DOMAIN "wesnoth-lib"
16 
18 
19 #include "gui/auxiliary/field.hpp"
21 #include "gui/widgets/settings.hpp"
22 
23 #include "utils/functional.hpp"
24 
25 namespace gui2
26 {
27 
28 /*WIKI
29  * @page = GUIWindowDefinitionWML
30  * @order = 2_edit_side
31  *
32  * == Edit side ==
33  *
34  * Dialog for editing gamemap sides.
35  *
36  * @begin{table}{dialog_widgets}
37  *
38  * title & & label & m &
39  * Dialog title label. $
40  *
41  * id & & text_box & m &
42  * Input field for the id. $
43  *
44  * team_only_toggle & & toggle_button & m &
45  * Checkbox for whether to make the label visible to the player's team
46  * only or not. $
47  *
48  * @end{table}
49  */
50 
51 REGISTER_DIALOG(editor_edit_side)
52 
54  std::string& id,
55  std::string& name,
56  int& gold,
57  int& income,
58  int& village_income,
59  int& village_support,
60  bool& fog,
61  bool& shroud,
62  team::SHARE_VISION& share_vision,
63  team::CONTROLLER& controller,
64  bool& no_leader,
65  bool& hidden)
66  : controller_(controller)
67  , share_vision_(share_vision)
68 {
69  std::stringstream side_stream;
70  side_stream << side;
71  register_label("side_number", true, side_stream.str(), true);
72 
73  register_text("team_name", true, id, true);
74  register_text("user_team_name", true, name, true);
75 
76  register_integer("gold", true, gold);
77  register_integer("income", true, income);
78 
79  register_integer("village_income", true, village_income);
80  register_integer("village_support", true, village_support);
81 
82  register_bool("fog", true, fog);
83  register_bool("shroud", true, shroud);
84 
85  register_bool("no_leader", true, no_leader);
86  register_bool("hidden", true, hidden);
87 }
88 
90 {
91  register_radio_toggle<team::CONTROLLER>("controller_human", controller_group, team::CONTROLLER::HUMAN, controller_, window);
92  register_radio_toggle<team::CONTROLLER>("controller_ai", controller_group, team::CONTROLLER::AI, controller_, window);
93  register_radio_toggle<team::CONTROLLER>("controller_null", controller_group, team::CONTROLLER::EMPTY, controller_, window);
94 
95  register_radio_toggle<team::SHARE_VISION>("vision_all", vision_group, team::SHARE_VISION::ALL, share_vision_, window);
96  register_radio_toggle<team::SHARE_VISION>("vision_shroud", vision_group, team::SHARE_VISION::SHROUD, share_vision_, window);
97  register_radio_toggle<team::SHARE_VISION>("vision_null", vision_group, team::SHARE_VISION::NONE, share_vision_, window);
98 }
99 
100 template <typename T>
101 void teditor_edit_side::register_radio_toggle(const std::string& toggle_id, tgroup<T>& group, const T& enum_value, T& current_value, twindow& window)
102 {
103  ttoggle_button& b = find_widget<ttoggle_button>(&window, toggle_id, false);
104 
105  b.set_value(enum_value == current_value);
106 
107  group.add_member(&b, enum_value);
108 }
109 
111 {
114 }
115 
116 } // end namespace gui2
tgroup< team::SHARE_VISION > vision_group
Definition: edit_side.hpp:86
int village_support
Definition: game_config.cpp:39
REGISTER_DIALOG(label_settings)
void post_show(twindow &window)
Actions to be taken after the window has been shown.
Definition: edit_side.cpp:110
STL namespace.
Implements some helper classes to ease adding fields to a dialog and hide the synchronization needed...
tgroup< team::CONTROLLER > controller_group
Definition: edit_side.hpp:83
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:62
Class for a toggle button.
A class inherited from ttext_box that displays its input as stars.
Definition: field-fwd.hpp:23
GLdouble GLdouble GLdouble b
Definition: glew.h:6966
This class stores all the data for a single 'side' (in game nomenclature).
Definition: team.hpp:50
This file contains the settings handling of the widget library.
void pre_show(twindow &window)
Actions to be taken before showing the window.
Definition: edit_side.cpp:89
int village_income
Definition: game_config.cpp:38
team::CONTROLLER & controller_
Definition: edit_side.hpp:82
T get_active_member_value()
Returns the value paired with the currently activiely toggled member of the group.
Definition: group.hpp:97
GLuint const GLchar * name
Definition: glew.h:1782
GLboolean GLuint group
Definition: glew.h:2589
void register_radio_toggle(const std::string &toggle_id, tgroup< T > &group, const T &enum_value, T &current_value, twindow &window)
Definition: edit_side.cpp:101
void add_member(tselectable_ *widget, const T &value)
Adds a widget/value pair to the group vector.
Definition: group.hpp:43
team::SHARE_VISION & share_vision_
Definition: edit_side.hpp:85
void set_value(const unsigned selected)
Inherited from tselectable_.
GLsizei const GLcharARB ** string
Definition: glew.h:4503