Show login screen with error message if automatic login did not work.

If user has left main menu screen, an error notification message is displayed.
For .
This commit is contained in:
hiker 2015-02-23 23:06:29 +11:00
parent 2c1b80b939
commit e56b4e33bc
3 changed files with 27 additions and 3 deletions

@ -52,6 +52,8 @@ public:
m_message = message;
if(mt==MessageQueue::MT_ACHIEVEMENT)
m_render_type = "achievement-message::neutral";
else if (mt==MessageQueue::MT_ERROR)
m_render_type = "achievement-message::neutral";
else
m_render_type = "friend-message::neutral";
} // Message
@ -77,7 +79,7 @@ class CompareMessages
public:
/** Used to sort messages by priority in the priority queue. Achievement
* messages (1) need to have a higher priority than friend messages
* (value 0). */
* (value 0), and errors (3) the highest priority. */
bool operator() (const Message *a, const Message *b) const
{
return a->getMessageType() < b->getMessageType();

@ -34,7 +34,7 @@ namespace MessageQueue
* different look. This type is used to sort the messages, so it is
* important that messages that need to be shown as early as possible
* will be listed last (i.e. have highest priority). */
enum MessageType {MT_FRIEND, MT_ACHIEVEMENT};
enum MessageType { MT_FRIEND, MT_ACHIEVEMENT, MT_ERROR};
void add(MessageType mt, const core::stringw &message);
void updatePosition();

@ -26,6 +26,7 @@
#include "online/online_profile.hpp"
#include "online/profile_manager.hpp"
#include "online/servers_manager.hpp"
#include "states_screens/main_menu_screen.hpp"
#include "states_screens/online_profile_friends.hpp"
#include "states_screens/user_screen.hpp"
#include "states_screens/dialogs/change_password_dialog.hpp"
@ -141,7 +142,6 @@ namespace Online
{
PlayerManager::getCurrentPlayer()->signIn(isSuccess(), getXMLData());
GUIEngine::Screen *screen = GUIEngine::getCurrentScreen();
BaseUserScreen *login = dynamic_cast<BaseUserScreen*>(screen);
// If the login is successful, reset any saved session of other
// local players using the same online account (which are now invalid)
@ -160,6 +160,8 @@ namespace Online
}
}
// Test if failure while showing user login screen
BaseUserScreen *login = dynamic_cast<BaseUserScreen*>(screen);
if (login)
{
if(isSuccess())
@ -167,6 +169,26 @@ namespace Online
else
login->loginError(getInfo());
} // if dialog
// Check if failure happened during automatic (saved) signin.
else if (!isSuccess())
{
if (GUIEngine::getCurrentScreen() != MainMenuScreen::getInstance())
{
// User has already opened another menu, so use message queue
// to inform user that login failed.
MessageQueue::add(MessageQueue::MT_ERROR, getInfo());
return;
}
// User still at main menu screen, push user screen. Note that
// this function is called from the main thread, so we can
// push screens without synchronisations.
UserScreen::getInstance()->push();
UserScreen::getInstance()->loginError(getInfo());
}
} // SignInRequest::callback
// ------------------------------------------------------------------------