X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fmenu.cpp;h=044d94a23022b385ef62553409013703679a9ead;hb=63d73bc2cd3c356ffcf25af79256fbf2af1dd07c;hp=d05f5109cc07533855ef9f06e74540735264c11e;hpb=f951f51612fce3a9c1857745ac8bf2da64ca19a3;p=supertux.git diff --git a/src/menu.cpp b/src/menu.cpp index d05f5109c..044d94a23 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -1,20 +1,28 @@ -/* - menu.c - - Super Tux - Menu - - by Tobias Glaesser - tobi.web@gmx.de - http://www.newbreedsoftware.com/supertux/ - - December 20, 2003 - March 15, 2004 -*/ +// $Id$ +// +// SuperTux +// Copyright (C) 2004 Tobias Glaesser +// +// 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 2 +// 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, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef WIN32 #include #include #endif +#include #include #include #include @@ -47,6 +55,7 @@ Menu* save_game_menu = 0; Menu* contrib_menu = 0; Menu* contrib_subset_menu = 0; +std::stack Menu::last_menus; Menu* Menu::current_ = 0; void @@ -54,7 +63,9 @@ Menu::set_current(Menu* menu) { if (menu) { - menu->last_menu = current_; + if (last_menus.empty() || menu != last_menus.top()) + last_menus.push(current_); + menu->effect.start(500); } @@ -136,10 +147,8 @@ Menu::Menu() pos_x = screen->w/2; pos_y = screen->h/2; has_backitem = false; - last_menu = 0; arrange_left = 0; active_item = 0; - last_menu = 0; effect.init(false); } @@ -242,8 +251,11 @@ Menu::action() break; case MN_BACK: - if(last_menu != NULL) - Menu::set_current(last_menu); + if (!last_menus.empty()) + { + Menu::set_current(last_menus.top()); + last_menus.pop(); + } break; default: break; @@ -523,17 +535,6 @@ Menu::draw() } } -/* --- MENU --- */ -/* Draw the current menu and execute the (menu)events */ -void menu_process_current() -{ - if(Menu::current()) - { - Menu::current()->action(); - Menu::current()->draw(); - } -} - /* Check for menu event */ void Menu::event(SDL_Event& event) @@ -592,8 +593,11 @@ Menu::event(SDL_Event& event) case SDLK_ESCAPE: if(Menu::current()) { - if (has_backitem == true && last_menu != NULL) - Menu::set_current(last_menu); + if (has_backitem == true && !last_menus.empty()) + { + Menu::set_current(last_menus.top()); + last_menus.pop(); + } else Menu::set_current(0); }