The Battle for Wesnoth  1.15.12+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 <functional>
24 
25 namespace gui2::dialogs
26 {
27 
28 REGISTER_DIALOG(editor_edit_side)
29 
31  : controller_(info.controller)
32  , share_vision_(info.share_vision)
33 {
34  register_label("side_number", true, std::to_string(info.side), true);
35 
36  register_text("team_name", true, info.id, true);
37  register_text("user_team_name", true, info.name, false);
38 
39  register_integer("gold", true, info.gold);
40  register_integer("income", true, info.income);
41 
42  register_integer("village_income", true, info.village_income);
43  register_integer("village_support", true, info.village_support);
44 
45  register_bool("fog", true, info.fog);
46  register_bool("shroud", true, info.shroud);
47 
48  register_bool("no_leader", true, info.no_leader);
49  register_bool("hidden", true, info.hidden);
50 }
51 
53 {
54  controller_group.add_member(find_widget<toggle_button>(&window, "controller_human", false, true), team::CONTROLLER::HUMAN);
55  controller_group.add_member(find_widget<toggle_button>(&window, "controller_ai", false, true), team::CONTROLLER::AI);
56  controller_group.add_member(find_widget<toggle_button>(&window, "controller_null", false, true), team::CONTROLLER::EMPTY);
57 
59 
60  vision_group.add_member(find_widget<toggle_button>(&window, "vision_all", false, true), team::SHARE_VISION::ALL);
61  vision_group.add_member(find_widget<toggle_button>(&window, "vision_shroud", false, true), team::SHARE_VISION::SHROUD);
62  vision_group.add_member(find_widget<toggle_button>(&window, "vision_null", false, true), team::SHARE_VISION::NONE);
63 
65 
66  window.add_to_tab_order(find_widget<text_box>(&window, "team_name", false, true));
67  window.add_to_tab_order(find_widget<text_box>(&window, "user_team_name", false, true));
68 }
69 
71 {
74 }
75 
76 } // namespace dialogs
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
Definition: edit_side.cpp:70
Dialog for editing gamemap sides.
Definition: edit_side.hpp:38
logger & info()
Definition: log.cpp:88
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:53
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:52
This file contains the settings handling of the widget library.
Manage the empty-palette in the editor.
Definition: action.cpp:29
group< team::SHARE_VISION > vision_group
Definition: edit_side.hpp:54
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:1291
team::CONTROLLER & controller_
Definition: edit_side.hpp:50
base class of top level items, the only item which needs to store the final canvases to draw on...
Definition: window.hpp:64
group< team::CONTROLLER > controller_group
Definition: edit_side.hpp:51
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