Convert the MP create game-set password dialog to GUI2
This commit is contained in:
parent
8ad14c9312
commit
95667feed3
7 changed files with 262 additions and 2 deletions
136
data/gui/default/window/mp_create_game_set_password.cfg
Normal file
136
data/gui/default/window/mp_create_game_set_password.cfg
Normal file
|
@ -0,0 +1,136 @@
|
|||
#textdomain wesnoth-lib
|
||||
###
|
||||
### Definition of the window to place and edit gamemap labels
|
||||
###
|
||||
|
||||
[window]
|
||||
id = "mp_create_game_set_password"
|
||||
description = "Dialog for setting a join password for MP games."
|
||||
|
||||
[resolution]
|
||||
definition = "default"
|
||||
|
||||
automatic_placement = "true"
|
||||
vertical_placement = "center"
|
||||
horizontal_placement = "center"
|
||||
|
||||
maximum_width = 800
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
[label]
|
||||
id = "title"
|
||||
definition = "title"
|
||||
|
||||
label = _ "Set Password"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
[scroll_label]
|
||||
id = "message"
|
||||
definition = "default"
|
||||
|
||||
label = _ "Set the password that people wanting to join your game as players must enter."
|
||||
[/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]
|
||||
# grow_factor = 1
|
||||
# horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
|
||||
[button]
|
||||
id = "ok"
|
||||
definition = "default"
|
||||
|
||||
label = _ "OK"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/resolution]
|
||||
|
||||
[/window]
|
|
@ -420,6 +420,7 @@ set(wesnoth-main_SRC
|
|||
gui/dialogs/message.cpp
|
||||
gui/dialogs/mp_connect.cpp
|
||||
gui/dialogs/mp_create_game.cpp
|
||||
gui/dialogs/mp_create_game_set_password.cpp
|
||||
gui/dialogs/mp_method_selection.cpp
|
||||
gui/dialogs/mp_cmd_wrapper.cpp
|
||||
gui/dialogs/simple_item_selector.cpp
|
||||
|
|
|
@ -191,6 +191,7 @@ wesnoth_source = \
|
|||
gui/dialogs/message.cpp \
|
||||
gui/dialogs/mp_connect.cpp \
|
||||
gui/dialogs/mp_create_game.cpp \
|
||||
gui/dialogs/mp_create_game_set_password.cpp \
|
||||
gui/dialogs/mp_method_selection.cpp \
|
||||
gui/dialogs/mp_cmd_wrapper.cpp \
|
||||
gui/dialogs/simple_item_selector.cpp \
|
||||
|
|
|
@ -359,6 +359,7 @@ wesnoth_sources = Split("""
|
|||
gui/dialogs/message.cpp
|
||||
gui/dialogs/mp_connect.cpp
|
||||
gui/dialogs/mp_create_game.cpp
|
||||
gui/dialogs/mp_create_game_set_password.cpp
|
||||
gui/dialogs/mp_method_selection.cpp
|
||||
gui/dialogs/mp_cmd_wrapper.cpp
|
||||
gui/dialogs/simple_item_selector.cpp
|
||||
|
|
66
src/gui/dialogs/mp_create_game_set_password.cpp
Normal file
66
src/gui/dialogs/mp_create_game_set_password.cpp
Normal file
|
@ -0,0 +1,66 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2010 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.
|
||||
*/
|
||||
|
||||
#define GETTEXT_DOMAIN "wesnoth-lib"
|
||||
|
||||
#include "gui/dialogs/mp_create_game_set_password.hpp"
|
||||
|
||||
#include "gui/dialogs/field.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
/*WIKI
|
||||
* @page = GUIWindowDefinitionWML
|
||||
* @order = 2_mp_create_game_set_password
|
||||
*
|
||||
* == Create Game: Set Password ==
|
||||
*
|
||||
* Dialog for setting a join password for MP games.
|
||||
*
|
||||
* @begin{table}[dialog_widgets]
|
||||
*
|
||||
* password & & text_box & m &
|
||||
* Input field for the game password. $
|
||||
*
|
||||
* @end{table}
|
||||
*/
|
||||
|
||||
REGISTER_WINDOW(mp_create_game_set_password)
|
||||
|
||||
tmp_create_game_set_password::tmp_create_game_set_password(const std::string& password)
|
||||
: password_(password)
|
||||
, password_field_(register_text("password", false))
|
||||
{
|
||||
}
|
||||
|
||||
void tmp_create_game_set_password::pre_show(CVideo& /*video*/, twindow& window)
|
||||
{
|
||||
assert(password_field_);
|
||||
password_field_->set_widget_value(window, password_);
|
||||
window.keyboard_capture(password_field_->widget(window));
|
||||
}
|
||||
|
||||
void tmp_create_game_set_password::post_show(twindow& window)
|
||||
{
|
||||
if(get_retval() != twindow::OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
password_ = password_field_->get_widget_value(window);
|
||||
}
|
||||
|
||||
}
|
53
src/gui/dialogs/mp_create_game_set_password.hpp
Normal file
53
src/gui/dialogs/mp_create_game_set_password.hpp
Normal file
|
@ -0,0 +1,53 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2010 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_CREATE_GAME_SET_PASSWORD_HPP_INCLUDED
|
||||
#define GUI_DIALOGS_MP_CREATE_GAME_SET_PASSWORD_HPP_INCLUDED
|
||||
|
||||
#include "gui/dialogs/dialog.hpp"
|
||||
#include "gui/dialogs/field-fwd.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
class tmp_create_game_set_password : public tdialog
|
||||
{
|
||||
public:
|
||||
tmp_create_game_set_password(const std::string& password);
|
||||
|
||||
const std::string& password() const {
|
||||
return password_;
|
||||
}
|
||||
|
||||
void set_password(const std::string& password) {
|
||||
password_ = password;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string password_;
|
||||
tfield_text* password_field_;
|
||||
|
||||
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
|
||||
virtual const std::string& window_id() const;
|
||||
|
||||
/** Inherited from tdialog. */
|
||||
void pre_show(CVideo& video, twindow& window);
|
||||
|
||||
/** Inherited from tdialog. */
|
||||
void post_show(twindow& window);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* ! GUI_DIALOGS_MP_CREATE_GAME_SET_PASSWORD_HPP_INCLUDED */
|
|
@ -30,6 +30,7 @@
|
|||
#include "map_exception.hpp"
|
||||
#include "map_create.hpp"
|
||||
#include "gui/dialogs/message.hpp"
|
||||
#include "gui/dialogs/mp_create_game_set_password.hpp"
|
||||
#include "gui/dialogs/transient_message.hpp"
|
||||
#include "minimap.hpp"
|
||||
#include "multiplayer_create.hpp"
|
||||
|
@ -342,8 +343,9 @@ void create::process_event()
|
|||
}
|
||||
|
||||
if(password_button_.pressed()) {
|
||||
gui::show_dialog(disp_, NULL, _("Set Password"),
|
||||
_("Set the password that people wanting to join your game as players must enter."), gui::OK_ONLY, NULL, NULL, _("Password: "), ¶meters_.password);
|
||||
gui2::tmp_create_game_set_password pwd_dlg(parameters_.password);
|
||||
pwd_dlg.show(disp_.video());
|
||||
parameters_.password = pwd_dlg.password();
|
||||
}
|
||||
|
||||
// Turns per game
|
||||
|
|
Loading…
Add table
Reference in a new issue