Back to index

supertuxkart  0.5+dfsg1
Public Member Functions | Private Attributes
MenuManager Class Reference

#include <menu_manager.hpp>

Collaboration diagram for MenuManager:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 MenuManager ()
virtual ~MenuManager ()
void switchToGrandPrixEnding ()
void switchToRace ()
void switchToMainMenu ()
void pushMenu (MenuManagerIDs)
 Puts the given menu into the menu stack and saves the widgetToken of the last selected widget for later reactivation.
void popMenu ()
int getMenuStackSize ()
bool isCurrentMenu (MenuManagerIDs id)
bool isSomewhereOnStack (MenuManagerIDs id)
BaseGUIgetCurrentMenu () const
RaceGUIgetRaceMenu () const
void update ()

Private Attributes

std::vector< std::pair
< MenuManagerIDs, int > > 
m_menu_stack
BaseGUIm_current_menu
BaseGUIm_RaceGUI
bool m_change_menu

Detailed Description

Definition at line 71 of file menu_manager.hpp.


Constructor & Destructor Documentation

Definition at line 63 of file menu_manager.cpp.

{
    m_current_menu = NULL;
    m_RaceGUI      = NULL;
    m_change_menu = false;
}

Definition at line 71 of file menu_manager.cpp.

{
    delete m_current_menu;
}

Member Function Documentation

BaseGUI* MenuManager::getCurrentMenu ( ) const [inline]

Definition at line 90 of file menu_manager.hpp.

{return m_current_menu;}

Here is the caller graph for this function:

Definition at line 86 of file menu_manager.hpp.

{return (int)m_menu_stack.size();}

Here is the caller graph for this function:

RaceGUI* MenuManager::getRaceMenu ( ) const [inline]

Definition at line 91 of file menu_manager.hpp.

{return (RaceGUI*)m_RaceGUI;}

Here is the caller graph for this function:

Definition at line 88 of file menu_manager.hpp.

{return (m_menu_stack.back().first == id);}

Here is the caller graph for this function:

Definition at line 300 of file menu_manager.cpp.

{
       for(vector<pair<MenuManagerIDs,int> >::iterator i = m_menu_stack.begin(); i != m_menu_stack.end(); i++)
       {
              if ((*i).first == id)
                     return true;
       }
       
       return false;
}   // isSomewhereOnStack

Here is the caller graph for this function:

Definition at line 114 of file menu_manager.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Puts the given menu into the menu stack and saves the widgetToken of the last selected widget for later reactivation.

Definition at line 79 of file menu_manager.cpp.

{
    // If we store the selected widget when we have send the order to change
    // the menu but haven't done it, we would change the previous menu, not
    // the current menu.
       if ( m_menu_stack.size() && m_change_menu != true )
    {
              m_menu_stack.back().second = widget_manager->getSelectedWgt();
    }

       // used to suppress select-sound on startup
    static bool is_startup = true;

    if( MENUID_EXITGAME == id )
    {
        sound_manager->playSfx(SOUND_BACK_MENU);
    }
    else
    {
        if( !is_startup ) sound_manager->playSfx(SOUND_SELECT_MENU);
        else is_startup = false;
    }

       // Creates a new entry for the to be displayed menu.
       pair <MenuManagerIDs, int> element;
       element.first = id;
       element.second = WidgetManager::WGT_NONE;

    m_menu_stack.push_back(element);

    if( m_current_menu) m_current_menu->lockInput();
    m_change_menu = true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 277 of file menu_manager.cpp.

Here is the caller graph for this function:

Definition at line 312 of file menu_manager.cpp.

Here is the caller graph for this function:

Definition at line 291 of file menu_manager.cpp.

Here is the caller graph for this function:

Definition at line 124 of file menu_manager.cpp.

{

    if ( m_change_menu )
    {
        m_change_menu = false;

        if (m_RaceGUI
            && m_current_menu == m_RaceGUI)
        {
            m_RaceGUI = 0;
            inputDriver->setMode(MENU);
        }

        delete m_current_menu;
        m_current_menu= NULL;

        if (!m_menu_stack.empty())
        {
                     pair<MenuManagerIDs, int> saved = m_menu_stack.back();
            MenuManagerIDs id = saved.first;
                     int saved_widget = saved.second;

            switch (id)
            {
            case MENUID_MAINMENU:
                m_current_menu= new MainMenu();
                break;
            case MENUID_CHALLENGES:
                m_current_menu= new ChallengesMenu();
                break;
            case MENUID_CHARSEL_P1:
            case MENUID_CHARSEL_P2:
            case MENUID_CHARSEL_P3:
            case MENUID_CHARSEL_P4:
                m_current_menu= new CharSel(id - MENUID_CHARSEL_P1);
                break;
            case MENUID_RACE_OPTIONS:
                m_current_menu= new RaceOptions();
                break;
            case MENUID_GAMEMODE:
                m_current_menu= new GameMode();
                break;
            case MENUID_OPTIONS:
                m_current_menu= new Options();
                break;
            case MENUID_TRACKSEL:
                m_current_menu= new TrackSel();
                break;
            case MENUID_UNLOCKED_FEATURE:
                m_current_menu = new FeatureUnlocked();
                break;
            case MENUID_NUMPLAYERS:
                m_current_menu= new NumPlayers();
                break;
            case MENUID_RACE:
                inputDriver->setMode(INGAME);
                m_current_menu = new RaceGUI();
                m_RaceGUI      = m_current_menu;
                break;
            case MENUID_RACERESULT:
                m_current_menu= new RaceResultsGUI();
                break;
            case MENUID_LEADERRESULT:
                m_current_menu= new LeaderResult();
                break;
            case MENUID_GRANDPRIXEND:
                m_current_menu= new GrandPrixEnd();
                break;
            case MENUID_GRANDPRIXSELECT:
                m_current_menu= new GrandPrixSelect();
                break;
            case MENUID_RACEMENU:
                m_current_menu= new RaceMenu();
                break;
            case MENUID_EXITGAME:
                m_menu_stack.clear();
                game_manager->abort();
                break;

            case MENUID_CONFIG_CONTROLS:
                m_current_menu= new ConfigControls();
                break;
            case MENUID_CONFIG_P1:
            case MENUID_CONFIG_P2:
            case MENUID_CONFIG_P3:
            case MENUID_CONFIG_P4:
                m_current_menu= new PlayerControls(id - MENUID_CONFIG_P1);
                break;
            case MENUID_CONFIG_DISPLAY:
                m_current_menu= new ConfigDisplay();
                break;
            case MENUID_RESOLUTION_CONFIRM_FS:
                {
                    const bool FROM_FULLSCREEN = false;
                    m_current_menu= new DisplayResConfirm( FROM_FULLSCREEN );
                }
                break;
            case MENUID_RESOLUTION_CONFIRM_WIN:
                {
                    const bool FROM_WINDOW = true;
                    m_current_menu= new DisplayResConfirm( FROM_WINDOW );
                }
                break;
            case MENUID_CONFIG_SOUND:
                m_current_menu= new ConfigSound();
                break;
            case MENUID_HELP1:
                m_current_menu = new HelpPageOne();
                break;
            case MENUID_HELP2:
                m_current_menu = new HelpPageTwo();
                break;
            case MENUID_HELP3:
                m_current_menu = new HelpPageThree();
                break;
            case MENUID_CREDITS:
                m_current_menu = new CreditsMenu();
                break;
            case MENUID_START_RACE_FEEDBACK:
                m_current_menu = new StartRaceFeedback();
            default:
                break;
            }   // switch


            if( id != MENUID_EXITGAME )
            {
                // Restores the previously selected widget if there was one.
                if (saved_widget != WidgetManager::WGT_NONE)
                {
                    widget_manager->lightenWgtColor( saved_widget );
                    widget_manager->pulseWgt( saved_widget );
                    widget_manager->setSelectedWgt(saved_widget);
                } else if( widget_manager->getSelectedWgt() != WidgetManager::WGT_NONE )
                {
                    widget_manager->lightenWgtColor (
                        widget_manager->getSelectedWgt() );
                }
            }
        }
    }

    static ulClock now  = ulClock();
    now.update();

    if (m_current_menu != NULL)
    {
        m_current_menu->update((float)now.getDeltaTime());
    }
}   // update

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 99 of file menu_manager.hpp.

Definition at line 97 of file menu_manager.hpp.

std::vector< std::pair<MenuManagerIDs, int> > MenuManager::m_menu_stack [private]

Definition at line 96 of file menu_manager.hpp.

Definition at line 98 of file menu_manager.hpp.


The documentation for this class was generated from the following files: