* MP Method Selection: clarified the account requirement for the official server

Also sets the tooltip type for this dialog back to bottom-of-the-screen ones instead
of floating ones. And some formatting cleanup to the C++.

(cherry-picked from commit 851b28e24b)
This commit is contained in:
Charles Dang 2018-05-06 16:39:31 +11:00
parent ff61a878c8
commit d90c6d9d34
2 changed files with 66 additions and 18 deletions

View file

@ -14,17 +14,19 @@
vertical_placement = "center"
horizontal_placement = "center"
maximum_width = 420
[linked_group]
id = "icon"
fixed_width = true
[/linked_group]
[tooltip]
id = "tooltip"
id = "tooltip_large"
[/tooltip]
[helptip]
id = "tooltip"
id = "tooltip_large"
[/helptip]
[grid]
@ -81,17 +83,13 @@
border = "all"
border_size = 5
horizontal_alignment = "right"
horizontal_grow = true
[text_box]
id = "user_name"
definition = "default"
history = "mp_user_name_history"
max_input_length = 20
tooltip = _ "You may login to the official multiplayer server with your forum username and password.
The Battle for Wesnoth forum can be found at https://forums.wesnoth.org/"
[/text_box]
[/column]
@ -104,6 +102,52 @@ The Battle for Wesnoth forum can be found at https://forums.wesnoth.org/"
[/row]
[row]
grow_factor = 0
[column]
horizontal_grow = true
[grid]
[row]
[column]
border = "all"
border_size = 5
horizontal_grow = true
[label]
label = _ "A registered account on the Wesnoth forums is required to join the official server."
wrap = true
[/label]
[/column]
[column]
border = "all"
border_size = 5
horizontal_alignment = "right"
[button]
id = "register"
definition = "default"
label = _ "Sign Up"
[/button]
[/column]
[/row]
[/grid]
[/column]
[/row]
{GUI_FILLER_ROW HEIGHT=10}
[row]
grow_factor = 1

View file

@ -16,24 +16,24 @@
#include "gui/dialogs/multiplayer/mp_method_selection.hpp"
#include "preferences/credentials.hpp"
#include "desktop/open.hpp"
#include "game_initialization/multiplayer.hpp"
#include "gui/auxiliary/find_widget.hpp"
#include "gui/widgets/button.hpp"
#ifdef GUI2_EXPERIMENTAL_LISTBOX
#include "gui/widgets/list.hpp"
#else
#include "gui/widgets/listbox.hpp"
#endif
#include "gui/widgets/window.hpp"
#include "gui/widgets/settings.hpp"
#include "gui/widgets/text_box.hpp"
#include "gui/widgets/toggle_button.hpp"
#include "game_initialization/multiplayer.hpp"
#include "gui/widgets/window.hpp"
#include "preferences/credentials.hpp"
namespace gui2
{
namespace dialogs
{
/*WIKI
* @page = GUIWindowDefinitionWML
* @order = 2_mp_method_selection
@ -56,30 +56,34 @@ namespace dialogs
REGISTER_DIALOG(mp_method_selection)
static const std::string forum_registration_url = "https://forums.wesnoth.org/ucp.php?mode=register";
void mp_method_selection::pre_show(window& window)
{
user_name_ = preferences::login();
text_box* user_widget
= find_widget<text_box>(&window, "user_name", false, true);
text_box* user_widget = find_widget<text_box>(&window, "user_name", false, true);
user_widget->set_value(user_name_);
user_widget->set_maximum_length(mp::max_login_size);
window.keyboard_capture(user_widget);
listbox* list = find_widget<listbox>(&window, "method_list", false, true);
window.add_to_keyboard_chain(list);
connect_signal_mouse_left_click(find_widget<button>(&window, "register", false),
std::bind(&desktop::open_object, forum_registration_url));
}
void mp_method_selection::post_show(window& window)
{
if(get_retval() == retval::OK) {
text_box& user_widget
= find_widget<text_box>(&window, "user_name", false);
listbox& list = find_widget<listbox>(&window, "method_list", false);
choice_ = list.get_selected_row();
text_box& user_widget = find_widget<text_box>(&window, "user_name", false);
user_widget.save_to_history();
user_name_ = user_widget.get_value();
preferences::set_login(user_name_);
}