/* ================= UI_LoadGame_Callback ================= */ static void UI_LoadGame_Callback( void *self, int event ) { menuCommon_s *item = (menuCommon_s *)self; if( event == QM_CHANGED ) { if( uiLoadGame.saveName[uiLoadGame.savesList.curItem][0] == '\0' ) uiLoadGame.load.generic.flags |= QMF_GRAYED; else uiLoadGame.load.generic.flags &= ~QMF_GRAYED; if( uiLoadGame.delName[uiLoadGame.savesList.curItem][0] == '\0' ) uiLoadGame.remove.generic.flags |= QMF_GRAYED; else uiLoadGame.remove.generic.flags &= ~QMF_GRAYED; return; } if( event != QM_ACTIVATED ) return; switch( item->id ) { case ID_CANCEL: UI_PopMenu(); break; case ID_LOAD: if( uiLoadGame.saveName[uiLoadGame.savesList.curItem][0] ) { char cmd[128]; sprintf( cmd, "load \"%s\"\n", uiLoadGame.saveName[uiLoadGame.savesList.curItem] ); BACKGROUND_TRACK( NULL, NULL ); CLIENT_COMMAND( FALSE, cmd ); } break; case ID_NO: case ID_DELETE: UI_DeleteDialog(); break; case ID_YES: if( uiLoadGame.delName[uiLoadGame.savesList.curItem][0] ) { char cmd[128]; sprintf( cmd, "killsave \"%s\"\n", uiLoadGame.delName[uiLoadGame.savesList.curItem] ); CLIENT_COMMAND( TRUE, cmd ); sprintf( cmd, "save/%s.bmp", uiLoadGame.delName[uiLoadGame.savesList.curItem] ); PIC_Free( cmd ); // restarts the menu UI_PopMenu(); UI_LoadGame_Menu(); return; } UI_DeleteDialog(); break; } }
/* ================= UI_PlayDemo_Callback ================= */ static void UI_PlayDemo_Callback( void *self, int event ) { menuCommon_s *item = (menuCommon_s *)self; if( event == QM_CHANGED ) { if( strlen( uiPlayDemo.demoName[uiPlayDemo.demosList.curItem] ) == 0 ) uiPlayDemo.play.generic.flags |= QMF_GRAYED; else uiPlayDemo.play.generic.flags &= ~QMF_GRAYED; if( strlen( uiPlayDemo.delName[uiPlayDemo.demosList.curItem] ) == 0 || !stricmp( gpGlobals->demoname, uiPlayDemo.delName[uiPlayDemo.demosList.curItem] )) uiPlayDemo.remove.generic.flags |= QMF_GRAYED; else uiPlayDemo.remove.generic.flags &= ~QMF_GRAYED; return; } if( event != QM_ACTIVATED ) return; switch( item->id ) { case ID_CANCEL: UI_PopMenu(); break; case ID_PLAY: if( gpGlobals->demoplayback || gpGlobals->demorecording ) { CLIENT_COMMAND( FALSE, "stop" ); uiPlayDemo.play.generic.name = "Play"; uiPlayDemo.play.generic.statusText = "Play a demo"; uiPlayDemo.remove.generic.flags &= ~QMF_GRAYED; } else if( strlen( uiPlayDemo.demoName[uiPlayDemo.demosList.curItem] )) { char cmd[128]; sprintf( cmd, "playdemo \"%s\"\n", uiPlayDemo.demoName[uiPlayDemo.demosList.curItem] ); CLIENT_COMMAND( FALSE, cmd ); } break; case ID_NO: case ID_DELETE: UI_DeleteDialog(); break; case ID_YES: if( strlen( uiPlayDemo.delName[uiPlayDemo.demosList.curItem] )) { char cmd[128]; sprintf( cmd, "killdemo \"%s\"\n", uiPlayDemo.delName[uiPlayDemo.demosList.curItem] ); CLIENT_COMMAND( TRUE, cmd ); sprintf( cmd, "demos/%s.bmp", uiPlayDemo.delName[uiPlayDemo.demosList.curItem] ); PIC_Free( cmd ); // restarts the menu UI_PopMenu(); UI_PlayDemo_Menu(); return; } UI_DeleteDialog(); break; } }
/* ================= UI_RecDemo_Callback ================= */ static void UI_RecDemo_Callback( void *self, int event ) { menuCommon_s *item = (menuCommon_s *)self; if( event == QM_CHANGED ) { // never overwrite existing saves, because their names was never get collision if( strlen( uiRecDemo.demoName[uiRecDemo.demosList.curItem] ) == 0 || !CL_IsActive() || gpGlobals->demoplayback ) uiRecDemo.record.generic.flags |= QMF_GRAYED; else uiRecDemo.record.generic.flags &= ~QMF_GRAYED; if( strlen( uiRecDemo.delName[uiRecDemo.demosList.curItem] ) == 0 || !stricmp( gpGlobals->demoname, uiRecDemo.delName[uiRecDemo.demosList.curItem] )) uiRecDemo.remove.generic.flags |= QMF_GRAYED; else uiRecDemo.remove.generic.flags &= ~QMF_GRAYED; return; } if( event != QM_ACTIVATED ) return; switch( item->id ) { case ID_CANCEL: UI_PopMenu(); break; case ID_RECORD: if( gpGlobals->demorecording ) { CLIENT_COMMAND( FALSE, "stop" ); uiRecDemo.record.generic.name = "Record"; uiRecDemo.record.generic.statusText = "Record a new demo"; uiRecDemo.remove.generic.flags &= ~QMF_GRAYED; } else if( strlen( uiRecDemo.demoName[uiRecDemo.demosList.curItem] )) { char cmd[128]; sprintf( cmd, "demos/%s.bmp", uiRecDemo.demoName[uiRecDemo.demosList.curItem] ); PIC_Free( cmd ); sprintf( cmd, "record \"%s\"\n", uiRecDemo.demoName[uiRecDemo.demosList.curItem] ); CLIENT_COMMAND( FALSE, cmd ); UI_CloseMenu(); } break; case ID_NO: case ID_DELETE: UI_DeleteDialog(); break; case ID_YES: if( strlen( uiRecDemo.delName[uiRecDemo.demosList.curItem] )) { char cmd[128]; sprintf( cmd, "killdemo \"%s\"\n", uiRecDemo.delName[uiRecDemo.demosList.curItem] ); CLIENT_COMMAND( TRUE, cmd ); sprintf( cmd, "demos/%s.bmp", uiRecDemo.delName[uiRecDemo.demosList.curItem] ); PIC_Free( cmd ); // restarts the menu UI_PopMenu(); UI_RecDemo_Menu(); return; } UI_DeleteDialog(); break; } }
/* ================= UI_SaveGame_Callback ================= */ static void UI_SaveGame_Callback( void *self, int event ) { menuCommon_s *item = (menuCommon_s *)self; if( event == QM_CHANGED ) { // never overwrite existing saves, because their names was never get collision if ( strlen( uiSaveGame.saveName[uiSaveGame.savesList.curItem] ) == 0 || CL_IsActive() == FALSE ) uiSaveGame.save.generic.flags |= QMF_GRAYED; else uiSaveGame.save.generic.flags &= ~QMF_GRAYED; if ( strlen( uiSaveGame.delName[uiSaveGame.savesList.curItem] ) == 0 ) uiSaveGame.remove.generic.flags |= QMF_GRAYED; else uiSaveGame.remove.generic.flags &= ~QMF_GRAYED; return; } if( event != QM_ACTIVATED ) return; switch( item->id ) { case ID_CANCEL: UI_PopMenu(); break; case ID_SAVE: if( strlen( uiSaveGame.saveName[uiSaveGame.savesList.curItem] )) { char cmd[128]; sprintf( cmd, "save/%s.bmp", uiSaveGame.saveName[uiSaveGame.savesList.curItem] ); PIC_Free( cmd ); sprintf( cmd, "save \"%s\"\n", uiSaveGame.saveName[uiSaveGame.savesList.curItem] ); CLIENT_COMMAND( FALSE, cmd ); UI_CloseMenu(); } break; case ID_NO: case ID_DELETE: UI_DeleteDialog(); break; case ID_YES: if( strlen( uiSaveGame.delName[uiSaveGame.savesList.curItem] )) { char cmd[128]; sprintf( cmd, "killsave \"%s\"\n", uiSaveGame.delName[uiSaveGame.savesList.curItem] ); CLIENT_COMMAND( TRUE, cmd ); sprintf( cmd, "save/%s.bmp", uiSaveGame.delName[uiSaveGame.savesList.curItem] ); PIC_Free( cmd ); // restarts the menu UI_PopMenu(); UI_SaveGame_Menu(); return; } UI_DeleteDialog(); break; } }
/* ================= UI_PlayerSetup_UpdateConfig ================= */ static void UI_PlayerSetup_UpdateConfig( void ) { char path[256], name[256]; char newImage[256]; int topColor, bottomColor; // see if the model has changed if( stricmp( uiPlayerSetup.currentModel, uiPlayerSetup.models[(int)uiPlayerSetup.model.curValue] )) { strcpy( uiPlayerSetup.currentModel, uiPlayerSetup.models[(int)uiPlayerSetup.model.curValue] ); } uiPlayerSetup.model.generic.name = uiPlayerSetup.models[(int)uiPlayerSetup.model.curValue]; strcpy( name, uiPlayerSetup.models[(int)uiPlayerSetup.model.curValue] ); if( !stricmp( name, "player" )) { strcpy( path, "models/player.mdl" ); newImage[0] = '\0'; } else { sprintf( path, "models/player/%s/%s.mdl", name, name ); sprintf( newImage, "models/player/%s/%s.bmp", name, name ); } topColor = (int)(uiPlayerSetup.topColor.curValue * 255 ); bottomColor = (int)(uiPlayerSetup.bottomColor.curValue * 255 ); CVAR_SET_STRING( "model", uiPlayerSetup.currentModel ); CVAR_SET_FLOAT( "cl_himodels", uiPlayerSetup.hiModels.enabled ); CVAR_SET_FLOAT( "ui_showmodels", uiPlayerSetup.showModels.enabled ); CVAR_SET_FLOAT( "topcolor", topColor ); CVAR_SET_FLOAT( "bottomcolor", bottomColor ); // IMPORTANT: always set default model becuase we need to have something valid here // if you wish draw your playermodel as normal studiomodel please change "models/player.mdl" to path if( uiPlayerSetup.ent ) ENGINE_SET_MODEL( uiPlayerSetup.ent, "models/player.mdl" ); if( !ui_showmodels->value ) { if( stricmp( lastImage, newImage )) { if( lastImage[0] && playerImage ) { // release old image PIC_Free( lastImage ); lastImage[0] = '\0'; playerImage = 0; } if( stricmp( name, "player" )) { sprintf( lastImage, "models/player/%s/%s.bmp", name, name ); playerImage = PIC_Load( lastImage, PIC_KEEP_8BIT ); // if present of course } else if( lastImage[0] && playerImage ) { // release old image PIC_Free( lastImage ); lastImage[0] = '\0'; playerImage = 0; } } if( playerImage != 0 ) // update remap colors PIC_Remap( playerImage, topColor, bottomColor ); } }