2 // Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "gui/menu_manager.hpp"
19 #include "control/joystickkeyboardcontroller.hpp"
20 #include "gui/menu.hpp"
21 #include "supertux/globals.hpp"
22 #include "supertux/timer.hpp"
24 std::vector<Menu*> MenuManager::last_menus;
25 std::list<Menu*> MenuManager::all_menus;
26 Menu* MenuManager::current_ = 0;
27 Menu* MenuManager::previous = 0;
30 MenuManager::push_current(Menu* pmenu)
35 last_menus.push_back(current_);
38 current_->effect_start_time = real_time;
39 current_->effect_progress = 0.0f;
43 MenuManager::pop_current()
47 if (last_menus.size() >= 1) {
48 current_ = last_menus.back();
49 current_->effect_start_time = real_time;
50 current_->effect_progress = 0.0f;
51 last_menus.pop_back();
58 MenuManager::set_current(Menu* menu)
60 if (current_ && current_->close == true)
66 menu->effect_start_time = real_time;
67 menu->effect_progress = 0.0f;
71 last_menus.clear(); //NULL new menu pointer => close all menus
72 current_->effect_start_time = real_time;
73 current_->effect_progress = 0.0f;
74 current_->close = true;
78 g_main_controller->reset();
82 MenuManager::recalc_pos()
85 current_->set_pos(SCREEN_WIDTH/2, SCREEN_HEIGHT/2);
87 for(std::list<Menu*>::iterator i = all_menus.begin(); i != all_menus.end(); ++i)
89 // FIXME: This is of course not quite right, since it ignores any previous set_pos() calls
90 (*i)->set_pos(SCREEN_WIDTH/2, SCREEN_HEIGHT/2);