Back to index

supertuxkart  0.5+dfsg1
menu_manager.hpp
Go to the documentation of this file.
00001 //  $Id: menu_manager.hpp 2111 2008-05-31 07:04:30Z cosmosninja $
00002 //
00003 //  SuperTuxKart - a fun racing game with go-kart
00004 //  Copyright (C) 2006 Patrick Ammann <pammann@aro.ch>
00005 //
00006 //  This program is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU General Public License
00008 //  as published by the Free Software Foundation; either version 2
00009 //  of the License, or (at your option) any later version.
00010 //
00011 //  This program is distributed in the hope that it will be useful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //  GNU General Public License for more details.
00015 //
00016 //  You should have received a copy of the GNU General Public License
00017 //  along with this program; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020 #ifndef HEADER_MENUMANAGER_H
00021 #define HEADER_MENUMANAGER_H
00022 
00023 #include <vector>
00024 #include "gui/race_gui.hpp"
00025 #include "gui/base_gui.hpp"
00026 
00027 enum MenuManagerIDs
00028 {
00029     // menu
00030     MENUID_MAINMENU,
00031     MENUID_CHARSEL_P1,
00032     MENUID_CHARSEL_P2,
00033     MENUID_CHARSEL_P3,
00034     MENUID_CHARSEL_P4,
00035     MENUID_CHALLENGES,
00036     MENUID_RACE_OPTIONS,
00037     MENUID_GAMEMODE,
00038     MENUID_RACERESULT,
00039     MENUID_LEADERRESULT,
00040     MENUID_GRANDPRIXEND,
00041     MENUID_RACEMENU,
00042     MENUID_TRACKSEL,
00043     MENUID_NUMPLAYERS,
00044     MENUID_OPTIONS,
00045     MENUID_EXITGAME,
00046     MENUID_GRANDPRIXSELECT,
00047     MENUID_UNLOCKED_FEATURE,
00048     MENUID_START_RACE_FEEDBACK,
00049 
00050     // menu configuration
00051     MENUID_CONFIG_DISPLAY,
00052     MENUID_RESOLUTION_CONFIRM_FS,
00053     MENUID_RESOLUTION_CONFIRM_WIN,
00054     MENUID_CONFIG_SOUND,
00055     MENUID_CONFIG_CONTROLS,
00056     MENUID_CONFIG_P1,
00057     MENUID_CONFIG_P2,
00058     MENUID_CONFIG_P3,
00059     MENUID_CONFIG_P4,
00060 
00061     // help and credit menu
00062     MENUID_HELP1,
00063     MENUID_HELP2,
00064     MENUID_HELP3,
00065     MENUID_CREDITS,
00066 
00067     // race gui
00068     MENUID_RACE,
00069 };
00070 
00071 class MenuManager
00072 {
00073 public:
00074     MenuManager();
00075     virtual ~MenuManager();
00076 
00077     // general functions
00078     void switchToGrandPrixEnding();
00079     void switchToRace();
00080     void switchToMainMenu();
00081 
00082     // use this function within menu classes
00083     void pushMenu(MenuManagerIDs);
00084     void popMenu();
00085 
00086     int getMenuStackSize() {return (int)m_menu_stack.size();}
00087 
00088     bool isCurrentMenu(MenuManagerIDs id) {return (m_menu_stack.back().first == id);}
00089     bool isSomewhereOnStack(MenuManagerIDs id);
00090     BaseGUI* getCurrentMenu() const {return m_current_menu;}
00091     RaceGUI* getRaceMenu   () const {return (RaceGUI*)m_RaceGUI;}
00092 
00093     void update();
00094 
00095 private:
00096     std::vector< std::pair<MenuManagerIDs, int> > m_menu_stack;
00097     BaseGUI* m_current_menu;
00098     BaseGUI* m_RaceGUI;
00099     bool m_change_menu;
00100 };
00101 
00102 extern MenuManager* menu_manager;
00103 
00104 #endif // HEADER_MENUMANAGER_H