[GSoC Uni_] Moved online gaming related gui xml files to a separate folder. Changed the login dialog to have an input message and started with a registration dialog.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@12976 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
unitraxx 2013-06-25 15:16:03 +00:00
parent 18828d5668
commit f553d962d5
9 changed files with 271 additions and 39 deletions

View File

@ -1,6 +1,6 @@
<stkgui> <stkgui>
<div x="2%" y="10%" width="96%" height="80%" layout="vertical-row" > <div x="2%" y="5%" width="96%" height="90%" layout="vertical-row" >
<header id="title" width="96%" proportion="2" text_align="center" word_wrap="true" <header id="title" width="96%" proportion="2" text_align="center" word_wrap="true"
I18N="In the login dialog' dialog" text="Sign in"/> I18N="In the login dialog' dialog" text="Sign in"/>
@ -9,29 +9,28 @@
<div width="80%" align="center" layout="vertical-row" proportion="4"> <div width="80%" align="center" layout="vertical-row" proportion="4">
<div width="100%" height="fit" layout="horizontal-row" > <div width="100%" height="fit" layout="horizontal-row" >
<label proportion="1" text_align="left" I18N="In the login form" text="Username"/> <label proportion="1" text_align="left" I18N="In the login dialog" text="Username"/>
<textbox proportion="2" id="username" I18N="In the login dialog"/> <textbox proportion="2" id="username" I18N="In the login dialog"/>
</div> </div>
<spacer height="20" width="20"> <spacer height="20" width="20">
<div width="100%" height="fit" layout="horizontal-row" > <div width="100%" height="fit" layout="horizontal-row" >
<label proportion="1" text_align="left" I18N="In the login form" text="Password"/> <label proportion="1" text_align="left" I18N="In the login dialog" text="Password"/>
<textbox proportion="2" id="password" I18N="In the login dialog"/> <textbox proportion="2" id="password" I18N="In the login dialog"/>
</div> </div>
</div> </div>
<label id="info" proportion="2" width="90%" align="center" text_align="center" word_wrap="true" <label id="info" proportion="2" width="90%" align="center" text_align="center" word_wrap="true" dialog" text=""/>
I18N="In the login dialog' dialog" text=""/>
<spacer height="20" width="50"> <spacer height="20" width="50">
<div id="options" width="fit" height="fit" align="center" layout="horizontal-row"> <div id="options" width="fit" proportion="2" align="center" layout="horizontal-row">
<button id="signin" height="100%" align="center" width="fit" I18N="In the login dialog" text="Sign In"/> <button id="signin" height="fit" align="center" width="fit" I18N="In the login dialog" text="Sign In"/>
<spacer height="50" width="50"> <spacer height="50" width="50">
<button id="signup" height="100%" align="center" width="fit" I18N="In the login dialog" text="Register"/> <button id="signup" height="fit" align="center" width="fit" I18N="In the login dialog" text="Register"/>
<spacer height="50" width="50"> <spacer height="50" width="50">
<button id="cancel" height="100%" align="center" width="fit" I18N="In the login dialog" text="Cancel"/> <button id="cancel" height="fit" align="center" width="fit" I18N="In the login dialog" text="Cancel"/>
</div> </div>

View File

@ -0,0 +1,61 @@
<stkgui>
<div x="2%" y="5%" width="96%" height="90%" layout="vertical-row" >
<header id="title" width="96%" proportion="1" text_align="center" word_wrap="true"
I18N="In the registration dialog' dialog" text="Registration"/>
<spacer height="50" width="50">
<div width="80%" align="center" layout="vertical-row" proportion="6">
<div width="100%" height="fit" layout="horizontal-row" >
<label proportion="1" text_align="left" I18N="In the registration dialog" text="Username"/>
<textbox proportion="2" id="username" I18N="In the registration dialog"/>
</div>
<spacer height="20" width="20">
<div width="100%" height="fit" layout="horizontal-row" >
<label proportion="1" text_align="left" I18N="In the registration dialog" text="Password"/>
<textbox proportion="2" id="password" I18N="In the registration dialog"/>
</div>
<spacer height="20" width="20">
<div width="100%" height="fit" layout="horizontal-row" >
<label proportion="1" text_align="left" I18N="In the registration dialog" text="Confirm"/>
<textbox proportion="2" id="password_confirm" I18N="In the registration dialog"/>
</div>
<spacer height="20" width="20">
<div width="100%" height="fit" layout="horizontal-row" >
<label proportion="1" text_align="left" I18N="In the registration dialog" text="Email"/>
<textbox proportion="2" id="email" I18N="In the registration dialog"/>
</div>
<spacer height="20" width="20">
<div width="100%" height="fit" layout="horizontal-row" >
<label proportion="1" text_align="left" I18N="In the registration dialog" text="Confirm"/>
<textbox proportion="2" id="email_confirm" I18N="In the registration dialog"/>
</div>
</div>
<label id="info" proportion="1" width="90%" align="center" text_align="center" word_wrap="true"
I18N="In the registration dialog' dialog" text=""/>
<spacer height="20" width="50">
<div id="options" width="fit" proportion="1" align="center" layout="horizontal-row">
<button id="previous" height="fit" align="center" width="fit" I18N="In the registration dialog" text="Previous"/>
<spacer height="50" width="50">
<button id="next" height="fit" align="center" width="fit" I18N="In the registration dialog" text="Next"/>
<spacer height="50" width="50">
<button id="cancel" height="fit" align="center" width="fit" I18N="In the registration dialog" text="Cancel"/>
</div>
</div>
</stkgui>

View File

@ -177,6 +177,7 @@ src/states_screens/dialogs/message_dialog.cpp
src/states_screens/dialogs/player_info_dialog.cpp src/states_screens/dialogs/player_info_dialog.cpp
src/states_screens/dialogs/press_a_key_dialog.cpp src/states_screens/dialogs/press_a_key_dialog.cpp
src/states_screens/dialogs/race_paused_dialog.cpp src/states_screens/dialogs/race_paused_dialog.cpp
src/states_screens/dialogs/registration_dialog.cpp
src/states_screens/dialogs/select_challenge.cpp src/states_screens/dialogs/select_challenge.cpp
src/states_screens/dialogs/track_info_dialog.cpp src/states_screens/dialogs/track_info_dialog.cpp
src/states_screens/dialogs/tutorial_message_dialog.cpp src/states_screens/dialogs/tutorial_message_dialog.cpp
@ -442,6 +443,7 @@ src/states_screens/dialogs/message_dialog.hpp
src/states_screens/dialogs/player_info_dialog.hpp src/states_screens/dialogs/player_info_dialog.hpp
src/states_screens/dialogs/press_a_key_dialog.hpp src/states_screens/dialogs/press_a_key_dialog.hpp
src/states_screens/dialogs/race_paused_dialog.hpp src/states_screens/dialogs/race_paused_dialog.hpp
src/states_screens/dialogs/registration_dialog.hpp
src/states_screens/dialogs/select_challenge.hpp src/states_screens/dialogs/select_challenge.hpp
src/states_screens/dialogs/track_info_dialog.hpp src/states_screens/dialogs/track_info_dialog.hpp
src/states_screens/dialogs/tutorial_message_dialog.hpp src/states_screens/dialogs/tutorial_message_dialog.hpp
@ -516,5 +518,6 @@ src/utils/string_utils.hpp
src/utils/synchronised.hpp src/utils/synchronised.hpp
src/utils/time.hpp src/utils/time.hpp
src/utils/translation.hpp src/utils/translation.hpp
src/utils/types.hpp
src/utils/vec3.hpp src/utils/vec3.hpp
) )

View File

@ -20,7 +20,6 @@
#include <IGUIEnvironment.h> #include <IGUIEnvironment.h>
#include "audio/sfx_manager.hpp" #include "audio/sfx_manager.hpp"
#include "challenges/unlock_manager.hpp"
#include "config/player.hpp" #include "config/player.hpp"
#include "guiengine/engine.hpp" #include "guiengine/engine.hpp"
#include "guiengine/widgets/button_widget.hpp" #include "guiengine/widgets/button_widget.hpp"
@ -30,6 +29,7 @@
#include "utils/translation.hpp" #include "utils/translation.hpp"
#include "utils/string_utils.hpp" #include "utils/string_utils.hpp"
#include "online/current_online_user.hpp" #include "online/current_online_user.hpp"
#include "states_screens/dialogs/registration_dialog.hpp"
using namespace GUIEngine; using namespace GUIEngine;
@ -38,19 +38,23 @@ using namespace irr::gui;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
LoginDialog::LoginDialog(const float w, const float h) : LoginDialog::LoginDialog(const float w, const float h, const core::stringw& msg) :
ModalDialog(w,h) ModalDialog(w,h)
{ {
m_self_destroy = false; m_self_destroy = false;
loadFromFile("login_dialog.stkgui"); loadFromFile("online/login_dialog.stkgui");
TextBoxWidget* textCtrl = getWidget<TextBoxWidget>("password"); TextBoxWidget* textBox = getWidget<TextBoxWidget>("password");
assert(textCtrl != NULL); assert(textBox != NULL);
textCtrl->setPasswordBox(true,L'*'); textBox->setPasswordBox(true,L'*');
textCtrl = getWidget<TextBoxWidget>("username"); textBox = getWidget<TextBoxWidget>("username");
assert(textCtrl != NULL); assert(textBox != NULL);
textCtrl->setFocusForPlayer(PLAYER_ID_GAME_MASTER); textBox->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
LabelWidget * info = getWidget<LabelWidget>("info");
assert(info != NULL);
info->setText(msg, false);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -87,6 +91,12 @@ GUIEngine::EventPropagation LoginDialog::processEvent(const std::string& eventSo
getWidget<LabelWidget>("info")->setText(info, false); getWidget<LabelWidget>("info")->setText(info, false);
return GUIEngine::EVENT_BLOCK; return GUIEngine::EVENT_BLOCK;
} }
else if(eventSource == "signup")
{
m_self_destroy = true;
new RegistrationDialog(0.6f, 0.9f);
return GUIEngine::EVENT_BLOCK;
}
return GUIEngine::EVENT_LET; return GUIEngine::EVENT_LET;
} }

View File

@ -23,13 +23,6 @@
#include "guiengine/modaldialog.hpp" #include "guiengine/modaldialog.hpp"
#include "guiengine/widgets/text_box_widget.hpp" #include "guiengine/widgets/text_box_widget.hpp"
/*
namespace GUIEngine
{
class TextBoxWidget;
class ButtonWidget;
class LabelWidget;
}*/
/** /**
* \brief Dialog that allows a user to sign in * \brief Dialog that allows a user to sign in
@ -47,7 +40,7 @@ public:
/** /**
* Creates a modal dialog with given percentage of screen width and height * Creates a modal dialog with given percentage of screen width and height
*/ */
LoginDialog(const float percentWidth, const float percentHeight); LoginDialog(const float percentWidth, const float percentHeight, const core::stringw& msg);
~LoginDialog(); ~LoginDialog();
void onEnterPressedInternal(); void onEnterPressedInternal();

View File

@ -0,0 +1,123 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2013 Glenn De Jonghe
//
// 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 3
// 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; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "states_screens/dialogs/registration_dialog.hpp"
#include <IGUIEnvironment.h>
#include "audio/sfx_manager.hpp"
#include "config/player.hpp"
#include "guiengine/engine.hpp"
#include "guiengine/widgets/button_widget.hpp"
#include "guiengine/widgets/label_widget.hpp"
#include "guiengine/widgets/text_box_widget.hpp"
#include "states_screens/state_manager.hpp"
#include "utils/translation.hpp"
#include "utils/string_utils.hpp"
#include "online/current_online_user.hpp"
using namespace GUIEngine;
using namespace irr;
using namespace irr::gui;
// -----------------------------------------------------------------------------
RegistrationDialog::RegistrationDialog(const float w, const float h) :
ModalDialog(w,h)
{
m_self_destroy = false;
loadFromFile("online/registration_info.stkgui");
TextBoxWidget* textBox = getWidget<TextBoxWidget>("password");
assert(textBox != NULL);
textBox->setPasswordBox(true,L'*');
textBox = getWidget<TextBoxWidget>("password_confirm");
assert(textBox != NULL);
textBox->setPasswordBox(true,L'*');
textBox = getWidget<TextBoxWidget>("username");
assert(textBox != NULL);
textBox->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
}
// -----------------------------------------------------------------------------
RegistrationDialog::~RegistrationDialog()
{
}
// -----------------------------------------------------------------------------
GUIEngine::EventPropagation RegistrationDialog::processEvent(const std::string& eventSource)
{
if (eventSource == "cancel")
{
dismiss();
return GUIEngine::EVENT_BLOCK;
}
else if(eventSource == "signin")
{
// ---- See if we can accept the input
const stringw username = getWidget<TextBoxWidget>("username")->getText().trim();
const stringw password = getWidget<TextBoxWidget>("password")->getText().trim();
stringw info = "";
if(CurrentOnlineUser::get()->signIn(username,password,info))
{
m_self_destroy = true;
}
else
{
sfx_manager->quickSound( "anvil" );
m_self_destroy = false;
}
getWidget<LabelWidget>("info")->setText(info, false);
return GUIEngine::EVENT_BLOCK;
}
return GUIEngine::EVENT_LET;
}
// -----------------------------------------------------------------------------
void RegistrationDialog::onEnterPressedInternal()
{
// ---- Cancel button pressed
const int playerID = PLAYER_ID_GAME_MASTER;
ButtonWidget* cancelButton = getWidget<ButtonWidget>("cancel");
if (GUIEngine::isFocusedForPlayer(cancelButton, playerID))
{
std::string fakeEvent = "cancel";
processEvent(fakeEvent);
return;
}
}
// -----------------------------------------------------------------------------
void RegistrationDialog::onUpdate(float dt)
{
// It's unsafe to delete from inside the event handler so we do it here
if (m_self_destroy)
{
GUIEngine::getGUIEnv()->removeFocus( m_irrlicht_window );
ModalDialog::dismiss();
}
}

View File

@ -0,0 +1,53 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2013 Glenn De Jonghe
//
// 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 3
// 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; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_REGISTRATION_DIALOG_HPP
#define HEADER_REGISTRATION_DIALOG_HPP
#include <irrString.h>
#include "guiengine/modaldialog.hpp"
#include "guiengine/widgets/text_box_widget.hpp"
/**
* \brief Dialog that allows a user to register
* \ingroup states_screens
*/
class RegistrationDialog : public GUIEngine::ModalDialog
{
private:
bool m_self_destroy;
public:
/**
* Creates a modal dialog with given percentage of screen width and height
*/
RegistrationDialog(const float percentWidth, const float percentHeight);
~RegistrationDialog();
void onEnterPressedInternal();
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
virtual void onUpdate(float dt);
//virtual void onTextUpdated();
};
#endif

View File

@ -22,7 +22,6 @@
#include <string> #include <string>
#include <iostream> #include <iostream>
#include "addons/inetwork_http.hpp"
#include "challenges/game_slot.hpp" #include "challenges/game_slot.hpp"
#include "challenges/unlock_manager.hpp" #include "challenges/unlock_manager.hpp"
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
@ -33,20 +32,11 @@
#include "input/device_manager.hpp" #include "input/device_manager.hpp"
#include "input/input_manager.hpp" #include "input/input_manager.hpp"
#include "io/file_manager.hpp" #include "io/file_manager.hpp"
#include "karts/kart_properties_manager.hpp"
#include "main_loop.hpp" #include "main_loop.hpp"
#include "modes/cutscene_world.hpp"
#include "modes/overworld.hpp"
#include "modes/demo_world.hpp"
#include "network/network_manager.hpp"
#include "states_screens/online_screen.hpp" #include "states_screens/online_screen.hpp"
#include "states_screens/addons_screen.hpp"
#include "states_screens/credits.hpp"
#include "states_screens/help_screen_1.hpp"
#include "states_screens/kart_selection.hpp"
#include "states_screens/options_screen_video.hpp"
#include "states_screens/state_manager.hpp" #include "states_screens/state_manager.hpp"
#include "modes/demo_world.hpp" #include "modes/demo_world.hpp"
#include "utils/translation.hpp"
#include "states_screens/dialogs/login_dialog.hpp" #include "states_screens/dialogs/login_dialog.hpp"
@ -56,7 +46,7 @@ DEFINE_SCREEN_SINGLETON( OnlineScreen );
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
OnlineScreen::OnlineScreen() : Screen("online.stkgui") OnlineScreen::OnlineScreen() : Screen("online/online.stkgui")
{ {
} // OnlineScreen } // OnlineScreen
@ -119,7 +109,7 @@ void OnlineScreen::eventCallback(Widget* widget, const std::string& name,
if (selection == "login") if (selection == "login")
{ {
new LoginDialog(0.6f, 0.7f); new LoginDialog(0.6f, 0.6f, _("Not yet an account? Press register beneath!"));
} }
} // eventCallback } // eventCallback