16 #define GETTEXT_DOMAIN "wesnoth-lib"
32 #include <boost/algorithm/string/trim.hpp>
35 #define ERR_DLG LOG_STREAM(err, log_mpconnect)
36 #define WRN_DLG LOG_STREAM(warn, log_mpconnect)
37 #define LOG_DLG LOG_STREAM(info, log_mpconnect)
38 #define DBG_DLG LOG_STREAM(debug, log_mpconnect)
48 void clear_listbox_selection(listbox& listbox)
50 const auto selection = listbox.get_selected_row();
52 listbox.select_row(selection,
false);
66 , host_name_(register_text("host_name",
71 , builtin_servers_(
prefs::get().builtin_servers_list())
72 , user_servers_(
prefs::get().user_servers_list())
83 text_box& hostname_box = find_widget<text_box>(
"host_name");
85 button& button_add = find_widget<button>(
"server_add");
86 button& button_del = find_widget<button>(
"server_delete");
89 for(
const auto& server : *servers) {
114 text_box& hostname_box = find_widget<text_box>(
"host_name");
116 button& button_add = find_widget<button>(
"server_add");
117 button& button_del = find_widget<button>(
"server_delete");
119 const auto& address = boost::trim_copy(hostname_box.
get_value());
124 for(
const auto& server : *servers) {
125 if(server.address == address) {
160 text_box& hostname_box = find_widget<text_box>(
"host_name");
163 const auto& address = boost::trim_copy(hostname_box.
get_value());
181 if(!gui2::dialogs::edit_text::execute(
_(
"Add Server"),
_(
"Name:"), name,
true) || name.empty()) {
187 info.address = address;
216 text_box& hostname_box = find_widget<text_box>(
"host_name");
217 button& button_add = find_widget<button>(
"server_add");
218 button& button_del = find_widget<button>(
"server_delete");
254 return valid() && std::size_t(row_) >=
owner_->builtin_servers_.size();
260 return unsigned(row_);
266 return user_defined() ? row() -
owner_->builtin_servers_.size() : row();
272 return user_defined() ?
owner_->user_servers_ :
owner_->builtin_servers_;
Abstract base class for all modal dialogs.
bool user_defined() const
server_list & parent_list() const
void must_be_valid() const
std::size_t relative_index() const
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() 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.
A widget that allows the user to input text in single line.
dialogs::modal_dialog * owner_
The dialog that owns the window.
void set_network_host(const std::string &host)
std::string network_host()
void set_user_servers_list(const std::vector< game_config::server_info > &value)
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).
static lg::log_domain log_mpconnect
Various uncategorised dialogs.
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::map< std::string, widget_item > widget_data
std::map< std::string, t_string > widget_item
std::string address
may include ':' followed by port number