#include "supertux/levelintro.hpp"
#include "supertux/globals.hpp"
#include "supertux/mainloop.hpp"
+#include "supertux/menu/menu_manager.hpp"
#include "supertux/menu/options_menu.hpp"
#include "supertux/sector.hpp"
#include "util/file_system.hpp"
game_menu->add_label(level->name);
game_menu->add_hl();
game_menu->add_entry(MNID_CONTINUE, _("Continue"));
- game_menu->add_submenu(_("Options"), get_options_menu());
+ game_menu->add_submenu(_("Options"), MenuManager::get_options_menu());
game_menu->add_hl();
game_menu->add_entry(MNID_ABORTLEVEL, _("Abort Level"));
}
delete capture_demo_stream;
delete playback_demo_stream;
delete demo_controller;
- free_options_menu();
+ MenuManager::free_options_menu();
}
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/menu_manager.hpp"
+
+#include "supertux/menu/options_menu.hpp"
+#include "supertux/menu/profile_menu.hpp"
+
+Menu* MenuManager::options_menu = 0;
+Menu* MenuManager::profile_menu = 0;
+
+Menu*
+MenuManager::get_options_menu()
+{
+ options_menu = new OptionsMenu();
+ return options_menu;
+}
+
+void
+MenuManager::free_options_menu()
+{
+ delete options_menu;
+ options_menu = 0;
+}
+
+Menu*
+MenuManager::get_profile_menu()
+{
+ profile_menu = new ProfileMenu();
+ return profile_menu;
+}
+
+void
+MenuManager::free_profile_menu()
+{
+ delete profile_menu;
+ profile_menu = 0;
+}
+
+/* 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_MENU_MANAGER_HPP
+#define HEADER_SUPERTUX_SUPERTUX_MENU_MENU_MANAGER_HPP
+
+class Menu;
+
+class MenuManager
+{
+public:
+ MenuManager();
+
+ static Menu* get_options_menu();
+ static void free_options_menu();
+
+ static Menu* get_profile_menu();
+ static void free_profile_menu();
+
+private:
+ static Menu* options_menu;
+ static Menu* profile_menu;
+
+private:
+ MenuManager(const MenuManager&);
+ MenuManager& operator=(const MenuManager&);
+};
+
+#endif
+
+/* EOF */
#include "supertux/main.hpp"
#include "supertux/menu/profile_menu.hpp"
#include "supertux/menu/language_menu.hpp"
+#include "supertux/menu/menu_manager.hpp"
#include "util/gettext.hpp"
#include "video/renderer.hpp"
-Menu* options_menu = 0;
-
enum OptionsMenuIDs {
MNID_FULLSCREEN,
MNID_FULLSCREEN_RESOLUTION,
add_submenu(_("Select Language"), language_menu.get())
->set_help(_("Select a different language to display text in"));
- add_submenu(_("Select Profile"), get_profile_menu())
+ add_submenu(_("Select Profile"), MenuManager::get_profile_menu())
->set_help(_("Select a profile to play with"));
add_toggle(MNID_PROFILES, _("Profile on Startup"), g_config->sound_enabled)
break;
case MNID_FULLSCREEN:
- if(g_config->use_fullscreen != options_menu->is_toggled(MNID_FULLSCREEN)) {
+ if(g_config->use_fullscreen != is_toggled(MNID_FULLSCREEN)) {
g_config->use_fullscreen = !g_config->use_fullscreen;
init_video(); // FIXME: Should call apply_config instead
Menu::recalc_pos();
break;
case MNID_SOUND:
- if(g_config->sound_enabled != options_menu->is_toggled(MNID_SOUND)) {
+ if(g_config->sound_enabled != is_toggled(MNID_SOUND)) {
g_config->sound_enabled = !g_config->sound_enabled;
sound_manager->enable_sound(g_config->sound_enabled);
g_config->save();
break;
case MNID_MUSIC:
- if(g_config->music_enabled != options_menu->is_toggled(MNID_MUSIC)) {
+ if(g_config->music_enabled != is_toggled(MNID_MUSIC)) {
g_config->music_enabled = !g_config->music_enabled;
sound_manager->enable_music(g_config->music_enabled);
g_config->save();
}
}
-Menu* get_options_menu()
-{
- //static OptionsMenu menu;
- options_menu = new OptionsMenu();
- return options_menu;
-}
-
-void free_options_menu()
-{
- delete options_menu;
- options_menu = 0;
-}
-
/* EOF */
class LanguageMenu;
-Menu* get_options_menu();
-void free_options_menu();
-
class OptionsMenu : public Menu
{
public:
virtual void menu_action(MenuItem* item);
protected:
- std::auto_ptr<LanguageMenu> language_menu;
-
+ std::auto_ptr<LanguageMenu> language_menu;
};
#endif
// 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/profile_menu.hpp"
+
#include <sstream>
#include "gui/menu.hpp"
#include "supertux/gameconfig.hpp"
#include "util/gettext.hpp"
-enum ProfileMenuIDs {
-
-};
-
-class ProfileMenu : public Menu
+ProfileMenu::ProfileMenu()
{
-public:
- ProfileMenu() {
- add_label(_("Select Profile"));
- add_hl();
- for(int i = 0; i < 5; ++i)
- {
- std::ostringstream out;
- out << "Profile " << i+1;
- add_entry(i+1, out.str());
- }
-
- add_hl();
- add_back(_("Back"));
- }
-
- void menu_action(MenuItem* item) {
- g_config->profile = item->id;
- Menu::set_current(0);
+ add_label(_("Select Profile"));
+ add_hl();
+ for(int i = 0; i < 5; ++i)
+ {
+ std::ostringstream out;
+ out << "Profile " << i+1;
+ add_entry(i+1, out.str());
}
-};
-Menu* profile_menu = 0;
-
-Menu* get_profile_menu()
-{
- //static ProfileMenu menu;
- profile_menu = new ProfileMenu();
- return profile_menu;
+ add_hl();
+ add_back(_("Back"));
}
-void free_profile_menu()
+void
+ProfileMenu::menu_action(MenuItem* item)
{
- delete profile_menu;
- profile_menu = 0;
+ g_config->profile = item->id;
+ Menu::set_current(0);
}
/*
#ifndef HEADER_SUPERTUX_SUPERTUX_PROFILE_MENU_HPP
#define HEADER_SUPERTUX_SUPERTUX_PROFILE_MENU_HPP
-class Menu;
-Menu* get_profile_menu();
-void free_profile_menu();
+#include "gui/menu.hpp"
+
+class ProfileMenu : public Menu
+{
+public:
+ ProfileMenu();
+
+ void menu_action(MenuItem* item);
+};
#endif
#include "supertux/gameconfig.hpp"
#include "supertux/globals.hpp"
#include "supertux/mainloop.hpp"
+#include "supertux/menu/menu_manager.hpp"
#include "supertux/menu/options_menu.hpp"
#include "supertux/resources.hpp"
#include "supertux/sector.hpp"
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"), get_options_menu());
+ main_menu->add_submenu(_("Options"), MenuManager::get_options_menu());
main_menu->add_entry(MNID_CREDITS, _("Credits"));
main_menu->add_entry(MNID_QUITMAINMENU, _("Quit"));
}
#include "supertux/game_session.hpp"
#include "supertux/globals.hpp"
#include "supertux/mainloop.hpp"
+#include "supertux/menu/menu_manager.hpp"
#include "supertux/menu/options_menu.hpp"
#include "supertux/player_status.hpp"
#include "supertux/resources.hpp"
worldmap_menu->add_label(_("Pause"));
worldmap_menu->add_hl();
worldmap_menu->add_entry(MNID_RETURNWORLDMAP, _("Continue"));
- worldmap_menu->add_submenu(_("Options"), get_options_menu());
+ worldmap_menu->add_submenu(_("Options"), MenuManager::get_options_menu());
worldmap_menu->add_hl();
worldmap_menu->add_entry(MNID_QUITWORLDMAP, _("Quit World"));