From 6dc18a3557f9605ea2e071fd8da60c76b2d0c56c Mon Sep 17 00:00:00 2001 From: hiker Date: Fri, 10 Oct 2014 16:19:25 +1100 Subject: [PATCH] Change "Cancel" to 'Exit game' and make the back arrow invisible if the login screen is shown before the race start. --- src/guiengine/abstract_state_manager.hpp | 4 ++++ src/states_screens/user_screen.cpp | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/guiengine/abstract_state_manager.hpp b/src/guiengine/abstract_state_manager.hpp index 07f8bf8fd..ea45e4acf 100644 --- a/src/guiengine/abstract_state_manager.hpp +++ b/src/guiengine/abstract_state_manager.hpp @@ -167,6 +167,10 @@ namespace GUIEngine virtual void onTopMostScreenChanged() = 0; + // -------------------------------------------------------------------- + /** Returns the number of screens on the stack. Is used to decide + * if exiting a screen would cause STK to end or not. */ + unsigned int getMenuStackSize() const { return m_menu_stack.size(); } }; // Class AbstractStateManager } // GUIEngine diff --git a/src/states_screens/user_screen.cpp b/src/states_screens/user_screen.cpp index 6c21c14df..148848885 100644 --- a/src/states_screens/user_screen.cpp +++ b/src/states_screens/user_screen.cpp @@ -73,6 +73,15 @@ void BaseUserScreen::init() m_info_widget = getWidget("message"); assert(m_info_widget); + // The behaviour of the screen is slightly different at startup, i.e. + // when it is the first screen: cancel will exit the game, and in + // this case no 'back' error should be shown. + bool is_first_screen = StateManager::get()->getMenuStackSize()==1; + getWidget("back")->setVisible(!is_first_screen); + getWidget("cancel")->setLabel(is_first_screen + ? _("Exit game") + : _("Cancel") ); + m_sign_out_name = ""; m_sign_in_name = ""; @@ -293,7 +302,7 @@ void BaseUserScreen::eventCallback(Widget* widget, } else if (button == "cancel") { - StateManager::get()->popMenu(); + // EscapePressed will pop this screen. StateManager::get()->escapePressed(); } else if (button == "recover")