The Battle for Wesnoth  1.19.0+dev
edit_side.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2024
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 
23 
24 namespace gui2::dialogs
25 {
26 
27 REGISTER_DIALOG(editor_edit_side)
28 
30  : modal_dialog(window_id())
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  register_text("recruit_list", true, info.recruit_list, 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), side_controller::type::human);
56  controller_group.add_member(find_widget<toggle_button>(&window, "controller_ai", false, true), side_controller::type::ai);
57  controller_group.add_member(find_widget<toggle_button>(&window, "controller_null", false, true), side_controller::type::none);
58 
60 
61  vision_group.add_member(find_widget<toggle_button>(&window, "vision_all", false, true), team_shared_vision::type::all);
62  vision_group.add_member(find_widget<toggle_button>(&window, "vision_shroud", false, true), team_shared_vision::type::shroud);
63  vision_group.add_member(find_widget<toggle_button>(&window, "vision_null", false, true), team_shared_vision::type::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  window.add_to_tab_order(find_widget<text_box>(&window, "recruit_list", false, true));
70 }
71 
73 {
76 }
77 
78 } // namespace dialogs
group< side_controller::type > controller_group
Definition: edit_side.hpp:42
side_controller::type & controller_
Definition: edit_side.hpp:41
virtual void pre_show(window &window) override
The execute function.
Definition: edit_side.cpp:53
team_shared_vision::type & share_vision_
Definition: edit_side.hpp:44
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
Definition: edit_side.cpp:72
group< team_shared_vision::type > vision_group
Definition: edit_side.hpp:45
Abstract base class for all modal dialogs.
void add_member(selectable_item *w, const T &value)
Adds a widget/value pair to the group map.
Definition: group.hpp:42
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
T get_active_member_value()
Returns the value paired with the currently actively toggled member of the group.
Definition: group.hpp:96
base class of top level items, the only item which needs to store the final canvases to draw on.
Definition: window.hpp:61
void add_to_tab_order(widget *widget, int at=-1)
Add the widget to the tabbing order.
Definition: window.cpp:1239
Implements some helper classes to ease adding fields to a dialog and hide the synchronization needed.
Manage the empty-palette in the editor.
Definition: action.cpp:31
REGISTER_DIALOG(editor_edit_unit)
logger & info()
Definition: log.cpp:314