mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-17 11:28:16 +00:00
gui2/tmp_join_game_password_prompt: Port GUI1 MP password prompt (bug #23455)
This is the prompt for joining a password-protected game, not for configuring password protection (which was already ported to GUI2 ages ago).
This commit is contained in:
parent
0b3b0a139d
commit
0fcf4e3cb9
@ -187,6 +187,8 @@ Version 1.13.0-dev:
|
||||
specify backwards compatibility with earlier versions.
|
||||
* Missing content for games hosted in the mp server may now be retrieved
|
||||
automatically by clicking on these games in the mp lobby.
|
||||
* Ported the password prompt displayed when joining a password-protected MP
|
||||
game to GUI2 (bug #23455).
|
||||
* Music:
|
||||
* Change main menu track to Journey's End.
|
||||
* Replays:
|
||||
|
167
data/gui/default/window/mp_join_game_password_prompt.cfg
Normal file
167
data/gui/default/window/mp_join_game_password_prompt.cfg
Normal file
@ -0,0 +1,167 @@
|
||||
#textdomain wesnoth-lib
|
||||
###
|
||||
### Definition of the window to place and edit gamemap labels
|
||||
###
|
||||
|
||||
[window]
|
||||
id = "mp_join_game_password_prompt"
|
||||
description = "Dialog for entering a password to join a password-protected MP game."
|
||||
|
||||
[resolution]
|
||||
definition = "default"
|
||||
|
||||
automatic_placement = "true"
|
||||
vertical_placement = "center"
|
||||
horizontal_placement = "center"
|
||||
|
||||
maximum_width = 800
|
||||
|
||||
[tooltip]
|
||||
id = "tooltip_large"
|
||||
[/tooltip]
|
||||
|
||||
[helptip]
|
||||
id = "tooltip_large"
|
||||
[/helptip]
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
[label]
|
||||
id = "title"
|
||||
definition = "title"
|
||||
|
||||
label = _ "Password Required"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
[scroll_label]
|
||||
id = "message"
|
||||
definition = "default"
|
||||
|
||||
label = _ "Joining this game requires a password."
|
||||
[/scroll_label]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
|
||||
horizontal_grow = "true"
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[label]
|
||||
definition = "default"
|
||||
label = _ "Password:"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_grow = "true"
|
||||
|
||||
[text_box]
|
||||
id = "password"
|
||||
definition = "default"
|
||||
label = ""
|
||||
[/text_box]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
horizontal_alignment = "right"
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
|
||||
[button]
|
||||
id = "ok"
|
||||
definition = "default"
|
||||
label = _ "OK"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
|
||||
[button]
|
||||
id = "cancel"
|
||||
definition = "default"
|
||||
label = _ "Cancel"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/resolution]
|
||||
|
||||
[/window]
|
@ -689,6 +689,8 @@
|
||||
<Unit filename="../../src/gui/dialogs/mp_create_game_set_password.hpp" />
|
||||
<Unit filename="../../src/gui/dialogs/mp_host_game_prompt.cpp" />
|
||||
<Unit filename="../../src/gui/dialogs/mp_host_game_prompt.hpp" />
|
||||
<Unit filename="../../src/gui/dialogs/mp_join_game_password_prompt.cpp" />
|
||||
<Unit filename="../../src/gui/dialogs/mp_join_game_password_prompt.hpp" />
|
||||
<Unit filename="../../src/gui/dialogs/mp_login.cpp" />
|
||||
<Unit filename="../../src/gui/dialogs/mp_login.hpp" />
|
||||
<Unit filename="../../src/gui/dialogs/mp_method_selection.cpp" />
|
||||
|
@ -890,6 +890,7 @@ set(wesnoth-main_SRC
|
||||
gui/dialogs/mp_create_game.cpp
|
||||
gui/dialogs/mp_create_game_set_password.cpp
|
||||
gui/dialogs/mp_host_game_prompt.cpp
|
||||
gui/dialogs/mp_join_game_password_prompt.cpp
|
||||
gui/dialogs/mp_login.cpp
|
||||
gui/dialogs/mp_method_selection.cpp
|
||||
gui/dialogs/network_transmission.cpp
|
||||
|
@ -425,6 +425,7 @@ wesnoth_sources = Split("""
|
||||
gui/dialogs/mp_create_game.cpp
|
||||
gui/dialogs/mp_create_game_set_password.cpp
|
||||
gui/dialogs/mp_host_game_prompt.cpp
|
||||
gui/dialogs/mp_join_game_password_prompt.cpp
|
||||
gui/dialogs/mp_login.cpp
|
||||
gui/dialogs/mp_method_selection.cpp
|
||||
gui/dialogs/network_transmission.cpp
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "gettext.hpp"
|
||||
#include "gui/auxiliary/old_markup.hpp"
|
||||
#include "gui/dialogs/message.hpp" // for gui2::show_message
|
||||
#include "gui/dialogs/mp_join_game_password_prompt.hpp"
|
||||
#include "gui/widgets/window.hpp" // for gui2::twindow::OK
|
||||
#include "lobby_reload_request_exception.hpp"
|
||||
#include "log.hpp"
|
||||
@ -1265,10 +1266,7 @@ void lobby::process_event_impl(const process_event_data & data)
|
||||
|
||||
std::string password;
|
||||
if(join && game.password_required) {
|
||||
const int res = gui::show_dialog(disp_, NULL, _("Password Required"),
|
||||
_("Joining this game requires a password."),
|
||||
gui::OK_CANCEL, NULL, NULL, _("Password: "), &password);
|
||||
if(res != 0) {
|
||||
if(!gui2::tmp_join_game_password_prompt::execute(password, disp_.video())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include "gui/dialogs/lobby_main.hpp"
|
||||
#include "gui/dialogs/lobby_player_info.hpp"
|
||||
#include "gui/dialogs/mp_join_game_password_prompt.hpp"
|
||||
#include "gui/dialogs/field.hpp"
|
||||
#include "gui/dialogs/helper.hpp"
|
||||
|
||||
@ -1643,23 +1644,11 @@ bool tlobby_main::do_game_join(int idx, bool observe)
|
||||
join["observe"] = observe;
|
||||
if(join && !observe && game.password_required) {
|
||||
std::string password;
|
||||
// TODO replace with a gui2 dialog
|
||||
const int res
|
||||
= gui::show_dialog(disp_,
|
||||
NULL,
|
||||
_("Password Required"),
|
||||
_("Joining this game requires a password."),
|
||||
gui::OK_CANCEL,
|
||||
NULL,
|
||||
NULL,
|
||||
_("Password: "),
|
||||
&password);
|
||||
if(res != 0) {
|
||||
if(!gui2::tmp_join_game_password_prompt::execute(password, disp_.video())) {
|
||||
return false;
|
||||
}
|
||||
if(!password.empty()) {
|
||||
join["password"] = password;
|
||||
}
|
||||
|
||||
join["password"] = password;
|
||||
}
|
||||
network::send_data(response, 0);
|
||||
if(observe && game.started) {
|
||||
|
46
src/gui/dialogs/mp_join_game_password_prompt.cpp
Normal file
46
src/gui/dialogs/mp_join_game_password_prompt.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
Copyright (C) 2015 by Ignacio Riquelme Morelle <shadowm2006@gmail.com>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#include "gui/dialogs/mp_join_game_password_prompt.hpp"
|
||||
|
||||
#include "gui/widgets/settings.hpp"
|
||||
|
||||
namespace gui2
|
||||
{
|
||||
|
||||
/*WIKI
|
||||
* @page = GUIWindowDefinitionWML
|
||||
* @order = 2_mp_join_game_password_prompt
|
||||
*
|
||||
* == Join Game: Password Prompt ==
|
||||
*
|
||||
* Dialog for entering a password for joining a password-protected MP game.
|
||||
*
|
||||
* @begin{table}{dialog_widgets}
|
||||
*
|
||||
* password & & text_box & m &
|
||||
* Input field for the game password. $
|
||||
*
|
||||
* @end{table}
|
||||
*/
|
||||
|
||||
REGISTER_DIALOG(mp_join_game_password_prompt)
|
||||
|
||||
tmp_join_game_password_prompt::tmp_join_game_password_prompt(
|
||||
std::string& password)
|
||||
{
|
||||
register_text("password", true, password, true);
|
||||
}
|
||||
|
||||
} // end namespace gui2
|
50
src/gui/dialogs/mp_join_game_password_prompt.hpp
Normal file
50
src/gui/dialogs/mp_join_game_password_prompt.hpp
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
Copyright (C) 2015 by Ignacio Riquelme Morelle <shadowm2006@gmail.com>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#ifndef GUI_DIALOGS_MP_JOIN_GAME_PASSWORD_PROMPT_HPP_INCLUDED
|
||||
#define GUI_DIALOGS_MP_JOIN_GAME_PASSWORD_PROMPT_HPP_INCLUDED
|
||||
|
||||
#include "gui/dialogs/dialog.hpp"
|
||||
|
||||
namespace gui2
|
||||
{
|
||||
|
||||
class tmp_join_game_password_prompt : public tdialog
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param [in, out] password The parameter's usage is:
|
||||
* - Input: The initial value for the password.
|
||||
* - Output: The password input by the user
|
||||
* if the dialog returns @ref twindow::OK,
|
||||
* undefined otherwise.
|
||||
*/
|
||||
explicit tmp_join_game_password_prompt(std::string& password);
|
||||
|
||||
/** The execute function -- see @ref tdialog for more information. */
|
||||
static bool execute(std::string& password, CVideo& video)
|
||||
{
|
||||
return tmp_join_game_password_prompt(password).show(video);
|
||||
}
|
||||
|
||||
private:
|
||||
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
|
||||
virtual const std::string& window_id() const;
|
||||
};
|
||||
|
||||
} // namespace gui2
|
||||
|
||||
#endif /* ! GUI_DIALOGS_MP_JOIN_GAME_PASSWORD_PROMPT_HPP_INCLUDED */
|
Loading…
x
Reference in New Issue
Block a user