From 61bcdffb64d730954e189e375798ae6cad660124 Mon Sep 17 00:00:00 2001 From: auria Date: Sun, 17 Feb 2013 00:20:40 +0000 Subject: [PATCH] Show confir dialog before aborting GP git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12492 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/states_screens/race_result_gui.cpp | 32 +++++++++++++++++--------- src/states_screens/race_result_gui.hpp | 5 +++- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/states_screens/race_result_gui.cpp b/src/states_screens/race_result_gui.cpp index 3d04a8ae6..abd7a2d7e 100644 --- a/src/states_screens/race_result_gui.cpp +++ b/src/states_screens/race_result_gui.cpp @@ -23,6 +23,7 @@ #include "challenges/unlock_manager.hpp" #include "graphics/material.hpp" #include "guiengine/engine.hpp" +#include "guiengine/modaldialog.hpp" #include "guiengine/scalable_font.hpp" #include "guiengine/widget.hpp" #include "guiengine/widgets/icon_button_widget.hpp" @@ -225,17 +226,8 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget, } else if (name == "bottom") // Abort { - cleanupGPProgress(); - StateManager::get()->popMenu(); - race_manager->exitRace(); - race_manager->setAIKartOverride(""); - StateManager::get()->resetAndGoToScreen( - MainMenuScreen::getInstance()); - - if (race_manager->raceWasStartedFromOverworld()) - { - OverWorld::enterOverWorld(); - } + new MessageDialog(_("Do you really want to abort the Grand Prix?"), + MessageDialog::MESSAGE_DIALOG_CONFIRM, this, false); } else if (!getWidget(name.c_str())->isVisible()) { @@ -281,6 +273,24 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget, return; } // eventCallback +//----------------------------------------------------------------------------- + +void RaceResultGUI::onConfirm() +{ + GUIEngine::ModalDialog::dismiss(); + cleanupGPProgress(); + StateManager::get()->popMenu(); + race_manager->exitRace(); + race_manager->setAIKartOverride(""); + StateManager::get()->resetAndGoToScreen( + MainMenuScreen::getInstance()); + + if (race_manager->raceWasStartedFromOverworld()) + { + OverWorld::enterOverWorld(); + } +} + //----------------------------------------------------------------------------- /** This determines the layout, i.e. the size of all columns, font size etc. */ diff --git a/src/states_screens/race_result_gui.hpp b/src/states_screens/race_result_gui.hpp index a282b9e64..30bd83056 100644 --- a/src/states_screens/race_result_gui.hpp +++ b/src/states_screens/race_result_gui.hpp @@ -25,6 +25,7 @@ #include #include "guiengine/screen.hpp" +#include "states_screens/dialogs/message_dialog.hpp" #include "states_screens/state_manager.hpp" namespace irr @@ -43,7 +44,8 @@ class SFXBase; */ class RaceResultGUI : public RaceGUIBase, public GUIEngine::Screen, - public GUIEngine::ScreenSingleton + public GUIEngine::ScreenSingleton, + public MessageDialog::IConfirmDialogListener { private: /** Timer variable for animations. */ @@ -250,6 +252,7 @@ public: void setHighscore(const std::string &kart, StateManager::ActivePlayer* player, int rank, int time); + virtual void onConfirm(); }; // RaceResultGUI #endif