src/supertux/menu/main_menu.cpp

Go to the documentation of this file.
00001 //  SuperTux
00002 //  Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
00003 //
00004 //  This program is free software: you can redistribute it and/or modify
00005 //  it under the terms of the GNU General Public License as published by
00006 //  the Free Software Foundation, either version 3 of the License, or
00007 //  (at your option) any later version.
00008 //
00009 //  This program is distributed in the hope that it will be useful,
00010 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 //  GNU General Public License for more details.
00013 //
00014 //  You should have received a copy of the GNU General Public License
00015 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 
00017 #include "supertux/menu/main_menu.hpp"
00018 
00019 #include "audio/sound_manager.hpp"
00020 #include "gui/menu_manager.hpp"
00021 #include "supertux/fadeout.hpp"
00022 #include "supertux/globals.hpp"
00023 #include "supertux/menu/menu_storage.hpp"
00024 #include "supertux/menu/addon_menu.hpp"
00025 #include "supertux/menu/options_menu.hpp"
00026 #include "supertux/menu/contrib_menu.hpp"
00027 #include "supertux/screen_manager.hpp"
00028 #include "supertux/textscroller.hpp"
00029 #include "supertux/title_screen.hpp"
00030 #include "supertux/world.hpp"
00031 #include "util/gettext.hpp"
00032 
00033 MainMenu::MainMenu() :
00034   m_addon_menu(),
00035   m_contrib_menu(),
00036   m_main_world()
00037 {
00038   set_pos(SCREEN_WIDTH/2, SCREEN_HEIGHT/2 + 35);
00039   add_entry(MNID_STARTGAME, _("Start Game"));
00040   add_entry(MNID_LEVELS_CONTRIB, _("Contrib Levels"));
00041   add_entry(MNID_ADDONS, _("Add-ons"));
00042   add_submenu(_("Options"), MenuStorage::get_options_menu());
00043   add_entry(MNID_CREDITS, _("Credits"));
00044   add_entry(MNID_QUITMAINMENU, _("Quit"));
00045 }
00046 
00047 void
00048 MainMenu::check_menu()
00049 {
00050   switch (check())
00051   {
00052     case MNID_STARTGAME:
00053       if (m_main_world.get() == NULL)
00054       {
00055         m_main_world.reset(new World());
00056         m_main_world->load("levels/world1/info");
00057       }
00058       TitleScreen::start_game(m_main_world.get());
00059       break;
00060 
00061     case MNID_LEVELS_CONTRIB:
00062       // Contrib Menu
00063       m_contrib_menu.reset(new ContribMenu());
00064       MenuManager::push_current(m_contrib_menu.get());
00065       break;
00066 
00067     case MNID_ADDONS:
00068       // Add-ons Menu
00069       m_addon_menu.reset(new AddonMenu());
00070       MenuManager::push_current(m_addon_menu.get());
00071       break;
00072 
00073     case MNID_CREDITS:
00074       MenuManager::set_current(NULL);
00075       g_screen_manager->push_screen(new TextScroller("credits.txt"),
00076                                     new FadeOut(0.5));
00077       break;
00078 
00079     case MNID_QUITMAINMENU:
00080       g_screen_manager->quit(new FadeOut(0.25));
00081       sound_manager->stop_music(0.25);
00082       break;
00083   }
00084 }
00085 
00086 /* EOF */

Generated on Mon Jun 9 03:38:22 2014 for SuperTux by  doxygen 1.5.1