From 7c3164a9c1a5a63128f1b0f0c63c794cc49a15c4 Mon Sep 17 00:00:00 2001 From: hiker Date: Thu, 4 Sep 2014 09:38:25 +1000 Subject: [PATCH] Added 'reload' random GP support, fixed 'back' icon on screen. --- data/gui/random_gp_info.stkgui | 6 ++-- src/states_screens/gp_info_screen.cpp | 41 +++++++++++++++++++++------ src/states_screens/gp_info_screen.hpp | 8 ++++++ 3 files changed, 44 insertions(+), 11 deletions(-) diff --git a/data/gui/random_gp_info.stkgui b/data/gui/random_gp_info.stkgui index 871a97546..45d90944a 100644 --- a/data/gui/random_gp_info.stkgui +++ b/data/gui/random_gp_info.stkgui @@ -2,9 +2,9 @@ -
+
-
+
@@ -62,7 +62,7 @@ I18N="Start race" text="Start Race"/> + I18N="Continue saved GP" text="Continue saved GP"/>
diff --git a/src/states_screens/gp_info_screen.cpp b/src/states_screens/gp_info_screen.cpp index b14459fe6..196d8428a 100644 --- a/src/states_screens/gp_info_screen.cpp +++ b/src/states_screens/gp_info_screen.cpp @@ -73,7 +73,7 @@ void BaseGPInfoScreen::loadedFromFile() // The group spinner is filled in init every time the screen is shown // (since the groups can change if addons are added/deleted). m_group_spinner = getWidget("group-spinner"); - + m_continue_button = getWidget("continue"); m_reverse_spinner = getWidget("reverse-spinner"); m_reverse_spinner->addLabel(_("No")); m_reverse_spinner->addLabel(_("Yes")); @@ -136,8 +136,12 @@ void BaseGPInfoScreen::init() if(random) { + RibbonWidget *rb = getWidget("buttons"); + rb->setLabel(1,_(L"Reload") ); getWidget("name")->setText(_("Random Grand Prix"), false); - getWidget("continue")->setVisible(false); + std::string restart = file_manager->getAsset(FileManager::GUI, "restart.png"); + m_continue_button->setImage(restart, IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE); + m_continue_button->setVisible(true); // We have to recreate the group spinner, but a new group might have // been added or deleted since the last time this screen was shown. @@ -190,7 +194,9 @@ void BaseGPInfoScreen::init() race_manager->getNumberOfKarts(), race_manager->getNumLocalPlayers()); - getWidget("continue")->setVisible(saved_gp != NULL); + //I18N: Continue a previously saved Grand Prix. + m_continue_button->setText(_(L"Continue saved GP")); + m_continue_button->setVisible(saved_gp != NULL); } addTracks(); @@ -198,7 +204,8 @@ void BaseGPInfoScreen::init() } // init // ---------------------------------------------------------------------------- - +/** Updates the list of tracks shown. + */ void BaseGPInfoScreen::addTracks() { const std::vector tracks = m_gp.getTrackNames(); @@ -214,7 +221,8 @@ void BaseGPInfoScreen::addTracks() } // addTracks // ---------------------------------------------------------------------------- - +/** Creates a screenshot widget in the placeholder of the GUI. + */ void BaseGPInfoScreen::addScreenshot() { Widget* screenshot_div = getWidget("screenshot_div"); @@ -277,7 +285,8 @@ void BaseGPInfoScreen::updateRandomGP() } // updateRandomGP // ---------------------------------------------------------------------------- - +/** Handle user input. + */ void BaseGPInfoScreen::eventCallback(GUIEngine::Widget *, const std::string &name, const int player_id) { @@ -286,8 +295,18 @@ void BaseGPInfoScreen::eventCallback(GUIEngine::Widget *, const std::string &nam const std::string &button = getWidget("buttons") ->getSelectionIDString(PLAYER_ID_GAME_MASTER); - if (button == "start" || button=="continue") + // The continue button becomes a 'reload' button in random GP: + if(button=="continue" && m_gp.isRandomGP()) { + // Create a new GP: + m_gp.createRandomGP(m_num_tracks_spinner->getValue(), + m_group_name, getReverse(), + /*new tracks*/ true ); + addTracks(); + } + else if (button == "start" || button=="continue") + { + // Normal GP: start/continue a saved GP int n = getWidget("ai-spinner")->getValue(); race_manager->setNumKarts(race_manager->getNumLocalPlayers() + n); @@ -326,11 +345,17 @@ void BaseGPInfoScreen::eventCallback(GUIEngine::Widget *, const std::string &nam { m_gp.changeReverse(getReverse()); } + else if(name=="back") + { + StateManager::get()->escapePressed(); + } } // eventCallback // ---------------------------------------------------------------------------- - +/** Called every update. Used to cycle the screenshots. + * \param dt Time step size. + */ void BaseGPInfoScreen::onUpdate(float dt) { if (dt == 0) diff --git a/src/states_screens/gp_info_screen.hpp b/src/states_screens/gp_info_screen.hpp index 1e8a0f5e9..cb9776fba 100644 --- a/src/states_screens/gp_info_screen.hpp +++ b/src/states_screens/gp_info_screen.hpp @@ -38,10 +38,18 @@ namespace GUIEngine class BaseGPInfoScreen : public GUIEngine::Screen { private: + /** Spinner for the different track groups. */ GUIEngine::SpinnerWidget *m_group_spinner; + + /** Spinner for reverse mode. */ GUIEngine::SpinnerWidget *m_reverse_spinner; + + /** Spinner for number of tracks (in case of random GP). */ GUIEngine::SpinnerWidget *m_num_tracks_spinner; + /** The continue/reload (in case of random GP) icon. */ + GUIEngine::IconButtonWidget *m_continue_button; + /** The currently selected group name. */ std::string m_group_name;