00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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
00063 m_contrib_menu.reset(new ContribMenu());
00064 MenuManager::push_current(m_contrib_menu.get());
00065 break;
00066
00067 case MNID_ADDONS:
00068
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