15 #define GETTEXT_DOMAIN "wesnoth-lib"
50 , connect_engine_(connect_engine)
51 , ai_algorithms_(
ai::configuration::get_available_ais())
52 , network_connection_(connection)
54 , state_changed_(false)
57 , player_list_(
nullptr)
59 set_show_even_without_video(
true);
61 assert(!ai_algorithms_.empty());
83 find_widget<button>(
"ok").set_tooltip(
tooltip.str());
88 label& title = find_widget<label>(
"title");
105 chatbox& chat = find_widget<chatbox>(
"chat");
135 if(side->team() == side_engine->team() && side->index() > side_engine->index()) {
143 template<
typename... T>
152 if(team_node ==
nullptr) {
153 tree_view& tree = find_widget<tree_view>(
"side_list");
158 tree_item[
"label"] = side->user_team_name();
159 tree_data.emplace(
"tree_view_node_label", tree_item);
161 team_node = &tree.
add_node(
"team_header", tree_data);
167 assert(team_node &&
"No team node found!");
168 return team_node->
add_child(std::forward<T>(params)...);
176 item[
"label"] = std::to_string(side->index() + 1);
177 data.emplace(
"side_number", item);
180 item[
"label"] =
"units/unknown-unit.png~RC(magenta>" + side->color_id() +
")";
181 data.emplace(
"leader_image", item);
183 item[
"label"] =
"icons/icon-random.png";
184 data.emplace(
"leader_gender", item);
198 const bool lock_gold = side->cfg()[
"gold_lock"].to_bool(fls);
199 const bool lock_income = side->cfg()[
"income_lock"].to_bool(fls);
200 const bool lock_team = side->cfg()[
"team_lock"].to_bool(fls);
201 const bool lock_color = side->cfg()[
"color_lock"].to_bool(fls);
211 std::vector<config> ai_options;
216 ai_options.emplace_back(
"label",
"Keep saved AI");
228 ai_selection.
set_values(ai_options, selection);
237 std::vector<config> controller_names;
238 for(
const auto&
controller : side->controller_options()) {
239 controller_names.emplace_back(
"label",
controller.second);
244 controller_selection.
set_values(controller_names, side->current_controller_index());
245 controller_selection.
set_active(controller_names.size() > 1);
266 std::vector<config> team_names;
267 unsigned initial_team_selection = 0;
282 entry[
"team_index"] =
i;
284 team_names.push_back(std::move(entry));
289 if(side->team() ==
i) {
290 initial_team_selection = team_names.size() - 1;
296 team_selection.
set_values(team_names, initial_team_selection);
306 std::vector<config> color_options;
307 for(
const auto& color_opt : side->color_options()) {
310 auto team_color =
_(
"Invalid Color");
316 color_options.emplace_back(
318 "icon", (
formatter() <<
"misc/status.png~RC(magenta>" << color_opt <<
")").str()
324 color_selection.
set_values(color_options, side->color());
334 const auto slider_setup_helper = [](
slider&
slider,
const int value) {
347 slider_setup_helper(slider_gold, side->gold());
350 &mp_staging::on_side_slider_change<&ng::side_engine::set_gold>,
this, side, std::ref(slider_gold)));
353 slider_setup_helper(slider_income, side->income());
356 &mp_staging::on_side_slider_change<&ng::side_engine::set_income>,
this, side, std::ref(slider_income)));
381 if(side->controller_changed(controller_selection.get_value())) {
398 side->set_ai_algorithm(
"use_saved");
421 const unsigned team_index = team_menu.
get_value_config()[
"team_index"].to_unsigned();
423 if(team_index == side->team()) {
429 const std::string old_team = side->team_name();
430 side->set_team(team_index);
432 auto& tree = find_widget<tree_view>(
"side_list");
443 if(old_team_node->
empty()) {
446 tree.remove_node(old_team_node);
456 if(gui2::dialogs::faction_select::execute(side->flg(), side->color_id(), side->index() + 1)) {
463 template<
void(ng::s
ide_engine::*fptr)(
int)>
474 std::string current_leader = side->flg().current_leader() !=
"null" ? side->flg().current_leader() :
font::unicode_em_dash;
475 const std::string current_gender = side->flg().current_gender() !=
"null" ? side->flg().current_gender() :
font::unicode_em_dash;
478 std::string new_image;
480 if(side->flg().is_random_faction() || current_leader ==
"random") {
485 const unit_type&
type = ut->get_gender_unit_type(current_gender);
487 new_image =
formatter() <<
type.image() <<
"~RC(magenta>" << side->color_id() <<
")";
490 current_leader =
type.type_name();
496 if(!side->cfg()[
"name"].empty()) {
505 const std::string gender_icon =
formatter() <<
"icons/icon-" << current_gender <<
".png";
514 find_widget<label>(
"status_label").set_label(
516 ?
_(
"Waiting for players to join...")
517 :
_(
"Waiting for players to choose factions...")
537 find_widget<chatbox>(
"chat").process_network_data(
data);
542 bool quit_signal_received;
545 if(quit_signal_received) {
554 grid& row_grid = tree_entry.second->get_grid();
558 std::vector<config> controller_names;
559 for(
const auto&
controller : side->controller_options()) {
560 controller_names.emplace_back(
"label",
controller.second);
565 controller_selection.
set_values(controller_names, side->current_controller_index());
566 controller_selection.
set_active(controller_names.size() > 1);
570 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.
int get_retval() const
Returns the cached window exit code.
void update_leader_display(ng::side_engine_ptr side, grid &row_grid)
void on_color_select(ng::side_engine_ptr side, grid &row_grid)
wesnothd_connection * network_connection_
int get_side_node_position(ng::side_engine_ptr side) const
Find an appropriate position to insert a side node.
virtual void post_show() override
Actions to be taken after the window has been shown.
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_
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)
virtual void pre_show() override
Actions to be taken before showing the window.
void add_side_node(ng::side_engine_ptr side)
std::unique_ptr< plugins_context > plugins_context_
void register_hotkey(const hotkey::HOTKEY_COMMAND id, const hotkey_function &function)
Registers a hotkey.
virtual void set_active(const bool active) override
See styled_widget::set_active.
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 sibling 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.
tree_view_node & add_node(const std::string &id, const widget_data &data, const int index=-1)
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)
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::map< std::string, t_string, std::less<> > team_rgb_name
std::chrono::milliseconds lobby_network_timer
std::map< std::string, std::vector< color_t >, std::less<> > team_rgb_colors
REGISTER_DIALOG(editor_edit_unit)
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 std::chrono::milliseconds &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::string get_names(const std::string &id)
Returns a comma-separated string of hotkey names.
Functions to load and save images from/to disk.
std::string italic(Args &&... data)
std::string span_color(const color_t &color, Args &&... data)
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.
static const hotkey_command & get_command_by_command(HOTKEY_COMMAND command)
the execute_command argument was changed from HOTKEY_COMMAND to hotkey_command, to be able to call it...
saved_game_mode::type saved_game
std::string user_team_name
unit_type_data unit_types