Signin in now fully uses asynchronous http requesting. Implemented a nice "loading dots" gimmick for loading.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@13276 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
unitraxx 2013-07-18 22:49:19 +00:00
parent 3724fc3dae
commit 8ec5adeec0
4 changed files with 26 additions and 7 deletions

View File

@ -39,6 +39,7 @@ LoginDialog::LoginDialog(const Message message_type) :
{
m_self_destroy = false;
m_open_registration_dialog = false;
m_load_timer = 0.0f;
m_signin_request = NULL;
loadFromFile("online/login_dialog.stkgui");
@ -94,6 +95,7 @@ LoginDialog::LoginDialog(const Message message_type) :
LoginDialog::~LoginDialog()
{
delete m_signin_request;
}
@ -115,6 +117,8 @@ GUIEngine::EventPropagation LoginDialog::processEvent(const std::string& eventSo
const std::string& selection = m_options_widget->getSelectionIDString(PLAYER_ID_GAME_MASTER);
if (selection == m_cancel_widget->m_properties[PROP_ID])
{
if(m_signin_request != NULL)
m_signin_request->cancel();
m_self_destroy = true;
return GUIEngine::EVENT_BLOCK;
}
@ -150,13 +154,12 @@ void LoginDialog::onUpdate(float dt)
{
if(m_signin_request != NULL)
{
// load screen
if(m_signin_request->isDone())
{
stringw info = "";
if(online::CurrentUser::get()->signIn(m_signin_request->getResult(), info))
{
m_self_destroy = true;
m_self_destroy = true;
}
else
{
@ -165,6 +168,13 @@ void LoginDialog::onUpdate(float dt)
m_message_widget->setColor(irr::video::SColor(255, 255, 0, 0));
m_message_widget->setText(info, false);
}
delete m_signin_request;
m_signin_request = NULL;
}
else
{
m_load_timer += dt;
m_message_widget->setText(irr::core::stringw(_("Signing in")) + StringUtils::loadingDots(m_load_timer), false);
}
}

View File

@ -24,11 +24,7 @@
#include "online/current_user.hpp"
#include "guiengine/modaldialog.hpp"
#include "guiengine/widgets/text_box_widget.hpp"
#include "guiengine/widgets/check_box_widget.hpp"
#include "guiengine/widgets/icon_button_widget.hpp"
#include "guiengine/widgets/ribbon_widget.hpp"
#include "guiengine/widgets/label_widget.hpp"
#include "guiengine/widgets.hpp"
/**
* \brief Dialog that allows a user to sign in
@ -58,6 +54,8 @@ private:
void login();
float m_load_timer;
public:
enum Message

View File

@ -709,6 +709,14 @@ namespace StringUtils
printf("Invalid version string '%s'.\n", s.c_str());
return version;
} // versionToInt
// ------------------------------------------------------------------------
irr::core::stringw loadingDots(float time, bool spaces, float interval, int max_dots)
{
int nr_dots = int(floor(time * (1 / interval))) % (max_dots+1);
return irr::core::stringw((std::string(nr_dots,'.') + std::string(max_dots-nr_dots,' ')).c_str());
}
} // namespace StringUtils

View File

@ -413,6 +413,9 @@ namespace StringUtils
/** Compute a simple hash of a string */
unsigned int simpleHash(const char* input);
irr::core::stringw loadingDots(float time, bool spaces = true, float interval = 0.5f, int max_dots = 3);
} // namespace StringUtils
#endif