/* ================= UI_InternetGames_Callback ================= */ static void UI_InternetGames_Callback( void *self, int event ) { menuCommon_s *item = (menuCommon_s *)self; if( event != QM_ACTIVATED ) return; switch( item->id ) { case ID_JOINGAME: if( CL_IsActive( )) UI_PromptDialog(); else UI_InternetGames_JoinGame(); break; case ID_CREATEGAME: CVAR_SET_FLOAT( "public", 1.0f ); UI_CreateGame_Menu(); break; case ID_GAMEINFO: // UNDONE: not implemented break; case ID_REFRESH: UI_RefreshInternetServerList(); break; case ID_DONE: UI_PopMenu(); break; case ID_YES: UI_InternetGames_JoinGame(); break; case ID_NO: UI_PromptDialog(); break; } }
/* ================= UI_CreateGame_Callback ================= */ static void UI_CreateGame_Callback( void *self, int event ) { menuCommon_s *item = (menuCommon_s *)self; switch( item->id ) { case ID_DEDICATED: if( event == QM_PRESSED ) ((menuCheckBox_s *)self)->focusPic = UI_CHECKBOX_PRESSED; else ((menuCheckBox_s *)self)->focusPic = UI_CHECKBOX_FOCUS; break; } if( event != QM_ACTIVATED ) return; switch( item->id ) { case ID_ADVOPTIONS: // UNDONE: not implemented break; case ID_DONE: UI_PromptDialog(); break; case ID_CANCEL: UI_PopMenu(); break; case ID_YES: UI_CreateGame_Begin(); break; case ID_NO: UI_PromptDialog(); break; } }
/* ================= UI_NewGame_Callback ================= */ static void UI_NewGame_Callback( void *self, int event ) { menuCommon_s *item = (menuCommon_s *)self; if( event != QM_ACTIVATED ) return; switch( item->id ) { case ID_EASY: UI_PromptDialog( 1.0f ); break; case ID_MEDIUM: UI_PromptDialog( 2.0f ); break; case ID_DIFFICULT: UI_PromptDialog( 3.0f ); break; case ID_CANCEL: UI_PopMenu(); break; case ID_YES: UI_NewGame_StartGame( uiNewGame.skill ); break; case ID_NO: UI_PromptDialog( 1.0f ); // clear skill break; } }
/* ================= UI_InternetGames_KeyFunc ================= */ static const char *UI_InternetGames_KeyFunc( int key, int down ) { if( down && key == K_ESCAPE && !( uiInternetGames.dlgMessage1.generic.flags & QMF_HIDDEN )) { UI_PromptDialog(); return uiSoundNull; } return UI_DefaultKey( &uiInternetGames.menu, key, down ); }
/* ================= UI_NewGame_KeyFunc ================= */ static const char *UI_NewGame_KeyFunc( int key, int down ) { if( down && key == K_ESCAPE && !( uiNewGame.dlgMessage1.generic.flags & QMF_HIDDEN )) { UI_PromptDialog( 0.0f ); // clear skill return uiSoundNull; } return UI_DefaultKey( &uiNewGame.menu, key, down ); }
/* ================= UI_InternetGames_JoinGame ================= */ static void UI_InternetGames_JoinGame( void ) { // close dialog if( !(uiInternetGames.yes.generic.flags & QMF_HIDDEN ) ) UI_PromptDialog(); if( !strlen( uiInternetGames.gameDescription[uiInternetGames.gameList.curItem] )) return; CLIENT_JOIN( uiStatic.serverAddresses[uiInternetGames.gameList.curItem] ); // prevent refresh durning connect uiInternetGames.refreshTime = uiStatic.realTime + 999999999; }
/* ================= UI_Main_KeyFunc ================= */ static const char *UI_Main_KeyFunc( int key, int down ) { if( down && key == K_ESCAPE ) { if ( CL_IsActive( )) { if(!( uiMain.dlgMessage1.generic.flags & QMF_HIDDEN )) UI_PromptDialog(); else if(!( uiMain.quitMessage.generic.flags & QMF_HIDDEN )) UI_QuitDialog(); else UI_CloseMenu(); } else UI_QuitDialog(); return uiSoundNull; } return UI_DefaultKey( &uiMain.menu, key, down ); }
/* ================= UI_Controls_KeyFunc ================= */ static const char *UI_Controls_KeyFunc( int key, int down ) { char cmd[128]; if( uiControls.msgBox1.generic.flags & QMF_HIDDEN ) { if( down && key == K_ESCAPE && uiControls.defaults.generic.flags & QMF_INACTIVE ) { UI_ResetToDefaultsDialog(); return uiSoundNull; } } if( down ) { if( uiControls.bind_grab ) // assume we are in grab-mode { // defining a key if( key == '`' || key == '~' ) { return uiSoundBuzz; } else if( key != K_ESCAPE ) { const char *bindName = uiControls.keysBind[uiControls.keysList.curItem]; sprintf( cmd, "bind \"%s\" \"%s\"\n", KEY_KeynumToString( key ), bindName ); CLIENT_COMMAND( TRUE, cmd ); } uiControls.bind_grab = false; UI_Controls_RestartMenu(); return uiSoundLaunch; } if( key == K_ENTER && uiControls.dlgMessage.generic.flags & QMF_HIDDEN ) { if( !strlen( uiControls.keysBind[uiControls.keysList.curItem] )) { // probably it's a seperator return uiSoundBuzz; } // entering to grab-mode const char *bindName = uiControls.keysBind[uiControls.keysList.curItem]; int keys[2]; UI_Controls_GetKeyBindings( bindName, keys ); if( keys[1] != -1 ) UI_UnbindCommand( bindName ); uiControls.bind_grab = true; UI_PromptDialog(); // show prompt return uiSoundKey; } if(( key == K_BACKSPACE || key == K_DEL ) && uiControls.dlgMessage.generic.flags & QMF_HIDDEN ) { // delete bindings if( !strlen( uiControls.keysBind[uiControls.keysList.curItem] )) { // probably it's a seperator return uiSoundNull; } const char *bindName = uiControls.keysBind[uiControls.keysList.curItem]; UI_UnbindCommand( bindName ); UI_StartSound( uiSoundRemoveKey ); UI_Controls_RestartMenu(); return uiSoundNull; } } return UI_DefaultKey( &uiControls.menu, key, down ); }
/* ================= 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; } }