/* =========================================================================== Copyright (C) 1999-2005 Id Software, Inc. Copyright (C) 2002-2021 Q3Rally Team (Per Thormann - q3rally@gmail.com) This file is part of q3rally source code. q3rally source code is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. q3rally source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with q3rally; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ // #include "ui_local.h" // STONELANCE /* #define ART_FRAMEL "menu/art/frame2_l" #define ART_FRAMER "menu/art/frame1_r" #define ART_MODEL0 "menu/art/model_0" #define ART_MODEL1 "menu/art/model_1" #define ART_BACK0 "menu/art/back_0" #define ART_BACK1 "menu/art/back_1" */ #define ART_SELECT "menu/art/menu_select" #define ART_SELECTED "menu/art/menu_selected" #define ART_PORT "menu/art/menu_port" #define ART_LEFT0 "menu/art/arrow_l0" #define ART_LEFT1 "menu/art/arrow_l1" #define ART_RIGHT0 "menu/art/arrow_r0" #define ART_RIGHT1 "menu/art/arrow_r1" // END #define ART_FX_BASE "menu/art/fx_base" #define ART_FX_BLUE "menu/art/fx_blue" #define ART_FX_CYAN "menu/art/fx_cyan" #define ART_FX_GREEN "menu/art/fx_grn" #define ART_FX_RED "menu/art/fx_red" #define ART_FX_TEAL "menu/art/fx_teal" #define ART_FX_WHITE "menu/art/fx_white" #define ART_FX_YELLOW "menu/art/fx_yel" #define ID_NAME 10 #define ID_HANDICAP 11 #define ID_EFFECTS 12 #define ID_BACK 13 // STONELANCE // #define ID_MODEL 14 #define ID_CUSTOMIZE 14 #define ID_FAVORITE1 15 #define ID_FAVORITE2 16 #define ID_FAVORITE3 17 #define ID_FAVORITE4 18 #define ID_LEFT 19 #define ID_RIGHT 20 #define ID_PLATE 21 // END #define MAX_NAMELENGTH 20 // STONELANCE #define NUM_FAVORITES 4 #define MAX_PLAYERMODELS 256 // END typedef struct { menuframework_s menu; menutext_s banner; // STONELANCE /* menubitmap_s framel; menubitmap_s framer; */ // END menubitmap_s player; menufield_s name; menulist_s handicap; menulist_s effects; // STONELANCE // menubitmap_s back; menutext_s back; menutext_s customize; menutext_s plate; menubitmap_s left; menutext_s modelname; menubitmap_s right; menutext_s favorites; menubitmap_s favpics[NUM_FAVORITES]; menubitmap_s favpicbuttons[NUM_FAVORITES]; menubitmap_s ports[NUM_FAVORITES]; char modelList[MAX_PLAYERMODELS][MAX_QPATH]; int selectedModel; int numModels; int allModels; char modelskin[MAX_QPATH]; char rimskin[MAX_QPATH]; char headskin[MAX_QPATH]; char favIcons[NUM_FAVORITES][MAX_QPATH]; qboolean modelChanged; // END qhandle_t fxBasePic; qhandle_t fxPic[7]; playerInfo_t playerinfo; int current_fx; char playerModel[MAX_QPATH]; } playersettings_t; static playersettings_t s_playersettings; static int gamecodetoui[] = {4,2,3,0,5,1,6}; static int uitogamecode[] = {4,6,2,3,1,5,7}; static const char *handicap_items[] = { "None", "95", "90", "85", "80", "75", "70", "65", "60", "55", "50", "45", "40", "35", "30", "25", "20", "15", "10", "5", 0 }; /* ================= PlayerSettings_DrawName ================= */ static void PlayerSettings_DrawName( void *self ) { menufield_s *f; qboolean focus; int style; char *txt; char c; float *color; int n; int basex, x, y; // STONELANCE // char name[32]; // END f = (menufield_s*)self; basex = f->generic.x; y = f->generic.y; focus = (f->generic.parent->cursor == f->generic.menuPosition); style = UI_LEFT|UI_SMALLFONT; // STONELANCE /* color = text_color_normal; if( focus ) { style |= UI_PULSE; color = text_color_highlight; } UI_DrawProportionalString( basex, y, "Name", style, color ); */ color = uis.text_color; if( focus ) { style |= UI_PULSE; color = text_color_highlight; } UI_DrawProportionalString( basex + 16, y, "Name", style, color ); // END // draw the actual name basex += 64; // STONELANCE // y += PROP_HEIGHT; y += 18; // END txt = f->field.buffer; // STONELANCE // color = g_color_table[ColorIndex(COLOR_WHITE)]; // END x = basex; while ( (c = *txt) != 0 ) { if ( !focus && Q_IsColorString( txt ) ) { n = ColorIndex( *(txt+1) ); if( n == 0 ) { n = 7; } color = g_color_table[n]; txt += 2; continue; } UI_DrawChar( x, y, c, style, color ); txt++; x += SMALLCHAR_WIDTH; } // draw cursor if we have focus if( focus ) { if ( trap_Key_GetOverstrikeMode() ) { c = 11; } else { c = 10; } style &= ~UI_PULSE; style |= UI_BLINK; UI_DrawChar( basex + f->field.cursor * SMALLCHAR_WIDTH, y, c, style, color_white ); } // STONELANCE /* // draw at bottom also using proportional font Q_strncpyz( name, f->field.buffer, sizeof(name) ); Q_CleanStr( name ); UI_DrawProportionalString( 320, 440, name, UI_CENTER|UI_BIGFONT, text_color_normal ); */ // END } /* ================= PlayerSettings_DrawHandicap ================= */ static void PlayerSettings_DrawHandicap( void *self ) { menulist_s *item; qboolean focus; int style; float *color; item = (menulist_s *)self; focus = (item->generic.parent->cursor == item->generic.menuPosition); style = UI_LEFT|UI_SMALLFONT; // STONELANCE /* color = text_color_normal; if( focus ) { style |= UI_PULSE; color = text_color_highlight; } UI_DrawProportionalString( item->generic.x, item->generic.y, "Handicap", style, color ); UI_DrawProportionalString( item->generic.x + 64, item->generic.y + PROP_HEIGHT, handicap_items[item->curvalue], style, color ); */ color = uis.text_color; if( focus && !(uis.transitionIn || uis.transitionOut)) { style |= UI_PULSE; color = text_color_highlight; } UI_DrawProportionalString( item->generic.x + 16, item->generic.y, "Handicap", style, color ); UI_DrawString( item->generic.x + 64, item->generic.y + 18, handicap_items[item->curvalue], style, color ); // END } /* ================= PlayerSettings_DrawEffects ================= */ static void PlayerSettings_DrawEffects( void *self ) { menulist_s *item; qboolean focus; int style; float *color; item = (menulist_s *)self; focus = (item->generic.parent->cursor == item->generic.menuPosition); style = UI_LEFT|UI_SMALLFONT; // STONELANCE /* color = text_color_normal; if( focus ) { style |= UI_PULSE; color = text_color_highlight; } UI_DrawProportionalString( item->generic.x, item->generic.y, "Effects", style, color ); UI_DrawHandlePic( item->generic.x + 64, item->generic.y + PROP_HEIGHT + 8, 128, 8, s_playersettings.fxBasePic ); UI_DrawHandlePic( item->generic.x + 64 + item->curvalue * 16 + 8, item->generic.y + PROP_HEIGHT + 6, 16, 12, s_playersettings.fxPic[item->curvalue] ); */ color = uis.text_color; if( focus && !(uis.transitionIn || uis.transitionOut)) { style |= UI_PULSE; color = text_color_highlight; } UI_DrawProportionalString( item->generic.x + 16, item->generic.y, "Effects", style, color ); UI_DrawHandlePic( item->generic.x + 18, item->generic.y + 20, 128, 16, s_playersettings.fxBasePic ); UI_DrawHandlePic( item->generic.x + 23 + item->curvalue * 17, item->generic.y + 20, 16, 16, s_playersettings.fxPic[item->curvalue] ); // END } // STONELANCE /* ================= PlayerSettings_DrawCustomize ================= */ static void PlayerSettings_DrawCustomize( void *self ) { menulist_s *item; qboolean focus; int style; float *color; item = (menulist_s *)self; focus = (item->generic.parent->cursor == item->generic.menuPosition); style = UI_RIGHT | UI_SMALLFONT; color = uis.text_color; if( focus && !(uis.transitionIn || uis.transitionOut)) { style |= UI_PULSE; color = text_color_highlight; } UI_DrawProportionalString( item->generic.x, item->generic.y, "CUSTOMIZE", style, color ); UI_DrawProportionalString( item->generic.x, item->generic.y + 20, "THIS CAR >", style, color ); } /* ================= PlayerSettings_DrawBackShaders ================= */ static void PlayerSettings_DrawBackShaders( void ) { vec4_t color; Vector4Copy(menu_back_color, color); color[3] *= uis.tFrac; UI_FillRect( 24, 80, 592, 48, color); UI_FillRect( 124, 138, 392, 32, menu_back_color); Menu_Draw( &s_playersettings.menu ); } /* ================= PlayerSettings_UpdateModel ================= */ static void PlayerSettings_UpdateModel( void ) { vec3_t viewangles; vec3_t moveangles; char plate[MAX_QPATH]; memset( &s_playersettings.playerinfo, 0, sizeof(playerInfo_t) ); VectorClear( viewangles ); VectorClear( moveangles ); trap_Cvar_VariableStringBuffer( "plate", plate, sizeof( plate ) ); UI_PlayerInfo_SetModel( &s_playersettings.playerinfo, s_playersettings.modelskin, s_playersettings.rimskin, s_playersettings.headskin, plate); UI_PlayerInfo_SetInfo( &s_playersettings.playerinfo, LEGS_IDLE, TORSO_STAND, viewangles, moveangles, WP_NONE, qfalse ); } // END /* ================= PlayerSettings_DrawPlayer ================= */ static void PlayerSettings_DrawPlayer( void *self ) { menubitmap_s *b; // STONELANCE /* vec3_t viewangles; char buf[MAX_QPATH]; trap_Cvar_VariableStringBuffer( "model", buf, sizeof( buf ) ); if ( strcmp( buf, s_playersettings.playerModel ) != 0 ) { UI_PlayerInfo_SetModel( &s_playersettings.playerinfo, buf ); strcpy( s_playersettings.playerModel, buf ); viewangles[YAW] = 180 - 30; viewangles[PITCH] = 0; viewangles[ROLL] = 0; UI_PlayerInfo_SetInfo( &s_playersettings.playerinfo, LEGS_IDLE, TORSO_STAND, viewangles, vec3_origin, WP_MACHINEGUN, qfalse ); } */ // END b = (menubitmap_s*) self; UI_DrawPlayer( b->generic.x, b->generic.y, b->width, b->height, &s_playersettings.playerinfo, uis.realtime ); } // STONELANCE (new function) /* ================= LoadFavorite ================= */ static void LoadFavorite( const char *favorite ) { char modelName[MAX_QPATH]; char skinName[MAX_QPATH]; char rimName[MAX_QPATH]; char headName[MAX_QPATH]; int i; qboolean carFound; GetValuesFromFavorite(favorite, modelName, skinName, rimName, headName); // find model in our list carFound = qfalse; for (i = 0; i < s_playersettings.allModels; i++) { if (!Q_stricmp( modelName, s_playersettings.modelList[i] )) { // found pic, set selection here s_playersettings.selectedModel = i; s_playersettings.modelname.string = s_playersettings.modelList[s_playersettings.selectedModel]; carFound = qtrue; break; } } if (!carFound){ s_playersettings.selectedModel = 0; // get model Com_sprintf(s_playersettings.modelskin, sizeof(s_playersettings.modelskin), "%s/%s", s_playersettings.modelList[s_playersettings.selectedModel], DEFAULT_SKIN); s_playersettings.modelname.string = s_playersettings.modelList[s_playersettings.selectedModel]; // FIXME: check to see if these exist Q_strncpyz(s_playersettings.rimskin, DEFAULT_RIM, sizeof(s_playersettings.rimskin)); Q_strncpyz(s_playersettings.headskin, DEFAULT_HEAD, sizeof(s_playersettings.headskin)); s_playersettings.modelChanged = qtrue; } else { Com_sprintf(s_playersettings.modelskin, sizeof(s_playersettings.modelskin), "%s/%s", modelName, skinName); Q_strncpyz(s_playersettings.rimskin, rimName, sizeof(s_playersettings.rimskin)); Q_strncpyz(s_playersettings.headskin, headName, sizeof(s_playersettings.headskin)); trap_Cvar_Set( "model", s_playersettings.modelskin ); trap_Cvar_Set( "rim", rimName ); trap_Cvar_Set( "head", headName ); s_playersettings.modelChanged = qtrue; } } /* ================= PlayerSettings_UpdateFavorites ================= */ static void PlayerSettings_UpdateFavorites( void ) { int i; char buf[MAX_QPATH]; char modelName[MAX_QPATH]; char skinName[MAX_QPATH]; qboolean error; for (i=0; i < NUM_FAVORITES; i++){ Com_sprintf(buf, sizeof(buf), "favoritecar%i", (i+1)); error = GetValuesFromFavorite(buf, modelName, skinName, NULL, NULL); if (!error){ Com_sprintf(s_playersettings.favIcons[i], sizeof(s_playersettings.favIcons[i]), "models/players/%s/icon_%s", modelName, skinName); s_playersettings.favpics[i].generic.name = s_playersettings.favIcons[i]; s_playersettings.favpicbuttons[i].generic.flags &= ~QMF_INACTIVE; } else{ s_playersettings.favpics[i].generic.name = NULL; s_playersettings.favpicbuttons[i].generic.flags |= QMF_INACTIVE; } s_playersettings.favpics[i].shader = 0; } } /* ================= PlayerSettings_Update ================= */ void PlayerSettings_Update( void ){ trap_Cvar_VariableStringBuffer( "rim", s_playersettings.rimskin, sizeof( s_playersettings.rimskin ) ); trap_Cvar_VariableStringBuffer( "head", s_playersettings.headskin, sizeof( s_playersettings.headskin ) ); trap_Cvar_VariableStringBuffer( "model", s_playersettings.modelskin, sizeof( s_playersettings.modelskin ) ); PlayerSettings_UpdateFavorites(); PlayerSettings_UpdateModel(); } // END /* ================= PlayerSettings_SaveChanges ================= */ static void PlayerSettings_SaveChanges( void ) { // name trap_Cvar_Set( "name", s_playersettings.name.field.buffer ); // STONELANCE if (s_playersettings.modelChanged){ trap_Cvar_Set( "model", s_playersettings.modelskin ); } // END // handicap trap_Cvar_SetValue( "handicap", 100 - s_playersettings.handicap.curvalue * 5 ); // effects color trap_Cvar_SetValue( "color1", uitogamecode[s_playersettings.effects.curvalue] ); } /* ================= PlayerSettings_MenuKey ================= */ static sfxHandle_t PlayerSettings_MenuKey( int key ) { if( key == K_MOUSE2 || key == K_ESCAPE ) { // STONELANCE // PlayerSettings_SaveChanges(); s_playersettings.menu.transitionMenu = ID_BACK; uis.transitionOut = uis.realtime; return 0; // END } return Menu_DefaultKey( &s_playersettings.menu, key ); } /* ================= PlayerSettings_SetMenuItems ================= */ static void PlayerSettings_SetMenuItems( void ) { // vec3_t viewangles; int c; int h; // STONELANCE int i; char modelName[MAX_QPATH]; char *slash; qboolean carFound; trap_Cvar_VariableStringBuffer( "rim", s_playersettings.rimskin, sizeof( s_playersettings.rimskin ) ); trap_Cvar_VariableStringBuffer( "head", s_playersettings.headskin, sizeof( s_playersettings.headskin ) ); trap_Cvar_VariableStringBuffer( "model", s_playersettings.modelskin, sizeof( s_playersettings.modelskin ) ); // END // name Q_strncpyz( s_playersettings.name.field.buffer, UI_Cvar_VariableString("name"), sizeof(s_playersettings.name.field.buffer) ); // effects color c = trap_Cvar_VariableValue( "color1" ) - 1; if( c < 0 || c > 6 ) { c = 6; } s_playersettings.effects.curvalue = gamecodetoui[c]; // model/skin memset( &s_playersettings.playerinfo, 0, sizeof(playerInfo_t) ); /* viewangles[YAW] = 180 - 30; viewangles[PITCH] = 0; viewangles[ROLL] = 0; */ // STONELANCE Q_strncpyz( modelName, s_playersettings.modelskin, sizeof( modelName ) ); slash = strchr( modelName, '/' ); if ( slash ) { *slash = 0; } s_playersettings.modelChanged = qfalse; // find model in our list carFound = qfalse; for (i = 0; i < s_playersettings.allModels; i++) { if (!Q_stricmp( modelName, s_playersettings.modelList[i] )){ // found pic, set selection here s_playersettings.selectedModel = i; s_playersettings.modelname.string = s_playersettings.modelList[s_playersettings.selectedModel]; carFound = qtrue; break; } } if (!carFound){ s_playersettings.selectedModel = 0; // get model Com_sprintf( s_playersettings.modelskin, sizeof(s_playersettings.modelskin), "%s/%s", s_playersettings.modelList[s_playersettings.selectedModel], DEFAULT_SKIN); s_playersettings.modelname.string = s_playersettings.modelList[s_playersettings.selectedModel]; s_playersettings.modelChanged = qtrue; } /* UI_PlayerInfo_SetModel( &s_playersettings.playerinfo, UI_Cvar_VariableString( "model" ) ); UI_PlayerInfo_SetInfo( &s_playersettings.playerinfo, LEGS_IDLE, TORSO_STAND, viewangles, vec3_origin, WP_MACHINEGUN, qfalse ); */ PlayerSettings_UpdateModel(); PlayerSettings_UpdateFavorites(); // END // handicap h = Com_Clamp( 5, 100, trap_Cvar_VariableValue("handicap") ); s_playersettings.handicap.curvalue = 20 - h / 5; } // STONELANCE /* ================= PlayerSettings_PicEvent ================= */ static void PlayerSettings_PicEvent( void* ptr, int event ) { if (event != QM_ACTIVATED) return; switch(((menucommon_s*)ptr)->id){ case ID_FAVORITE1: LoadFavorite("favoritecar1"); break; case ID_FAVORITE2: LoadFavorite("favoritecar2"); break; case ID_FAVORITE3: LoadFavorite("favoritecar3"); break; case ID_FAVORITE4: LoadFavorite("favoritecar4"); break; } PlayerSettings_UpdateModel(); } // END /* ================= PlayerSettings_MenuEvent ================= */ static void PlayerSettings_MenuEvent( void* ptr, int event ) { if( event != QM_ACTIVATED ) { return; } switch( ((menucommon_s*)ptr)->id ) { case ID_HANDICAP: trap_Cvar_Set( "handicap", va( "%i", 100 - 25 * s_playersettings.handicap.curvalue ) ); break; // STONELANCE /* case ID_MODEL: PlayerSettings_SaveChanges(); UI_PlayerModelMenu(); break; case ID_BACK: PlayerSettings_SaveChanges(); UI_PopMenu(); break; */ case ID_CUSTOMIZE: case ID_BACK: s_playersettings.menu.transitionMenu = ((menucommon_s*)ptr)->id; uis.transitionOut = uis.realtime; break; case ID_PLATE: UI_PlateSelectionMenu(); break; case ID_LEFT: //Com_Printf("Clicked car selection LEFT\n"); if (s_playersettings.selectedModel > 0) { s_playersettings.selectedModel--; //Com_Printf("PS: Car selected, %i\n", s_playersettings.selectedmodel); // get model Com_sprintf(s_playersettings.modelskin, sizeof(s_playersettings.modelskin), "%s/%s", s_playersettings.modelList[s_playersettings.selectedModel], DEFAULT_SKIN); //Com_Printf("PS: modelskin set to: %s\n", s_playersettings.modelskin); s_playersettings.modelname.string = s_playersettings.modelList[s_playersettings.selectedModel]; //Com_Printf("PS: modelname set to: %s\n", s_playersettings.modelname.string); s_playersettings.modelChanged = qtrue; PlayerSettings_UpdateModel(); } break; case ID_RIGHT: //Com_Printf("Clicked car selection RIGHT\n"); if (s_playersettings.selectedModel < s_playersettings.numModels - 1 ) { s_playersettings.selectedModel++; //Com_Printf("PS: Car selected, %i\n", s_playersettings.selectedmodel); // get model Com_sprintf(s_playersettings.modelskin, sizeof(s_playersettings.modelskin), "%s/%s", s_playersettings.modelList[s_playersettings.selectedModel], DEFAULT_SKIN); //Com_Printf("PS: modelskin set to: %s\n", s_playersettings.modelskin); s_playersettings.modelname.string = s_playersettings.modelList[s_playersettings.selectedModel]; //Com_Printf("PS: modelname set to: %s\n", s_playersettings.modelname.string); s_playersettings.modelChanged = qtrue; PlayerSettings_UpdateModel(); } break; // END } } // STONELANCE /* ================= PlayerSettigns_ChangeMenu ================= */ void PlayerSettigns_ChangeMenu( int menuID ){ switch(menuID){ case ID_CUSTOMIZE: PlayerSettings_SaveChanges(); s_playersettings.modelChanged = qfalse; UI_PlayerModelMenu( s_playersettings.modelname.string ); break; case ID_BACK: PlayerSettings_SaveChanges(); s_playersettings.modelChanged = qfalse; // uis.transitionIn = uis.realtime; UI_PopMenu(); break; } } /* ================= PlayerSettings_RunTransition ================= */ void PlayerSettings_RunTransition(float frac){ int i, y; uis.text_color[0] = text_color_normal[0]; uis.text_color[1] = text_color_normal[1]; uis.text_color[2] = text_color_normal[2]; uis.text_color[3] = text_color_normal[3] * frac; s_playersettings.banner.color = uis.text_color; s_playersettings.customize.color = uis.text_color; s_playersettings.favorites.color = uis.text_color; s_playersettings.modelname.color = uis.text_color; s_playersettings.plate.color = uis.text_color; if (s_playersettings.menu.transitionMenu != ID_CUSTOMIZE){ y = 403 + (int)(77 * (1 - frac)); for (i=0; iid; if( event != QM_ACTIVATED && id != ID_LIST ) { return; } switch( id ) { case ID_LIST: // update plateSkin Q_strncpyz( s_plateSelection.plateSkin, s_plateSelection.plateList[s_plateSelection.list.curvalue], sizeof(s_plateSelection.plateSkin) ); break; case ID_CANCEL: UI_PopMenu(); uis.transitionIn = 0; break; case ID_ACCEPT: trap_Cvar_Set( "plate", s_plateSelection.plateSkin ); PlayerSettings_UpdateModel(); UI_PopMenu(); uis.transitionIn = 0; break; } } /* ================= PlateSelection_DrawMenu ================= */ static void PlateSelection_DrawMenu( void ) { refdef_t refdef; refEntity_t ent; vec3_t origin; vec3_t angles; float x, y, w, h; // setup the refdef memset( &refdef, 0, sizeof( refdef ) ); refdef.rdflags = RDF_NOWORLDMODEL; AxisClear( refdef.viewaxis ); x = 150; y = 115; w = 328; h = 232; UI_AdjustFrom640( &x, &y, &w, &h ); refdef.x = x; refdef.y = y; refdef.width = w; refdef.height = h; refdef.fov_x = 180; refdef.fov_y = 180; refdef.time = uis.realtime; origin[0] = 300; origin[1] = 0; origin[2] = 0; trap_R_ClearScene(); // draw license plate with selected skin memset( &ent, 0, sizeof(ent) ); VectorSet( angles, 45, 45, 45 ); AnglesToAxis( angles, ent.axis ); if (strstr(s_plateSelection.plateSkin, "usa_")) ent.hModel = trap_R_RegisterModel("models/players/plates/plate_usa.md3"); else ent.hModel = trap_R_RegisterModel("models/players/plates/plate_eu.md3"); ent.customShader = trap_R_RegisterShaderNoMip( va("models/players/plates/%s", s_plateSelection.plateSkin) ); VectorCopy( origin, ent.origin ); VectorCopy( origin, ent.lightingOrigin ); ent.renderfx = RF_LIGHTING_ORIGIN | RF_NOSHADOW; VectorCopy( ent.origin, ent.oldorigin ); trap_R_AddRefEntityToScene( &ent ); trap_R_RenderScene( &refdef ); /* qhandle_t plate; plate = trap_R_RegisterShaderNoMip( va("models/players/plates/%s", s_plateSelection.plateSkin) ); if (strstr(s_plateSelection.plateSkin, "usa_")) UI_DrawHandlePic(250+32, 215, 64, 32, plate); else UI_DrawHandlePic(250, 215, 128, 32, plate); */ Menu_Draw( &s_plateSelection.menu ); } /* ================= PlateSelection_SetMenuItems ================= */ static void PlateSelection_SetMenuItems( void ) { int i; trap_Cvar_VariableStringBuffer( "plate", s_plateSelection.plateSkin, sizeof( s_plateSelection.plateSkin ) ); if (!s_plateSelection.numPlates) return; // find model in our list for (i = 0; i < s_plateSelection.numPlates; i++) { if (!Q_stricmp( s_plateSelection.plateSkin, s_plateSelection.plateList[i] )){ // found pic, set selection here s_plateSelection.list.curvalue = i; if (s_plateSelection.list.top + s_plateSelection.list.height > s_plateSelection.numPlates) s_plateSelection.list.top = s_plateSelection.numPlates - s_plateSelection.list.height; if (s_plateSelection.list.top < 0) s_plateSelection.list.top = 0; else s_plateSelection.list.top = i; return; } } s_plateSelection.list.curvalue = 0; s_plateSelection.list.top = 0; Q_strncpyz(s_plateSelection.plateSkin, s_plateSelection.plateList[0], sizeof(s_plateSelection.plateSkin)); } /* ================= PlateSelection_Cache ================= */ void PlateSelection_Cache( void ) { // get car list s_plateSelection.numPlates = UI_BuildFileList("models/players/plates", "tga", "*usa_", qtrue, qfalse, qtrue, 0, s_plateSelection.plateList); s_plateSelection.numPlates = UI_BuildFileList("models/players/plates", "tga", "*eu_", qtrue, qfalse, qtrue, s_plateSelection.numPlates, s_plateSelection.plateList); } /* ================= PlateSelection_MenuInit ================= */ static void PlateSelection_MenuInit( void ) { int i; memset(&s_plateSelection, 0, sizeof(plateSelection_t)); PlateSelection_Cache(); s_plateSelection.menu.wrapAround = qtrue; s_plateSelection.menu.transparent = qtrue; s_plateSelection.menu.fullscreen = qtrue; s_plateSelection.menu.draw = PlateSelection_DrawMenu; s_plateSelection.list.generic.type = MTYPE_LISTBOX; s_plateSelection.list.scrollbarAlignment = SB_RIGHT; s_plateSelection.list.generic.flags = QMF_LEFT_JUSTIFY|QMF_HIGHLIGHT_IF_FOCUS; s_plateSelection.list.generic.id = ID_LIST; s_plateSelection.list.generic.callback = PlateSelection_Event; s_plateSelection.list.generic.x = 50; s_plateSelection.list.generic.y = 175; s_plateSelection.list.width = 25; s_plateSelection.list.height = 11; s_plateSelection.list.itemnames = (const char **)s_plateSelection.items; s_plateSelection.list.numitems = s_plateSelection.numPlates; for( i = 0; i < MAX_PLATEMODELS; i++ ) { s_plateSelection.items[i] = s_plateSelection.plateList[i]; } s_plateSelection.cancel.generic.type = MTYPE_PTEXT; s_plateSelection.cancel.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS; s_plateSelection.cancel.generic.x = 250; s_plateSelection.cancel.generic.y = 350; s_plateSelection.cancel.generic.id = ID_CANCEL; s_plateSelection.cancel.generic.callback = PlateSelection_Event; s_plateSelection.cancel.string = "Cancel"; s_plateSelection.cancel.color = text_color_normal; s_plateSelection.cancel.style = UI_LEFT | UI_SMALLFONT; s_plateSelection.accept.generic.type = MTYPE_PTEXT; s_plateSelection.accept.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS; s_plateSelection.accept.generic.x = 350; s_plateSelection.accept.generic.y = 350; s_plateSelection.accept.generic.id = ID_ACCEPT; s_plateSelection.accept.generic.callback = PlateSelection_Event; s_plateSelection.accept.string = "Accept"; s_plateSelection.accept.color = text_color_normal; s_plateSelection.accept.style = UI_LEFT | UI_SMALLFONT; Menu_AddItem( &s_plateSelection.menu, &s_plateSelection.list ); Menu_AddItem( &s_plateSelection.menu, &s_plateSelection.cancel ); Menu_AddItem( &s_plateSelection.menu, &s_plateSelection.accept ); PlateSelection_SetMenuItems(); } /* ================= UI_PlateSelectionMenu ================= */ void UI_PlateSelectionMenu( void ) { PlateSelection_MenuInit(); UI_PushMenu( &s_plateSelection.menu ); } // END