/* ================= UI_PopMenu ================= */ void UI_PopMenu( void ) { UI_StartSound( uiSoundOut ); uiStatic.menuDepth--; if( uiStatic.menuDepth < 0 ) HOST_ERROR( "UI_PopMenu: menu stack underflow\n" ); UI_PopPButtonStack(); if( uiStatic.menuDepth ) { uiStatic.menuActive = uiStatic.menuStack[uiStatic.menuDepth-1]; uiStatic.firstDraw = true; } else if ( CL_IsActive( )) { UI_CloseMenu(); } else { // never trying the close menu when client isn't connected KEY_SetDest( KEY_MENU ); UI_Main_Menu(); } if( uiStatic.m_fDemosPlayed && uiStatic.m_iOldMenuDepth == uiStatic.menuDepth ) { CLIENT_COMMAND( FALSE, "demos\n" ); uiStatic.m_fDemosPlayed = false; uiStatic.m_iOldMenuDepth = 0; } }
/* ================= UI_PopMenu ================= */ void UI_PopMenu( void ) { UI_StartSound( uiSoundOut ); uiStatic.menuDepth--; if( uiStatic.menuDepth < 0 ) HOST_ERROR( "UI_PopMenu: menu stack underflow\n" ); UI_PopPButtonStack(); if( uiStatic.menuDepth ) { uiStatic.menuActive = uiStatic.menuStack[uiStatic.menuDepth-1]; uiStatic.firstDraw = true; } else if ( CL_IsActive( )) { UI_CloseMenu(); } else { // never trying the close menu when client isn't connected KEY_SetDest( KEY_MENU ); UI_Main_Menu(); } }
/* ================= UI_CloseMenu ================= */ void UI_CloseMenu( void ) { uiStatic.menuActive = NULL; uiStatic.menuDepth = 0; uiStatic.visible = false; // clearing serverlist uiStatic.numServers = 0; memset( uiStatic.serverAddresses, 0, sizeof( uiStatic.serverAddresses )); memset( uiStatic.serverNames, 0, sizeof( uiStatic.serverNames )); UI_ClearButtonStack (); // KEY_ClearStates (); KEY_SetDest ( KEY_GAME ); }
/* ================= UI_PushMenu ================= */ void UI_PushMenu( menuFramework_s *menu ) { int i; menuCommon_s *item; // if this menu is already present, drop back to that level to avoid stacking menus by hotkeys for( i = 0; i < uiStatic.menuDepth; i++ ) { if( uiStatic.menuStack[i] == menu ) { uiStatic.menuDepth = i; break; } } if( i == uiStatic.menuDepth ) { if( uiStatic.menuDepth >= UI_MAX_MENUDEPTH ) HOST_ERROR( "UI_PushMenu: menu stack overflow\n" ); uiStatic.menuStack[uiStatic.menuDepth++] = menu; } uiStatic.menuActive = menu; uiStatic.firstDraw = true; uiStatic.enterSound = gpGlobals->time + 0.15; // make some delay uiStatic.visible = true; KEY_SetDest ( KEY_MENU ); menu->cursor = 0; menu->cursorPrev = 0; // force first available item to have focus for( i = 0; i < menu->numItems; i++ ) { item = (menuCommon_s *)menu->items[i]; if( item->flags & (QMF_GRAYED|QMF_INACTIVE|QMF_HIDDEN|QMF_MOUSEONLY)) continue; menu->cursorPrev = -1; UI_SetCursor( menu, i ); break; } }
/* ================= UI_SetActiveMenu ================= */ void UI_SetActiveMenu( int fActive ) { if( !uiStatic.initialized ) return; // don't continue firing if we leave game KEY_ClearStates(); uiStatic.framecount = 0; if( fActive ) { KEY_SetDest( KEY_MENU ); UI_Main_Menu(); } else { UI_CloseMenu(); } }
/* ================= UI_Main_Callback ================= */ static void UI_Main_Callback( void *self, int event ) { menuCommon_s *item = (menuCommon_s *)self; switch( item->id ) { case ID_QUIT_BUTTON: if( event == QM_PRESSED ) ((menuBitmap_s *)self)->focusPic = ART_CLOSEBTN_D; else ((menuBitmap_s *)self)->focusPic = ART_CLOSEBTN_F; break; case ID_MINIMIZE: if( event == QM_PRESSED ) ((menuBitmap_s *)self)->focusPic = ART_MINIMIZE_D; else ((menuBitmap_s *)self)->focusPic = ART_MINIMIZE_F; break; } if( event != QM_ACTIVATED ) return; switch( item->id ) { case ID_CONSOLE: UI_SetActiveMenu( FALSE ); KEY_SetDest( KEY_CONSOLE ); break; case ID_RESUME: UI_CloseMenu(); break; case ID_NEWGAME: if( CL_IsActive( )) UI_PromptDialog(); else UI_Main_NewGame(); break; case ID_MULTIPLAYER: UI_MultiPlayer_Menu(); break; case ID_CONFIGURATION: UI_Options_Menu(); break; case ID_SAVERESTORE: if( CL_IsActive( )) UI_SaveLoad_Menu(); else UI_LoadGame_Menu(); break; case ID_CUSTOMGAME: UI_CustomGame_Menu(); break; case ID_PREVIEWS: SHELL_EXECUTE( MenuStrings[HINT_PREVIEWS_CMD], NULL, false ); break; case ID_QUIT: case ID_QUIT_BUTTON: UI_QuitDialog(); break; case ID_MINIMIZE: CLIENT_COMMAND( FALSE, "minimize\n" ); break; case ID_YES: if( !( uiMain.quitMessage.generic.flags & QMF_HIDDEN )) CLIENT_COMMAND( FALSE, "quit\n" ); else UI_Main_NewGame(); break; case ID_NO: if( !( uiMain.quitMessage.generic.flags & QMF_HIDDEN )) UI_QuitDialog(); else UI_PromptDialog(); break; } }