[_GSoC Uni_] Signing out. Online screen (beta) improvements.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@13001 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
unitraxx 2013-06-28 01:33:15 +00:00
parent 075b3aa3c7
commit f99f27cbf1
7 changed files with 85 additions and 40 deletions

View File

@ -1,31 +1,53 @@
<stkgui>
<icon-button id="back" x="0" y="0" height="8%" icon="gui/back.png"/>
<div x="0" y="0" width="100%" height="100%" layout="vertical-row" >
<icon id="logo" align="center" proportion="5" width="100%" icon="gui/logo.png"/>
<header text_align="center" width="80%" align="center" I18N="In the online multiplayer screen" text="Online Multiplayer"/>
<spacer height="15" width="10"/>
<box proportion="4" width="90%" layout="vertical-row" align="center">
<div x="2%" y="2%" width="96%" height="96%" layout="vertical-row" id="outer_box" >
<label I18N="In the online multiplayer screen" proportion="4" text="Graphical Effects Level" align="center"/>
<spacer width="20" height="20"/>
<div id="options" width="fit" proportion="1" align="center" layout="horizontal-row">
<button id="signin" height="fit" align="center" width="fit" I18N="In the login dialog" text="Sign In"/>
<spacer height="50" width="50">
<button id="signup" height="fit" align="center" width="fit" I18N="In the login dialog" text="Register"/>
<spacer height="50" width="50">
<button id="cancel" height="fit" align="center" width="fit" I18N="In the login dialog" text="Cancel"/>
</div>
</div>
</box>
<buttonbar id="menu_toprow" proportion="3" width="75%" align="center">
<icon-button id="signin" width="128" height="128"
<buttonbar id="menu_toprow" proportion="3" width="90%" align="center">
<icon-button id="quick_play" width="128" height="128"
icon="gui/menu_race.png" focus_icon="gui/menu_race_focus.png"
I18N="Online menu button" text="Sign in"/>
I18N="Online menu button" text="Quick Play"/>
<icon-button id="find_server" width="128" height="128"
icon="gui/menu_race.png" focus_icon="gui/menu_race_focus.png"
I18N="Online menu button" text="Find Server"/>
<icon-button id="create_server" width="128" height="128"
icon="gui/menu_race.png" focus_icon="gui/menu_race_focus.png"
I18N="Online menu button" text="Create Server"/>
</buttonbar>
<spacer width="10" height="7%"/>
<bottombar width="100%" height="10%" layout="horizontal-row">
<spacer proportion="3" height="10" />
<bottombar x="2%" width="96%" height="10%" layout="horizontal-row">
<label text_align="left" align="center" height="100%" id="online_status" proportion="1" I18N="In the online multiplayer screen" text="Loading..."/>
<spacer width="10" height="10" />
<buttonbar id="menu_bottomrow" x="0" y="0" width="20%" height="100%" align="center">
<icon-button id="signin" width="64" height="64" icon="gui/main_options.png" extend_label="50"
I18N="Main menu button" text="Log In" label_location="hover"/>
<icon-button id="signout" width="64" height="64" icon="gui/main_quit.png" extend_label="50"
I18N="Main menu button" text="Log Out" label_location="hover"/>
<buttonbar id="menu_bottomrow" x="0" y="0" width="20%" height="100%" align="right">
<icon-button id="sign_in" width="64" height="64" icon="gui/main_options.png" extend_label="50"
I18N="Main menu button" text="Sign In" label_location="hover"/>
<icon-button id="sign_out" width="64" height="64" icon="gui/main_quit.png" extend_label="50"
I18N="Main menu button" text="Sign Out" label_location="hover"/>
<icon-button id="register" width="64" height="64" icon="gui/main_quit.png" extend_label="50"
I18N="Main menu button" text="Register" label_location="hover"/>
</buttonbar>
</bottombar>
</div>
<icon-button id="back" x="0" y="0" height="8%" icon="gui/back.png"/>
</stkgui>

View File

@ -46,6 +46,7 @@ void CurrentOnlineUser::deallocate()
CurrentOnlineUser::CurrentOnlineUser(){
m_is_signed_in = false;
m_is_guest = true;
m_id = 0;
m_name = "";
m_token = "";
@ -104,6 +105,7 @@ bool CurrentOnlineUser::signIn( const irr::core::stringw &username,
assert(result->get("username", &m_name));
assert(result->get("userid", &m_id));
m_is_signed_in = true;
m_is_guest = false;
}
result->get("info", &info);
}

View File

@ -37,6 +37,7 @@ class CurrentOnlineUser : public OnlineUser
protected:
std::string m_token;
bool m_is_signed_in;
bool m_is_guest;
CurrentOnlineUser();
public:
@ -59,6 +60,7 @@ class CurrentOnlineUser : public OnlineUser
/** Returns the username if signed in. */
irr::core::stringw getUserName() const;
bool isSignedIn(){ return m_is_signed_in; }
bool isGuest(){ return m_is_guest; }
}; // class CurrentOnlineUser

View File

@ -127,7 +127,6 @@ void LoginDialog::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();
if (m_open_registration_dialog)
new RegistrationDialog(0.8f, 0.9f);

View File

@ -277,7 +277,6 @@ 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();
}
if (m_show_registration_info)

View File

@ -27,8 +27,8 @@
#include "graphics/irr_driver.hpp"
#include "guiengine/scalable_font.hpp"
#include "guiengine/widgets/label_widget.hpp"
#include "guiengine/widgets/list_widget.hpp"
#include "guiengine/widgets/ribbon_widget.hpp"
#include "guiengine/widgets/icon_button_widget.hpp"
#include "input/device_manager.hpp"
#include "input/input_manager.hpp"
#include "io/file_manager.hpp"
@ -38,6 +38,7 @@
#include "modes/demo_world.hpp"
#include "utils/translation.hpp"
#include "online/current_online_user.hpp"
#include "states_screens/dialogs/login_dialog.hpp"
using namespace GUIEngine;
@ -62,31 +63,37 @@ void OnlineScreen::loadedFromFile()
void OnlineScreen::init()
{
Screen::init();
// Avoid incorrect behaviour in certain race circumstances:
// If a multi-player game is played with two keyboards, the 2nd
// player selects his kart last, and only the keyboard is used
// to select all other settings - then if the next time the kart
// selection screen comes up, the default device will still be
// the 2nd player. So if the first player presses 'select', it
// will instead add a second player (so basically the key
// binding for the second player become the default, so pressing
// select will add a new player). See bug 3090931
// To avoid this, we will clean the last used device, making
// the key bindings for the first player the default again.
input_manager->getDeviceList()->clearLatestUsedDevice();
RibbonWidget* r = getWidget<RibbonWidget>("menu_toprow");
r->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
DemoWorld::resetIdleTime();
#if _IRR_MATERIAL_MAX_TEXTURES_ < 8
getWidget<IconButtonWidget>("logo")->setImage("gui/logo_broken.png",
IconButtonWidget::ICON_PATH_TYPE_RELATIVE);
#endif
} // init
void OnlineScreen::beforeAddingWidget()
{
RibbonWidget* topRow = getWidget<RibbonWidget>("menu_toprow");
assert(topRow != NULL);
RibbonWidget* bottomRow = getWidget<RibbonWidget>("menu_bottomrow");
assert(bottomRow != NULL);
if(CurrentOnlineUser::get()->isSignedIn())
{
if(CurrentOnlineUser::get()->isGuest())
{
}
else
{
//Signed in and not guest
bottomRow->removeChildNamed("sign_in");
}
}
else
{
bottomRow->removeChildNamed("sign_out");
}
}
// ----------------------------------------------------------------------------
void OnlineScreen::onUpdate(float delta, irr::video::IVideoDriver* driver)
{
@ -106,13 +113,13 @@ void OnlineScreen::eventCallback(Widget* widget, const std::string& name, const
if (ribbon == NULL) return; // what's that event??
std::string selection = ribbon->getSelectionIDString(PLAYER_ID_GAME_MASTER);
if (selection == "signin")
if (selection == "sign_in")
{
new LoginDialog(0.6f, 0.6f, _("Not yet an account? Press register beneath!"));
}
else if (selection == "signout")
else if (selection == "sign_out")
{
new LoginDialog(0.6f, 0.6f, _("Not yet an account? Press register beneath!"));
CurrentOnlineUser::get()->signOut();
}
} // eventCallback
@ -128,3 +135,12 @@ void OnlineScreen::tearDown()
void OnlineScreen::onDisabledItemClicked(const std::string& item)
{
} // onDisabledItemClicked
// ----------------------------------------------------------------------------
void OnlineScreen::reload()
{
this->unload();
if (!this->isLoaded()) this->loadFromFile();
this->init();
}

View File

@ -35,6 +35,8 @@ private:
public:
void reload();
virtual void onUpdate(float delta, irr::video::IVideoDriver* driver) OVERRIDE;
/** \brief implement callback from parent class GUIEngine::Screen */
@ -44,6 +46,9 @@ public:
virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name,
const int playerID) OVERRIDE;
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void beforeAddingWidget() OVERRIDE;
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void init() OVERRIDE;