if (Console::instance->hasFocus()) {
// if console is open: send key there
process_console_key_event(event);
- } else if (MenuManager2::current()) {
+ } else if (MenuManager::current()) {
// if menu mode: send key there
process_menu_key_event(event);
} else if(key_mapping == keymap.end()) {
arrow_left(),
arrow_right()
{
- MenuManager2::all_menus.push_back(this);
+ MenuManager::all_menus.push_back(this);
hit_item = -1;
menuaction = MENU_ACTION_NONE;
Menu::~Menu()
{
- MenuManager2::all_menus.remove(this);
+ MenuManager::all_menus.remove(this);
for(std::vector<MenuItem*>::iterator i = items.begin();
i != items.end(); ++i)
delete *i;
}
- if (MenuManager2::current_ == this)
- MenuManager2::current_ = NULL;
+ if (MenuManager::current_ == this)
+ MenuManager::current_ = NULL;
- if (MenuManager2::previous == this)
- MenuManager2::previous = NULL;
+ if (MenuManager::previous == this)
+ MenuManager::previous = NULL;
}
void
effect_progress = 1.0f;
if (close) {
- MenuManager2::current_ = 0;
+ MenuManager::current_ = 0;
close = false;
}
}
switch (items[active_item]->kind) {
case MN_GOTO:
assert(items[active_item]->target_menu != 0);
- MenuManager2::push_current(items[active_item]->target_menu);
+ MenuManager::push_current(items[active_item]->target_menu);
break;
case MN_TOGGLE:
break;
case MN_BACK:
- MenuManager2::pop_current();
+ MenuManager::pop_current();
break;
default:
break;
break;
case MENU_ACTION_BACK:
- MenuManager2::pop_current();
+ MenuManager::pop_current();
break;
case MENU_ACTION_NONE:
{
if (close)
{
- menu_width = (MenuManager2::current_->get_width() * (1.0f - effect_progress));
- menu_height = (MenuManager2::current_->get_height() * (1.0f - effect_progress));
+ menu_width = (MenuManager::current_->get_width() * (1.0f - effect_progress));
+ menu_height = (MenuManager::current_->get_height() * (1.0f - effect_progress));
}
- else if (MenuManager2::previous)
+ else if (MenuManager::previous)
{
- menu_width = (menu_width * effect_progress) + (MenuManager2::previous->get_width() * (1.0f - effect_progress));
- menu_height = (menu_height * effect_progress) + (MenuManager2::previous->get_height() * (1.0f - effect_progress));
+ menu_width = (menu_width * effect_progress) + (MenuManager::previous->get_width() * (1.0f - effect_progress));
+ menu_height = (menu_height * effect_progress) + (MenuManager::previous->get_height() * (1.0f - effect_progress));
//std::cout << effect_progress << " " << this << " " << last_menus.back() << std::endl;
}
else
Menu*
Menu::get_parent() const
{
- if (MenuManager2::last_menus.empty())
+ if (MenuManager::last_menus.empty())
return 0;
else
- return MenuManager2::last_menus.back();
+ return MenuManager::last_menus.back();
}
/* Check for menu event */
#include "supertux/globals.hpp"
#include "supertux/timer.hpp"
-std::vector<Menu*> MenuManager2::last_menus;
-std::list<Menu*> MenuManager2::all_menus;
-Menu* MenuManager2::current_ = 0;
-Menu* MenuManager2::previous = 0;
+std::vector<Menu*> MenuManager::last_menus;
+std::list<Menu*> MenuManager::all_menus;
+Menu* MenuManager::current_ = 0;
+Menu* MenuManager::previous = 0;
void
-MenuManager2::push_current(Menu* pmenu)
+MenuManager::push_current(Menu* pmenu)
{
previous = current_;
}
void
-MenuManager2::pop_current()
+MenuManager::pop_current()
{
previous = current_;
}
void
-MenuManager2::set_current(Menu* menu)
+MenuManager::set_current(Menu* menu)
{
if (current_ && current_->close == true)
return;
}
void
-MenuManager2::recalc_pos()
+MenuManager::recalc_pos()
{
if (current_)
current_->set_pos(SCREEN_WIDTH/2, SCREEN_HEIGHT/2);
class Menu;
-class MenuManager2 // FIXME: temporary name
+class MenuManager // FIXME: temporary name
{
public:
static std::vector<Menu*> last_menus;
}
private:
- MenuManager2(const MenuManager2&);
- MenuManager2& operator=(const MenuManager2&);
+ MenuManager(const MenuManager&);
+ MenuManager& operator=(const MenuManager&);
};
#endif
#include "supertux/levelintro.hpp"
#include "supertux/globals.hpp"
#include "supertux/mainloop.hpp"
-#include "supertux/menu/menu_manager.hpp"
+#include "supertux/menu/menu_storage.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"), MenuManager::get_options_menu());
+ game_menu->add_submenu(_("Options"), MenuStorage::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;
- MenuManager::free_options_menu();
+ MenuStorage::free_options_menu();
}
void
if(!game_pause) {
speed_before_pause = g_main_loop->get_speed();
g_main_loop->set_speed(0);
- MenuManager2::set_current(game_menu.get());
+ MenuManager::set_current(game_menu.get());
game_menu->set_active_item(MNID_CONTINUE);
game_pause = true;
}
void
GameSession::process_menu()
{
- Menu* menu = MenuManager2::current();
+ Menu* menu = MenuManager::current();
if(menu) {
if(menu == game_menu.get()) {
switch (game_menu->check()) {
case MNID_CONTINUE:
- MenuManager2::set_current(0);
+ MenuManager::set_current(0);
toggle_pause();
break;
case MNID_ABORTLEVEL:
- MenuManager2::set_current(0);
+ MenuManager::set_current(0);
g_main_loop->exit_screen();
break;
}
process_menu();
// Unpause the game if the menu has been closed
- if (game_pause && !MenuManager2::current()) {
+ if (game_pause && !MenuManager::current()) {
g_main_loop->set_speed(speed_before_pause);
game_pause = false;
}
static int frame_count = 0;
current_screen->draw(context);
- if(MenuManager2::current() != NULL)
- MenuManager2::current()->draw(context);
+ if(MenuManager::current() != NULL)
+ MenuManager::current()->draw(context);
if(screen_fade.get() != NULL)
screen_fade->draw(context);
Console::instance->draw(context);
Scripting::update_debugger();
Scripting::TimeScheduler::instance->update(game_time);
current_screen->update(elapsed_time);
- if (MenuManager2::current() != NULL)
- MenuManager2::current()->update();
+ if (MenuManager::current() != NULL)
+ MenuManager::current()->update();
if(screen_fade.get() != NULL)
screen_fade->update(elapsed_time);
Console::instance->update(elapsed_time);
{
g_main_controller->process_event(event);
- if(MenuManager2::current() != NULL)
- MenuManager2::current()->event(event);
+ if(MenuManager::current() != NULL)
+ MenuManager::current()->event(event);
switch(event.type)
{
case SDL_VIDEORESIZE:
Renderer::instance()->resize(event.resize.w, event.resize.h);
- MenuManager2::recalc_pos();
+ MenuManager::recalc_pos();
break;
case SDL_KEYDOWN:
{
g_config->use_fullscreen = !g_config->use_fullscreen;
init_video();
- MenuManager2::recalc_pos();
+ MenuManager::recalc_pos();
}
else if (event.key.keysym.sym == SDLK_PRINT ||
event.key.keysym.sym == SDLK_F12)
dictionary_manager.set_language(language);
g_config->locale = language.str();
g_config->save();
- MenuManager2::pop_current();
+ MenuManager::pop_current();
}
else if (item->id == MNID_LANGUAGE_ENGLISH) // english
{
g_config->locale = "en";
dictionary_manager.set_language(tinygettext::Language::from_name(g_config->locale));
g_config->save();
- MenuManager2::pop_current();
+ MenuManager::pop_current();
}
else
{
g_config->locale = i->str();
dictionary_manager.set_language(*i);
g_config->save();
- MenuManager2::pop_current();
+ MenuManager::pop_current();
break;
}
}
+++ /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 */
--- /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_storage.hpp"
+
+#include "supertux/menu/options_menu.hpp"
+#include "supertux/menu/profile_menu.hpp"
+
+Menu* MenuStorage::options_menu = 0;
+Menu* MenuStorage::profile_menu = 0;
+
+Menu*
+MenuStorage::get_options_menu()
+{
+ options_menu = new OptionsMenu();
+ return options_menu;
+}
+
+void
+MenuStorage::free_options_menu()
+{
+ delete options_menu;
+ options_menu = 0;
+}
+
+Menu*
+MenuStorage::get_profile_menu()
+{
+ profile_menu = new ProfileMenu();
+ return profile_menu;
+}
+
+void
+MenuStorage::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_STORAGE_HPP
+#define HEADER_SUPERTUX_SUPERTUX_MENU_MENU_STORAGE_HPP
+
+class Menu;
+
+class MenuStorage
+{
+public:
+ MenuStorage();
+
+ 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:
+ MenuStorage(const MenuStorage&);
+ MenuStorage& operator=(const MenuStorage&);
+};
+
+#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 "supertux/menu/menu_storage.hpp"
#include "util/gettext.hpp"
#include "video/renderer.hpp"
add_submenu(_("Select Language"), language_menu.get())
->set_help(_("Select a different language to display text in"));
- add_submenu(_("Select Profile"), MenuManager::get_profile_menu())
+ add_submenu(_("Select Profile"), MenuStorage::get_profile_menu())
->set_help(_("Select a profile to play with"));
add_toggle(MNID_PROFILES, _("Profile on Startup"), g_config->sound_enabled)
g_config->aspect_width = 0; // Magic values
g_config->aspect_height = 0;
Renderer::instance()->apply_config();
- MenuManager2::recalc_pos();
+ MenuManager::recalc_pos();
}
else if(sscanf(item->list[item->selected].c_str(), "%d:%d", &g_config->aspect_width, &g_config->aspect_height) == 2)
{
Renderer::instance()->apply_config();
- MenuManager2::recalc_pos();
+ MenuManager::recalc_pos();
}
else
{
g_config->magnification /= 100.0f;
}
Renderer::instance()->apply_config();
- MenuManager2::recalc_pos();
+ MenuManager::recalc_pos();
break;
case MNID_FULLSCREEN_RESOLUTION:
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
- MenuManager2::recalc_pos();
+ MenuManager::recalc_pos();
g_config->save();
}
break;
ProfileMenu::menu_action(MenuItem* item)
{
g_config->profile = item->id;
- MenuManager2::set_current(0);
+ MenuManager::set_current(0);
}
/*
#include "supertux/gameconfig.hpp"
#include "supertux/globals.hpp"
#include "supertux/mainloop.hpp"
-#include "supertux/menu/menu_manager.hpp"
+#include "supertux/menu/menu_storage.hpp"
#include "supertux/menu/options_menu.hpp"
#include "supertux/resources.hpp"
#include "supertux/sector.hpp"
contrib_world_menu->add_hl();
contrib_world_menu->add_back(_("Back"));
- MenuManager2::push_current(contrib_world_menu.get());
+ MenuManager::push_current(contrib_world_menu.get());
}
}
try {
AddonManager::get_instance().check_online();
generate_addons_menu();
- MenuManager2::set_current(addons_menu.get());
+ MenuManager::set_current(addons_menu.get());
addons_menu->set_active_item(index);
}
catch (std::runtime_error e) {
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"), MenuManager::get_options_menu());
+ main_menu->add_submenu(_("Options"), MenuStorage::get_options_menu());
main_menu->add_entry(MNID_CREDITS, _("Credits"));
main_menu->add_entry(MNID_QUITMAINMENU, _("Quit"));
}
sector->activate(sector->player->get_pos());
}
- MenuManager2::set_current(main_menu.get());
+ MenuManager::set_current(main_menu.get());
}
void
{
Sector* sector = titlesession->get_current_sector();
sector->deactivate();
- MenuManager2::set_current(NULL);
+ MenuManager::set_current(NULL);
}
void
make_tux_jump();
- Menu* menu = MenuManager2::current();
+ Menu* menu = MenuManager::current();
if(menu) {
if(menu == main_menu.get()) {
switch (main_menu->check()) {
case MNID_LEVELS_CONTRIB:
// Contrib Menu
generate_contrib_menu();
- MenuManager2::push_current(contrib_menu.get());
+ MenuManager::push_current(contrib_menu.get());
break;
case MNID_ADDONS:
// Add-ons Menu
generate_addons_menu();
- MenuManager2::push_current(addons_menu.get());
+ MenuManager::push_current(addons_menu.get());
break;
case MNID_CREDITS:
- MenuManager2::set_current(NULL);
+ MenuManager::set_current(NULL);
g_main_loop->push_screen(new TextScroller("credits.txt"),
new FadeOut(0.5));
break;
// reopen menu if user closed it (so that the app doesn't close when user
// accidently hit ESC)
- if(MenuManager2::current() == 0 && g_main_loop->has_no_pending_fadeout()) {
+ if(MenuManager::current() == 0 && g_main_loop->has_no_pending_fadeout()) {
generate_main_menu();
- MenuManager2::set_current(main_menu.get());
+ MenuManager::set_current(main_menu.get());
}
}
void
TitleScreen::start_game()
{
- MenuManager2::set_current(NULL);
+ MenuManager::set_current(NULL);
std::string basename = current_world->get_basedir();
basename = basename.substr(0, basename.length()-1);
std::string worlddirname = FileSystem::basename(basename);
#include "supertux/game_session.hpp"
#include "supertux/globals.hpp"
#include "supertux/mainloop.hpp"
-#include "supertux/menu/menu_manager.hpp"
+#include "supertux/menu/menu_storage.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"), MenuManager::get_options_menu());
+ worldmap_menu->add_submenu(_("Options"), MenuStorage::get_options_menu());
worldmap_menu->add_hl();
worldmap_menu->add_entry(MNID_QUITWORLDMAP, _("Quit World"));
WorldMap::on_escape_press()
{
// Show or hide the menu
- if(!MenuManager2::current()) {
- MenuManager2::set_current(worldmap_menu.get());
+ if(!MenuManager::current()) {
+ MenuManager::set_current(worldmap_menu.get());
tux->set_direction(D_NONE); // stop tux movement when menu is called
} else {
- MenuManager2::set_current(NULL);
+ MenuManager::set_current(NULL);
}
}
WorldMap::update(float delta)
{
if(!in_level) {
- Menu* menu = MenuManager2::current();
+ Menu* menu = MenuManager::current();
if(menu != NULL) {
if(menu == worldmap_menu.get()) {
switch (worldmap_menu->check())
{
case MNID_RETURNWORLDMAP: // Return to game
- MenuManager2::set_current(0);
+ MenuManager::set_current(0);
break;
case MNID_QUITWORLDMAP: // Quit Worldmap
g_main_loop->exit_screen();
WorldMap::setup()
{
sound_manager->play_music(music);
- MenuManager2::set_current(NULL);
+ MenuManager::set_current(NULL);
current_ = this;
load_state();