The Battle for Wesnoth  1.17.0-dev
edit_side.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2021
3  by Fabian Müller <fabianmueller5@gmx.de>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #define GETTEXT_DOMAIN "wesnoth-lib"
17 
19 
20 #include "gui/auxiliary/field.hpp"
22 #include "gui/widgets/settings.hpp"
23 
24 #include <functional>
25 
26 namespace gui2::dialogs
27 {
28 
29 REGISTER_DIALOG(editor_edit_side)
30 
32  : controller_(info.controller)
33  , share_vision_(info.share_vision)
34 {
35  register_label("side_number", true, std::to_string(info.side), true);
36 
37  register_text("team_name", true, info.id, true);
38  register_text("user_team_name", true, info.name, false);
39 
40  register_integer("gold", true, info.gold);
41  register_integer("income", true, info.income);
42 
43  register_integer("village_income", true, info.village_income);
44  register_integer("village_support", true, info.village_support);
45 
46  register_bool("fog", true, info.fog);
47  register_bool("shroud", true, info.shroud);
48 
49  register_bool("no_leader", true, info.no_leader);
50  register_bool("hidden", true, info.hidden);
51 }
52 
54 {
55  controller_group.add_member(find_widget<toggle_button>(&window, "controller_human", false, true), team::CONTROLLER::HUMAN);
56  controller_group.add_member(find_widget<toggle_button>(&window, "controller_ai", false, true), team::CONTROLLER::AI);
57  controller_group.add_member(find_widget<toggle_button>(&window, "controller_null", false, true), team::CONTROLLER::EMPTY);
58 
60 
61  vision_group.add_member(find_widget<toggle_button>(&window, "vision_all", false, true), team::SHARE_VISION::ALL);
62  vision_group.add_member(find_widget<toggle_button>(&window, "vision_shroud", false, true), team::SHARE_VISION::SHROUD);
63  vision_group.add_member(find_widget<toggle_button>(&window, "vision_null", false, true), team::SHARE_VISION::NONE);
64 
66 
67  window.add_to_tab_order(find_widget<text_box>(&window, "team_name", false, true));
68  window.add_to_tab_order(find_widget<text_box>(&window, "user_team_name", false, true));
69 }
70 
72 {
75 }
76 
77 } // namespace dialogs
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
Definition: edit_side.cpp:71
Dialog for editing gamemap sides.
Definition: edit_side.hpp:39
logger & info()
Definition: log.cpp:89
T get_active_member_value()
Returns the value paired with the currently actively toggled member of the group. ...
Definition: group.hpp:96
team::SHARE_VISION & share_vision_
Definition: edit_side.hpp:54
Implements some helper classes to ease adding fields to a dialog and hide the synchronization needed...
virtual void pre_show(window &window) override
The execute function.
Definition: edit_side.cpp:53
This file contains the settings handling of the widget library.
Manage the empty-palette in the editor.
Definition: action.cpp:30
group< team::SHARE_VISION > vision_group
Definition: edit_side.hpp:55
void add_member(selectable_item *w, const T &value)
Adds a widget/value pair to the group map.
Definition: group.hpp:42
Default, unset return value.
Definition: retval.hpp:32
void add_to_tab_order(widget *widget, int at=-1)
Add the widget to the tabbing order.
Definition: window.cpp:1294
team::CONTROLLER & controller_
Definition: edit_side.hpp:51
base class of top level items, the only item which needs to store the final canvases to draw on...
Definition: window.hpp:65
group< team::CONTROLLER > controller_group
Definition: edit_side.hpp:52
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:111