The menu manager can now switch menus even if the amount of menus don't change (i.e. the amount of menus popped is the same as the ones pushed), plus the usual minor style changes and fixing a small bug.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1354 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
cosmosninja 2007-12-14 03:46:05 +00:00
parent 0037afa8ea
commit e07116d262
4 changed files with 22 additions and 16 deletions

View File

@ -237,6 +237,11 @@ void HelpPageOne::select()
switch ( widget_manager->get_selected_wgt() )
{
case WTOK_SECOND_PAGE:
//This switches thee first page with the second page, so they
//are not stacked by the menu manager, and the menu that called
//this help is the one that gets called back when the next page
//is popped.
menu_manager->popMenu();
menu_manager->pushMenu(MENUID_HELP2);
break;

View File

@ -167,11 +167,12 @@ void HelpPageTwo::select()
switch ( widget_manager->get_selected_wgt() )
{
case WTOK_FIRST_PAGE:
menu_manager->popMenu();
menu_manager->pushMenu(MENUID_HELP1);
break;
case WTOK_QUIT:
menu_manager->switchToMainMenu();
menu_manager->popMenu();
break;
}
} // select

View File

@ -59,7 +59,7 @@ MenuManager::MenuManager()
{
m_current_menu = NULL;
m_RaceGUI = NULL;
m_handled_size = 0;
m_change_menu = false;
}
//-----------------------------------------------------------------------------
@ -99,6 +99,8 @@ void MenuManager::pushMenu(MenuManagerIDs id)
element.second = WidgetManager::WGT_NONE;
m_menu_stack.push_back(element);
m_change_menu = true;
}
//-----------------------------------------------------------------------------
@ -107,26 +109,28 @@ void MenuManager::popMenu()
sound_manager->playSfx(SOUND_BACK_MENU);
m_menu_stack.pop_back();
m_change_menu = true;
}
//-----------------------------------------------------------------------------
void MenuManager::update()
{
if (m_handled_size != m_menu_stack.size())
if ( m_change_menu )
{
m_change_menu = false;
if (m_RaceGUI
&& m_current_menu == m_RaceGUI)
{
m_RaceGUI = 0;
drv_setMode(MENU);
m_RaceGUI = 0;
drv_setMode(MENU);
}
delete m_current_menu;
m_current_menu= NULL;
m_handled_size = (unsigned int)m_menu_stack.size();
if (m_handled_size > 0)
if (!m_menu_stack.empty())
{
pair<MenuManagerIDs, int> saved = m_menu_stack.back();
MenuManagerIDs id = saved.first;
@ -175,11 +179,6 @@ void MenuManager::update()
case MENUID_GRANDPRIXSELECT:
m_current_menu= new GrandPrixSelect();
break;
#if 0
case MENUID_NEXTRACE:
race_manager->next();
break;
#endif
case MENUID_RACEMENU:
m_current_menu= new RaceMenu();
break;
@ -253,7 +252,7 @@ void MenuManager::switchToGrandPrixEnding()
delete m_current_menu;
m_current_menu= NULL;
}
m_handled_size = 0;
m_change_menu = true;
m_menu_stack.clear();
pushMenu(MENUID_GRANDPRIXEND);
@ -285,11 +284,11 @@ void MenuManager::switchToMainMenu()
{
if (m_current_menu != NULL)
{
if(m_current_menu==m_RaceGUI) m_RaceGUI=0;
if(m_current_menu == m_RaceGUI) m_RaceGUI = 0;
delete m_current_menu;
m_current_menu= NULL;
}
m_handled_size = 0;
m_change_menu = true;
m_menu_stack.clear();
pushMenu(MENUID_MAINMENU);

View File

@ -57,6 +57,7 @@ enum MenuManagerIDs
MENUID_HELP1,
MENUID_HELP2,
MENUID_CREDITS,
// race gui
MENUID_RACE,
};
@ -89,7 +90,7 @@ private:
std::vector< std::pair<MenuManagerIDs, int> > m_menu_stack;
BaseGUI* m_current_menu;
BaseGUI* m_RaceGUI;
unsigned int m_handled_size;
bool m_change_menu;
};
extern MenuManager* menu_manager;