From 6650827784dd88a955181491f28b448aaf6bd3c5 Mon Sep 17 00:00:00 2001 From: hiker Date: Fri, 16 May 2014 08:24:15 +1000 Subject: [PATCH] Fixed various bugs in menu not showing up. --- src/main.cpp | 9 ++++++++- src/states_screens/user_screen.cpp | 27 +++++++++++---------------- src/states_screens/user_screen.hpp | 2 +- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index ce7f5dcb7..f0b928b14 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,3 +1,4 @@ + // // SuperTuxKart - a fun racing game with go-kart // Copyright (C) 2004-2013 Steve Baker @@ -1286,7 +1287,13 @@ int main(int argc, char *argv[] ) if(!UserConfigParams::m_no_start_screen) { - StateManager::get()->pushScreen(UserScreen::getInstance()); + // If there is a current player, it was saved in the config file, + // so we immediately start the main menu. Otherwise show the login + // screen first. + if(PlayerManager::getCurrentPlayer()) + StateManager::get()->pushScreen(MainMenuScreen::getInstance()); + else + StateManager::get()->pushScreen(UserScreen::getInstance()); #ifdef ENABLE_WIIUSE // Show a dialog to allow connection of wiimotes. */ if(WiimoteManager::isEnabled()) diff --git a/src/states_screens/user_screen.cpp b/src/states_screens/user_screen.cpp index 00d4aef9c..5d8ce5a65 100644 --- a/src/states_screens/user_screen.cpp +++ b/src/states_screens/user_screen.cpp @@ -193,6 +193,14 @@ void BaseUserScreen::makeEntryFieldsVisible(bool online) m_password_tb->setVisible(online); } // makeEntryFieldsVisible +// ---------------------------------------------------------------------------- +/** Make sure that a current player is defined when escape is pressed. + */ +bool BaseUserScreen::onEscapePressed() +{ + return Screen::onEscapePressed(); +} // onEscapePressed + // ---------------------------------------------------------------------------- /** Called when the user selects anything on the screen. */ @@ -460,21 +468,6 @@ void BaseUserScreen::onDialogClose() } // onDialogClose -// ============================================================================ -/** If there already is a player (i.e. default player is saved), no need to - * show this dialog, go directly to the main menu screen. - */ -void UserScreen::init() -{ - PlayerProfile *player = PlayerManager::getCurrentPlayer(); - if (player) - { - StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance()); - return; - } - BaseUserScreen::init(); -} // init - // ============================================================================ /** In the tab version, make sure the right tab is selected. */ @@ -494,7 +487,7 @@ void TabbedUserScreen::init() */ void TabbedUserScreen::eventCallback(GUIEngine::Widget* widget, const std::string& name, - const int playerID) + const int player_id) { if (name == "options_choice") { @@ -509,5 +502,7 @@ void TabbedUserScreen::eventCallback(GUIEngine::Widget* widget, assert(s); StateManager::get()->replaceTopMostScreen(s); } + else + BaseUserScreen::eventCallback(widget, name, player_id); } // eventCallback diff --git a/src/states_screens/user_screen.hpp b/src/states_screens/user_screen.hpp index c49958f7f..badb7c3f9 100644 --- a/src/states_screens/user_screen.hpp +++ b/src/states_screens/user_screen.hpp @@ -95,6 +95,7 @@ public: /** \brief implement optional callback from parent class GUIEngine::Screen */ virtual void unloaded(); + virtual bool onEscapePressed(); void loginSuccessful(); void loginError(const irr::core::stringw &error_message); @@ -111,7 +112,6 @@ private: {}; public: friend class GUIEngine::ScreenSingleton; - virtual void init(); }; // class UserScreenTabed // ============================================================================