Added little toy test for Dialog when exiting SuperTux
authorIngo Ruhnke <grumbel@gmail.com>
Mon, 25 Aug 2014 04:30:20 +0000 (06:30 +0200)
committerIngo Ruhnke <grumbel@gmail.com>
Mon, 25 Aug 2014 07:54:13 +0000 (09:54 +0200)
src/supertux/menu/main_menu.cpp

index 8eb4d7a..615c0aa 100644 (file)
@@ -17,6 +17,7 @@
 #include "supertux/menu/main_menu.hpp"
 
 #include "audio/sound_manager.hpp"
+#include "gui/dialog.hpp"
 #include "gui/menu_item.hpp"
 #include "gui/menu_manager.hpp"
 #include "supertux/fadeout.hpp"
@@ -80,8 +81,15 @@ MainMenu::menu_action(MenuItem* item)
       break;
 
     case MNID_QUITMAINMENU:
-      ScreenManager::current()->quit(std::unique_ptr<ScreenFade>(new FadeOut(0.25)));
-      SoundManager::current()->stop_music(0.25);
+      std::unique_ptr<Dialog> dialog(new Dialog);
+      dialog->set_text(_("Do you really want to quit SuperTux?"));
+      dialog->add_button(_("Cancel"));
+      dialog->add_button(_("Quit SuperTux"), [] {
+          MenuManager::instance().clear_menu_stack();
+          ScreenManager::current()->quit(std::unique_ptr<ScreenFade>(new FadeOut(0.25)));
+          SoundManager::current()->stop_music(0.25);
+        }, true);
+      MenuManager::instance().set_dialog(std::move(dialog));
       break;
   }
 }