16 #define GETTEXT_DOMAIN "wesnoth-lib"
33 #include <boost/algorithm/string/trim.hpp>
36 #define ERR_DLG LOG_STREAM(err, log_mpconnect)
37 #define WRN_DLG LOG_STREAM(warn, log_mpconnect)
38 #define LOG_DLG LOG_STREAM(info, log_mpconnect)
39 #define DBG_DLG LOG_STREAM(debug, log_mpconnect)
49 void clear_listbox_selection(listbox& listbox)
51 const auto selection = listbox.get_selected_row();
53 listbox.select_row(selection,
false);
67 , host_name_(register_text("host_name",
84 text_box& hostname_box = find_widget<text_box>(&win,
"host_name",
false);
86 button& button_add = find_widget<button>(&win,
"server_add",
false);
87 button& button_del = find_widget<button>(&win,
"server_delete",
false);
90 for(
const auto& server : *servers) {
117 text_box& hostname_box = find_widget<text_box>(
window,
"host_name",
false);
119 button& button_add = find_widget<button>(
window,
"server_add",
false);
120 button& button_del = find_widget<button>(
window,
"server_delete",
false);
122 const auto& address = boost::trim_copy(hostname_box.
get_value());
127 for(
const auto& server : *servers) {
128 if(server.address == address) {
165 text_box& hostname_box = find_widget<text_box>(
window,
"host_name",
false);
168 const auto& address = boost::trim_copy(hostname_box.
get_value());
186 if(!gui2::dialogs::edit_text::execute(
_(
"Add Server"),
_(
"Name:"), name,
true) || name.empty()) {
192 info.address = address;
225 text_box& hostname_box = find_widget<text_box>(
window,
"host_name",
false);
226 button& button_add = find_widget<button>(
window,
"server_add",
false);
227 button& button_del = find_widget<button>(
window,
"server_delete",
false);
262 return unsigned(row_);
268 return user_defined() ? row() -
owner_->builtin_servers_.size() : row();
274 return user_defined() ?
owner_->user_servers_ :
owner_->builtin_servers_;
Abstract base class for all modal dialogs.
window * get_window()
Returns a pointer to the dialog's window.
bool user_defined() const
server_list & parent_list() const
void must_be_valid() const
std::size_t relative_index() const
This shows the dialog to the MP server to connect to.
void insert_into_server_listbox(listbox &listbox, const server_info &srv, int pos=-1)
std::vector< server_info > server_list
void select_first_match()
selection current_selection()
std::array< server_list *, 2 > server_lists()
server_list user_servers_
server_list builtin_servers_
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
grid & add_row(const widget_item &item, const int index=-1)
When an item in the list is selected by the user we need to update the state.
std::string get_value() const
virtual void set_value(const std::string &text)
The set_value is virtual for the password_box class.
Class for a single line text area.
base class of top level items, the only item which needs to store the final canvases to draw on.
dialogs::modal_dialog * owner_
The dialog that owns the window.
Implements some helper classes to ease adding fields to a dialog and hide the synchronization needed.
static std::string _(const char *str)
Standard logging facilities (interface).
#define REGISTER_DIALOG(window_id)
Wrapper for REGISTER_DIALOG2.
static lg::log_domain log_mpconnect
Various uncategorised dialogs.
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::map< std::string, widget_item > widget_data
std::map< std::string, t_string > widget_item
Modify, read and display user preferences.
void set_user_servers_list(const std::vector< game_config::server_info > &value)
std::string network_host()
std::vector< game_config::server_info > user_servers_list()
void set_network_host(const std::string &host)
const std::vector< game_config::server_info > & builtin_servers_list()
This file contains the settings handling of the widget library.
std::string address
may include ':' followed by port number