15 #define GETTEXT_DOMAIN "wesnoth-lib"
49 , connect_engine_(connect_engine)
50 , ai_algorithms_(
ai::configuration::get_available_ais())
51 , network_connection_(connection)
53 , state_changed_(false)
56 , player_list_(
nullptr)
58 set_show_even_without_video(
true);
60 assert(!ai_algorithms_.empty());
77 connect_signal<event::SDL_KEY_DOWN>(std::bind(
91 label& title = find_widget<label>(&
window,
"title",
false);
108 chatbox& chat = find_widget<chatbox>(&
window,
"chat",
false);
138 if(side->team() == side_engine->team() && side->index() > side_engine->index()) {
146 template<
typename... T>
155 if(team_node ==
nullptr) {
161 tree_item[
"label"] = side->user_team_name();
162 tree_data.emplace(
"tree_view_node_label", tree_item);
164 team_node = &tree.
add_node(
"team_header", tree_data);
170 assert(team_node &&
"No team node found!");
171 return team_node->
add_child(std::forward<T>(params)...);
179 item[
"label"] = std::to_string(side->index() + 1);
183 item[
"label"] =
"units/unknown-unit.png~RC(magenta>" + side->color_id() +
")";
186 item[
"label"] =
"icons/icon-random.png";
187 data.emplace(
"leader_gender",
item);
201 const bool lock_gold = side->cfg()[
"gold_lock"].to_bool(fls);
202 const bool lock_income = side->cfg()[
"income_lock"].to_bool(fls);
203 const bool lock_team = side->cfg()[
"team_lock"].to_bool(fls);
204 const bool lock_color = side->cfg()[
"color_lock"].to_bool(fls);
214 std::vector<config> ai_options;
219 ai_options.emplace_back(
"label",
"Keep saved AI");
229 menu_button& ai_selection = find_widget<menu_button>(&row_grid,
"ai_controller",
false);
231 ai_selection.
set_values(ai_options, selection);
240 std::vector<config> controller_names;
241 for(
const auto&
controller : side->controller_options()) {
242 controller_names.emplace_back(
"label",
controller.second);
245 menu_button& controller_selection = find_widget<menu_button>(&row_grid,
"controller",
false);
247 controller_selection.
set_values(controller_names, side->current_controller_index());
248 controller_selection.
set_active(controller_names.size() > 1);
258 button& leader_select = find_widget<button>(&row_grid,
"select_leader",
false);
269 std::vector<config> team_names;
270 unsigned initial_team_selection = 0;
285 entry[
"team_index"] =
i;
287 team_names.push_back(std::move(entry));
292 if(side->team() ==
i) {
293 initial_team_selection = team_names.size() - 1;
297 menu_button& team_selection = find_widget<menu_button>(&row_grid,
"side_team",
false);
299 team_selection.
set_values(team_names, initial_team_selection);
309 std::vector<config> color_options;
310 for(
const auto& color : side->color_options()) {
311 color_options.emplace_back(
313 "icon", (
formatter() <<
"misc/status.png~RC(magenta>" << color <<
")").str()
317 menu_button& color_selection = find_widget<menu_button>(&row_grid,
"side_color",
false);
319 color_selection.
set_values(color_options, side->color());
329 const auto slider_setup_helper = [](
slider&
slider,
const int value) {
341 slider& slider_gold = find_widget<slider>(&row_grid,
"side_gold_slider",
false);
342 slider_setup_helper(slider_gold, side->gold());
345 &mp_staging::on_side_slider_change<&ng::side_engine::set_gold>,
this, side, std::ref(slider_gold)));
347 slider& slider_income = find_widget<slider>(&row_grid,
"side_income_slider",
false);
348 slider_setup_helper(slider_income, side->income());
351 &mp_staging::on_side_slider_change<&ng::side_engine::set_income>,
this, side, std::ref(slider_income)));
373 menu_button& ai_selection = find_widget<menu_button>(&row_grid,
"ai_controller",
false);
374 menu_button& controller_selection = find_widget<menu_button>(&row_grid,
"controller",
false);
376 if(side->controller_changed(controller_selection.
get_value())) {
393 side->set_ai_algorithm(
"use_saved");
403 side->set_color(find_widget<menu_button>(&row_grid,
"side_color",
false).get_value());
416 const unsigned team_index = team_menu.
get_value_config()[
"team_index"].to_unsigned();
418 if(team_index == side->team()) {
424 const std::string old_team = side->team_name();
425 side->set_team(team_index);
427 auto& tree = find_widget<tree_view>(
get_window(),
"side_list",
false);
438 if(old_team_node->
empty()) {
441 tree.remove_node(old_team_node);
451 if(gui2::dialogs::faction_select::execute(side->flg(), side->color_id(), side->index() + 1)) {
458 template<
void(ng::s
ide_engine::*fptr)(
int)>
468 const std::string current_faction = side->flg().current_faction()[
"name"];
471 std::string current_leader = side->flg().current_leader() !=
"null" ? side->flg().current_leader() :
font::unicode_em_dash;
472 const std::string current_gender = side->flg().current_gender() !=
"null" ? side->flg().current_gender() :
font::unicode_em_dash;
475 std::string new_image;
477 if(side->flg().is_random_faction() || current_leader ==
"random") {
482 const unit_type&
type = ut->get_gender_unit_type(current_gender);
484 new_image =
formatter() <<
type.image() <<
"~RC(magenta>" << side->color_id() <<
")";
487 current_leader =
type.type_name();
490 find_widget<drawing>(&row_grid,
"leader_image",
false).set_label(new_image);
493 if(!side->cfg()[
"name"].empty()) {
494 current_leader =
formatter() << side->cfg()[
"name"] <<
" (<i>" << current_leader <<
"</i>)";
497 find_widget<label>(&row_grid,
"leader_type",
false).set_label(current_leader ==
"random" ?
_(
"Random") : current_leader);
498 find_widget<label>(&row_grid,
"leader_faction",
false).set_label(
"<span color='#a69275'>" + current_faction +
"</span>");
502 const std::string gender_icon =
formatter() <<
"icons/icon-" << current_gender <<
".png";
504 image& icon = find_widget<image>(&row_grid,
"leader_gender",
false);
511 find_widget<label>(
get_window(),
"status_label",
false).set_label(
513 ?
_(
"Waiting for players to join...")
514 :
_(
"Waiting for players to choose factions...")
534 find_widget<chatbox>(
get_window(),
"chat",
false).process_network_data(
data);
539 bool quit_signal_received;
542 if(quit_signal_received) {
551 grid& row_grid = tree_entry.second->get_grid();
555 std::vector<config> controller_names;
556 for(
const auto&
controller : side->controller_options()) {
557 controller_names.emplace_back(
"label",
controller.second);
560 menu_button& controller_selection = find_widget<menu_button>(&row_grid,
"controller",
false);
562 controller_selection.
set_values(controller_names, side->current_controller_index());
563 controller_selection.
set_active(controller_names.size() > 1);
567 if(
data.has_child(
"user")) {
583 const SDL_Keycode key,
590 const SDL_Keycode modifier_key = KMOD_GUI;
594 const SDL_Keycode modifier_key = KMOD_CTRL;
597 if ((key == SDLK_g) && (modifier & modifier_key)) {
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 signal_handler_sdl_key_down(const event::ui_event, bool &handled, const SDL_Keycode key, SDL_Keymod modifier)
for Ctrl+G handling
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 text that 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)
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(tod_new_schedule)
ui_event
The event sent to the dispatcher.
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.
saved_game_mode::type saved_game
std::string user_team_name
unit_type_data unit_types