#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(),
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
--- /dev/null
+// SuperTux
+// Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
+//
+// 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 <http://www.gnu.org/licenses/>.
+
+#include "supertux/menu/addon_menu.hpp"
+
+#include <config.h>
+
+#include "addon/addon.hpp"
+#include "util/gettext.hpp"
+
+AddonMenu::AddonMenu(const std::vector<Addon*>& 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 */
--- /dev/null
+// SuperTux
+// Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
+//
+// 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 <http://www.gnu.org/licenses/>.
+
+#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<Addon*>& addons);
+
+private:
+ AddonMenu(const AddonMenu&);
+ AddonMenu& operator=(const AddonMenu&);
+};
+
+#endif
+
+/* EOF */
--- /dev/null
+// SuperTux
+// Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
+//
+// 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 <http://www.gnu.org/licenses/>.
+
+#include "supertux/menu/contrib_menu.hpp"
+
+#include "supertux/world.hpp"
+#include "util/gettext.hpp"
+
+ContribMenu::ContribMenu(const std::vector<std::string>& level_worlds,
+ std::vector<World*>& contrib_worlds)
+{
+ add_label(_("Contrib Levels"));
+ add_hl();
+
+ int i = 0;
+ for (std::vector<std::string>::const_iterator it = level_worlds.begin(); it != level_worlds.end(); ++it)
+ {
+ try
+ {
+ std::auto_ptr<World> 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 */
--- /dev/null
+// SuperTux
+// Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
+//
+// 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 <http://www.gnu.org/licenses/>.
+
+#ifndef HEADER_SUPERTUX_SUPERTUX_MENU_CONTRIB_MENU_HPP
+#define HEADER_SUPERTUX_SUPERTUX_MENU_CONTRIB_MENU_HPP
+
+#include "gui/menu.hpp"
+
+#include <vector>
+#include <string>
+
+class World;
+
+class ContribMenu : public Menu
+{
+private:
+public:
+ ContribMenu(const std::vector<std::string>& level_worlds,
+ std::vector<World*>& contrib_worlds);
+
+private:
+ ContribMenu(const ContribMenu&);
+ ContribMenu& operator=(const ContribMenu&);
+};
+
+#endif
+
+/* EOF */
--- /dev/null
+// SuperTux
+// Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
+//
+// 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 <http://www.gnu.org/licenses/>.
+
+#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 */
--- /dev/null
+// SuperTux
+// Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
+//
+// 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 <http://www.gnu.org/licenses/>.
+
+#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 */
--- /dev/null
+// SuperTux
+// Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
+//
+// 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 <http://www.gnu.org/licenses/>.
+
+#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 */
--- /dev/null
+// SuperTux
+// Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
+//
+// 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 <http://www.gnu.org/licenses/>.
+
+#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 */
--- /dev/null
+// SuperTux
+// Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
+//
+// 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 <http://www.gnu.org/licenses/>.
+
+#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 */
--- /dev/null
+// SuperTux
+// Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
+//
+// 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 <http://www.gnu.org/licenses/>.
+
+#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 */
--- /dev/null
+// SuperTux
+// Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
+//
+// 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 <http://www.gnu.org/licenses/>.
+
+#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 */
--- /dev/null
+// SuperTux
+// Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
+//
+// 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 <http://www.gnu.org/licenses/>.
+
+#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 */
#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"
#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(),
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<std::string>::iterator it = level_worlds.begin();
- it != level_worlds.end(); ++it) {
- try {
- std::auto_ptr<World> 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
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());
}
}
{
return a1->title < a2->title;
}
-
-const int ADDON_LIST_START_ID = 10;
}
void
// (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
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()
class TitleScreen : public Screen
{
public:
+ static std::string get_level_name(const std::string& levelfile);
+
+public:
TitleScreen();
virtual ~TitleScreen();
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();
#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"
namespace WorldMapNS {
-enum WorldMapMenuIDs {
- MNID_RETURNWORLDMAP,
- MNID_QUITWORLDMAP
-};
-
WorldMap* WorldMap::current_ = NULL;
Direction reverse_dir(Direction direction)
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;