15 #define GETTEXT_DOMAIN "wesnoth-lib"
51 , connect_engine_(connect_engine)
52 , ai_algorithms_(
ai::configuration::get_available_ais())
53 , network_connection_(connection)
55 , state_changed_(false)
58 , player_list_(
nullptr)
60 set_show_even_without_video(
true);
62 assert(!ai_algorithms_.empty());
89 label& title = find_widget<label>(&
window,
"title",
false);
106 chatbox& chat = find_widget<chatbox>(&
window,
"chat",
false);
136 if(side->team() == side_engine->team() && side->index() > side_engine->index()) {
144 template<
typename... T>
153 if(team_node ==
nullptr) {
159 tree_item[
"label"] = side->user_team_name();
160 tree_data.emplace(
"tree_view_node_label", tree_item);
162 team_node = &tree.
add_node(
"team_header", tree_data);
168 assert(team_node &&
"No team node found!");
169 return team_node->
add_child(std::forward<T>(params)...);
177 item[
"label"] = std::to_string(side->index() + 1);
181 item[
"label"] =
"units/unknown-unit.png~RC(magenta>" + side->color_id() +
")";
184 item[
"label"] =
"icons/icon-random.png";
185 data.emplace(
"leader_gender",
item);
199 const bool lock_gold = side->cfg()[
"gold_lock"].to_bool(fls);
200 const bool lock_income = side->cfg()[
"income_lock"].to_bool(fls);
201 const bool lock_team = side->cfg()[
"team_lock"].to_bool(fls);
202 const bool lock_color = side->cfg()[
"color_lock"].to_bool(fls);
212 std::vector<config> ai_options;
217 ai_options.emplace_back(
"label",
"Keep saved AI");
227 menu_button& ai_selection = find_widget<menu_button>(&row_grid,
"ai_controller",
false);
229 ai_selection.
set_values(ai_options, selection);
238 std::vector<config> controller_names;
239 for(
const auto&
controller : side->controller_options()) {
240 controller_names.emplace_back(
"label",
controller.second);
243 menu_button& controller_selection = find_widget<menu_button>(&row_grid,
"controller",
false);
245 controller_selection.
set_values(controller_names, side->current_controller_index());
246 controller_selection.
set_active(controller_names.size() > 1);
256 button& leader_select = find_widget<button>(&row_grid,
"select_leader",
false);
267 std::vector<config> team_names;
268 unsigned initial_team_selection = 0;
283 entry[
"team_index"] =
i;
285 team_names.push_back(std::move(entry));
290 if(side->team() ==
i) {
291 initial_team_selection = team_names.size() - 1;
295 menu_button& team_selection = find_widget<menu_button>(&row_grid,
"side_team",
false);
297 team_selection.
set_values(team_names, initial_team_selection);
307 std::vector<config> color_options;
308 for(
const auto& color : side->color_options()) {
309 color_options.emplace_back(
311 "icon", (
formatter() <<
"misc/status.png~RC(magenta>" << color <<
")").str()
315 menu_button& color_selection = find_widget<menu_button>(&row_grid,
"side_color",
false);
317 color_selection.
set_values(color_options, side->color());
327 const auto slider_setup_helper = [](
slider&
slider,
const int value) {
339 slider& slider_gold = find_widget<slider>(&row_grid,
"side_gold_slider",
false);
340 slider_setup_helper(slider_gold, side->gold());
343 &mp_staging::on_side_slider_change<&ng::side_engine::set_gold>,
this, side, std::ref(slider_gold)));
345 slider& slider_income = find_widget<slider>(&row_grid,
"side_income_slider",
false);
346 slider_setup_helper(slider_income, side->income());
349 &mp_staging::on_side_slider_change<&ng::side_engine::set_income>,
this, side, std::ref(slider_income)));
371 menu_button& ai_selection = find_widget<menu_button>(&row_grid,
"ai_controller",
false);
372 menu_button& controller_selection = find_widget<menu_button>(&row_grid,
"controller",
false);
374 if(side->controller_changed(controller_selection.
get_value())) {
391 side->set_ai_algorithm(
"use_saved");
401 side->set_color(find_widget<menu_button>(&row_grid,
"side_color",
false).get_value());
414 const unsigned team_index = team_menu.
get_value_config()[
"team_index"].to_unsigned();
416 if(team_index == side->team()) {
422 const std::string old_team = side->team_name();
423 side->set_team(team_index);
425 auto& tree = find_widget<tree_view>(
get_window(),
"side_list",
false);
436 if(old_team_node->
empty()) {
439 tree.remove_node(old_team_node);
449 if(gui2::dialogs::faction_select::execute(side->flg(), side->color_id(), side->index() + 1)) {
456 template<
void(ng::s
ide_engine::*fptr)(
int)>
467 std::string current_leader = side->flg().current_leader() !=
"null" ? side->flg().current_leader() :
font::unicode_em_dash;
468 const std::string current_gender = side->flg().current_gender() !=
"null" ? side->flg().current_gender() :
font::unicode_em_dash;
471 std::string new_image;
473 if(side->flg().is_random_faction() || current_leader ==
"random") {
478 const unit_type&
type = ut->get_gender_unit_type(current_gender);
480 new_image =
formatter() <<
type.image() <<
"~RC(magenta>" << side->color_id() <<
")";
483 current_leader =
type.type_name();
486 find_widget<drawing>(&row_grid,
"leader_image",
false).set_label(new_image);
489 if(!side->cfg()[
"name"].empty()) {
490 current_leader =
formatter() << side->cfg()[
"name"] <<
" (<i>" << current_leader <<
"</i>)";
493 find_widget<label>(&row_grid,
"leader_type",
false).set_label(current_leader ==
"random" ?
_(
"Random") : current_leader);
494 find_widget<label>(&row_grid,
"leader_faction",
false).set_label(side->flg().current_faction()[
"name"]);
498 const std::string gender_icon =
formatter() <<
"icons/icon-" << current_gender <<
".png";
500 image& icon = find_widget<image>(&row_grid,
"leader_gender",
false);
507 find_widget<label>(
get_window(),
"status_label",
false).set_label(
509 ?
_(
"Waiting for players to join...")
510 :
_(
"Waiting for players to choose factions...")
530 find_widget<chatbox>(
get_window(),
"chat",
false).process_network_data(
data);
535 bool quit_signal_received;
538 if(quit_signal_received) {
547 grid& row_grid = tree_entry.second->get_grid();
551 std::vector<config> controller_names;
552 for(
const auto&
controller : side->controller_options()) {
553 controller_names.emplace_back(
"label",
controller.second);
556 menu_button& controller_selection = find_widget<menu_button>(&row_grid,
"controller",
false);
558 controller_selection.
set_values(controller_names, side->current_controller_index());
559 controller_selection.
set_active(controller_names.size() > 1);
563 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_
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 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.
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)
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
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 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
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::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