From: grumbel Date: Thu, 19 Nov 2009 14:45:12 +0000 (+0000) Subject: Move all Menus into separate classes X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=62a43f316a361b819bf3bf6b74a13e8984016fe7;p=supertux.git Move all Menus into separate classes git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6045 837edb03-e0f3-0310-88ca-d4d4e8b29345 --- diff --git a/src/supertux/game_session.cpp b/src/supertux/game_session.cpp index de0e53921..001b5e7ed 100644 --- a/src/supertux/game_session.cpp +++ b/src/supertux/game_session.cpp @@ -36,17 +36,13 @@ #include "supertux/globals.hpp" #include "supertux/mainloop.hpp" #include "supertux/menu/menu_storage.hpp" +#include "supertux/menu/game_menu.hpp" #include "supertux/menu/options_menu.hpp" #include "supertux/sector.hpp" #include "util/file_system.hpp" #include "util/gettext.hpp" #include "worldmap/worldmap.hpp" -enum GameMenuIDs { - MNID_CONTINUE, - MNID_ABORTLEVEL -}; - GameSession::GameSession(const std::string& levelfile_, Statistics* statistics) : level(0), statistics_backdrop(), @@ -81,13 +77,7 @@ GameSession::GameSession(const std::string& levelfile_, Statistics* statistics) restart_level(); - game_menu.reset(new Menu()); - game_menu->add_label(level->name); - game_menu->add_hl(); - game_menu->add_entry(MNID_CONTINUE, _("Continue")); - game_menu->add_submenu(_("Options"), MenuStorage::get_options_menu()); - game_menu->add_hl(); - game_menu->add_entry(MNID_ABORTLEVEL, _("Abort Level")); + game_menu.reset(new GameMenu(*level)); } void diff --git a/src/supertux/menu/addon_menu.cpp b/src/supertux/menu/addon_menu.cpp new file mode 100644 index 000000000..c21e1db05 --- /dev/null +++ b/src/supertux/menu/addon_menu.cpp @@ -0,0 +1,60 @@ +// SuperTux +// Copyright (C) 2009 Ingo Ruhnke +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#include "supertux/menu/addon_menu.hpp" + +#include + +#include "addon/addon.hpp" +#include "util/gettext.hpp" + +AddonMenu::AddonMenu(const std::vector& addons) +{ + add_label(_("Add-ons")); + add_hl(); + + // FIXME: don't use macro, use AddonManager::online_available() or so +#ifdef HAVE_LIBCURL + add_entry(0, std::string(_("Check Online"))); +#else + add_inactive(0, std::string(_("Check Online (disabled)"))); +#endif + + //add_hl(); + + for (unsigned int i = 0; i < addons.size(); i++) + { + const Addon& addon = *addons[i]; + std::string text = ""; + + if (!addon.kind.empty()) + { + text += addon.kind + " "; + } + text += std::string("\"") + addon.title + "\""; + + if (!addon.author.empty()) + { + text += " by \"" + addon.author + "\""; + } + add_toggle(ADDON_LIST_START_ID + i, text, addon.loaded); + } + + add_hl(); + add_back(_("Back")); +} + +/* EOF */ diff --git a/src/supertux/menu/addon_menu.hpp b/src/supertux/menu/addon_menu.hpp new file mode 100644 index 000000000..9be3468c7 --- /dev/null +++ b/src/supertux/menu/addon_menu.hpp @@ -0,0 +1,41 @@ +// SuperTux +// Copyright (C) 2009 Ingo Ruhnke +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#ifndef HEADER_SUPERTUX_SUPERTUX_MENU_ADDON_MENU_HPP +#define HEADER_SUPERTUX_SUPERTUX_MENU_ADDON_MENU_HPP + +#include "gui/menu.hpp" + +enum { + ADDON_LIST_START_ID = 10 +}; + +class Addon; + +class AddonMenu : public Menu +{ +private: +public: + AddonMenu(const std::vector& addons); + +private: + AddonMenu(const AddonMenu&); + AddonMenu& operator=(const AddonMenu&); +}; + +#endif + +/* EOF */ diff --git a/src/supertux/menu/contrib_menu.cpp b/src/supertux/menu/contrib_menu.cpp new file mode 100644 index 000000000..39c8c817a --- /dev/null +++ b/src/supertux/menu/contrib_menu.cpp @@ -0,0 +1,51 @@ +// SuperTux +// Copyright (C) 2009 Ingo Ruhnke +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#include "supertux/menu/contrib_menu.hpp" + +#include "supertux/world.hpp" +#include "util/gettext.hpp" + +ContribMenu::ContribMenu(const std::vector& level_worlds, + std::vector& contrib_worlds) +{ + add_label(_("Contrib Levels")); + add_hl(); + + int i = 0; + for (std::vector::const_iterator it = level_worlds.begin(); it != level_worlds.end(); ++it) + { + try + { + std::auto_ptr world (new World()); + world->load(*it + "/info"); + if (!world->hide_from_contribs) + { + add_entry(i++, world->title); + contrib_worlds.push_back(world.release()); + } + } + catch(std::exception& e) + { + log_warning << "Couldn't parse levelset info for '" << *it << "': " << e.what() << std::endl; + } + } + + add_hl(); + add_back(_("Back")); +} + +/* EOF */ diff --git a/src/supertux/menu/contrib_menu.hpp b/src/supertux/menu/contrib_menu.hpp new file mode 100644 index 000000000..1cfbccc87 --- /dev/null +++ b/src/supertux/menu/contrib_menu.hpp @@ -0,0 +1,41 @@ +// SuperTux +// Copyright (C) 2009 Ingo Ruhnke +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#ifndef HEADER_SUPERTUX_SUPERTUX_MENU_CONTRIB_MENU_HPP +#define HEADER_SUPERTUX_SUPERTUX_MENU_CONTRIB_MENU_HPP + +#include "gui/menu.hpp" + +#include +#include + +class World; + +class ContribMenu : public Menu +{ +private: +public: + ContribMenu(const std::vector& level_worlds, + std::vector& contrib_worlds); + +private: + ContribMenu(const ContribMenu&); + ContribMenu& operator=(const ContribMenu&); +}; + +#endif + +/* EOF */ diff --git a/src/supertux/menu/contrib_world_menu.cpp b/src/supertux/menu/contrib_world_menu.cpp new file mode 100644 index 000000000..5991c59df --- /dev/null +++ b/src/supertux/menu/contrib_world_menu.cpp @@ -0,0 +1,40 @@ +// SuperTux +// Copyright (C) 2009 Ingo Ruhnke +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#include "supertux/menu/contrib_world_menu.hpp" + +#include "supertux/title_screen.hpp" +#include "supertux/world.hpp" +#include "util/gettext.hpp" + +ContribWorldMenu::ContribWorldMenu(const World& current_world) +{ + add_label(current_world.title); + add_hl(); + + for (unsigned int i = 0; i < current_world.get_num_levels(); ++i) + { + /** get level's title */ + std::string filename = current_world.get_level_filename(i); + std::string title = TitleScreen::get_level_name(filename); + add_entry(i, title); + } + + add_hl(); + add_back(_("Back")); +} + +/* EOF */ diff --git a/src/supertux/menu/contrib_world_menu.hpp b/src/supertux/menu/contrib_world_menu.hpp new file mode 100644 index 000000000..123b2c75d --- /dev/null +++ b/src/supertux/menu/contrib_world_menu.hpp @@ -0,0 +1,37 @@ +// SuperTux +// Copyright (C) 2009 Ingo Ruhnke +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#ifndef HEADER_SUPERTUX_SUPERTUX_MENU_CONTRIB_WORLD_MENU_HPP +#define HEADER_SUPERTUX_SUPERTUX_MENU_CONTRIB_WORLD_MENU_HPP + +#include "gui/menu.hpp" + +class World; + +class ContribWorldMenu : public Menu +{ +private: +public: + ContribWorldMenu(const World& current_world); + +private: + ContribWorldMenu(const ContribWorldMenu&); + ContribWorldMenu& operator=(const ContribWorldMenu&); +}; + +#endif + +/* EOF */ diff --git a/src/supertux/menu/game_menu.cpp b/src/supertux/menu/game_menu.cpp new file mode 100644 index 000000000..cb260032e --- /dev/null +++ b/src/supertux/menu/game_menu.cpp @@ -0,0 +1,33 @@ +// SuperTux +// Copyright (C) 2009 Ingo Ruhnke +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#include "supertux/menu/game_menu.hpp" + +#include "supertux/level.hpp" +#include "supertux/menu/menu_storage.hpp" +#include "util/gettext.hpp" + +GameMenu::GameMenu(const Level& level) +{ + add_label(level.name); + add_hl(); + add_entry(MNID_CONTINUE, _("Continue")); + add_submenu(_("Options"), MenuStorage::get_options_menu()); + add_hl(); + add_entry(MNID_ABORTLEVEL, _("Abort Level")); +} + +/* EOF */ diff --git a/src/supertux/menu/game_menu.hpp b/src/supertux/menu/game_menu.hpp new file mode 100644 index 000000000..b4f4799bd --- /dev/null +++ b/src/supertux/menu/game_menu.hpp @@ -0,0 +1,42 @@ +// SuperTux +// Copyright (C) 2009 Ingo Ruhnke +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#ifndef HEADER_SUPERTUX_SUPERTUX_MENU_GAME_MENU_HPP +#define HEADER_SUPERTUX_SUPERTUX_MENU_GAME_MENU_HPP + +#include "gui/menu.hpp" + +class Level; + +enum GameMenuIDs { + MNID_CONTINUE, + MNID_ABORTLEVEL +}; + +class GameMenu : public Menu +{ +private: +public: + GameMenu(const Level& level); + +private: + GameMenu(const GameMenu&); + GameMenu& operator=(const GameMenu&); +}; + +#endif + +/* EOF */ diff --git a/src/supertux/menu/main_menu.cpp b/src/supertux/menu/main_menu.cpp new file mode 100644 index 000000000..59b18321b --- /dev/null +++ b/src/supertux/menu/main_menu.cpp @@ -0,0 +1,34 @@ +// SuperTux +// Copyright (C) 2009 Ingo Ruhnke +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#include "supertux/menu/main_menu.hpp" + +#include "supertux/globals.hpp" +#include "supertux/menu/menu_storage.hpp" +#include "util/gettext.hpp" + +MainMenu::MainMenu() +{ + set_pos(SCREEN_WIDTH/2, SCREEN_HEIGHT/2 + 35); + add_entry(MNID_STARTGAME, _("Start Game")); + add_entry(MNID_LEVELS_CONTRIB, _("Contrib Levels")); + add_entry(MNID_ADDONS, _("Add-ons")); + add_submenu(_("Options"), MenuStorage::get_options_menu()); + add_entry(MNID_CREDITS, _("Credits")); + add_entry(MNID_QUITMAINMENU, _("Quit")); +} + +/* EOF */ diff --git a/src/supertux/menu/main_menu.hpp b/src/supertux/menu/main_menu.hpp new file mode 100644 index 000000000..db065ccf6 --- /dev/null +++ b/src/supertux/menu/main_menu.hpp @@ -0,0 +1,45 @@ +// SuperTux +// Copyright (C) 2009 Ingo Ruhnke +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#ifndef HEADER_SUPERTUX_SUPERTUX_MENU_MAIN_MENU_HPP +#define HEADER_SUPERTUX_SUPERTUX_MENU_MAIN_MENU_HPP + +#include "gui/menu.hpp" + +enum MainMenuIDs { + MNID_STARTGAME, + MNID_LEVELS_CONTRIB, + MNID_ADDONS, + MNID_OPTIONMENU, + MNID_LEVELEDITOR, + MNID_CREDITS, + MNID_QUITMAINMENU +}; + +class MainMenu : public Menu +{ +private: +public: + MainMenu(); + +private: + MainMenu(const MainMenu&); + MainMenu& operator=(const MainMenu&); +}; + +#endif + +/* EOF */ diff --git a/src/supertux/menu/worldmap_menu.cpp b/src/supertux/menu/worldmap_menu.cpp new file mode 100644 index 000000000..5dbef701d --- /dev/null +++ b/src/supertux/menu/worldmap_menu.cpp @@ -0,0 +1,32 @@ +// SuperTux +// Copyright (C) 2009 Ingo Ruhnke +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#include "supertux/menu/worldmap_menu.hpp" + +#include "supertux/menu/menu_storage.hpp" +#include "util/gettext.hpp" + +WorldmapMenu::WorldmapMenu() +{ + add_label(_("Pause")); + add_hl(); + add_entry(MNID_RETURNWORLDMAP, _("Continue")); + add_submenu(_("Options"), MenuStorage::get_options_menu()); + add_hl(); + add_entry(MNID_QUITWORLDMAP, _("Quit World")); +} + +/* EOF */ diff --git a/src/supertux/menu/worldmap_menu.hpp b/src/supertux/menu/worldmap_menu.hpp new file mode 100644 index 000000000..142f7a148 --- /dev/null +++ b/src/supertux/menu/worldmap_menu.hpp @@ -0,0 +1,40 @@ +// SuperTux +// Copyright (C) 2009 Ingo Ruhnke +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#ifndef HEADER_SUPERTUX_SUPERTUX_MENU_WORLDMAP_MENU_HPP +#define HEADER_SUPERTUX_SUPERTUX_MENU_WORLDMAP_MENU_HPP + +#include "gui/menu.hpp" + +enum WorldMapMenuIDs { + MNID_RETURNWORLDMAP, + MNID_QUITWORLDMAP +}; + +class WorldmapMenu : public Menu +{ +private: +public: + WorldmapMenu(); + +private: + WorldmapMenu(const WorldmapMenu&); + WorldmapMenu& operator=(const WorldmapMenu&); +}; + +#endif + +/* EOF */ diff --git a/src/supertux/title_screen.cpp b/src/supertux/title_screen.cpp index 177328867..10abd39ba 100644 --- a/src/supertux/title_screen.cpp +++ b/src/supertux/title_screen.cpp @@ -35,6 +35,10 @@ #include "supertux/globals.hpp" #include "supertux/mainloop.hpp" #include "supertux/menu/menu_storage.hpp" +#include "supertux/menu/addon_menu.hpp" +#include "supertux/menu/contrib_world_menu.hpp" +#include "supertux/menu/contrib_menu.hpp" +#include "supertux/menu/main_menu.hpp" #include "supertux/menu/options_menu.hpp" #include "supertux/resources.hpp" #include "supertux/sector.hpp" @@ -45,16 +49,6 @@ #include "util/reader.hpp" #include "video/drawing_context.hpp" -enum MainMenuIDs { - MNID_STARTGAME, - MNID_LEVELS_CONTRIB, - MNID_ADDONS, - MNID_OPTIONMENU, - MNID_LEVELEDITOR, - MNID_CREDITS, - MNID_QUITMAINMENU -}; - TitleScreen::TitleScreen() : main_menu(), contrib_menu(), @@ -109,29 +103,8 @@ TitleScreen::generate_contrib_menu() PHYSFS_freeList(files); free_contrib_menu(); - contrib_menu.reset(new Menu()); - - contrib_menu->add_label(_("Contrib Levels")); - contrib_menu->add_hl(); - - int i = 0; - for (std::vector::iterator it = level_worlds.begin(); - it != level_worlds.end(); ++it) { - try { - std::auto_ptr world (new World()); - world->load(*it + "/info"); - if(world->hide_from_contribs) { - continue; - } - contrib_menu->add_entry(i++, world->title); - contrib_worlds.push_back(world.release()); - } catch(std::exception& e) { - log_warning << "Couldn't parse levelset info for '" << *it << "': " << e.what() << std::endl; - } - } - - contrib_menu->add_hl(); - contrib_menu->add_back(_("Back")); + contrib_menu.reset(new ContribMenu(level_worlds, + contrib_worlds)); } std::string @@ -167,22 +140,7 @@ TitleScreen::check_levels_contrib_menu() if(!current_world->is_levelset) { start_game(); } else { - contrib_world_menu.reset(new Menu()); - - contrib_world_menu->add_label(current_world->title); - contrib_world_menu->add_hl(); - - for (unsigned int i = 0; i < current_world->get_num_levels(); ++i) - { - /** get level's title */ - std::string filename = current_world->get_level_filename(i); - std::string title = get_level_name(filename); - contrib_world_menu->add_entry(i, title); - } - - contrib_world_menu->add_hl(); - contrib_world_menu->add_back(_("Back")); - + contrib_world_menu.reset(new ContribWorldMenu(*current_world)); MenuManager::push_current(contrib_world_menu.get()); } } @@ -206,8 +164,6 @@ bool generate_addons_menu_sorter(const Addon* a1, const Addon* a2) { return a1->title < a2->title; } - -const int ADDON_LIST_START_ID = 10; } void @@ -223,30 +179,7 @@ TitleScreen::generate_addons_menu() // (re)generate menu free_addons_menu(); - addons_menu.reset(new Menu()); - - addons_menu->add_label(_("Add-ons")); - addons_menu->add_hl(); - -#ifdef HAVE_LIBCURL - addons_menu->add_entry(0, std::string(_("Check Online"))); -#else - addons_menu->add_inactive(0, std::string(_("Check Online (disabled)"))); -#endif - - //addons_menu->add_hl(); - - for (unsigned int i = 0; i < addons.size(); i++) { - const Addon& addon = *addons[i]; - std::string text = ""; - if (addon.kind != "") text += addon.kind + " "; - text += std::string("\"") + addon.title + "\""; - if (addon.author != "") text += " by \"" + addon.author + "\""; - addons_menu->add_toggle(ADDON_LIST_START_ID + i, text, addon.loaded); - } - - addons_menu->add_hl(); - addons_menu->add_back(_("Back")); + addons_menu.reset(new AddonMenu(addons)); } void @@ -336,14 +269,7 @@ TitleScreen::make_tux_jump() void TitleScreen::generate_main_menu() { - main_menu.reset(new Menu()); - main_menu->set_pos(SCREEN_WIDTH/2, SCREEN_HEIGHT/2 + 35); - main_menu->add_entry(MNID_STARTGAME, _("Start Game")); - main_menu->add_entry(MNID_LEVELS_CONTRIB, _("Contrib Levels")); - main_menu->add_entry(MNID_ADDONS, _("Add-ons")); - main_menu->add_submenu(_("Options"), MenuStorage::get_options_menu()); - main_menu->add_entry(MNID_CREDITS, _("Credits")); - main_menu->add_entry(MNID_QUITMAINMENU, _("Quit")); + main_menu.reset(new MainMenu()); } TitleScreen::~TitleScreen() diff --git a/src/supertux/title_screen.hpp b/src/supertux/title_screen.hpp index b61fb01ed..ef4a5d077 100644 --- a/src/supertux/title_screen.hpp +++ b/src/supertux/title_screen.hpp @@ -31,6 +31,9 @@ class CodeController; class TitleScreen : public Screen { public: + static std::string get_level_name(const std::string& levelfile); + +public: TitleScreen(); virtual ~TitleScreen(); @@ -42,7 +45,6 @@ public: virtual void update(float elapsed_time); private: - std::string get_level_name(const std::string& levelfile); void start_game(); void make_tux_jump(); void update_load_game_menu(); diff --git a/src/worldmap/worldmap.cpp b/src/worldmap/worldmap.cpp index 0a0c50f0a..82e87add7 100644 --- a/src/worldmap/worldmap.cpp +++ b/src/worldmap/worldmap.cpp @@ -48,6 +48,7 @@ #include "supertux/mainloop.hpp" #include "supertux/menu/menu_storage.hpp" #include "supertux/menu/options_menu.hpp" +#include "supertux/menu/worldmap_menu.hpp" #include "supertux/player_status.hpp" #include "supertux/resources.hpp" #include "supertux/sector.hpp" @@ -73,11 +74,6 @@ static const float CAMERA_PAN_SPEED = 5.0; namespace WorldMapNS { -enum WorldMapMenuIDs { - MNID_RETURNWORLDMAP, - MNID_QUITWORLDMAP -}; - WorldMap* WorldMap::current_ = NULL; Direction reverse_dir(Direction direction) @@ -174,13 +170,7 @@ WorldMap::WorldMap(const std::string& filename, const std::string& force_spawnpo total_stats.reset(); - worldmap_menu.reset(new Menu()); - worldmap_menu->add_label(_("Pause")); - worldmap_menu->add_hl(); - worldmap_menu->add_entry(MNID_RETURNWORLDMAP, _("Continue")); - worldmap_menu->add_submenu(_("Options"), MenuStorage::get_options_menu()); - worldmap_menu->add_hl(); - worldmap_menu->add_entry(MNID_QUITWORLDMAP, _("Quit World")); + worldmap_menu.reset(new WorldmapMenu()); // create a new squirrel table for the worldmap using namespace Scripting;