diff --git a/src/guiengine/message_queue.cpp b/src/guiengine/message_queue.cpp index dbea7a2d5..747e9b403 100755 --- a/src/guiengine/message_queue.cpp +++ b/src/guiengine/message_queue.cpp @@ -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(); diff --git a/src/guiengine/message_queue.hpp b/src/guiengine/message_queue.hpp index 0bb3a5e0a..8a06d41f0 100644 --- a/src/guiengine/message_queue.hpp +++ b/src/guiengine/message_queue.hpp @@ -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(); diff --git a/src/online/online_player_profile.cpp b/src/online/online_player_profile.cpp index dbe9b7219..f2a6d6472 100644 --- a/src/online/online_player_profile.cpp +++ b/src/online/online_player_profile.cpp @@ -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(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(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 // ------------------------------------------------------------------------