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>(&win,
"host_name",
false);
85 button& button_add = find_widget<button>(&win,
"server_add",
false);
86 button& button_del = find_widget<button>(&win,
"server_delete",
false);
89 for(
const auto& server : *servers) {
116 text_box& hostname_box = find_widget<text_box>(
window,
"host_name",
false);
118 button& button_add = find_widget<button>(
window,
"server_add",
false);
119 button& button_del = find_widget<button>(
window,
"server_delete",
false);
121 const auto& address = boost::trim_copy(hostname_box.
get_value());
126 for(
const auto& server : *servers) {
127 if(server.address == address) {
164 text_box& hostname_box = find_widget<text_box>(
window,
"host_name",
false);
167 const auto& address = boost::trim_copy(hostname_box.
get_value());
185 if(!gui2::dialogs::edit_text::execute(
_(
"Add Server"),
_(
"Name:"), name,
true) || name.empty()) {
191 info.address = address;
224 text_box& hostname_box = find_widget<text_box>(
window,
"host_name",
false);
225 button& button_add = find_widget<button>(
window,
"server_add",
false);
226 button& button_del = find_widget<button>(
window,
"server_delete",
false);
261 return unsigned(row_);
267 return user_defined() ? row() -
owner_->builtin_servers_.size() : row();
273 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
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.
A widget that allows the user to input text in single line.
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.
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