15 #define GETTEXT_DOMAIN "wesnoth-lib"
52 , connect_engine_(connect_engine)
53 , ai_algorithms_(
ai::configuration::get_available_ais())
54 , network_connection_(connection)
56 , state_changed_(false)
59 , player_list_(
nullptr)
61 set_show_even_without_video(
true);
63 assert(!ai_algorithms_.empty());
82 label& title = find_widget<label>(&
window,
"title",
false);
129 if(side->team() == side_engine->team() && side->index() > side_engine->index()) {
137 template<
typename... T>
146 if(team_node ==
nullptr) {
152 tree_item[
"label"] = side->user_team_name();
153 tree_data.emplace(
"tree_view_node_label", tree_item);
155 team_node = &tree.
add_node(
"team_header", tree_data);
161 assert(team_node &&
"No team node found!");
162 return team_node->
add_child(std::forward<T>(params)...);
170 item[
"label"] = std::to_string(side->index() + 1);
174 item[
"label"] =
"units/unknown-unit.png~RC(magenta>" + side->color_id() +
")";
177 item[
"label"] =
"icons/icon-random.png";
178 data.emplace(
"leader_gender",
item);
192 const bool lock_gold = side->cfg()[
"gold_lock"].to_bool(fls);
193 const bool lock_income = side->cfg()[
"income_lock"].to_bool(fls);
194 const bool lock_team = side->cfg()[
"team_lock"].to_bool(fls);
195 const bool lock_color = side->cfg()[
"color_lock"].to_bool(fls);
205 std::vector<config> ai_options;
210 ai_options.emplace_back(
"label",
"Keep saved AI");
220 menu_button& ai_selection = find_widget<menu_button>(&row_grid,
"ai_controller",
false);
222 ai_selection.
set_values(ai_options, selection);
231 std::vector<config> controller_names;
232 for(
const auto&
controller : side->controller_options()) {
233 controller_names.emplace_back(
"label",
controller.second);
236 menu_button& controller_selection = find_widget<menu_button>(&row_grid,
"controller",
false);
238 controller_selection.
set_values(controller_names, side->current_controller_index());
239 controller_selection.
set_active(controller_names.size() > 1);
249 button& leader_select = find_widget<button>(&row_grid,
"select_leader",
false);
260 std::vector<config> team_names;
261 unsigned initial_team_selection = 0;
276 entry[
"team_index"] =
i;
278 team_names.push_back(std::move(entry));
283 if(side->team() ==
i) {
284 initial_team_selection = team_names.size() - 1;
288 menu_button& team_selection = find_widget<menu_button>(&row_grid,
"side_team",
false);
290 team_selection.
set_values(team_names, initial_team_selection);
300 std::vector<config> color_options;
301 for(
const auto& color : side->color_options()) {
302 color_options.emplace_back(
304 "icon", (
formatter() <<
"misc/status.png~RC(magenta>" << color <<
")").str()
308 menu_button& color_selection = find_widget<menu_button>(&row_grid,
"side_color",
false);
310 color_selection.
set_values(color_options, side->color());
320 const auto slider_setup_helper = [](
slider&
slider,
const int value) {
332 slider& slider_gold = find_widget<slider>(&row_grid,
"side_gold_slider",
false);
333 slider_setup_helper(slider_gold, side->gold());
336 &mp_staging::on_side_slider_change<&ng::side_engine::set_gold>,
this, side, std::ref(slider_gold)));
338 slider& slider_income = find_widget<slider>(&row_grid,
"side_income_slider",
false);
339 slider_setup_helper(slider_income, side->income());
342 &mp_staging::on_side_slider_change<&ng::side_engine::set_income>,
this, side, std::ref(slider_income)));
364 menu_button& ai_selection = find_widget<menu_button>(&row_grid,
"ai_controller",
false);
365 menu_button& controller_selection = find_widget<menu_button>(&row_grid,
"controller",
false);
367 if(side->controller_changed(controller_selection.
get_value())) {
384 side->set_ai_algorithm(
"use_saved");
394 side->set_color(find_widget<menu_button>(&row_grid,
"side_color",
false).get_value());
407 const unsigned team_index = team_menu.
get_value_config()[
"team_index"].to_unsigned();
409 if(team_index == side->team()) {
415 const std::string old_team = side->team_name();
416 side->set_team(team_index);
418 auto& tree = find_widget<tree_view>(
get_window(),
"side_list",
false);
429 if(old_team_node->
empty()) {
432 tree.remove_node(old_team_node);
442 if(gui2::dialogs::faction_select::execute(side->flg(), side->color_id(), side->index() + 1)) {
449 template<
void(ng::s
ide_engine::*fptr)(
int)>
459 const std::string current_faction = side->flg().current_faction()[
"name"];
462 std::string current_leader = side->flg().current_leader() !=
"null" ? side->flg().current_leader() :
font::unicode_em_dash;
463 const std::string current_gender = side->flg().current_gender() !=
"null" ? side->flg().current_gender() :
font::unicode_em_dash;
466 std::string new_image;
468 if(side->flg().is_random_faction() || current_leader ==
"random") {
473 const unit_type&
type = ut->get_gender_unit_type(current_gender);
475 new_image =
formatter() <<
type.image() <<
"~RC(magenta>" << side->color_id() <<
")";
478 current_leader =
type.type_name();
481 find_widget<drawing>(&row_grid,
"leader_image",
false).set_label(new_image);
484 if(!side->cfg()[
"name"].empty()) {
485 current_leader =
formatter() << side->cfg()[
"name"] <<
" (<i>" << current_leader <<
"</i>)";
488 find_widget<label>(&row_grid,
"leader_type",
false).set_label(current_leader ==
"random" ?
_(
"Random") : current_leader);
489 find_widget<label>(&row_grid,
"leader_faction",
false).set_label(
"<span color='#a69275'>" + current_faction +
"</span>");
493 const std::string gender_icon =
formatter() <<
"icons/icon-" << current_gender <<
".png";
495 image& icon = find_widget<image>(&row_grid,
"leader_gender",
false);
502 find_widget<label>(
get_window(),
"status_label",
false).set_label(
504 ?
_(
"Waiting for players to join...")
505 :
_(
"Waiting for players to choose factions...")
525 find_widget<chatbox>(
get_window(),
"chat",
false).process_network_data(
data);
530 bool quit_signal_received;
533 if(quit_signal_received) {
542 grid& row_grid = tree_entry.second->get_grid();
546 std::vector<config> controller_names;
547 for(
const auto&
controller : side->controller_options()) {
548 controller_names.emplace_back(
"label",
controller.second);
551 menu_button& controller_selection = find_widget<menu_button>(&row_grid,
"controller",
false);
553 controller_selection.
set_values(controller_names, side->current_controller_index());
554 controller_selection.
set_active(controller_names.size() > 1);
558 if(
data.has_child(
"user")) {
std::map< std::string, chatroom_log > default_chat_log
A config object defines a single node in a WML file, with access to child nodes.
lobby_chat_window * room_window_open(const std::string &room, const bool open_new, const bool allow_close=true)
Check if a room window for "room" is open, if open_new is true then it will be created if not found.
virtual void send_chat_message(const std::string &message, bool allies_only) override
Inherited form chat_handler.
void load_log(std::map< std::string, chatroom_log > &log, bool show_lobby)
void active_window_changed()
Abstract base class for all modal dialogs.
window * get_window()
Returns a pointer to the dialog's window.
void update_leader_display(ng::side_engine_ptr side, grid &row_grid)
void on_color_select(ng::side_engine_ptr side, grid &row_grid)
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
wesnothd_connection * network_connection_
int get_side_node_position(ng::side_engine_ptr side) const
Find an appropriate position to insert a side node.
ng::connect_engine & connect_engine_
void on_controller_select(ng::side_engine_ptr side, grid &row_grid)
void select_leader_callback(ng::side_engine_ptr side, grid &row_grid)
void on_ai_select(ng::side_engine_ptr side, menu_button &ai_menu, const bool saved_game)
void update_status_label_and_buttons()
void on_team_select(ng::side_engine_ptr side, menu_button &team_menu)
std::map< ng::side_engine_ptr, tree_view_node * > side_tree_map_
std::size_t update_timer_
void on_side_slider_change(ng::side_engine_ptr side, slider &slider)
std::unique_ptr< player_list_helper > player_list_
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
std::vector< ai::description * > ai_algorithms_
std::map< std::string, tree_view_node * > team_tree_map_
tree_view_node & add_side_to_team_node(ng::side_engine_ptr side, T &&... params)
void add_side_node(ng::side_engine_ptr side)
std::unique_ptr< plugins_context > plugins_context_
A label displays a text, the text can be wrapped but no scrollbars are provided.
virtual void set_active(const bool active) override
See styled_widget::set_active.
A slider is a control that can select a value by moving a grip on a groove.
virtual int get_minimum_value() const override
Inherited from integer_selector.
virtual void set_value(int value) override
Inherited from integer_selector.
virtual int get_maximum_value() const override
Inherited from integer_selector.
void set_value_range(int min_value, int max_value)
virtual int get_value() const override
Inherited from integer_selector.
tree_view_node & add_sibling(const std::string &id, const widget_data &data)
Adds a sibbling for a node at the end of the list.
bool empty() const
Does the node have children?
tree_view_node * get_node_below()
tree_view_node & add_child(const std::string &id, const widget_data &data, const int index=-1)
Constructs a new child node.
A tree view is a control that holds several items of the same or different types.
tree_view_node & add_node(const std::string &id, const widget_data &data, const int index=-1)
base class of top level items, the only item which needs to store the final canvases to draw on.
void set_enter_disabled(const bool enter_disabled)
Disable the enter key.
void set_retval(const int retval, const bool close_window=true)
Sets there return value of the window.
static const std::string & type()
Static type getter that does not rely on the widget being constructed.
void set_escape_disabled(const bool escape_disabled)
Disable the escape key.
const std::vector< team_data_pod > & team_data() const
std::vector< side_engine_ptr > & side_engines()
std::pair< bool, bool > process_network_data(const config &data)
bool sides_available() const
void update_and_send_diff()
bool force_lock_settings() const
const mp_game_settings & params() const
bool can_start_game() const
static t_string from_serialized(const std::string &string)
const unit_type * find(const std::string &key, unit_type::BUILD_STATUS status=unit_type::FULL) const
Finds a unit_type by its id() and makes sure it is built to the specified level.
A single unit type that the player may recruit.
A class that represents a TCP/IP connection to the wesnothd server.
bool receive_data(config &result)
Receives the next pending data pack from the server, if available.
Managing the AIs configuration - headers.
static std::string _(const char *str)
#define REGISTER_DIALOG(window_id)
Wrapper for REGISTER_DIALOG2.
A small explanation about what's going on here: Each action has access to two game_info objects First...
const std::string unicode_em_dash
std::string get_color_string_pango(const std::string &id)
Returns the name of a color range, colored with its own color.
unsigned lobby_network_timer
void connect_signal_notify_modified(dispatcher &dispatcher, const signal_notification &signal)
Connects a signal handler for getting a notification upon modification.
void connect_signal_mouse_left_click(dispatcher &dispatcher, const signal &signal)
Connects a signal handler for a left mouse button click.
std::size_t add_timer(const uint32_t interval, const std::function< void(std::size_t id)> &callback, const bool repeat)
Adds a new timer.
std::map< std::string, widget_item > widget_data
std::map< std::string, t_string > widget_item
bool remove_timer(const std::size_t id)
Removes a timer.
@ OK
Dialog was closed with the OK button.
@ CANCEL
Dialog was closed with the CANCEL button.
std::pair< std::string, unsigned > item
Functions to load and save images from/to disk.
std::shared_ptr< side_engine > side_engine_ptr
const std::string random_enemy_picture("units/random-dice.png")
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
This file contains the settings handling of the widget library.
saved_game_mode::type saved_game
std::string user_team_name
unit_type_data unit_types