The Battle for Wesnoth  1.15.1+dev
edit_side.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2018 by Fabian Müller <fabianmueller5@gmx.de>
3  Part of the Battle for Wesnoth Project https://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 namespace dialogs
28 {
29 
30 /*WIKI
31  * @page = GUIWindowDefinitionWML
32  * @order = 2_edit_side
33  *
34  * == Edit side ==
35  *
36  * Dialog for editing gamemap sides.
37  *
38  * @begin{table}{dialog_widgets}
39  *
40  * title & & label & m &
41  * Dialog title label. $
42  *
43  * id & & text_box & m &
44  * Input field for the id. $
45  *
46  * team_only_toggle & & toggle_button & m &
47  * Checkbox for whether to make the label visible to the player's team
48  * only or not. $
49  *
50  * @end{table}
51  */
52 
53 REGISTER_DIALOG(editor_edit_side)
54 
56  : controller_(info.controller)
57  , share_vision_(info.share_vision)
58 {
59  register_label("side_number", true, std::to_string(info.side), true);
60 
61  register_text("team_name", true, info.id, true);
62  register_text("user_team_name", true, info.name, false);
63 
64  register_integer("gold", true, info.gold);
65  register_integer("income", true, info.income);
66 
67  register_integer("village_income", true, info.village_income);
68  register_integer("village_support", true, info.village_support);
69 
70  register_bool("fog", true, info.fog);
71  register_bool("shroud", true, info.shroud);
72 
73  register_bool("no_leader", true, info.no_leader);
74  register_bool("hidden", true, info.hidden);
75 }
76 
78 {
79  controller_group.add_member(find_widget<toggle_button>(&window, "controller_human", false, true), team::CONTROLLER::HUMAN);
80  controller_group.add_member(find_widget<toggle_button>(&window, "controller_ai", false, true), team::CONTROLLER::AI);
81  controller_group.add_member(find_widget<toggle_button>(&window, "controller_null", false, true), team::CONTROLLER::EMPTY);
82 
84 
85  vision_group.add_member(find_widget<toggle_button>(&window, "vision_all", false, true), team::SHARE_VISION::ALL);
86  vision_group.add_member(find_widget<toggle_button>(&window, "vision_shroud", false, true), team::SHARE_VISION::SHROUD);
87  vision_group.add_member(find_widget<toggle_button>(&window, "vision_null", false, true), team::SHARE_VISION::NONE);
88 
90 
91  window.add_to_tab_order(find_widget<text_box>(&window, "team_name", false, true));
92  window.add_to_tab_order(find_widget<text_box>(&window, "user_team_name", false, true));
93 }
94 
96 {
99 }
100 
101 } // namespace dialogs
102 } // namespace gui2
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
Definition: edit_side.cpp:95
logger & info()
Definition: log.cpp:90
T get_active_member_value()
Returns the value paired with the currently actively toggled member of the group. ...
Definition: group.hpp:95
team::SHARE_VISION & share_vision_
Definition: edit_side.hpp:43
Implements some helper classes to ease adding fields to a dialog and hide the synchronization needed...
Generic file dialog.
Definition: field-fwd.hpp:22
virtual void pre_show(window &window) override
The execute function.
Definition: edit_side.cpp:77
This file contains the settings handling of the widget library.
Manage the empty-palette in the editor.
Definition: action.cpp:29
Various uncategorised dialogs.
group< team::SHARE_VISION > vision_group
Definition: edit_side.hpp:44
void add_member(selectable_item *w, const T &value)
Adds a widget/value pair to the group map.
Definition: group.hpp:41
Default, unset return value.
Definition: retval.hpp:31
void add_to_tab_order(widget *widget, int at=-1)
Add the widget to the tabbing order.
Definition: window.cpp:1300
team::CONTROLLER & controller_
Definition: edit_side.hpp:40
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:63
group< team::CONTROLLER > controller_group
Definition: edit_side.hpp:41
void set_member_states(const T &value)
Sets the toggle values for all widgets besides the one associated with the specified value to false...
Definition: group.hpp:110