| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
#include "ui_local.h" |
| 35 |
|
| 36 |
uiInfo_t uiInfo; |
| 37 |
|
| 38 |
static const char *MonthAbbrev[] = { |
| 39 |
"Jan","Feb","Mar", |
| 40 |
"Apr","May","Jun", |
| 41 |
"Jul","Aug","Sep", |
| 42 |
"Oct","Nov","Dec" |
| 43 |
}; |
| 44 |
|
| 45 |
|
| 46 |
static const char *skillLevels[] = { |
| 47 |
"I Can Win", |
| 48 |
"Bring It On", |
| 49 |
"Hurt Me Plenty", |
| 50 |
"Hardcore", |
| 51 |
"Nightmare" |
| 52 |
}; |
| 53 |
|
| 54 |
static const int numSkillLevels = ARRAY_LEN( skillLevels ); |
| 55 |
|
| 56 |
|
| 57 |
#define UIAS_LOCAL 0 |
| 58 |
#define UIAS_GLOBAL0 1 |
| 59 |
#define UIAS_GLOBAL1 2 |
| 60 |
#define UIAS_GLOBAL2 3 |
| 61 |
#define UIAS_GLOBAL3 4 |
| 62 |
#define UIAS_GLOBAL4 5 |
| 63 |
#define UIAS_GLOBAL5 6 |
| 64 |
#define UIAS_FAVORITES 7 |
| 65 |
|
| 66 |
static const char *netSources[] = { |
| 67 |
"Local", |
| 68 |
"Internet", |
| 69 |
"Master1", |
| 70 |
"Master2", |
| 71 |
"Master3", |
| 72 |
"Master4", |
| 73 |
"Master5", |
| 74 |
"Favorites" |
| 75 |
}; |
| 76 |
static const int numNetSources = ARRAY_LEN( netSources ); |
| 77 |
|
| 78 |
static const serverFilter_t serverFilters[] = { |
| 79 |
{"All", "" }, |
| 80 |
{"Quake 3 Arena", "" }, |
| 81 |
{"Team Arena", BASETA }, |
| 82 |
{"Rocket Arena", "arena" }, |
| 83 |
{"Alliance", "alliance20" }, |
| 84 |
{"Weapons Factory Arena", "wfa" }, |
| 85 |
{"OSP", "osp" }, |
| 86 |
}; |
| 87 |
|
| 88 |
static const int numServerFilters = ARRAY_LEN( serverFilters ); |
| 89 |
|
| 90 |
|
| 91 |
static const char *teamArenaGameTypes[] = { |
| 92 |
"FFA", |
| 93 |
"TOURNAMENT", |
| 94 |
"SP", |
| 95 |
"TEAM DM", |
| 96 |
"CTF", |
| 97 |
"1FCTF", |
| 98 |
"OVERLOAD", |
| 99 |
"HARVESTER" |
| 100 |
}; |
| 101 |
|
| 102 |
static int const numTeamArenaGameTypes = ARRAY_LEN( teamArenaGameTypes ); |
| 103 |
|
| 104 |
|
| 105 |
static char* netnames[] = { |
| 106 |
"???", |
| 107 |
"UDP", |
| 108 |
"UDP6" |
| 109 |
}; |
| 110 |
|
| 111 |
#ifndef MISSIONPACK |
| 112 |
static char quake3worldMessage[] = "Visit www.quake3world.com - News, Community, Events, Files"; |
| 113 |
#endif |
| 114 |
|
| 115 |
static int gamecodetoui[] = {4,2,3,0,5,1,6}; |
| 116 |
static int uitogamecode[] = {4,6,2,3,1,5,7}; |
| 117 |
|
| 118 |
|
| 119 |
static void UI_StartServerRefresh(qboolean full, qboolean force); |
| 120 |
static void UI_StopServerRefresh( void ); |
| 121 |
static void UI_DoServerRefresh( void ); |
| 122 |
static void UI_FeederSelection(float feederID, int index); |
| 123 |
static void UI_BuildServerDisplayList(int force); |
| 124 |
static void UI_BuildServerStatus(qboolean force); |
| 125 |
static void UI_BuildFindPlayerList(qboolean force); |
| 126 |
static int QDECL UI_ServersQsortCompare( const void *arg1, const void *arg2 ); |
| 127 |
static int UI_MapCountByGameType(qboolean singlePlayer); |
| 128 |
static int UI_HeadCountByTeam( void ); |
| 129 |
static void UI_ParseGameInfo(const char *teamFile); |
| 130 |
static void UI_ParseTeamInfo(const char *teamFile); |
| 131 |
static const char *UI_SelectedMap(int index, int *actual); |
| 132 |
static const char *UI_SelectedHead(int index, int *actual); |
| 133 |
static int UI_GetIndexFromSelection(int actual); |
| 134 |
static void UI_DrawCinematic(int handle, float x, float y, float w, float h); |
| 135 |
|
| 136 |
int ProcessNewUI( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6 ); |
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
vmCvar_t ui_new; |
| 147 |
vmCvar_t ui_debug; |
| 148 |
vmCvar_t ui_initialized; |
| 149 |
vmCvar_t ui_teamArenaFirstRun; |
| 150 |
|
| 151 |
void _UI_Init( qboolean ); |
| 152 |
void _UI_Shutdown( void ); |
| 153 |
void _UI_KeyEvent( int key, qboolean down ); |
| 154 |
void _UI_MouseEvent( int dx, int dy ); |
| 155 |
void _UI_Refresh( int realtime ); |
| 156 |
qboolean _UI_IsFullscreen( void ); |
| 157 |
Q_EXPORT intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) { |
| 158 |
switch ( command ) { |
| 159 |
case UI_GETAPIVERSION: |
| 160 |
return UI_API_VERSION; |
| 161 |
|
| 162 |
case UI_INIT: |
| 163 |
_UI_Init(arg0); |
| 164 |
return 0; |
| 165 |
|
| 166 |
case UI_SHUTDOWN: |
| 167 |
_UI_Shutdown(); |
| 168 |
return 0; |
| 169 |
|
| 170 |
case UI_KEY_EVENT: |
| 171 |
_UI_KeyEvent( arg0, arg1 ); |
| 172 |
return 0; |
| 173 |
|
| 174 |
case UI_MOUSE_EVENT: |
| 175 |
_UI_MouseEvent( arg0, arg1 ); |
| 176 |
return 0; |
| 177 |
|
| 178 |
case UI_REFRESH: |
| 179 |
_UI_Refresh( arg0 ); |
| 180 |
return 0; |
| 181 |
|
| 182 |
case UI_IS_FULLSCREEN: |
| 183 |
return _UI_IsFullscreen(); |
| 184 |
|
| 185 |
case UI_SET_ACTIVE_MENU: |
| 186 |
_UI_SetActiveMenu( arg0 ); |
| 187 |
return 0; |
| 188 |
|
| 189 |
case UI_CONSOLE_COMMAND: |
| 190 |
return UI_ConsoleCommand(arg0); |
| 191 |
|
| 192 |
case UI_DRAW_CONNECT_SCREEN: |
| 193 |
UI_DrawConnectScreen( arg0 ); |
| 194 |
return 0; |
| 195 |
case UI_HASUNIQUECDKEY: |
| 196 |
return qtrue; |
| 197 |
|
| 198 |
} |
| 199 |
|
| 200 |
return -1; |
| 201 |
} |
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
void AssetCache( void ) { |
| 206 |
int n; |
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
uiInfo.uiDC.Assets.gradientBar = trap_R_RegisterShaderNoMip( ASSET_GRADIENTBAR ); |
| 212 |
uiInfo.uiDC.Assets.fxBasePic = trap_R_RegisterShaderNoMip( ART_FX_BASE ); |
| 213 |
uiInfo.uiDC.Assets.fxPic[0] = trap_R_RegisterShaderNoMip( ART_FX_RED ); |
| 214 |
uiInfo.uiDC.Assets.fxPic[1] = trap_R_RegisterShaderNoMip( ART_FX_YELLOW ); |
| 215 |
uiInfo.uiDC.Assets.fxPic[2] = trap_R_RegisterShaderNoMip( ART_FX_GREEN ); |
| 216 |
uiInfo.uiDC.Assets.fxPic[3] = trap_R_RegisterShaderNoMip( ART_FX_TEAL ); |
| 217 |
uiInfo.uiDC.Assets.fxPic[4] = trap_R_RegisterShaderNoMip( ART_FX_BLUE ); |
| 218 |
uiInfo.uiDC.Assets.fxPic[5] = trap_R_RegisterShaderNoMip( ART_FX_CYAN ); |
| 219 |
uiInfo.uiDC.Assets.fxPic[6] = trap_R_RegisterShaderNoMip( ART_FX_WHITE ); |
| 220 |
uiInfo.uiDC.Assets.scrollBar = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR ); |
| 221 |
uiInfo.uiDC.Assets.scrollBarArrowDown = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWDOWN ); |
| 222 |
uiInfo.uiDC.Assets.scrollBarArrowUp = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWUP ); |
| 223 |
uiInfo.uiDC.Assets.scrollBarArrowLeft = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWLEFT ); |
| 224 |
uiInfo.uiDC.Assets.scrollBarArrowRight = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWRIGHT ); |
| 225 |
uiInfo.uiDC.Assets.scrollBarThumb = trap_R_RegisterShaderNoMip( ASSET_SCROLL_THUMB ); |
| 226 |
uiInfo.uiDC.Assets.sliderBar = trap_R_RegisterShaderNoMip( ASSET_SLIDER_BAR ); |
| 227 |
uiInfo.uiDC.Assets.sliderThumb = trap_R_RegisterShaderNoMip( ASSET_SLIDER_THUMB ); |
| 228 |
|
| 229 |
for( n = 0; n < NUM_CROSSHAIRS; n++ ) { |
| 230 |
uiInfo.uiDC.Assets.crosshairShader[n] = trap_R_RegisterShaderNoMip( va("gfx/2d/crosshair%c", 'a' + n ) ); |
| 231 |
} |
| 232 |
|
| 233 |
uiInfo.newHighScoreSound = trap_S_RegisterSound("sound/feedback/voc_newhighscore.wav", qfalse); |
| 234 |
} |
| 235 |
|
| 236 |
void _UI_DrawSides(float x, float y, float w, float h, float size) { |
| 237 |
UI_AdjustFrom640( &x, &y, &w, &h ); |
| 238 |
size *= uiInfo.uiDC.xscale; |
| 239 |
trap_R_DrawStretchPic( x, y, size, h, 0, 0, 0, 0, uiInfo.uiDC.whiteShader ); |
| 240 |
trap_R_DrawStretchPic( x + w - size, y, size, h, 0, 0, 0, 0, uiInfo.uiDC.whiteShader ); |
| 241 |
} |
| 242 |
|
| 243 |
void _UI_DrawTopBottom(float x, float y, float w, float h, float size) { |
| 244 |
UI_AdjustFrom640( &x, &y, &w, &h ); |
| 245 |
size *= uiInfo.uiDC.yscale; |
| 246 |
trap_R_DrawStretchPic( x, y, w, size, 0, 0, 0, 0, uiInfo.uiDC.whiteShader ); |
| 247 |
trap_R_DrawStretchPic( x, y + h - size, w, size, 0, 0, 0, 0, uiInfo.uiDC.whiteShader ); |
| 248 |
} |
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
void _UI_DrawRect( float x, float y, float width, float height, float size, const float *color ) { |
| 257 |
trap_R_SetColor( color ); |
| 258 |
|
| 259 |
_UI_DrawTopBottom(x, y, width, height, size); |
| 260 |
_UI_DrawSides(x, y, width, height, size); |
| 261 |
|
| 262 |
trap_R_SetColor( NULL ); |
| 263 |
} |
| 264 |
|
| 265 |
int Text_Width(const char *text, float scale, int limit) { |
| 266 |
int count,len; |
| 267 |
float out; |
| 268 |
glyphInfo_t *glyph; |
| 269 |
float useScale; |
| 270 |
const char *s = text; |
| 271 |
fontInfo_t *font = &uiInfo.uiDC.Assets.textFont; |
| 272 |
if (scale <= ui_smallFont.value) { |
| 273 |
font = &uiInfo.uiDC.Assets.smallFont; |
| 274 |
} else if (scale >= ui_bigFont.value) { |
| 275 |
font = &uiInfo.uiDC.Assets.bigFont; |
| 276 |
} |
| 277 |
useScale = scale * font->glyphScale; |
| 278 |
out = 0; |
| 279 |
if (text) { |
| 280 |
len = strlen(text); |
| 281 |
if (limit > 0 && len > limit) { |
| 282 |
len = limit; |
| 283 |
} |
| 284 |
count = 0; |
| 285 |
while (s && *s && count < len) { |
| 286 |
if ( Q_IsColorString(s) ) { |
| 287 |
s += 2; |
| 288 |
continue; |
| 289 |
} else { |
| 290 |
glyph = &font->glyphs[*s & 255]; |
| 291 |
out += glyph->xSkip; |
| 292 |
s++; |
| 293 |
count++; |
| 294 |
} |
| 295 |
} |
| 296 |
} |
| 297 |
return out * useScale; |
| 298 |
} |
| 299 |
|
| 300 |
int Text_Height(const char *text, float scale, int limit) { |
| 301 |
int len, count; |
| 302 |
float max; |
| 303 |
glyphInfo_t *glyph; |
| 304 |
float useScale; |
| 305 |
const char *s = text; |
| 306 |
fontInfo_t *font = &uiInfo.uiDC.Assets.textFont; |
| 307 |
if (scale <= ui_smallFont.value) { |
| 308 |
font = &uiInfo.uiDC.Assets.smallFont; |
| 309 |
} else if (scale >= ui_bigFont.value) { |
| 310 |
font = &uiInfo.uiDC.Assets.bigFont; |
| 311 |
} |
| 312 |
useScale = scale * font->glyphScale; |
| 313 |
max = 0; |
| 314 |
if (text) { |
| 315 |
len = strlen(text); |
| 316 |
if (limit > 0 && len > limit) { |
| 317 |
len = limit; |
| 318 |
} |
| 319 |
count = 0; |
| 320 |
while (s && *s && count < len) { |
| 321 |
if ( Q_IsColorString(s) ) { |
| 322 |
s += 2; |
| 323 |
continue; |
| 324 |
} else { |
| 325 |
glyph = &font->glyphs[*s & 255]; |
| 326 |
if (max < glyph->height) { |
| 327 |
max = glyph->height; |
| 328 |
} |
| 329 |
s++; |
| 330 |
count++; |
| 331 |
} |
| 332 |
} |
| 333 |
} |
| 334 |
return max * useScale; |
| 335 |
} |
| 336 |
|
| 337 |
void Text_PaintChar(float x, float y, float width, float height, float scale, float s, float t, float s2, float t2, qhandle_t hShader) { |
| 338 |
float w, h; |
| 339 |
w = width * scale; |
| 340 |
h = height * scale; |
| 341 |
UI_AdjustFrom640( &x, &y, &w, &h ); |
| 342 |
trap_R_DrawStretchPic( x, y, w, h, s, t, s2, t2, hShader ); |
| 343 |
} |
| 344 |
|
| 345 |
void Text_Paint(float x, float y, float scale, vec4_t color, const char *text, float adjust, int limit, int style) { |
| 346 |
int len, count; |
| 347 |
vec4_t newColor; |
| 348 |
glyphInfo_t *glyph; |
| 349 |
float useScale; |
| 350 |
fontInfo_t *font = &uiInfo.uiDC.Assets.textFont; |
| 351 |
if (scale <= ui_smallFont.value) { |
| 352 |
font = &uiInfo.uiDC.Assets.smallFont; |
| 353 |
} else if (scale >= ui_bigFont.value) { |
| 354 |
font = &uiInfo.uiDC.Assets.bigFont; |
| 355 |
} |
| 356 |
useScale = scale * font->glyphScale; |
| 357 |
if (text) { |
| 358 |
const char *s = text; |
| 359 |
trap_R_SetColor( color ); |
| 360 |
memcpy(&newColor[0], &color[0], sizeof(vec4_t)); |
| 361 |
len = strlen(text); |
| 362 |
if (limit > 0 && len > limit) { |
| 363 |
len = limit; |
| 364 |
} |
| 365 |
count = 0; |
| 366 |
while (s && *s && count < len) { |
| 367 |
glyph = &font->glyphs[*s & 255]; |
| 368 |
|
| 369 |
|
| 370 |
if ( Q_IsColorString( s ) ) { |
| 371 |
memcpy( newColor, g_color_table[ColorIndex(*(s+1))], sizeof( newColor ) ); |
| 372 |
newColor[3] = color[3]; |
| 373 |
trap_R_SetColor( newColor ); |
| 374 |
s += 2; |
| 375 |
continue; |
| 376 |
} else { |
| 377 |
float yadj = useScale * glyph->top; |
| 378 |
if (style == ITEM_TEXTSTYLE_SHADOWED || style == ITEM_TEXTSTYLE_SHADOWEDMORE) { |
| 379 |
int ofs = style == ITEM_TEXTSTYLE_SHADOWED ? 1 : 2; |
| 380 |
colorBlack[3] = newColor[3]; |
| 381 |
trap_R_SetColor( colorBlack ); |
| 382 |
Text_PaintChar(x + ofs, y - yadj + ofs, |
| 383 |
glyph->imageWidth, |
| 384 |
glyph->imageHeight, |
| 385 |
useScale, |
| 386 |
glyph->s, |
| 387 |
glyph->t, |
| 388 |
glyph->s2, |
| 389 |
glyph->t2, |
| 390 |
glyph->glyph); |
| 391 |
trap_R_SetColor( newColor ); |
| 392 |
colorBlack[3] = 1.0; |
| 393 |
} |
| 394 |
Text_PaintChar(x, y - yadj, |
| 395 |
glyph->imageWidth, |
| 396 |
glyph->imageHeight, |
| 397 |
useScale, |
| 398 |
glyph->s, |
| 399 |
glyph->t, |
| 400 |
glyph->s2, |
| 401 |
glyph->t2, |
| 402 |
glyph->glyph); |
| 403 |
|
| 404 |
x += (glyph->xSkip * useScale) + adjust; |
| 405 |
s++; |
| 406 |
count++; |
| 407 |
} |
| 408 |
} |
| 409 |
trap_R_SetColor( NULL ); |
| 410 |
} |
| 411 |
} |
| 412 |
|
| 413 |
void Text_PaintWithCursor(float x, float y, float scale, vec4_t color, const char *text, int cursorPos, char cursor, int limit, int style) { |
| 414 |
int len, count; |
| 415 |
vec4_t newColor; |
| 416 |
glyphInfo_t *glyph, *glyph2; |
| 417 |
float yadj; |
| 418 |
float useScale; |
| 419 |
fontInfo_t *font = &uiInfo.uiDC.Assets.textFont; |
| 420 |
if (scale <= ui_smallFont.value) { |
| 421 |
font = &uiInfo.uiDC.Assets.smallFont; |
| 422 |
} else if (scale >= ui_bigFont.value) { |
| 423 |
font = &uiInfo.uiDC.Assets.bigFont; |
| 424 |
} |
| 425 |
useScale = scale * font->glyphScale; |
| 426 |
if (text) { |
| 427 |
const char *s = text; |
| 428 |
trap_R_SetColor( color ); |
| 429 |
memcpy(&newColor[0], &color[0], sizeof(vec4_t)); |
| 430 |
len = strlen(text); |
| 431 |
if (limit > 0 && len > limit) { |
| 432 |
len = limit; |
| 433 |
} |
| 434 |
count = 0; |
| 435 |
glyph2 = &font->glyphs[cursor & 255]; |
| 436 |
while (s && *s && count < len) { |
| 437 |
glyph = &font->glyphs[*s & 255]; |
| 438 |
|
| 439 |
|
| 440 |
if ( Q_IsColorString( s ) ) { |
| 441 |
memcpy( newColor, g_color_table[ColorIndex(*(s+1))], sizeof( newColor ) ); |
| 442 |
newColor[3] = color[3]; |
| 443 |
trap_R_SetColor( newColor ); |
| 444 |
s += 2; |
| 445 |
continue; |
| 446 |
} else { |
| 447 |
yadj = useScale * glyph->top; |
| 448 |
if (style == ITEM_TEXTSTYLE_SHADOWED || style == ITEM_TEXTSTYLE_SHADOWEDMORE) { |
| 449 |
int ofs = style == ITEM_TEXTSTYLE_SHADOWED ? 1 : 2; |
| 450 |
colorBlack[3] = newColor[3]; |
| 451 |
trap_R_SetColor( colorBlack ); |
| 452 |
Text_PaintChar(x + ofs, y - yadj + ofs, |
| 453 |
glyph->imageWidth, |
| 454 |
glyph->imageHeight, |
| 455 |
useScale, |
| 456 |
glyph->s, |
| 457 |
glyph->t, |
| 458 |
glyph->s2, |
| 459 |
glyph->t2, |
| 460 |
glyph->glyph); |
| 461 |
colorBlack[3] = 1.0; |
| 462 |
trap_R_SetColor( newColor ); |
| 463 |
} |
| 464 |
Text_PaintChar(x, y - yadj, |
| 465 |
glyph->imageWidth, |
| 466 |
glyph->imageHeight, |
| 467 |
useScale, |
| 468 |
glyph->s, |
| 469 |
glyph->t, |
| 470 |
glyph->s2, |
| 471 |
glyph->t2, |
| 472 |
glyph->glyph); |
| 473 |
|
| 474 |
yadj = useScale * glyph2->top; |
| 475 |
if (count == cursorPos && !((uiInfo.uiDC.realTime/BLINK_DIVISOR) & 1)) { |
| 476 |
Text_PaintChar(x, y - yadj, |
| 477 |
glyph2->imageWidth, |
| 478 |
glyph2->imageHeight, |
| 479 |
useScale, |
| 480 |
glyph2->s, |
| 481 |
glyph2->t, |
| 482 |
glyph2->s2, |
| 483 |
glyph2->t2, |
| 484 |
glyph2->glyph); |
| 485 |
} |
| 486 |
|
| 487 |
x += (glyph->xSkip * useScale); |
| 488 |
s++; |
| 489 |
count++; |
| 490 |
} |
| 491 |
} |
| 492 |
|
| 493 |
if (cursorPos == len && !((uiInfo.uiDC.realTime/BLINK_DIVISOR) & 1)) { |
| 494 |
yadj = useScale * glyph2->top; |
| 495 |
Text_PaintChar(x, y - yadj, |
| 496 |
glyph2->imageWidth, |
| 497 |
glyph2->imageHeight, |
| 498 |
useScale, |
| 499 |
glyph2->s, |
| 500 |
glyph2->t, |
| 501 |
glyph2->s2, |
| 502 |
glyph2->t2, |
| 503 |
glyph2->glyph); |
| 504 |
|
| 505 |
} |
| 506 |
|
| 507 |
trap_R_SetColor( NULL ); |
| 508 |
} |
| 509 |
} |
| 510 |
|
| 511 |
|
| 512 |
static void Text_Paint_Limit(float *maxX, float x, float y, float scale, vec4_t color, const char* text, float adjust, int limit) { |
| 513 |
int len, count; |
| 514 |
vec4_t newColor; |
| 515 |
glyphInfo_t *glyph; |
| 516 |
if (text) { |
| 517 |
const char *s = text; |
| 518 |
float max = *maxX; |
| 519 |
float useScale; |
| 520 |
fontInfo_t *font = &uiInfo.uiDC.Assets.textFont; |
| 521 |
if (scale <= ui_smallFont.value) { |
| 522 |
font = &uiInfo.uiDC.Assets.smallFont; |
| 523 |
} else if (scale > ui_bigFont.value) { |
| 524 |
font = &uiInfo.uiDC.Assets.bigFont; |
| 525 |
} |
| 526 |
useScale = scale * font->glyphScale; |
| 527 |
trap_R_SetColor( color ); |
| 528 |
len = strlen(text); |
| 529 |
if (limit > 0 && len > limit) { |
| 530 |
len = limit; |
| 531 |
} |
| 532 |
count = 0; |
| 533 |
while (s && *s && count < len) { |
| 534 |
glyph = &font->glyphs[*s & 255]; |
| 535 |
if ( Q_IsColorString( s ) ) { |
| 536 |
memcpy( newColor, g_color_table[ColorIndex(*(s+1))], sizeof( newColor ) ); |
| 537 |
newColor[3] = color[3]; |
| 538 |
trap_R_SetColor( newColor ); |
| 539 |
s += 2; |
| 540 |
continue; |
| 541 |
} else { |
| 542 |
float yadj = useScale * glyph->top; |
| 543 |
if (Text_Width(s, scale, 1) + x > max) { |
| 544 |
*maxX = 0; |
| 545 |
break; |
| 546 |
} |
| 547 |
Text_PaintChar(x, y - yadj, |
| 548 |
glyph->imageWidth, |
| 549 |
glyph->imageHeight, |
| 550 |
useScale, |
| 551 |
glyph->s, |
| 552 |
glyph->t, |
| 553 |
glyph->s2, |
| 554 |
glyph->t2, |
| 555 |
glyph->glyph); |
| 556 |
x += (glyph->xSkip * useScale) + adjust; |
| 557 |
*maxX = x; |
| 558 |
count++; |
| 559 |
s++; |
| 560 |
} |
| 561 |
} |
| 562 |
trap_R_SetColor( NULL ); |
| 563 |
} |
| 564 |
|
| 565 |
} |
| 566 |
|
| 567 |
|
| 568 |
void UI_ShowPostGame(qboolean newHigh) { |
| 569 |
trap_Cvar_Set ("cg_cameraOrbit", "0"); |
| 570 |
trap_Cvar_Set("cg_thirdPerson", "0"); |
| 571 |
uiInfo.soundHighScore = newHigh; |
| 572 |
_UI_SetActiveMenu(UIMENU_POSTGAME); |
| 573 |
} |
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
void UI_DrawCenteredPic(qhandle_t image, int w, int h) { |
| 581 |
int x, y; |
| 582 |
x = (SCREEN_WIDTH - w) / 2; |
| 583 |
y = (SCREEN_HEIGHT - h) / 2; |
| 584 |
UI_DrawHandlePic(x, y, w, h, image); |
| 585 |
} |
| 586 |
|
| 587 |
int frameCount = 0; |
| 588 |
int startTime; |
| 589 |
|
| 590 |
#define UI_FPS_FRAMES 4 |
| 591 |
void _UI_Refresh( int realtime ) |
| 592 |
{ |
| 593 |
static int index; |
| 594 |
static int previousTimes[UI_FPS_FRAMES]; |
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
uiInfo.uiDC.frameTime = realtime - uiInfo.uiDC.realTime; |
| 601 |
uiInfo.uiDC.realTime = realtime; |
| 602 |
|
| 603 |
previousTimes[index % UI_FPS_FRAMES] = uiInfo.uiDC.frameTime; |
| 604 |
index++; |
| 605 |
if ( index > UI_FPS_FRAMES ) { |
| 606 |
int i, total; |
| 607 |
|
| 608 |
total = 0; |
| 609 |
for ( i = 0 ; i < UI_FPS_FRAMES ; i++ ) { |
| 610 |
total += previousTimes[i]; |
| 611 |
} |
| 612 |
if ( !total ) { |
| 613 |
total = 1; |
| 614 |
} |
| 615 |
uiInfo.uiDC.FPS = 1000 * UI_FPS_FRAMES / total; |
| 616 |
} |
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
UI_UpdateCvars(); |
| 621 |
|
| 622 |
if (Menu_Count() > 0) { |
| 623 |
|
| 624 |
Menu_PaintAll(); |
| 625 |
|
| 626 |
UI_DoServerRefresh(); |
| 627 |
|
| 628 |
UI_BuildServerStatus(qfalse); |
| 629 |
|
| 630 |
UI_BuildFindPlayerList(qfalse); |
| 631 |
} |
| 632 |
|
| 633 |
|
| 634 |
UI_SetColor( NULL ); |
| 635 |
if (Menu_Count() > 0 && (trap_Key_GetCatcher() & KEYCATCH_UI)) { |
| 636 |
UI_DrawHandlePic( uiInfo.uiDC.cursorx-16, uiInfo.uiDC.cursory-16, 32, 32, uiInfo.uiDC.Assets.cursor); |
| 637 |
} |
| 638 |
|
| 639 |
#ifndef NDEBUG |
| 640 |
if (uiInfo.uiDC.debug) |
| 641 |
{ |
| 642 |
|
| 643 |
|
| 644 |
|
| 645 |
} |
| 646 |
#endif |
| 647 |
|
| 648 |
} |
| 649 |
|
| 650 |
|
| 651 |
|
| 652 |
|
| 653 |
|
| 654 |
|
| 655 |
void _UI_Shutdown( void ) { |
| 656 |
trap_LAN_SaveCachedServers(); |
| 657 |
} |
| 658 |
|
| 659 |
char *defaultMenu = NULL; |
| 660 |
|
| 661 |
char *GetMenuBuffer(const char *filename) { |
| 662 |
int len; |
| 663 |
fileHandle_t f; |
| 664 |
static char buf[MAX_MENUFILE]; |
| 665 |
|
| 666 |
len = trap_FS_FOpenFile( filename, &f, FS_READ ); |
| 667 |
if ( !f ) { |
| 668 |
trap_Print( va( S_COLOR_RED "menu file not found: %s, using default\n", filename ) ); |
| 669 |
return defaultMenu; |
| 670 |
} |
| 671 |
if ( len >= MAX_MENUFILE ) { |
| 672 |
trap_Print( va( S_COLOR_RED "menu file too large: %s is %i, max allowed is %i\n", filename, len, MAX_MENUFILE ) ); |
| 673 |
trap_FS_FCloseFile( f ); |
| 674 |
return defaultMenu; |
| 675 |
} |
| 676 |
|
| 677 |
trap_FS_Read( buf, len, f ); |
| 678 |
buf[len] = 0; |
| 679 |
trap_FS_FCloseFile( f ); |
| 680 |
|
| 681 |
return buf; |
| 682 |
|
| 683 |
} |
| 684 |
|
| 685 |
qboolean Asset_Parse(int handle) { |
| 686 |
pc_token_t token; |
| 687 |
const char *tempStr; |
| 688 |
|
| 689 |
if (!trap_PC_ReadToken(handle, &token)) |
| 690 |
return qfalse; |
| 691 |
if (Q_stricmp(token.string, "{") != 0) { |
| 692 |
return qfalse; |
| 693 |
} |
| 694 |
|
| 695 |
while ( 1 ) { |
| 696 |
|
| 697 |
memset(&token, 0, sizeof(pc_token_t)); |
| 698 |
|
| 699 |
if (!trap_PC_ReadToken(handle, &token)) |
| 700 |
return qfalse; |
| 701 |
|
| 702 |
if (Q_stricmp(token.string, "}") == 0) { |
| 703 |
return qtrue; |
| 704 |
} |
| 705 |
|
| 706 |
|
| 707 |
if (Q_stricmp(token.string, "font") == 0) { |
| 708 |
int pointSize; |
| 709 |
if (!PC_String_Parse(handle, &tempStr) || !PC_Int_Parse(handle,&pointSize)) { |
| 710 |
return qfalse; |
| 711 |
} |
| 712 |
trap_R_RegisterFont(tempStr, pointSize, &uiInfo.uiDC.Assets.textFont); |
| 713 |
uiInfo.uiDC.Assets.fontRegistered = qtrue; |
| 714 |
continue; |
| 715 |
} |
| 716 |
|
| 717 |
if (Q_stricmp(token.string, "smallFont") == 0) { |
| 718 |
int pointSize; |
| 719 |
if (!PC_String_Parse(handle, &tempStr) || !PC_Int_Parse(handle,&pointSize)) { |
| 720 |
return qfalse; |
| 721 |
} |
| 722 |
trap_R_RegisterFont(tempStr, pointSize, &uiInfo.uiDC.Assets.smallFont); |
| 723 |
continue; |
| 724 |
} |
| 725 |
|
| 726 |
if (Q_stricmp(token.string, "bigFont") == 0) { |
| 727 |
int pointSize; |
| 728 |
if (!PC_String_Parse(handle, &tempStr) || !PC_Int_Parse(handle,&pointSize)) { |
| 729 |
return qfalse; |
| 730 |
} |
| 731 |
trap_R_RegisterFont(tempStr, pointSize, &uiInfo.uiDC.Assets.bigFont); |
| 732 |
continue; |
| 733 |
} |
| 734 |
|
| 735 |
|
| 736 |
|
| 737 |
if (Q_stricmp(token.string, "gradientbar") == 0) { |
| 738 |
if (!PC_String_Parse(handle, &tempStr)) { |
| 739 |
return qfalse; |
| 740 |
} |
| 741 |
uiInfo.uiDC.Assets.gradientBar = trap_R_RegisterShaderNoMip(tempStr); |
| 742 |
continue; |
| 743 |
} |
| 744 |
|
| 745 |
|
| 746 |
if (Q_stricmp(token.string, "menuEnterSound") == 0) { |
| 747 |
if (!PC_String_Parse(handle, &tempStr)) { |
| 748 |
return qfalse; |
| 749 |
} |
| 750 |
uiInfo.uiDC.Assets.menuEnterSound = trap_S_RegisterSound( tempStr, qfalse ); |
| 751 |
continue; |
| 752 |
} |
| 753 |
|
| 754 |
|
| 755 |
if (Q_stricmp(token.string, "menuExitSound") == 0) { |
| 756 |
if (!PC_String_Parse(handle, &tempStr)) { |
| 757 |
return qfalse; |
| 758 |
} |
| 759 |
uiInfo.uiDC.Assets.menuExitSound = trap_S_RegisterSound( tempStr, qfalse ); |
| 760 |
continue; |
| 761 |
} |
| 762 |
|
| 763 |
|
| 764 |
if (Q_stricmp(token.string, "itemFocusSound") == 0) { |
| 765 |
if (!PC_String_Parse(handle, &tempStr)) { |
| 766 |
return qfalse; |
| 767 |
} |
| 768 |
uiInfo.uiDC.Assets.itemFocusSound = trap_S_RegisterSound( tempStr, qfalse ); |
| 769 |
continue; |
| 770 |
} |
| 771 |
|
| 772 |
|
| 773 |
if (Q_stricmp(token.string, "menuBuzzSound") == 0) { |
| 774 |
if (!PC_String_Parse(handle, &tempStr)) { |
| 775 |
return qfalse; |
| 776 |
} |
| 777 |
uiInfo.uiDC.Assets.menuBuzzSound = trap_S_RegisterSound( tempStr, qfalse ); |
| 778 |
continue; |
| 779 |
} |
| 780 |
|
| 781 |
if (Q_stricmp(token.string, "cursor") == 0) { |
| 782 |
if (!PC_String_Parse(handle, &uiInfo.uiDC.Assets.cursorStr)) { |
| 783 |
return qfalse; |
| 784 |
} |
| 785 |
uiInfo.uiDC.Assets.cursor = trap_R_RegisterShaderNoMip( uiInfo.uiDC.Assets.cursorStr); |
| 786 |
continue; |
| 787 |
} |
| 788 |
|
| 789 |
if (Q_stricmp(token.string, "fadeClamp") == 0) { |
| 790 |
if (!PC_Float_Parse(handle, &uiInfo.uiDC.Assets.fadeClamp)) { |
| 791 |
return qfalse; |
| 792 |
} |
| 793 |
continue; |
| 794 |
} |
| 795 |
|
| 796 |
if (Q_stricmp(token.string, "fadeCycle") == 0) { |
| 797 |
if (!PC_Int_Parse(handle, &uiInfo.uiDC.Assets.fadeCycle)) { |
| 798 |
return qfalse; |
| 799 |
} |
| 800 |
continue; |
| 801 |
} |
| 802 |
|
| 803 |
if (Q_stricmp(token.string, "fadeAmount") == 0) { |
| 804 |
if (!PC_Float_Parse(handle, &uiInfo.uiDC.Assets.fadeAmount)) { |
| 805 |
return qfalse; |
| 806 |
} |
| 807 |
continue; |
| 808 |
} |
| 809 |
|
| 810 |
if (Q_stricmp(token.string, "shadowX") == 0) { |
| 811 |
if (!PC_Float_Parse(handle, &uiInfo.uiDC.Assets.shadowX)) { |
| 812 |
return qfalse; |
| 813 |
} |
| 814 |
continue; |
| 815 |
} |
| 816 |
|
| 817 |
if (Q_stricmp(token.string, "shadowY") == 0) { |
| 818 |
if (!PC_Float_Parse(handle, &uiInfo.uiDC.Assets.shadowY)) { |
| 819 |
return qfalse; |
| 820 |
} |
| 821 |
continue; |
| 822 |
} |
| 823 |
|
| 824 |
if (Q_stricmp(token.string, "shadowColor") == 0) { |
| 825 |
if (!PC_Color_Parse(handle, &uiInfo.uiDC.Assets.shadowColor)) { |
| 826 |
return qfalse; |
| 827 |
} |
| 828 |
uiInfo.uiDC.Assets.shadowFadeClamp = uiInfo.uiDC.Assets.shadowColor[3]; |
| 829 |
continue; |
| 830 |
} |
| 831 |
|
| 832 |
} |
| 833 |
return qfalse; |
| 834 |
} |
| 835 |
|
| 836 |
void Font_Report( void ) { |
| 837 |
int i; |
| 838 |
Com_Printf("Font Info\n"); |
| 839 |
Com_Printf("=========\n"); |
| 840 |
for ( i = 32; i < 96; i++) { |
| 841 |
Com_Printf("Glyph handle %i: %i\n", i, uiInfo.uiDC.Assets.textFont.glyphs[i].glyph); |
| 842 |
} |
| 843 |
} |
| 844 |
|
| 845 |
void UI_Report( void ) { |
| 846 |
String_Report(); |
| 847 |
|
| 848 |
|
| 849 |
} |
| 850 |
|
| 851 |
void UI_ParseMenu(const char *menuFile) { |
| 852 |
int handle; |
| 853 |
pc_token_t token; |
| 854 |
|
| 855 |
Com_Printf("Parsing menu file: %s\n", menuFile); |
| 856 |
|
| 857 |
handle = trap_PC_LoadSource(menuFile); |
| 858 |
if (!handle) { |
| 859 |
return; |
| 860 |
} |
| 861 |
|
| 862 |
while ( 1 ) { |
| 863 |
memset(&token, 0, sizeof(pc_token_t)); |
| 864 |
if (!trap_PC_ReadToken( handle, &token )) { |
| 865 |
break; |
| 866 |
} |
| 867 |
|
| 868 |
|
| 869 |
|
| 870 |
|
| 871 |
|
| 872 |
|
| 873 |
|
| 874 |
|
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
if ( token.string[0] == '}' ) { |
| 879 |
break; |
| 880 |
} |
| 881 |
|
| 882 |
if (Q_stricmp(token.string, "assetGlobalDef") == 0) { |
| 883 |
if (Asset_Parse(handle)) { |
| 884 |
continue; |
| 885 |
} else { |
| 886 |
break; |
| 887 |
} |
| 888 |
} |
| 889 |
|
| 890 |
if (Q_stricmp(token.string, "menudef") == 0) { |
| 891 |
|
| 892 |
Menu_New(handle); |
| 893 |
} |
| 894 |
} |
| 895 |
trap_PC_FreeSource(handle); |
| 896 |
} |
| 897 |
|
| 898 |
qboolean Load_Menu(int handle) { |
| 899 |
pc_token_t token; |
| 900 |
|
| 901 |
if (!trap_PC_ReadToken(handle, &token)) |
| 902 |
return qfalse; |
| 903 |
if (token.string[0] != '{') { |
| 904 |
return qfalse; |
| 905 |
} |
| 906 |
|
| 907 |
while ( 1 ) { |
| 908 |
|
| 909 |
if (!trap_PC_ReadToken(handle, &token)) |
| 910 |
return qfalse; |
| 911 |
|
| 912 |
if ( token.string[0] == 0 ) { |
| 913 |
return qfalse; |
| 914 |
} |
| 915 |
|
| 916 |
if ( token.string[0] == '}' ) { |
| 917 |
return qtrue; |
| 918 |
} |
| 919 |
|
| 920 |
UI_ParseMenu(token.string); |
| 921 |
} |
| 922 |
return qfalse; |
| 923 |
} |
| 924 |
|
| 925 |
void UI_LoadMenus(const char *menuFile, qboolean reset) { |
| 926 |
pc_token_t token; |
| 927 |
int handle; |
| 928 |
int start; |
| 929 |
|
| 930 |
start = trap_Milliseconds(); |
| 931 |
|
| 932 |
handle = trap_PC_LoadSource( menuFile ); |
| 933 |
if (!handle) { |
| 934 |
Com_Printf( S_COLOR_YELLOW "menu file not found: %s, using default\n", menuFile ); |
| 935 |
handle = trap_PC_LoadSource( "ui/menus.txt" ); |
| 936 |
if (!handle) { |
| 937 |
trap_Error( S_COLOR_RED "default menu file not found: ui/menus.txt, unable to continue!" ); |
| 938 |
} |
| 939 |
} |
| 940 |
|
| 941 |
ui_new.integer = 1; |
| 942 |
|
| 943 |
if (reset) { |
| 944 |
Menu_Reset(); |
| 945 |
} |
| 946 |
|
| 947 |
while ( 1 ) { |
| 948 |
if (!trap_PC_ReadToken(handle, &token)) |
| 949 |
break; |
| 950 |
if( token.string[0] == 0 || token.string[0] == '}') { |
| 951 |
break; |
| 952 |
} |
| 953 |
|
| 954 |
if ( token.string[0] == '}' ) { |
| 955 |
break; |
| 956 |
} |
| 957 |
|
| 958 |
if (Q_stricmp(token.string, "loadmenu") == 0) { |
| 959 |
if (Load_Menu(handle)) { |
| 960 |
continue; |
| 961 |
} else { |
| 962 |
break; |
| 963 |
} |
| 964 |
} |
| 965 |
} |
| 966 |
|
| 967 |
Com_Printf("UI menu load time = %d milli seconds\n", trap_Milliseconds() - start); |
| 968 |
|
| 969 |
trap_PC_FreeSource( handle ); |
| 970 |
} |
| 971 |
|
| 972 |
void UI_Load(void) { |
| 973 |
char lastName[1024]; |
| 974 |
menuDef_t *menu = Menu_GetFocused(); |
| 975 |
char *menuSet = UI_Cvar_VariableString("ui_menuFiles"); |
| 976 |
if (menu && menu->window.name) { |
| 977 |
Q_strncpyz(lastName, menu->window.name, sizeof(lastName)); |
| 978 |
} |
| 979 |
if (menuSet == NULL || menuSet[0] == '\0') { |
| 980 |
menuSet = "ui/menus.txt"; |
| 981 |
} |
| 982 |
|
| 983 |
String_Init(); |
| 984 |
|
| 985 |
#ifdef PRE_RELEASE_TADEMO |
| 986 |
UI_ParseGameInfo("demogameinfo.txt"); |
| 987 |
#else |
| 988 |
UI_ParseGameInfo("gameinfo.txt"); |
| 989 |
UI_LoadArenas(); |
| 990 |
#endif |
| 991 |
|
| 992 |
UI_LoadMenus(menuSet, qtrue); |
| 993 |
Menus_CloseAll(); |
| 994 |
Menus_ActivateByName(lastName); |
| 995 |
|
| 996 |
} |
| 997 |
|
| 998 |
|
| 999 |
int UI_SourceForLAN(void) { |
| 1000 |
switch (ui_netSource.integer) { |
| 1001 |
default: |
| 1002 |
case UIAS_LOCAL: |
| 1003 |
return AS_LOCAL; |
| 1004 |
case UIAS_GLOBAL0: |
| 1005 |
case UIAS_GLOBAL1: |
| 1006 |
case UIAS_GLOBAL2: |
| 1007 |
case UIAS_GLOBAL3: |
| 1008 |
case UIAS_GLOBAL4: |
| 1009 |
case UIAS_GLOBAL5: |
| 1010 |
return AS_GLOBAL; |
| 1011 |
case UIAS_FAVORITES: |
| 1012 |
return AS_FAVORITES; |
| 1013 |
} |
| 1014 |
} |
| 1015 |
|
| 1016 |
|
| 1017 |
static const char *handicapValues[] = {"None","95","90","85","80","75","70","65","60","55","50","45","40","35","30","25","20","15","10","5",NULL}; |
| 1018 |
#ifndef MISSIONPACK |
| 1019 |
static int numHandicaps = ARRAY_LEN(handicapValues); |
| 1020 |
#endif |
| 1021 |
|
| 1022 |
static void UI_DrawHandicap(rectDef_t *rect, float scale, vec4_t color, int textStyle) { |
| 1023 |
int i, h; |
| 1024 |
|
| 1025 |
h = Com_Clamp( 5, 100, trap_Cvar_VariableValue("handicap") ); |
| 1026 |
i = 20 - h / 5; |
| 1027 |
|
| 1028 |
Text_Paint(rect->x, rect->y, scale, color, handicapValues[i], 0, 0, textStyle); |
| 1029 |
} |
| 1030 |
|
| 1031 |
static void UI_DrawClanName(rectDef_t *rect, float scale, vec4_t color, int textStyle) { |
| 1032 |
Text_Paint(rect->x, rect->y, scale, color, UI_Cvar_VariableString("ui_teamName"), 0, 0, textStyle); |
| 1033 |
} |
| 1034 |
|
| 1035 |
|
| 1036 |
static void UI_SetCapFragLimits(qboolean uiVars) { |
| 1037 |
int cap = 5; |
| 1038 |
int frag = 10; |
| 1039 |
if (uiInfo.gameTypes[ui_gameType.integer].gtEnum == GT_OBELISK) { |
| 1040 |
cap = 4; |
| 1041 |
} else if (uiInfo.gameTypes[ui_gameType.integer].gtEnum == GT_HARVESTER) { |
| 1042 |
cap = 15; |
| 1043 |
} |
| 1044 |
if (uiVars) { |
| 1045 |
trap_Cvar_Set("ui_captureLimit", va("%d", cap)); |
| 1046 |
trap_Cvar_Set("ui_fragLimit", va("%d", frag)); |
| 1047 |
} else { |
| 1048 |
trap_Cvar_Set("capturelimit", va("%d", cap)); |
| 1049 |
trap_Cvar_Set("fraglimit", va("%d", frag)); |
| 1050 |
} |
| 1051 |
} |
| 1052 |
|
| 1053 |
static void UI_DrawGameType(rectDef_t *rect, float scale, vec4_t color, int textStyle) { |
| 1054 |
Text_Paint(rect->x, rect->y, scale, color, uiInfo.gameTypes[ui_gameType.integer].gameType, 0, 0, textStyle); |
| 1055 |
} |
| 1056 |
|
| 1057 |
static void UI_DrawNetGameType(rectDef_t *rect, float scale, vec4_t color, int textStyle) { |
| 1058 |
if (ui_netGameType.integer < 0 || ui_netGameType.integer > uiInfo.numGameTypes) { |
| 1059 |
trap_Cvar_Set("ui_netGameType", "0"); |
| 1060 |
trap_Cvar_Set("ui_actualNetGameType", "0"); |
| 1061 |
} |
| 1062 |
Text_Paint(rect->x, rect->y, scale, color, uiInfo.gameTypes[ui_netGameType.integer].gameType , 0, 0, textStyle); |
| 1063 |
} |
| 1064 |
|
| 1065 |
static void UI_DrawJoinGameType(rectDef_t *rect, float scale, vec4_t color, int textStyle) { |
| 1066 |
if (ui_joinGameType.integer < 0 || ui_joinGameType.integer > uiInfo.numJoinGameTypes) { |
| 1067 |
trap_Cvar_Set("ui_joinGameType", "0"); |
| 1068 |
} |
| 1069 |
Text_Paint(rect->x, rect->y, scale, color, uiInfo.joinGameTypes[ui_joinGameType.integer].gameType , 0, 0, textStyle); |
| 1070 |
} |
| 1071 |
|
| 1072 |
|
| 1073 |
|
| 1074 |
static int UI_TeamIndexFromName(const char *name) { |
| 1075 |
int i; |
| 1076 |
|
| 1077 |
if (name && *name) { |
| 1078 |
for (i = 0; i < uiInfo.teamCount; i++) { |
| 1079 |
if (Q_stricmp(name, uiInfo.teamList[i].teamName) == 0) { |
| 1080 |
return i; |
| 1081 |
} |
| 1082 |
} |
| 1083 |
} |
| 1084 |
|
| 1085 |
return 0; |
| 1086 |
|
| 1087 |
} |
| 1088 |
|
| 1089 |
static void UI_DrawClanLogo(rectDef_t *rect, float scale, vec4_t color) { |
| 1090 |
int i; |
| 1091 |
i = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_teamName")); |
| 1092 |
if (i >= 0 && i < uiInfo.teamCount) { |
| 1093 |
trap_R_SetColor( color ); |
| 1094 |
|
| 1095 |
if (uiInfo.teamList[i].teamIcon == -1) { |
| 1096 |
uiInfo.teamList[i].teamIcon = trap_R_RegisterShaderNoMip(uiInfo.teamList[i].imageName); |
| 1097 |
uiInfo.teamList[i].teamIcon_Metal = trap_R_RegisterShaderNoMip(va("%s_metal",uiInfo.teamList[i].imageName)); |
| 1098 |
uiInfo.teamList[i].teamIcon_Name = trap_R_RegisterShaderNoMip(va("%s_name", uiInfo.teamList[i].imageName)); |
| 1099 |
} |
| 1100 |
|
| 1101 |
UI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.teamList[i].teamIcon); |
| 1102 |
trap_R_SetColor(NULL); |
| 1103 |
} |
| 1104 |
} |
| 1105 |
|
| 1106 |
static void UI_DrawClanCinematic(rectDef_t *rect, float scale, vec4_t color) { |
| 1107 |
int i; |
| 1108 |
i = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_teamName")); |
| 1109 |
if (i >= 0 && i < uiInfo.teamCount) { |
| 1110 |
|
| 1111 |
if (uiInfo.teamList[i].cinematic >= -2) { |
| 1112 |
if (uiInfo.teamList[i].cinematic == -1) { |
| 1113 |
uiInfo.teamList[i].cinematic = trap_CIN_PlayCinematic(va("%s.roq", uiInfo.teamList[i].imageName), 0, 0, 0, 0, (CIN_loop | CIN_silent) ); |
| 1114 |
} |
| 1115 |
if (uiInfo.teamList[i].cinematic >= 0) { |
| 1116 |
trap_CIN_RunCinematic(uiInfo.teamList[i].cinematic); |
| 1117 |
UI_DrawCinematic(uiInfo.teamList[i].cinematic, rect->x, rect->y, rect->w, rect->h); |
| 1118 |
} else { |
| 1119 |
trap_R_SetColor( color ); |
| 1120 |
UI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.teamList[i].teamIcon_Metal); |
| 1121 |
trap_R_SetColor(NULL); |
| 1122 |
uiInfo.teamList[i].cinematic = -2; |
| 1123 |
} |
| 1124 |
} else { |
| 1125 |
trap_R_SetColor( color ); |
| 1126 |
UI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.teamList[i].teamIcon); |
| 1127 |
trap_R_SetColor(NULL); |
| 1128 |
} |
| 1129 |
} |
| 1130 |
|
| 1131 |
} |
| 1132 |
|
| 1133 |
static void UI_DrawPreviewCinematic(rectDef_t *rect, float scale, vec4_t color) { |
| 1134 |
if (uiInfo.previewMovie > -2) { |
| 1135 |
uiInfo.previewMovie = trap_CIN_PlayCinematic(va("%s.roq", uiInfo.movieList[uiInfo.movieIndex]), 0, 0, 0, 0, (CIN_loop | CIN_silent) ); |
| 1136 |
if (uiInfo.previewMovie >= 0) { |
| 1137 |
trap_CIN_RunCinematic(uiInfo.previewMovie); |
| 1138 |
UI_DrawCinematic(uiInfo.previewMovie, rect->x, rect->y, rect->w, rect->h); |
| 1139 |
} else { |
| 1140 |
uiInfo.previewMovie = -2; |
| 1141 |
} |
| 1142 |
} |
| 1143 |
|
| 1144 |
} |
| 1145 |
|
| 1146 |
|
| 1147 |
|
| 1148 |
static void UI_DrawSkill(rectDef_t *rect, float scale, vec4_t color, int textStyle) { |
| 1149 |
int i; |
| 1150 |
i = trap_Cvar_VariableValue( "g_spSkill" ); |
| 1151 |
if (i < 1 || i > numSkillLevels) { |
| 1152 |
i = 1; |
| 1153 |
} |
| 1154 |
Text_Paint(rect->x, rect->y, scale, color, skillLevels[i-1],0, 0, textStyle); |
| 1155 |
} |
| 1156 |
|
| 1157 |
|
| 1158 |
static void UI_DrawTeamName(rectDef_t *rect, float scale, vec4_t color, qboolean blue, int textStyle) { |
| 1159 |
int i; |
| 1160 |
i = UI_TeamIndexFromName(UI_Cvar_VariableString((blue) ? "ui_blueTeam" : "ui_redTeam")); |
| 1161 |
if (i >= 0 && i < uiInfo.teamCount) { |
| 1162 |
Text_Paint(rect->x, rect->y, scale, color, va("%s: %s", (blue) ? "Blue" : "Red", uiInfo.teamList[i].teamName),0, 0, textStyle); |
| 1163 |
} |
| 1164 |
} |
| 1165 |
|
| 1166 |
static void UI_DrawTeamMember(rectDef_t *rect, float scale, vec4_t color, qboolean blue, int num, int textStyle) { |
| 1167 |
|
| 1168 |
|
| 1169 |
|
| 1170 |
int value = trap_Cvar_VariableValue(va(blue ? "ui_blueteam%i" : "ui_redteam%i", num)); |
| 1171 |
const char *text; |
| 1172 |
if (value <= 0) { |
| 1173 |
text = "Closed"; |
| 1174 |
} else if (value == 1) { |
| 1175 |
text = "Human"; |
| 1176 |
} else { |
| 1177 |
value -= 2; |
| 1178 |
|
| 1179 |
if (ui_actualNetGameType.integer >= GT_TEAM) { |
| 1180 |
if (value >= uiInfo.characterCount) { |
| 1181 |
value = 0; |
| 1182 |
} |
| 1183 |
text = uiInfo.characterList[value].name; |
| 1184 |
} else { |
| 1185 |
if (value >= UI_GetNumBots()) { |
| 1186 |
value = 0; |
| 1187 |
} |
| 1188 |
text = UI_GetBotNameByNumber(value); |
| 1189 |
} |
| 1190 |
} |
| 1191 |
Text_Paint(rect->x, rect->y, scale, color, text, 0, 0, textStyle); |
| 1192 |
} |
| 1193 |
|
| 1194 |
static void UI_DrawEffects(rectDef_t *rect, float scale, vec4_t color) { |
| 1195 |
UI_DrawHandlePic( rect->x, rect->y - 14, 128, 8, uiInfo.uiDC.Assets.fxBasePic ); |
| 1196 |
UI_DrawHandlePic( rect->x + uiInfo.effectsColor * 16 + 8, rect->y - 16, 16, 12, uiInfo.uiDC.Assets.fxPic[uiInfo.effectsColor] ); |
| 1197 |
} |
| 1198 |
|
| 1199 |
static void UI_DrawMapPreview(rectDef_t *rect, float scale, vec4_t color, qboolean net) { |
| 1200 |
int map = (net) ? ui_currentNetMap.integer : ui_currentMap.integer; |
| 1201 |
if (map < 0 || map > uiInfo.mapCount) { |
| 1202 |
if (net) { |
| 1203 |
ui_currentNetMap.integer = 0; |
| 1204 |
trap_Cvar_Set("ui_currentNetMap", "0"); |
| 1205 |
} else { |
| 1206 |
ui_currentMap.integer = 0; |
| 1207 |
trap_Cvar_Set("ui_currentMap", "0"); |
| 1208 |
} |
| 1209 |
map = 0; |
| 1210 |
} |
| 1211 |
|
| 1212 |
if (uiInfo.mapList[map].levelShot == -1) { |
| 1213 |
uiInfo.mapList[map].levelShot = trap_R_RegisterShaderNoMip(uiInfo.mapList[map].imageName); |
| 1214 |
} |
| 1215 |
|
| 1216 |
if (uiInfo.mapList[map].levelShot > 0) { |
| 1217 |
UI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.mapList[map].levelShot); |
| 1218 |
} else { |
| 1219 |
UI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, trap_R_RegisterShaderNoMip("menu/art/unknownmap")); |
| 1220 |
} |
| 1221 |
} |
| 1222 |
|
| 1223 |
|
| 1224 |
static void UI_DrawMapTimeToBeat(rectDef_t *rect, float scale, vec4_t color, int textStyle) { |
| 1225 |
int minutes, seconds, time; |
| 1226 |
if (ui_currentMap.integer < 0 || ui_currentMap.integer > uiInfo.mapCount) { |
| 1227 |
ui_currentMap.integer = 0; |
| 1228 |
trap_Cvar_Set("ui_currentMap", "0"); |
| 1229 |
} |
| 1230 |
|
| 1231 |
time = uiInfo.mapList[ui_currentMap.integer].timeToBeat[uiInfo.gameTypes[ui_gameType.integer].gtEnum]; |
| 1232 |
|
| 1233 |
minutes = time / 60; |
| 1234 |
seconds = time % 60; |
| 1235 |
|
| 1236 |
Text_Paint(rect->x, rect->y, scale, color, va("%02i:%02i", minutes, seconds), 0, 0, textStyle); |
| 1237 |
} |
| 1238 |
|
| 1239 |
|
| 1240 |
|
| 1241 |
static void UI_DrawMapCinematic(rectDef_t *rect, float scale, vec4_t color, qboolean net) { |
| 1242 |
|
| 1243 |
int map = (net) ? ui_currentNetMap.integer : ui_currentMap.integer; |
| 1244 |
if (map < 0 || map > uiInfo.mapCount) { |
| 1245 |
if (net) { |
| 1246 |
ui_currentNetMap.integer = 0; |
| 1247 |
trap_Cvar_Set("ui_currentNetMap", "0"); |
| 1248 |
} else { |
| 1249 |
ui_currentMap.integer = 0; |
| 1250 |
trap_Cvar_Set("ui_currentMap", "0"); |
| 1251 |
} |
| 1252 |
map = 0; |
| 1253 |
} |
| 1254 |
|
| 1255 |
if (uiInfo.mapList[map].cinematic >= -1) { |
| 1256 |
if (uiInfo.mapList[map].cinematic == -1) { |
| 1257 |
uiInfo.mapList[map].cinematic = trap_CIN_PlayCinematic(va("%s.roq", uiInfo.mapList[map].mapLoadName), 0, 0, 0, 0, (CIN_loop | CIN_silent) ); |
| 1258 |
} |
| 1259 |
if (uiInfo.mapList[map].cinematic >= 0) { |
| 1260 |
trap_CIN_RunCinematic(uiInfo.mapList[map].cinematic); |
| 1261 |
UI_DrawCinematic(uiInfo.mapList[map].cinematic, rect->x, rect->y, rect->w, rect->h); |
| 1262 |
} else { |
| 1263 |
uiInfo.mapList[map].cinematic = -2; |
| 1264 |
} |
| 1265 |
} else { |
| 1266 |
UI_DrawMapPreview(rect, scale, color, net); |
| 1267 |
} |
| 1268 |
} |
| 1269 |
|
| 1270 |
|
| 1271 |
|
| 1272 |
static qboolean updateModel = qtrue; |
| 1273 |
static qboolean q3Model = qfalse; |
| 1274 |
|
| 1275 |
static void UI_DrawPlayerModel(rectDef_t *rect) { |
| 1276 |
static playerInfo_t info; |
| 1277 |
char model[MAX_QPATH]; |
| 1278 |
char team[256]; |
| 1279 |
char head[256]; |
| 1280 |
vec3_t viewangles; |
| 1281 |
vec3_t moveangles; |
| 1282 |
|
| 1283 |
if (trap_Cvar_VariableValue("ui_Q3Model")) { |
| 1284 |
Q_strncpyz(model, UI_Cvar_VariableString("model"), sizeof(model)); |
| 1285 |
Q_strncpyz(head, UI_Cvar_VariableString("headmodel"), sizeof(head)); |
| 1286 |
if (!q3Model) { |
| 1287 |
q3Model = qtrue; |
| 1288 |
updateModel = qtrue; |
| 1289 |
} |
| 1290 |
team[0] = '\0'; |
| 1291 |
} else { |
| 1292 |
|
| 1293 |
Q_strncpyz(team, UI_Cvar_VariableString("ui_teamName"), sizeof(team)); |
| 1294 |
Q_strncpyz(model, UI_Cvar_VariableString("team_model"), sizeof(model)); |
| 1295 |
Q_strncpyz(head, UI_Cvar_VariableString("team_headmodel"), sizeof(head)); |
| 1296 |
if (q3Model) { |
| 1297 |
q3Model = qfalse; |
| 1298 |
updateModel = qtrue; |
| 1299 |
} |
| 1300 |
} |
| 1301 |
if (updateModel) { |
| 1302 |
memset( &info, 0, sizeof(playerInfo_t) ); |
| 1303 |
viewangles[YAW] = 180 - 10; |
| 1304 |
viewangles[PITCH] = 0; |
| 1305 |
viewangles[ROLL] = 0; |
| 1306 |
VectorClear( moveangles ); |
| 1307 |
UI_PlayerInfo_SetModel( &info, model, head, team); |
| 1308 |
UI_PlayerInfo_SetInfo( &info, LEGS_IDLE, TORSO_STAND, viewangles, vec3_origin, WP_MACHINEGUN, qfalse ); |
| 1309 |
|
| 1310 |
updateModel = qfalse; |
| 1311 |
} |
| 1312 |
|
| 1313 |
UI_DrawPlayer( rect->x, rect->y, rect->w, rect->h, &info, uiInfo.uiDC.realTime / 2); |
| 1314 |
|
| 1315 |
} |
| 1316 |
|
| 1317 |
static void UI_DrawNetSource(rectDef_t *rect, float scale, vec4_t color, int textStyle) { |
| 1318 |
if (ui_netSource.integer < 0 || ui_netSource.integer >= numNetSources) { |
| 1319 |
ui_netSource.integer = 0; |
| 1320 |
} |
| 1321 |
Text_Paint(rect->x, rect->y, scale, color, va("Source: %s", netSources[ui_netSource.integer]), 0, 0, textStyle); |
| 1322 |
} |
| 1323 |
|
| 1324 |
static void UI_DrawNetMapPreview(rectDef_t *rect, float scale, vec4_t color) { |
| 1325 |
|
| 1326 |
if (uiInfo.serverStatus.currentServerPreview > 0) { |
| 1327 |
UI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.serverStatus.currentServerPreview); |
| 1328 |
} else { |
| 1329 |
UI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, trap_R_RegisterShaderNoMip("menu/art/unknownmap")); |
| 1330 |
} |
| 1331 |
} |
| 1332 |
|
| 1333 |
static void UI_DrawNetMapCinematic(rectDef_t *rect, float scale, vec4_t color) { |
| 1334 |
if (ui_currentNetMap.integer < 0 || ui_currentNetMap.integer > uiInfo.mapCount) { |
| 1335 |
ui_currentNetMap.integer = 0; |
| 1336 |
trap_Cvar_Set("ui_currentNetMap", "0"); |
| 1337 |
} |
| 1338 |
|
| 1339 |
if (uiInfo.serverStatus.currentServerCinematic >= 0) { |
| 1340 |
trap_CIN_RunCinematic(uiInfo.serverStatus.currentServerCinematic); |
| 1341 |
UI_DrawCinematic(uiInfo.serverStatus.currentServerCinematic, rect->x, rect->y, rect->w, rect->h); |
| 1342 |
} else { |
| 1343 |
UI_DrawNetMapPreview(rect, scale, color); |
| 1344 |
} |
| 1345 |
} |
| 1346 |
|
| 1347 |
|
| 1348 |
|
| 1349 |
static void UI_DrawNetFilter(rectDef_t *rect, float scale, vec4_t color, int textStyle) { |
| 1350 |
if (ui_serverFilterType.integer < 0 || ui_serverFilterType.integer >= numServerFilters) { |
| 1351 |
ui_serverFilterType.integer = 0; |
| 1352 |
} |
| 1353 |
Text_Paint(rect->x, rect->y, scale, color, va("Filter: %s", serverFilters[ui_serverFilterType.integer].description), 0, 0, textStyle); |
| 1354 |
} |
| 1355 |
|
| 1356 |
|
| 1357 |
static void UI_DrawTier(rectDef_t *rect, float scale, vec4_t color, int textStyle) { |
| 1358 |
int i; |
| 1359 |
i = trap_Cvar_VariableValue( "ui_currentTier" ); |
| 1360 |
if (i < 0 || i >= uiInfo.tierCount) { |
| 1361 |
i = 0; |
| 1362 |
} |
| 1363 |
Text_Paint(rect->x, rect->y, scale, color, va("Tier: %s", uiInfo.tierList[i].tierName),0, 0, textStyle); |
| 1364 |
} |
| 1365 |
|
| 1366 |
static void UI_DrawTierMap(rectDef_t *rect, int index) { |
| 1367 |
int i; |
| 1368 |
i = trap_Cvar_VariableValue( "ui_currentTier" ); |
| 1369 |
if (i < 0 || i >= uiInfo.tierCount) { |
| 1370 |
i = 0; |
| 1371 |
} |
| 1372 |
|
| 1373 |
if (uiInfo.tierList[i].mapHandles[index] == -1) { |
| 1374 |
uiInfo.tierList[i].mapHandles[index] = trap_R_RegisterShaderNoMip(va("levelshots/%s", uiInfo.tierList[i].maps[index])); |
| 1375 |
} |
| 1376 |
|
| 1377 |
UI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.tierList[i].mapHandles[index]); |
| 1378 |
} |
| 1379 |
|
| 1380 |
static const char *UI_EnglishMapName(const char *map) { |
| 1381 |
int i; |
| 1382 |
for (i = 0; i < uiInfo.mapCount; i++) { |
| 1383 |
if (Q_stricmp(map, uiInfo.mapList[i].mapLoadName) == 0) { |
| 1384 |
return uiInfo.mapList[i].mapName; |
| 1385 |
} |
| 1386 |
} |
| 1387 |
return ""; |
| 1388 |
} |
| 1389 |
|
| 1390 |
static void UI_DrawTierMapName(rectDef_t *rect, float scale, vec4_t color, int textStyle) { |
| 1391 |
int i, j; |
| 1392 |
i = trap_Cvar_VariableValue( "ui_currentTier" ); |
| 1393 |
if (i < 0 || i >= uiInfo.tierCount) { |
| 1394 |
i = 0; |
| 1395 |
} |
| 1396 |
j = trap_Cvar_VariableValue("ui_currentMap"); |
| 1397 |
if (j < 0 || j >= MAPS_PER_TIER) { |
| 1398 |
j = 0; |
| 1399 |
} |
| 1400 |
|
| 1401 |
Text_Paint(rect->x, rect->y, scale, color, UI_EnglishMapName(uiInfo.tierList[i].maps[j]), 0, 0, textStyle); |
| 1402 |
} |
| 1403 |
|
| 1404 |
static void UI_DrawTierGameType(rectDef_t *rect, float scale, vec4_t color, int textStyle) { |
| 1405 |
int i, j; |
| 1406 |
i = trap_Cvar_VariableValue( "ui_currentTier" ); |
| 1407 |
if (i < 0 || i >= uiInfo.tierCount) { |
| 1408 |
i = 0; |
| 1409 |
} |
| 1410 |
j = trap_Cvar_VariableValue("ui_currentMap"); |
| 1411 |
if (j < 0 || j >= MAPS_PER_TIER) { |
| 1412 |
j = 0; |
| 1413 |
} |
| 1414 |
|
| 1415 |
Text_Paint(rect->x, rect->y, scale, color, uiInfo.gameTypes[uiInfo.tierList[i].gameTypes[j]].gameType , 0, 0, textStyle); |
| 1416 |
} |
| 1417 |
|
| 1418 |
|
| 1419 |
#ifndef MISSIONPACK |
| 1420 |
static const char *UI_OpponentLeaderName(void) { |
| 1421 |
int i = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_opponentName")); |
| 1422 |
return uiInfo.teamList[i].teamMembers[0]; |
| 1423 |
} |
| 1424 |
#endif |
| 1425 |
|
| 1426 |
static const char *UI_AIFromName(const char *name) { |
| 1427 |
int j; |
| 1428 |
for (j = 0; j < uiInfo.aliasCount; j++) { |
| 1429 |
if (Q_stricmp(uiInfo.aliasList[j].name, name) == 0) { |
| 1430 |
return uiInfo.aliasList[j].ai; |
| 1431 |
} |
| 1432 |
} |
| 1433 |
return "James"; |
| 1434 |
} |
| 1435 |
|
| 1436 |
#ifndef MISSIONPACK |
| 1437 |
static const int UI_AIIndex(const char *name) { |
| 1438 |
int j; |
| 1439 |
for (j = 0; j < uiInfo.characterCount; j++) { |
| 1440 |
if (Q_stricmp(name, uiInfo.characterList[j].name) == 0) { |
| 1441 |
return j; |
| 1442 |
} |
| 1443 |
} |
| 1444 |
return 0; |
| 1445 |
} |
| 1446 |
#endif |
| 1447 |
|
| 1448 |
#ifndef MISSIONPACK |
| 1449 |
static const int UI_AIIndexFromName(const char *name) { |
| 1450 |
int j; |
| 1451 |
for (j = 0; j < uiInfo.aliasCount; j++) { |
| 1452 |
if (Q_stricmp(uiInfo.aliasList[j].name, name) == 0) { |
| 1453 |
return UI_AIIndex(uiInfo.aliasList[j].ai); |
| 1454 |
} |
| 1455 |
} |
| 1456 |
return 0; |
| 1457 |
} |
| 1458 |
#endif |
| 1459 |
|
| 1460 |
|
| 1461 |
#ifndef MISSIONPACK |
| 1462 |
static const char *UI_OpponentLeaderHead(void) { |
| 1463 |
const char *leader = UI_OpponentLeaderName(); |
| 1464 |
return UI_AIFromName(leader); |
| 1465 |
} |
| 1466 |
#endif |
| 1467 |
|
| 1468 |
#ifndef MISSIONPACK |
| 1469 |
static const char *UI_OpponentLeaderModel(void) { |
| 1470 |
int i; |
| 1471 |
const char *head = UI_OpponentLeaderHead(); |
| 1472 |
for (i = 0; i < uiInfo.characterCount; i++) { |
| 1473 |
if (Q_stricmp(head, uiInfo.characterList[i].name) == 0) { |
| 1474 |
return uiInfo.characterList[i].base; |
| 1475 |
} |
| 1476 |
} |
| 1477 |
return "James"; |
| 1478 |
} |
| 1479 |
#endif |
| 1480 |
|
| 1481 |
|
| 1482 |
static qboolean updateOpponentModel = qtrue; |
| 1483 |
static void UI_DrawOpponent(rectDef_t *rect) { |
| 1484 |
static playerInfo_t info2; |
| 1485 |
char model[MAX_QPATH]; |
| 1486 |
char headmodel[MAX_QPATH]; |
| 1487 |
char team[256]; |
| 1488 |
vec3_t viewangles; |
| 1489 |
vec3_t moveangles; |
| 1490 |
|
| 1491 |
if (updateOpponentModel) { |
| 1492 |
|
| 1493 |
Q_strncpyz(model, UI_Cvar_VariableString("ui_opponentModel"), sizeof(model)); |
| 1494 |
Q_strncpyz(headmodel, UI_Cvar_VariableString("ui_opponentModel"), sizeof(headmodel)); |
| 1495 |
team[0] = '\0'; |
| 1496 |
|
| 1497 |
memset( &info2, 0, sizeof(playerInfo_t) ); |
| 1498 |
viewangles[YAW] = 180 - 10; |
| 1499 |
viewangles[PITCH] = 0; |
| 1500 |
viewangles[ROLL] = 0; |
| 1501 |
VectorClear( moveangles ); |
| 1502 |
UI_PlayerInfo_SetModel( &info2, model, headmodel, ""); |
| 1503 |
UI_PlayerInfo_SetInfo( &info2, LEGS_IDLE, TORSO_STAND, viewangles, vec3_origin, WP_MACHINEGUN, qfalse ); |
| 1504 |
UI_RegisterClientModelname( &info2, model, headmodel, team); |
| 1505 |
updateOpponentModel = qfalse; |
| 1506 |
} |
| 1507 |
|
| 1508 |
UI_DrawPlayer( rect->x, rect->y, rect->w, rect->h, &info2, uiInfo.uiDC.realTime / 2); |
| 1509 |
|
| 1510 |
} |
| 1511 |
|
| 1512 |
static void UI_NextOpponent( void ) { |
| 1513 |
int i = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_opponentName")); |
| 1514 |
int j = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_teamName")); |
| 1515 |
i++; |
| 1516 |
if (i >= uiInfo.teamCount) { |
| 1517 |
i = 0; |
| 1518 |
} |
| 1519 |
if (i == j) { |
| 1520 |
i++; |
| 1521 |
if ( i >= uiInfo.teamCount) { |
| 1522 |
i = 0; |
| 1523 |
} |
| 1524 |
} |
| 1525 |
trap_Cvar_Set( "ui_opponentName", uiInfo.teamList[i].teamName ); |
| 1526 |
} |
| 1527 |
|
| 1528 |
static void UI_PriorOpponent( void ) { |
| 1529 |
int i = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_opponentName")); |
| 1530 |
int j = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_teamName")); |
| 1531 |
i--; |
| 1532 |
if (i < 0) { |
| 1533 |
i = uiInfo.teamCount - 1; |
| 1534 |
} |
| 1535 |
if (i == j) { |
| 1536 |
i--; |
| 1537 |
if ( i < 0) { |
| 1538 |
i = uiInfo.teamCount - 1; |
| 1539 |
} |
| 1540 |
} |
| 1541 |
trap_Cvar_Set( "ui_opponentName", uiInfo.teamList[i].teamName ); |
| 1542 |
} |
| 1543 |
|
| 1544 |
static void UI_DrawPlayerLogo(rectDef_t *rect, vec3_t color) { |
| 1545 |
int i = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_teamName")); |
| 1546 |
|
| 1547 |
if (uiInfo.teamList[i].teamIcon == -1) { |
| 1548 |
uiInfo.teamList[i].teamIcon = trap_R_RegisterShaderNoMip(uiInfo.teamList[i].imageName); |
| 1549 |
uiInfo.teamList[i].teamIcon_Metal = trap_R_RegisterShaderNoMip(va("%s_metal",uiInfo.teamList[i].imageName)); |
| 1550 |
uiInfo.teamList[i].teamIcon_Name = trap_R_RegisterShaderNoMip(va("%s_name", uiInfo.teamList[i].imageName)); |
| 1551 |
} |
| 1552 |
|
| 1553 |
trap_R_SetColor( color ); |
| 1554 |
UI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.teamList[i].teamIcon ); |
| 1555 |
trap_R_SetColor( NULL ); |
| 1556 |
} |
| 1557 |
|
| 1558 |
static void UI_DrawPlayerLogoMetal(rectDef_t *rect, vec3_t color) { |
| 1559 |
int i = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_teamName")); |
| 1560 |
if (uiInfo.teamList[i].teamIcon == -1) { |
| 1561 |
uiInfo.teamList[i].teamIcon = trap_R_RegisterShaderNoMip(uiInfo.teamList[i].imageName); |
| 1562 |
uiInfo.teamList[i].teamIcon_Metal = trap_R_RegisterShaderNoMip(va("%s_metal",uiInfo.teamList[i].imageName)); |
| 1563 |
uiInfo.teamList[i].teamIcon_Name = trap_R_RegisterShaderNoMip(va("%s_name", uiInfo.teamList[i].imageName)); |
| 1564 |
} |
| 1565 |
|
| 1566 |
trap_R_SetColor( color ); |
| 1567 |
UI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.teamList[i].teamIcon_Metal ); |
| 1568 |
trap_R_SetColor( NULL ); |
| 1569 |
} |
| 1570 |
|
| 1571 |
static void UI_DrawPlayerLogoName(rectDef_t *rect, vec3_t color) { |
| 1572 |
int i = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_teamName")); |
| 1573 |
if (uiInfo.teamList[i].teamIcon == -1) { |
| 1574 |
uiInfo.teamList[i].teamIcon = trap_R_RegisterShaderNoMip(uiInfo.teamList[i].imageName); |
| 1575 |
uiInfo.teamList[i].teamIcon_Metal = trap_R_RegisterShaderNoMip(va("%s_metal",uiInfo.teamList[i].imageName)); |
| 1576 |
uiInfo.teamList[i].teamIcon_Name = trap_R_RegisterShaderNoMip(va("%s_name", uiInfo.teamList[i].imageName)); |
| 1577 |
} |
| 1578 |
|
| 1579 |
trap_R_SetColor( color ); |
| 1580 |
UI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.teamList[i].teamIcon_Name ); |
| 1581 |
trap_R_SetColor( NULL ); |
| 1582 |
} |
| 1583 |
|
| 1584 |
static void UI_DrawOpponentLogo(rectDef_t *rect, vec3_t color) { |
| 1585 |
int i = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_opponentName")); |
| 1586 |
if (uiInfo.teamList[i].teamIcon == -1) { |
| 1587 |
uiInfo.teamList[i].teamIcon = trap_R_RegisterShaderNoMip(uiInfo.teamList[i].imageName); |
| 1588 |
uiInfo.teamList[i].teamIcon_Metal = trap_R_RegisterShaderNoMip(va("%s_metal",uiInfo.teamList[i].imageName)); |
| 1589 |
uiInfo.teamList[i].teamIcon_Name = trap_R_RegisterShaderNoMip(va("%s_name", uiInfo.teamList[i].imageName)); |
| 1590 |
} |
| 1591 |
|
| 1592 |
trap_R_SetColor( color ); |
| 1593 |
UI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.teamList[i].teamIcon ); |
| 1594 |
trap_R_SetColor( NULL ); |
| 1595 |
} |
| 1596 |
|
| 1597 |
static void UI_DrawOpponentLogoMetal(rectDef_t *rect, vec3_t color) { |
| 1598 |
int i = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_opponentName")); |
| 1599 |
if (uiInfo.teamList[i].teamIcon == -1) { |
| 1600 |
uiInfo.teamList[i].teamIcon = trap_R_RegisterShaderNoMip(uiInfo.teamList[i].imageName); |
| 1601 |
uiInfo.teamList[i].teamIcon_Metal = trap_R_RegisterShaderNoMip(va("%s_metal",uiInfo.teamList[i].imageName)); |
| 1602 |
uiInfo.teamList[i].teamIcon_Name = trap_R_RegisterShaderNoMip(va("%s_name", uiInfo.teamList[i].imageName)); |
| 1603 |
} |
| 1604 |
|
| 1605 |
trap_R_SetColor( color ); |
| 1606 |
UI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.teamList[i].teamIcon_Metal ); |
| 1607 |
trap_R_SetColor( NULL ); |
| 1608 |
} |
| 1609 |
|
| 1610 |
static void UI_DrawOpponentLogoName(rectDef_t *rect, vec3_t color) { |
| 1611 |
int i = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_opponentName")); |
| 1612 |
if (uiInfo.teamList[i].teamIcon == -1) { |
| 1613 |
uiInfo.teamList[i].teamIcon = trap_R_RegisterShaderNoMip(uiInfo.teamList[i].imageName); |
| 1614 |
uiInfo.teamList[i].teamIcon_Metal = trap_R_RegisterShaderNoMip(va("%s_metal",uiInfo.teamList[i].imageName)); |
| 1615 |
uiInfo.teamList[i].teamIcon_Name = trap_R_RegisterShaderNoMip(va("%s_name", uiInfo.teamList[i].imageName)); |
| 1616 |
} |
| 1617 |
|
| 1618 |
trap_R_SetColor( color ); |
| 1619 |
UI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.teamList[i].teamIcon_Name ); |
| 1620 |
trap_R_SetColor( NULL ); |
| 1621 |
} |
| 1622 |
|
| 1623 |
static void UI_DrawAllMapsSelection(rectDef_t *rect, float scale, vec4_t color, int textStyle, qboolean net) { |
| 1624 |
int map = (net) ? ui_currentNetMap.integer : ui_currentMap.integer; |
| 1625 |
if (map >= 0 && map < uiInfo.mapCount) { |
| 1626 |
Text_Paint(rect->x, rect->y, scale, color, uiInfo.mapList[map].mapName, 0, 0, textStyle); |
| 1627 |
} |
| 1628 |
} |
| 1629 |
|
| 1630 |
static void UI_DrawOpponentName(rectDef_t *rect, float scale, vec4_t color, int textStyle) { |
| 1631 |
Text_Paint(rect->x, rect->y, scale, color, UI_Cvar_VariableString("ui_opponentName"), 0, 0, textStyle); |
| 1632 |
} |
| 1633 |
|
| 1634 |
|
| 1635 |
static int UI_OwnerDrawWidth(int ownerDraw, float scale) { |
| 1636 |
int i, h, value; |
| 1637 |
const char *text; |
| 1638 |
const char *s = NULL; |
| 1639 |
|
| 1640 |
switch (ownerDraw) { |
| 1641 |
case UI_HANDICAP: |
| 1642 |
h = Com_Clamp( 5, 100, trap_Cvar_VariableValue("handicap") ); |
| 1643 |
i = 20 - h / 5; |
| 1644 |
s = handicapValues[i]; |
| 1645 |
break; |
| 1646 |
case UI_CLANNAME: |
| 1647 |
s = UI_Cvar_VariableString("ui_teamName"); |
| 1648 |
break; |
| 1649 |
case UI_GAMETYPE: |
| 1650 |
s = uiInfo.gameTypes[ui_gameType.integer].gameType; |
| 1651 |
break; |
| 1652 |
case UI_SKILL: |
| 1653 |
i = trap_Cvar_VariableValue( "g_spSkill" ); |
| 1654 |
if (i < 1 || i > numSkillLevels) { |
| 1655 |
i = 1; |
| 1656 |
} |
| 1657 |
s = skillLevels[i-1]; |
| 1658 |
break; |
| 1659 |
case UI_BLUETEAMNAME: |
| 1660 |
i = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_blueTeam")); |
| 1661 |
if (i >= 0 && i < uiInfo.teamCount) { |
| 1662 |
s = va("%s: %s", "Blue", uiInfo.teamList[i].teamName); |
| 1663 |
} |
| 1664 |
break; |
| 1665 |
case UI_REDTEAMNAME: |
| 1666 |
i = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_redTeam")); |
| 1667 |
if (i >= 0 && i < uiInfo.teamCount) { |
| 1668 |
s = va("%s: %s", "Red", uiInfo.teamList[i].teamName); |
| 1669 |
} |
| 1670 |
break; |
| 1671 |
case UI_BLUETEAM1: |
| 1672 |
case UI_BLUETEAM2: |
| 1673 |
case UI_BLUETEAM3: |
| 1674 |
case UI_BLUETEAM4: |
| 1675 |
case UI_BLUETEAM5: |
| 1676 |
value = trap_Cvar_VariableValue(va("ui_blueteam%i", ownerDraw-UI_BLUETEAM1 + 1)); |
| 1677 |
if (value <= 0) { |
| 1678 |
text = "Closed"; |
| 1679 |
} else if (value == 1) { |
| 1680 |
text = "Human"; |
| 1681 |
} else { |
| 1682 |
value -= 2; |
| 1683 |
if (value >= uiInfo.aliasCount) { |
| 1684 |
value = 0; |
| 1685 |
} |
| 1686 |
text = uiInfo.aliasList[value].name; |
| 1687 |
} |
| 1688 |
s = va("%i. %s", ownerDraw-UI_BLUETEAM1 + 1, text); |
| 1689 |
break; |
| 1690 |
case UI_REDTEAM1: |
| 1691 |
case UI_REDTEAM2: |
| 1692 |
case UI_REDTEAM3: |
| 1693 |
case UI_REDTEAM4: |
| 1694 |
case UI_REDTEAM5: |
| 1695 |
value = trap_Cvar_VariableValue(va("ui_redteam%i", ownerDraw-UI_REDTEAM1 + 1)); |
| 1696 |
if (value <= 0) { |
| 1697 |
text = "Closed"; |
| 1698 |
} else if (value == 1) { |
| 1699 |
text = "Human"; |
| 1700 |
} else { |
| 1701 |
value -= 2; |
| 1702 |
if (value >= uiInfo.aliasCount) { |
| 1703 |
value = 0; |
| 1704 |
} |
| 1705 |
text = uiInfo.aliasList[value].name; |
| 1706 |
} |
| 1707 |
s = va("%i. %s", ownerDraw-UI_REDTEAM1 + 1, text); |
| 1708 |
break; |
| 1709 |
case UI_NETSOURCE: |
| 1710 |
if (ui_netSource.integer < 0 || ui_netSource.integer >= numNetSources) { |
| 1711 |
ui_netSource.integer = 0; |
| 1712 |
} |
| 1713 |
s = va("Source: %s", netSources[ui_netSource.integer]); |
| 1714 |
break; |
| 1715 |
case UI_NETFILTER: |
| 1716 |
if (ui_serverFilterType.integer < 0 || ui_serverFilterType.integer >= numServerFilters) { |
| 1717 |
ui_serverFilterType.integer = 0; |
| 1718 |
} |
| 1719 |
s = va("Filter: %s", serverFilters[ui_serverFilterType.integer].description ); |
| 1720 |
break; |
| 1721 |
case UI_TIER: |
| 1722 |
break; |
| 1723 |
case UI_TIER_MAPNAME: |
| 1724 |
break; |
| 1725 |
case UI_TIER_GAMETYPE: |
| 1726 |
break; |
| 1727 |
case UI_ALLMAPS_SELECTION: |
| 1728 |
break; |
| 1729 |
case UI_OPPONENT_NAME: |
| 1730 |
break; |
| 1731 |
case UI_KEYBINDSTATUS: |
| 1732 |
if (Display_KeyBindPending()) { |
| 1733 |
s = "Waiting for new key... Press ESCAPE to cancel"; |
| 1734 |
} else { |
| 1735 |
s = "Press ENTER or CLICK to change, Press BACKSPACE to clear"; |
| 1736 |
} |
| 1737 |
break; |
| 1738 |
case UI_SERVERREFRESHDATE: |
| 1739 |
s = UI_Cvar_VariableString(va("ui_lastServerRefresh_%i", ui_netSource.integer)); |
| 1740 |
break; |
| 1741 |
default: |
| 1742 |
break; |
| 1743 |
} |
| 1744 |
|
| 1745 |
if (s) { |
| 1746 |
return Text_Width(s, scale, 0); |
| 1747 |
} |
| 1748 |
return 0; |
| 1749 |
} |
| 1750 |
|
| 1751 |
static void UI_DrawBotName(rectDef_t *rect, float scale, vec4_t color, int textStyle) { |
| 1752 |
int value = uiInfo.botIndex; |
| 1753 |
int game = trap_Cvar_VariableValue("g_gametype"); |
| 1754 |
const char *text; |
| 1755 |
if (game >= GT_TEAM) { |
| 1756 |
text = uiInfo.characterList[value].name; |
| 1757 |
} else { |
| 1758 |
text = UI_GetBotNameByNumber(value); |
| 1759 |
} |
| 1760 |
Text_Paint(rect->x, rect->y, scale, color, text, 0, 0, textStyle); |
| 1761 |
} |
| 1762 |
|
| 1763 |
static void UI_DrawBotSkill(rectDef_t *rect, float scale, vec4_t color, int textStyle) { |
| 1764 |
if (uiInfo.skillIndex >= 0 && uiInfo.skillIndex < numSkillLevels) { |
| 1765 |
Text_Paint(rect->x, rect->y, scale, color, skillLevels[uiInfo.skillIndex], 0, 0, textStyle); |
| 1766 |
} |
| 1767 |
} |
| 1768 |
|
| 1769 |
static void UI_DrawRedBlue(rectDef_t *rect, float scale, vec4_t color, int textStyle) { |
| 1770 |
Text_Paint(rect->x, rect->y, scale, color, (uiInfo.redBlue == 0) ? "Red" : "Blue", 0, 0, textStyle); |
| 1771 |
} |
| 1772 |
|
| 1773 |
static void UI_DrawCrosshair(rectDef_t *rect, float scale, vec4_t color) { |
| 1774 |
if (!uiInfo.currentCrosshair) { |
| 1775 |
return; |
| 1776 |
} |
| 1777 |
trap_R_SetColor( color ); |
| 1778 |
UI_DrawHandlePic( rect->x, rect->y - rect->h, rect->w, rect->h, uiInfo.uiDC.Assets.crosshairShader[uiInfo.currentCrosshair]); |
| 1779 |
trap_R_SetColor( NULL ); |
| 1780 |
} |
| 1781 |
|
| 1782 |
|
| 1783 |
|
| 1784 |
|
| 1785 |
|
| 1786 |
|
| 1787 |
static void UI_BuildPlayerList( void ) { |
| 1788 |
uiClientState_t cs; |
| 1789 |
int n, count, team, team2, playerTeamNumber; |
| 1790 |
char info[MAX_INFO_STRING]; |
| 1791 |
|
| 1792 |
trap_GetClientState( &cs ); |
| 1793 |
trap_GetConfigString( CS_PLAYERS + cs.clientNum, info, MAX_INFO_STRING ); |
| 1794 |
uiInfo.playerNumber = cs.clientNum; |
| 1795 |
uiInfo.teamLeader = atoi(Info_ValueForKey(info, "tl")); |
| 1796 |
team = atoi(Info_ValueForKey(info, "t")); |
| 1797 |
trap_GetConfigString( CS_SERVERINFO, info, sizeof(info) ); |
| 1798 |
count = atoi( Info_ValueForKey( info, "sv_maxclients" ) ); |
| 1799 |
uiInfo.playerCount = 0; |
| 1800 |
uiInfo.myTeamCount = 0; |
| 1801 |
playerTeamNumber = 0; |
| 1802 |
for( n = 0; n < count; n++ ) { |
| 1803 |
trap_GetConfigString( CS_PLAYERS + n, info, MAX_INFO_STRING ); |
| 1804 |
|
| 1805 |
if (info[0]) { |
| 1806 |
Q_strncpyz( uiInfo.playerNames[uiInfo.playerCount], Info_ValueForKey( info, "n" ), MAX_NAME_LENGTH ); |
| 1807 |
Q_CleanStr( uiInfo.playerNames[uiInfo.playerCount] ); |
| 1808 |
uiInfo.playerCount++; |
| 1809 |
team2 = atoi(Info_ValueForKey(info, "t")); |
| 1810 |
if (team2 == team) { |
| 1811 |
Q_strncpyz( uiInfo.teamNames[uiInfo.myTeamCount], Info_ValueForKey( info, "n" ), MAX_NAME_LENGTH ); |
| 1812 |
Q_CleanStr( uiInfo.teamNames[uiInfo.myTeamCount] ); |
| 1813 |
uiInfo.teamClientNums[uiInfo.myTeamCount] = n; |
| 1814 |
if (uiInfo.playerNumber == n) { |
| 1815 |
playerTeamNumber = uiInfo.myTeamCount; |
| 1816 |
} |
| 1817 |
uiInfo.myTeamCount++; |
| 1818 |
} |
| 1819 |
} |
| 1820 |
} |
| 1821 |
|
| 1822 |
if (!uiInfo.teamLeader) { |
| 1823 |
trap_Cvar_Set("cg_selectedPlayer", va("%d", playerTeamNumber)); |
| 1824 |
} |
| 1825 |
|
| 1826 |
n = trap_Cvar_VariableValue("cg_selectedPlayer"); |
| 1827 |
if (n < 0 || n > uiInfo.myTeamCount) { |
| 1828 |
n = 0; |
| 1829 |
} |
| 1830 |
if (n < uiInfo.myTeamCount) { |
| 1831 |
trap_Cvar_Set("cg_selectedPlayerName", uiInfo.teamNames[n]); |
| 1832 |
} |
| 1833 |
} |
| 1834 |
|
| 1835 |
|
| 1836 |
static void UI_DrawSelectedPlayer(rectDef_t *rect, float scale, vec4_t color, int textStyle) { |
| 1837 |
if (uiInfo.uiDC.realTime > uiInfo.playerRefresh) { |
| 1838 |
uiInfo.playerRefresh = uiInfo.uiDC.realTime + 3000; |
| 1839 |
UI_BuildPlayerList(); |
| 1840 |
} |
| 1841 |
Text_Paint(rect->x, rect->y, scale, color, (uiInfo.teamLeader) ? UI_Cvar_VariableString("cg_selectedPlayerName") : UI_Cvar_VariableString("name") , 0, 0, textStyle); |
| 1842 |
} |
| 1843 |
|
| 1844 |
static void UI_DrawServerRefreshDate(rectDef_t *rect, float scale, vec4_t color, int textStyle) { |
| 1845 |
if (uiInfo.serverStatus.refreshActive) { |
| 1846 |
vec4_t lowLight, newColor; |
| 1847 |
lowLight[0] = 0.8 * color[0]; |
| 1848 |
lowLight[1] = 0.8 * color[1]; |
| 1849 |
lowLight[2] = 0.8 * color[2]; |
| 1850 |
lowLight[3] = 0.8 * color[3]; |
| 1851 |
LerpColor(color,lowLight,newColor,0.5+0.5*sin(uiInfo.uiDC.realTime / PULSE_DIVISOR)); |
| 1852 |
Text_Paint(rect->x, rect->y, scale, newColor, va("Getting info for %d servers (ESC to cancel)", trap_LAN_GetServerCount(UI_SourceForLAN())), 0, 0, textStyle); |
| 1853 |
} else { |
| 1854 |
char buff[64]; |
| 1855 |
Q_strncpyz(buff, UI_Cvar_VariableString(va("ui_lastServerRefresh_%i", ui_netSource.integer)), 64); |
| 1856 |
Text_Paint(rect->x, rect->y, scale, color, va("Refresh Time: %s", buff), 0, 0, textStyle); |
| 1857 |
} |
| 1858 |
} |
| 1859 |
|
| 1860 |
static void UI_DrawServerMOTD(rectDef_t *rect, float scale, vec4_t color) { |
| 1861 |
if (uiInfo.serverStatus.motdLen) { |
| 1862 |
float maxX; |
| 1863 |
|
| 1864 |
if (uiInfo.serverStatus.motdWidth == -1) { |
| 1865 |
uiInfo.serverStatus.motdWidth = 0; |
| 1866 |
uiInfo.serverStatus.motdPaintX = rect->x + 1; |
| 1867 |
uiInfo.serverStatus.motdPaintX2 = -1; |
| 1868 |
} |
| 1869 |
|
| 1870 |
if (uiInfo.serverStatus.motdOffset > uiInfo.serverStatus.motdLen) { |
| 1871 |
uiInfo.serverStatus.motdOffset = 0; |
| 1872 |
uiInfo.serverStatus.motdPaintX = rect->x + 1; |
| 1873 |
uiInfo.serverStatus.motdPaintX2 = -1; |
| 1874 |
} |
| 1875 |
|
| 1876 |
if (uiInfo.uiDC.realTime > uiInfo.serverStatus.motdTime) { |
| 1877 |
uiInfo.serverStatus.motdTime = uiInfo.uiDC.realTime + 10; |
| 1878 |
if (uiInfo.serverStatus.motdPaintX <= rect->x + 2) { |
| 1879 |
if (uiInfo.serverStatus.motdOffset < uiInfo.serverStatus.motdLen) { |
| 1880 |
uiInfo.serverStatus.motdPaintX += Text_Width(&uiInfo.serverStatus.motd[uiInfo.serverStatus.motdOffset], scale, 1) - 1; |
| 1881 |
uiInfo.serverStatus.motdOffset++; |
| 1882 |
} else { |
| 1883 |
uiInfo.serverStatus.motdOffset = 0; |
| 1884 |
if (uiInfo.serverStatus.motdPaintX2 >= 0) { |
| 1885 |
uiInfo.serverStatus.motdPaintX = uiInfo.serverStatus.motdPaintX2; |
| 1886 |
} else { |
| 1887 |
uiInfo.serverStatus.motdPaintX = rect->x + rect->w - 2; |
| 1888 |
} |
| 1889 |
uiInfo.serverStatus.motdPaintX2 = -1; |
| 1890 |
} |
| 1891 |
} else { |
| 1892 |
|
| 1893 |
uiInfo.serverStatus.motdPaintX -= 2; |
| 1894 |
if (uiInfo.serverStatus.motdPaintX2 >= 0) { |
| 1895 |
|
| 1896 |
uiInfo.serverStatus.motdPaintX2 -= 2; |
| 1897 |
} |
| 1898 |
} |
| 1899 |
} |
| 1900 |
|
| 1901 |
maxX = rect->x + rect->w - 2; |
| 1902 |
Text_Paint_Limit(&maxX, uiInfo.serverStatus.motdPaintX, rect->y + rect->h - 3, scale, color, &uiInfo.serverStatus.motd[uiInfo.serverStatus.motdOffset], 0, 0); |
| 1903 |
if (uiInfo.serverStatus.motdPaintX2 >= 0) { |
| 1904 |
float maxX2 = rect->x + rect->w - 2; |
| 1905 |
Text_Paint_Limit(&maxX2, uiInfo.serverStatus.motdPaintX2, rect->y + rect->h - 3, scale, color, uiInfo.serverStatus.motd, 0, uiInfo.serverStatus.motdOffset); |
| 1906 |
} |
| 1907 |
if (uiInfo.serverStatus.motdOffset && maxX > 0) { |
| 1908 |
|
| 1909 |
if (uiInfo.serverStatus.motdPaintX2 == -1) { |
| 1910 |
uiInfo.serverStatus.motdPaintX2 = rect->x + rect->w - 2; |
| 1911 |
} |
| 1912 |
} else { |
| 1913 |
uiInfo.serverStatus.motdPaintX2 = -1; |
| 1914 |
} |
| 1915 |
|
| 1916 |
} |
| 1917 |
} |
| 1918 |
|
| 1919 |
static void UI_DrawKeyBindStatus(rectDef_t *rect, float scale, vec4_t color, int textStyle) { |
| 1920 |
|
| 1921 |
if (Display_KeyBindPending()) { |
| 1922 |
Text_Paint(rect->x, rect->y, scale, color, "Waiting for new key... Press ESCAPE to cancel", 0, 0, textStyle); |
| 1923 |
} else { |
| 1924 |
Text_Paint(rect->x, rect->y, scale, color, "Press ENTER or CLICK to change, Press BACKSPACE to clear", 0, 0, textStyle); |
| 1925 |
} |
| 1926 |
} |
| 1927 |
|
| 1928 |
static void UI_DrawGLInfo(rectDef_t *rect, float scale, vec4_t color, int textStyle) { |
| 1929 |
char * eptr; |
| 1930 |
char buff[1024]; |
| 1931 |
const char *lines[64]; |
| 1932 |
int y, numLines, i; |
| 1933 |
|
| 1934 |
Text_Paint(rect->x + 2, rect->y, scale, color, va("VENDOR: %s", uiInfo.uiDC.glconfig.vendor_string), 0, 30, textStyle); |
| 1935 |
Text_Paint(rect->x + 2, rect->y + 15, scale, color, va("VERSION: %s: %s", uiInfo.uiDC.glconfig.version_string,uiInfo.uiDC.glconfig.renderer_string), 0, 30, textStyle); |
| 1936 |
Text_Paint(rect->x + 2, rect->y + 30, scale, color, va ("PIXELFORMAT: color(%d-bits) Z(%d-bits) stencil(%d-bits)", uiInfo.uiDC.glconfig.colorBits, uiInfo.uiDC.glconfig.depthBits, uiInfo.uiDC.glconfig.stencilBits), 0, 30, textStyle); |
| 1937 |
|
| 1938 |
|
| 1939 |
|
| 1940 |
|
| 1941 |
|
| 1942 |
Q_strncpyz(buff, uiInfo.uiDC.glconfig.extensions_string, 1024); |
| 1943 |
eptr = buff; |
| 1944 |
y = rect->y + 45; |
| 1945 |
numLines = 0; |
| 1946 |
while ( y < rect->y + rect->h && *eptr ) |
| 1947 |
{ |
| 1948 |
while ( *eptr && *eptr == ' ' ) |
| 1949 |
*eptr++ = '\0'; |
| 1950 |
|
| 1951 |
|
| 1952 |
if (*eptr && *eptr != ' ') { |
| 1953 |
lines[numLines++] = eptr; |
| 1954 |
} |
| 1955 |
|
| 1956 |
while ( *eptr && *eptr != ' ' ) |
| 1957 |
eptr++; |
| 1958 |
} |
| 1959 |
|
| 1960 |
i = 0; |
| 1961 |
while (i < numLines) { |
| 1962 |
Text_Paint(rect->x + 2, y, scale, color, lines[i++], 0, 20, textStyle); |
| 1963 |
if (i < numLines) { |
| 1964 |
Text_Paint(rect->x + rect->w / 2, y, scale, color, lines[i++], 0, 20, textStyle); |
| 1965 |
} |
| 1966 |
y += 10; |
| 1967 |
if (y > rect->y + rect->h - 11) { |
| 1968 |
break; |
| 1969 |
} |
| 1970 |
} |
| 1971 |
|
| 1972 |
|
| 1973 |
} |
| 1974 |
|
| 1975 |
|
| 1976 |
|
| 1977 |
static void UI_OwnerDraw(float x, float y, float w, float h, float text_x, float text_y, int ownerDraw, int ownerDrawFlags, int align, float special, float scale, vec4_t color, qhandle_t shader, int textStyle) { |
| 1978 |
rectDef_t rect; |
| 1979 |
|
| 1980 |
rect.x = x + text_x; |
| 1981 |
rect.y = y + text_y; |
| 1982 |
rect.w = w; |
| 1983 |
rect.h = h; |
| 1984 |
|
| 1985 |
switch (ownerDraw) { |
| 1986 |
case UI_HANDICAP: |
| 1987 |
UI_DrawHandicap(&rect, scale, color, textStyle); |
| 1988 |
break; |
| 1989 |
case UI_EFFECTS: |
| 1990 |
UI_DrawEffects(&rect, scale, color); |
| 1991 |
break; |
| 1992 |
case UI_PLAYERMODEL: |
| 1993 |
UI_DrawPlayerModel(&rect); |
| 1994 |
break; |
| 1995 |
case UI_CLANNAME: |
| 1996 |
UI_DrawClanName(&rect, scale, color, textStyle); |
| 1997 |
break; |
| 1998 |
case UI_CLANLOGO: |
| 1999 |
UI_DrawClanLogo(&rect, scale, color); |
| 2000 |
break; |
| 2001 |
case UI_CLANCINEMATIC: |
| 2002 |
UI_DrawClanCinematic(&rect, scale, color); |
| 2003 |
break; |
| 2004 |
case UI_PREVIEWCINEMATIC: |
| 2005 |
UI_DrawPreviewCinematic(&rect, scale, color); |
| 2006 |
break; |
| 2007 |
case UI_GAMETYPE: |
| 2008 |
UI_DrawGameType(&rect, scale, color, textStyle); |
| 2009 |
break; |
| 2010 |
case UI_NETGAMETYPE: |
| 2011 |
UI_DrawNetGameType(&rect, scale, color, textStyle); |
| 2012 |
break; |
| 2013 |
case UI_JOINGAMETYPE: |
| 2014 |
UI_DrawJoinGameType(&rect, scale, color, textStyle); |
| 2015 |
break; |
| 2016 |
case UI_MAPPREVIEW: |
| 2017 |
UI_DrawMapPreview(&rect, scale, color, qtrue); |
| 2018 |
break; |
| 2019 |
case UI_MAP_TIMETOBEAT: |
| 2020 |
UI_DrawMapTimeToBeat(&rect, scale, color, textStyle); |
| 2021 |
break; |
| 2022 |
case UI_MAPCINEMATIC: |
| 2023 |
UI_DrawMapCinematic(&rect, scale, color, qfalse); |
| 2024 |
break; |
| 2025 |
case UI_STARTMAPCINEMATIC: |
| 2026 |
UI_DrawMapCinematic(&rect, scale, color, qtrue); |
| 2027 |
break; |
| 2028 |
case UI_SKILL: |
| 2029 |
UI_DrawSkill(&rect, scale, color, textStyle); |
| 2030 |
break; |
| 2031 |
case UI_BLUETEAMNAME: |
| 2032 |
UI_DrawTeamName(&rect, scale, color, qtrue, textStyle); |
| 2033 |
break; |
| 2034 |
case UI_REDTEAMNAME: |
| 2035 |
UI_DrawTeamName(&rect, scale, color, qfalse, textStyle); |
| 2036 |
break; |
| 2037 |
case UI_BLUETEAM1: |
| 2038 |
case UI_BLUETEAM2: |
| 2039 |
case UI_BLUETEAM3: |
| 2040 |
case UI_BLUETEAM4: |
| 2041 |
case UI_BLUETEAM5: |
| 2042 |
UI_DrawTeamMember(&rect, scale, color, qtrue, ownerDraw - UI_BLUETEAM1 + 1, textStyle); |
| 2043 |
break; |
| 2044 |
case UI_REDTEAM1: |
| 2045 |
case UI_REDTEAM2: |
| 2046 |
case UI_REDTEAM3: |
| 2047 |
case UI_REDTEAM4: |
| 2048 |
case UI_REDTEAM5: |
| 2049 |
UI_DrawTeamMember(&rect, scale, color, qfalse, ownerDraw - UI_REDTEAM1 + 1, textStyle); |
| 2050 |
break; |
| 2051 |
case UI_NETSOURCE: |
| 2052 |
UI_DrawNetSource(&rect, scale, color, textStyle); |
| 2053 |
break; |
| 2054 |
case UI_NETMAPPREVIEW: |
| 2055 |
UI_DrawNetMapPreview(&rect, scale, color); |
| 2056 |
break; |
| 2057 |
case UI_NETMAPCINEMATIC: |
| 2058 |
UI_DrawNetMapCinematic(&rect, scale, color); |
| 2059 |
break; |
| 2060 |
case UI_NETFILTER: |
| 2061 |
UI_DrawNetFilter(&rect, scale, color, textStyle); |
| 2062 |
break; |
| 2063 |
case UI_TIER: |
| 2064 |
UI_DrawTier(&rect, scale, color, textStyle); |
| 2065 |
break; |
| 2066 |
case UI_OPPONENTMODEL: |
| 2067 |
UI_DrawOpponent(&rect); |
| 2068 |
break; |
| 2069 |
case UI_TIERMAP1: |
| 2070 |
UI_DrawTierMap(&rect, 0); |
| 2071 |
break; |
| 2072 |
case UI_TIERMAP2: |
| 2073 |
UI_DrawTierMap(&rect, 1); |
| 2074 |
break; |
| 2075 |
case UI_TIERMAP3: |
| 2076 |
UI_DrawTierMap(&rect, 2); |
| 2077 |
break; |
| 2078 |
case UI_PLAYERLOGO: |
| 2079 |
UI_DrawPlayerLogo(&rect, color); |
| 2080 |
break; |
| 2081 |
case UI_PLAYERLOGO_METAL: |
| 2082 |
UI_DrawPlayerLogoMetal(&rect, color); |
| 2083 |
break; |
| 2084 |
case UI_PLAYERLOGO_NAME: |
| 2085 |
UI_DrawPlayerLogoName(&rect, color); |
| 2086 |
break; |
| 2087 |
case UI_OPPONENTLOGO: |
| 2088 |
UI_DrawOpponentLogo(&rect, color); |
| 2089 |
break; |
| 2090 |
case UI_OPPONENTLOGO_METAL: |
| 2091 |
UI_DrawOpponentLogoMetal(&rect, color); |
| 2092 |
break; |
| 2093 |
case UI_OPPONENTLOGO_NAME: |
| 2094 |
UI_DrawOpponentLogoName(&rect, color); |
| 2095 |
break; |
| 2096 |
case UI_TIER_MAPNAME: |
| 2097 |
UI_DrawTierMapName(&rect, scale, color, textStyle); |
| 2098 |
break; |
| 2099 |
case UI_TIER_GAMETYPE: |
| 2100 |
UI_DrawTierGameType(&rect, scale, color, textStyle); |
| 2101 |
break; |
| 2102 |
case UI_ALLMAPS_SELECTION: |
| 2103 |
UI_DrawAllMapsSelection(&rect, scale, color, textStyle, qtrue); |
| 2104 |
break; |
| 2105 |
case UI_MAPS_SELECTION: |
| 2106 |
UI_DrawAllMapsSelection(&rect, scale, color, textStyle, qfalse); |
| 2107 |
break; |
| 2108 |
case UI_OPPONENT_NAME: |
| 2109 |
UI_DrawOpponentName(&rect, scale, color, textStyle); |
| 2110 |
break; |
| 2111 |
case UI_BOTNAME: |
| 2112 |
UI_DrawBotName(&rect, scale, color, textStyle); |
| 2113 |
break; |
| 2114 |
case UI_BOTSKILL: |
| 2115 |
UI_DrawBotSkill(&rect, scale, color, textStyle); |
| 2116 |
break; |
| 2117 |
case UI_REDBLUE: |
| 2118 |
UI_DrawRedBlue(&rect, scale, color, textStyle); |
| 2119 |
break; |
| 2120 |
case UI_CROSSHAIR: |
| 2121 |
UI_DrawCrosshair(&rect, scale, color); |
| 2122 |
break; |
| 2123 |
case UI_SELECTEDPLAYER: |
| 2124 |
UI_DrawSelectedPlayer(&rect, scale, color, textStyle); |
| 2125 |
break; |
| 2126 |
case UI_SERVERREFRESHDATE: |
| 2127 |
UI_DrawServerRefreshDate(&rect, scale, color, textStyle); |
| 2128 |
break; |
| 2129 |
case UI_SERVERMOTD: |
| 2130 |
UI_DrawServerMOTD(&rect, scale, color); |
| 2131 |
break; |
| 2132 |
case UI_GLINFO: |
| 2133 |
UI_DrawGLInfo(&rect,scale, color, textStyle); |
| 2134 |
break; |
| 2135 |
case UI_KEYBINDSTATUS: |
| 2136 |
UI_DrawKeyBindStatus(&rect,scale, color, textStyle); |
| 2137 |
break; |
| 2138 |
default: |
| 2139 |
break; |
| 2140 |
} |
| 2141 |
|
| 2142 |
} |
| 2143 |
|
| 2144 |
static qboolean UI_OwnerDrawVisible(int flags) { |
| 2145 |
qboolean vis = qtrue; |
| 2146 |
|
| 2147 |
while (flags) { |
| 2148 |
|
| 2149 |
if (flags & UI_SHOW_FFA) { |
| 2150 |
if (trap_Cvar_VariableValue("g_gametype") != GT_FFA) { |
| 2151 |
vis = qfalse; |
| 2152 |
} |
| 2153 |
flags &= ~UI_SHOW_FFA; |
| 2154 |
} |
| 2155 |
|
| 2156 |
if (flags & UI_SHOW_NOTFFA) { |
| 2157 |
if (trap_Cvar_VariableValue("g_gametype") == GT_FFA) { |
| 2158 |
vis = qfalse; |
| 2159 |
} |
| 2160 |
flags &= ~UI_SHOW_NOTFFA; |
| 2161 |
} |
| 2162 |
|
| 2163 |
if (flags & UI_SHOW_LEADER) { |
| 2164 |
|
| 2165 |
if (!uiInfo.teamLeader) { |
| 2166 |
vis = qfalse; |
| 2167 |
} else { |
| 2168 |
|
| 2169 |
if (ui_selectedPlayer.integer < uiInfo.myTeamCount && uiInfo.teamClientNums[ui_selectedPlayer.integer] == uiInfo.playerNumber) { |
| 2170 |
vis = qfalse; |
| 2171 |
} |
| 2172 |
} |
| 2173 |
flags &= ~UI_SHOW_LEADER; |
| 2174 |
} |
| 2175 |
if (flags & UI_SHOW_NOTLEADER) { |
| 2176 |
|
| 2177 |
if (uiInfo.teamLeader) { |
| 2178 |
|
| 2179 |
if (!(ui_selectedPlayer.integer < uiInfo.myTeamCount && uiInfo.teamClientNums[ui_selectedPlayer.integer] == uiInfo.playerNumber)) { |
| 2180 |
vis = qfalse; |
| 2181 |
} |
| 2182 |
|
| 2183 |
} |
| 2184 |
flags &= ~UI_SHOW_NOTLEADER; |
| 2185 |
} |
| 2186 |
if (flags & UI_SHOW_FAVORITESERVERS) { |
| 2187 |
|
| 2188 |
if (ui_netSource.integer != UIAS_FAVORITES) { |
| 2189 |
vis = qfalse; |
| 2190 |
} |
| 2191 |
flags &= ~UI_SHOW_FAVORITESERVERS; |
| 2192 |
} |
| 2193 |
if (flags & UI_SHOW_NOTFAVORITESERVERS) { |
| 2194 |
|
| 2195 |
if (ui_netSource.integer == UIAS_FAVORITES) { |
| 2196 |
vis = qfalse; |
| 2197 |
} |
| 2198 |
flags &= ~UI_SHOW_NOTFAVORITESERVERS; |
| 2199 |
} |
| 2200 |
if (flags & UI_SHOW_ANYTEAMGAME) { |
| 2201 |
if (uiInfo.gameTypes[ui_gameType.integer].gtEnum <= GT_TEAM ) { |
| 2202 |
vis = qfalse; |
| 2203 |
} |
| 2204 |
flags &= ~UI_SHOW_ANYTEAMGAME; |
| 2205 |
} |
| 2206 |
if (flags & UI_SHOW_ANYNONTEAMGAME) { |
| 2207 |
if (uiInfo.gameTypes[ui_gameType.integer].gtEnum > GT_TEAM ) { |
| 2208 |
vis = qfalse; |
| 2209 |
} |
| 2210 |
flags &= ~UI_SHOW_ANYNONTEAMGAME; |
| 2211 |
} |
| 2212 |
if (flags & UI_SHOW_NETANYTEAMGAME) { |
| 2213 |
if (uiInfo.gameTypes[ui_netGameType.integer].gtEnum <= GT_TEAM ) { |
| 2214 |
vis = qfalse; |
| 2215 |
} |
| 2216 |
flags &= ~UI_SHOW_NETANYTEAMGAME; |
| 2217 |
} |
| 2218 |
if (flags & UI_SHOW_NETANYNONTEAMGAME) { |
| 2219 |
if (uiInfo.gameTypes[ui_netGameType.integer].gtEnum > GT_TEAM ) { |
| 2220 |
vis = qfalse; |
| 2221 |
} |
| 2222 |
flags &= ~UI_SHOW_NETANYNONTEAMGAME; |
| 2223 |
} |
| 2224 |
if (flags & UI_SHOW_NEWHIGHSCORE) { |
| 2225 |
if (uiInfo.newHighScoreTime < uiInfo.uiDC.realTime) { |
| 2226 |
vis = qfalse; |
| 2227 |
} else { |
| 2228 |
if (uiInfo.soundHighScore) { |
| 2229 |
if (trap_Cvar_VariableValue("sv_killserver") == 0) { |
| 2230 |
|
| 2231 |
trap_S_StartLocalSound(uiInfo.newHighScoreSound, CHAN_ANNOUNCER); |
| 2232 |
uiInfo.soundHighScore = qfalse; |
| 2233 |
} |
| 2234 |
} |
| 2235 |
} |
| 2236 |
flags &= ~UI_SHOW_NEWHIGHSCORE; |
| 2237 |
} |
| 2238 |
if (flags & UI_SHOW_NEWBESTTIME) { |
| 2239 |
if (uiInfo.newBestTime < uiInfo.uiDC.realTime) { |
| 2240 |
vis = qfalse; |
| 2241 |
} |
| 2242 |
flags &= ~UI_SHOW_NEWBESTTIME; |
| 2243 |
} |
| 2244 |
if (flags & UI_SHOW_DEMOAVAILABLE) { |
| 2245 |
if (!uiInfo.demoAvailable) { |
| 2246 |
vis = qfalse; |
| 2247 |
} |
| 2248 |
flags &= ~UI_SHOW_DEMOAVAILABLE; |
| 2249 |
} else { |
| 2250 |
flags = 0; |
| 2251 |
} |
| 2252 |
} |
| 2253 |
return vis; |
| 2254 |
} |
| 2255 |
|
| 2256 |
static qboolean UI_Handicap_HandleKey(int flags, float *special, int key) { |
| 2257 |
int select = UI_SelectForKey(key); |
| 2258 |
if (select != 0) { |
| 2259 |
int h; |
| 2260 |
|
| 2261 |
h = Com_Clamp( 5, 100, trap_Cvar_VariableValue("handicap") ); |
| 2262 |
h += 5 * select; |
| 2263 |
|
| 2264 |
if (h > 100) { |
| 2265 |
h = 5; |
| 2266 |
} else if (h < 5) { |
| 2267 |
h = 100; |
| 2268 |
} |
| 2269 |
|
| 2270 |
trap_Cvar_SetValue( "handicap", h ); |
| 2271 |
return qtrue; |
| 2272 |
} |
| 2273 |
return qfalse; |
| 2274 |
} |
| 2275 |
|
| 2276 |
static qboolean UI_Effects_HandleKey(int flags, float *special, int key) { |
| 2277 |
int select = UI_SelectForKey(key); |
| 2278 |
if (select != 0) { |
| 2279 |
uiInfo.effectsColor += select; |
| 2280 |
|
| 2281 |
if( uiInfo.effectsColor > 6 ) { |
| 2282 |
uiInfo.effectsColor = 0; |
| 2283 |
} else if (uiInfo.effectsColor < 0) { |
| 2284 |
uiInfo.effectsColor = 6; |
| 2285 |
} |
| 2286 |
|
| 2287 |
trap_Cvar_SetValue( "color1", uitogamecode[uiInfo.effectsColor] ); |
| 2288 |
return qtrue; |
| 2289 |
} |
| 2290 |
return qfalse; |
| 2291 |
} |
| 2292 |
|
| 2293 |
static qboolean UI_ClanName_HandleKey(int flags, float *special, int key) { |
| 2294 |
int select = UI_SelectForKey(key); |
| 2295 |
if (select != 0) { |
| 2296 |
int i; |
| 2297 |
|
| 2298 |
i = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_teamName")); |
| 2299 |
|
| 2300 |
if (uiInfo.teamList[i].cinematic >= 0) { |
| 2301 |
trap_CIN_StopCinematic(uiInfo.teamList[i].cinematic); |
| 2302 |
uiInfo.teamList[i].cinematic = -1; |
| 2303 |
} |
| 2304 |
|
| 2305 |
i += select; |
| 2306 |
|
| 2307 |
if (i >= uiInfo.teamCount) { |
| 2308 |
i = 0; |
| 2309 |
} else if (i < 0) { |
| 2310 |
i = uiInfo.teamCount - 1; |
| 2311 |
} |
| 2312 |
|
| 2313 |
trap_Cvar_Set( "ui_teamName", uiInfo.teamList[i].teamName); |
| 2314 |
UI_HeadCountByTeam(); |
| 2315 |
UI_FeederSelection(FEEDER_HEADS, 0); |
| 2316 |
updateModel = qtrue; |
| 2317 |
return qtrue; |
| 2318 |
} |
| 2319 |
return qfalse; |
| 2320 |
} |
| 2321 |
|
| 2322 |
static qboolean UI_GameType_HandleKey(int flags, float *special, int key, qboolean resetMap) { |
| 2323 |
int select = UI_SelectForKey(key); |
| 2324 |
if (select != 0) { |
| 2325 |
int oldCount = UI_MapCountByGameType(qtrue); |
| 2326 |
|
| 2327 |
|
| 2328 |
if (select < 0) { |
| 2329 |
ui_gameType.integer--; |
| 2330 |
if (ui_gameType.integer == 2) { |
| 2331 |
ui_gameType.integer = 1; |
| 2332 |
} else if (ui_gameType.integer < 2) { |
| 2333 |
ui_gameType.integer = uiInfo.numGameTypes - 1; |
| 2334 |
} |
| 2335 |
} else { |
| 2336 |
ui_gameType.integer++; |
| 2337 |
if (ui_gameType.integer >= uiInfo.numGameTypes) { |
| 2338 |
ui_gameType.integer = 1; |
| 2339 |
} else if (ui_gameType.integer == 2) { |
| 2340 |
ui_gameType.integer = 3; |
| 2341 |
} |
| 2342 |
} |
| 2343 |
|
| 2344 |
if (uiInfo.gameTypes[ui_gameType.integer].gtEnum < GT_TEAM) { |
| 2345 |
trap_Cvar_SetValue( "ui_Q3Model", 1 ); |
| 2346 |
} else { |
| 2347 |
trap_Cvar_SetValue( "ui_Q3Model", 0 ); |
| 2348 |
} |
| 2349 |
|
| 2350 |
trap_Cvar_SetValue("ui_gameType", ui_gameType.integer); |
| 2351 |
UI_SetCapFragLimits(qtrue); |
| 2352 |
UI_LoadBestScores(uiInfo.mapList[ui_currentMap.integer].mapLoadName, uiInfo.gameTypes[ui_gameType.integer].gtEnum); |
| 2353 |
if (resetMap && oldCount != UI_MapCountByGameType(qtrue)) { |
| 2354 |
trap_Cvar_SetValue( "ui_currentMap", 0); |
| 2355 |
Menu_SetFeederSelection(NULL, FEEDER_MAPS, 0, NULL); |
| 2356 |
} |
| 2357 |
return qtrue; |
| 2358 |
} |
| 2359 |
return qfalse; |
| 2360 |
} |
| 2361 |
|
| 2362 |
static qboolean UI_NetGameType_HandleKey(int flags, float *special, int key) { |
| 2363 |
int select = UI_SelectForKey(key); |
| 2364 |
if (select != 0) { |
| 2365 |
ui_netGameType.integer += select; |
| 2366 |
|
| 2367 |
if (ui_netGameType.integer < 0) { |
| 2368 |
ui_netGameType.integer = uiInfo.numGameTypes - 1; |
| 2369 |
} else if (ui_netGameType.integer >= uiInfo.numGameTypes) { |
| 2370 |
ui_netGameType.integer = 0; |
| 2371 |
} |
| 2372 |
|
| 2373 |
trap_Cvar_SetValue( "ui_netGameType", ui_netGameType.integer); |
| 2374 |
trap_Cvar_SetValue( "ui_actualnetGameType", uiInfo.gameTypes[ui_netGameType.integer].gtEnum); |
| 2375 |
trap_Cvar_SetValue( "ui_currentNetMap", 0); |
| 2376 |
UI_MapCountByGameType(qfalse); |
| 2377 |
Menu_SetFeederSelection(NULL, FEEDER_ALLMAPS, 0, NULL); |
| 2378 |
return qtrue; |
| 2379 |
} |
| 2380 |
return qfalse; |
| 2381 |
} |
| 2382 |
|
| 2383 |
static qboolean UI_JoinGameType_HandleKey(int flags, float *special, int key) { |
| 2384 |
int select = UI_SelectForKey(key); |
| 2385 |
if (select != 0) { |
| 2386 |
ui_joinGameType.integer += select; |
| 2387 |
|
| 2388 |
if (ui_joinGameType.integer < 0) { |
| 2389 |
ui_joinGameType.integer = uiInfo.numJoinGameTypes - 1; |
| 2390 |
} else if (ui_joinGameType.integer >= uiInfo.numJoinGameTypes) { |
| 2391 |
ui_joinGameType.integer = 0; |
| 2392 |
} |
| 2393 |
|
| 2394 |
trap_Cvar_SetValue( "ui_joinGameType", ui_joinGameType.integer); |
| 2395 |
UI_BuildServerDisplayList(qtrue); |
| 2396 |
return qtrue; |
| 2397 |
} |
| 2398 |
return qfalse; |
| 2399 |
} |
| 2400 |
|
| 2401 |
|
| 2402 |
|
| 2403 |
static qboolean UI_Skill_HandleKey(int flags, float *special, int key) { |
| 2404 |
int select = UI_SelectForKey(key); |
| 2405 |
if (select != 0) { |
| 2406 |
int i = trap_Cvar_VariableValue( "g_spSkill" ); |
| 2407 |
|
| 2408 |
i += select; |
| 2409 |
|
| 2410 |
if (i < 1) { |
| 2411 |
i = numSkillLevels; |
| 2412 |
} else if (i > numSkillLevels) { |
| 2413 |
i = 1; |
| 2414 |
} |
| 2415 |
|
| 2416 |
trap_Cvar_SetValue("g_spSkill", i); |
| 2417 |
return qtrue; |
| 2418 |
} |
| 2419 |
return qfalse; |
| 2420 |
} |
| 2421 |
|
| 2422 |
static qboolean UI_TeamName_HandleKey(int flags, float *special, int key, qboolean blue) { |
| 2423 |
int select = UI_SelectForKey(key); |
| 2424 |
if (select != 0) { |
| 2425 |
int i; |
| 2426 |
|
| 2427 |
i = UI_TeamIndexFromName(UI_Cvar_VariableString((blue) ? "ui_blueTeam" : "ui_redTeam")); |
| 2428 |
i += select; |
| 2429 |
|
| 2430 |
if (i >= uiInfo.teamCount) { |
| 2431 |
i = 0; |
| 2432 |
} else if (i < 0) { |
| 2433 |
i = uiInfo.teamCount - 1; |
| 2434 |
} |
| 2435 |
|
| 2436 |
trap_Cvar_Set( (blue) ? "ui_blueTeam" : "ui_redTeam", uiInfo.teamList[i].teamName); |
| 2437 |
return qtrue; |
| 2438 |
} |
| 2439 |
return qfalse; |
| 2440 |
} |
| 2441 |
|
| 2442 |
static qboolean UI_TeamMember_HandleKey(int flags, float *special, int key, qboolean blue, int num) { |
| 2443 |
int select = UI_SelectForKey(key); |
| 2444 |
if (select != 0) { |
| 2445 |
|
| 2446 |
|
| 2447 |
|
| 2448 |
char *cvar = va(blue ? "ui_blueteam%i" : "ui_redteam%i", num); |
| 2449 |
int value = trap_Cvar_VariableValue(cvar); |
| 2450 |
|
| 2451 |
value += select; |
| 2452 |
|
| 2453 |
if (ui_actualNetGameType.integer >= GT_TEAM) { |
| 2454 |
if (value >= uiInfo.characterCount + 2) { |
| 2455 |
value = 0; |
| 2456 |
} else if (value < 0) { |
| 2457 |
value = uiInfo.characterCount + 2 - 1; |
| 2458 |
} |
| 2459 |
} else { |
| 2460 |
if (value >= UI_GetNumBots() + 2) { |
| 2461 |
value = 0; |
| 2462 |
} else if (value < 0) { |
| 2463 |
value = UI_GetNumBots() + 2 - 1; |
| 2464 |
} |
| 2465 |
} |
| 2466 |
|
| 2467 |
trap_Cvar_SetValue(cvar, value); |
| 2468 |
return qtrue; |
| 2469 |
} |
| 2470 |
return qfalse; |
| 2471 |
} |
| 2472 |
|
| 2473 |
static qboolean UI_NetSource_HandleKey(int flags, float *special, int key) { |
| 2474 |
int select = UI_SelectForKey(key); |
| 2475 |
if (select != 0) { |
| 2476 |
ui_netSource.integer += select; |
| 2477 |
|
| 2478 |
if(ui_netSource.integer >= UIAS_GLOBAL1 && ui_netSource.integer <= UIAS_GLOBAL5) |
| 2479 |
{ |
| 2480 |
char masterstr[2], cvarname[sizeof("sv_master1")]; |
| 2481 |
|
| 2482 |
while(ui_netSource.integer >= UIAS_GLOBAL1 && ui_netSource.integer <= UIAS_GLOBAL5) |
| 2483 |
{ |
| 2484 |
Com_sprintf(cvarname, sizeof(cvarname), "sv_master%d", ui_netSource.integer - UIAS_GLOBAL0); |
| 2485 |
trap_Cvar_VariableStringBuffer(cvarname, masterstr, sizeof(masterstr)); |
| 2486 |
if(*masterstr) |
| 2487 |
break; |
| 2488 |
|
| 2489 |
ui_netSource.integer += select; |
| 2490 |
} |
| 2491 |
} |
| 2492 |
|
| 2493 |
if (ui_netSource.integer >= numNetSources) { |
| 2494 |
ui_netSource.integer = 0; |
| 2495 |
} else if (ui_netSource.integer < 0) { |
| 2496 |
ui_netSource.integer = numNetSources - 1; |
| 2497 |
} |
| 2498 |
|
| 2499 |
UI_BuildServerDisplayList(qtrue); |
| 2500 |
UI_StartServerRefresh(qtrue, qfalse); |
| 2501 |
trap_Cvar_SetValue( "ui_netSource", ui_netSource.integer); |
| 2502 |
return qtrue; |
| 2503 |
} |
| 2504 |
return qfalse; |
| 2505 |
} |
| 2506 |
|
| 2507 |
static qboolean UI_NetFilter_HandleKey(int flags, float *special, int key) { |
| 2508 |
int select = UI_SelectForKey(key); |
| 2509 |
if (select != 0) { |
| 2510 |
ui_serverFilterType.integer += select; |
| 2511 |
|
| 2512 |
if (ui_serverFilterType.integer >= numServerFilters) { |
| 2513 |
ui_serverFilterType.integer = 0; |
| 2514 |
} else if (ui_serverFilterType.integer < 0) { |
| 2515 |
ui_serverFilterType.integer = numServerFilters - 1; |
| 2516 |
} |
| 2517 |
UI_BuildServerDisplayList(qtrue); |
| 2518 |
return qtrue; |
| 2519 |
} |
| 2520 |
return qfalse; |
| 2521 |
} |
| 2522 |
|
| 2523 |
static qboolean UI_OpponentName_HandleKey(int flags, float *special, int key) { |
| 2524 |
int select = UI_SelectForKey(key); |
| 2525 |
if (select != 0) { |
| 2526 |
if (select < 0) { |
| 2527 |
UI_PriorOpponent(); |
| 2528 |
} else { |
| 2529 |
UI_NextOpponent(); |
| 2530 |
} |
| 2531 |
return qtrue; |
| 2532 |
} |
| 2533 |
return qfalse; |
| 2534 |
} |
| 2535 |
|
| 2536 |
static qboolean UI_BotName_HandleKey(int flags, float *special, int key) { |
| 2537 |
int select = UI_SelectForKey(key); |
| 2538 |
if (select != 0) { |
| 2539 |
int game = trap_Cvar_VariableValue("g_gametype"); |
| 2540 |
int value = uiInfo.botIndex; |
| 2541 |
|
| 2542 |
value += select; |
| 2543 |
|
| 2544 |
if (game >= GT_TEAM) { |
| 2545 |
if (value >= uiInfo.characterCount) { |
| 2546 |
value = 0; |
| 2547 |
} else if (value < 0) { |
| 2548 |
value = uiInfo.characterCount - 1; |
| 2549 |
} |
| 2550 |
} else { |
| 2551 |
if (value >= UI_GetNumBots()) { |
| 2552 |
value = 0; |
| 2553 |
} else if (value < 0) { |
| 2554 |
value = UI_GetNumBots() - 1; |
| 2555 |
} |
| 2556 |
} |
| 2557 |
uiInfo.botIndex = value; |
| 2558 |
return qtrue; |
| 2559 |
} |
| 2560 |
return qfalse; |
| 2561 |
} |
| 2562 |
|
| 2563 |
static qboolean UI_BotSkill_HandleKey(int flags, float *special, int key) { |
| 2564 |
int select = UI_SelectForKey(key); |
| 2565 |
if (select != 0) { |
| 2566 |
uiInfo.skillIndex += select; |
| 2567 |
|
| 2568 |
if (uiInfo.skillIndex >= numSkillLevels) { |
| 2569 |
uiInfo.skillIndex = 0; |
| 2570 |
} else if (uiInfo.skillIndex < 0) { |
| 2571 |
uiInfo.skillIndex = numSkillLevels-1; |
| 2572 |
} |
| 2573 |
return qtrue; |
| 2574 |
} |
| 2575 |
return qfalse; |
| 2576 |
} |
| 2577 |
|
| 2578 |
static qboolean UI_RedBlue_HandleKey(int flags, float *special, int key) { |
| 2579 |
int select = UI_SelectForKey(key); |
| 2580 |
if (select != 0) { |
| 2581 |
uiInfo.redBlue ^= 1; |
| 2582 |
return qtrue; |
| 2583 |
} |
| 2584 |
return qfalse; |
| 2585 |
} |
| 2586 |
|
| 2587 |
static qboolean UI_Crosshair_HandleKey(int flags, float *special, int key) { |
| 2588 |
int select = UI_SelectForKey(key); |
| 2589 |
if (select != 0) { |
| 2590 |
uiInfo.currentCrosshair += select; |
| 2591 |
|
| 2592 |
if (uiInfo.currentCrosshair >= NUM_CROSSHAIRS) { |
| 2593 |
uiInfo.currentCrosshair = 0; |
| 2594 |
} else if (uiInfo.currentCrosshair < 0) { |
| 2595 |
uiInfo.currentCrosshair = NUM_CROSSHAIRS - 1; |
| 2596 |
} |
| 2597 |
trap_Cvar_SetValue("cg_drawCrosshair", uiInfo.currentCrosshair); |
| 2598 |
return qtrue; |
| 2599 |
} |
| 2600 |
return qfalse; |
| 2601 |
} |
| 2602 |
|
| 2603 |
|
| 2604 |
|
| 2605 |
static qboolean UI_SelectedPlayer_HandleKey(int flags, float *special, int key) { |
| 2606 |
int select = UI_SelectForKey(key); |
| 2607 |
if (select != 0) { |
| 2608 |
int selected; |
| 2609 |
|
| 2610 |
UI_BuildPlayerList(); |
| 2611 |
if (!uiInfo.teamLeader) { |
| 2612 |
return qfalse; |
| 2613 |
} |
| 2614 |
selected = trap_Cvar_VariableValue("cg_selectedPlayer"); |
| 2615 |
|
| 2616 |
selected += select; |
| 2617 |
|
| 2618 |
if (selected > uiInfo.myTeamCount) { |
| 2619 |
selected = 0; |
| 2620 |
} else if (selected < 0) { |
| 2621 |
selected = uiInfo.myTeamCount; |
| 2622 |
} |
| 2623 |
|
| 2624 |
if (selected == uiInfo.myTeamCount) { |
| 2625 |
trap_Cvar_Set( "cg_selectedPlayerName", "Everyone"); |
| 2626 |
} else { |
| 2627 |
trap_Cvar_Set( "cg_selectedPlayerName", uiInfo.teamNames[selected]); |
| 2628 |
} |
| 2629 |
trap_Cvar_SetValue( "cg_selectedPlayer", selected); |
| 2630 |
} |
| 2631 |
return qfalse; |
| 2632 |
} |
| 2633 |
|
| 2634 |
|
| 2635 |
static qboolean UI_OwnerDrawHandleKey(int ownerDraw, int flags, float *special, int key) { |
| 2636 |
switch (ownerDraw) { |
| 2637 |
case UI_HANDICAP: |
| 2638 |
return UI_Handicap_HandleKey(flags, special, key); |
| 2639 |
break; |
| 2640 |
case UI_EFFECTS: |
| 2641 |
return UI_Effects_HandleKey(flags, special, key); |
| 2642 |
break; |
| 2643 |
case UI_CLANNAME: |
| 2644 |
return UI_ClanName_HandleKey(flags, special, key); |
| 2645 |
break; |
| 2646 |
case UI_GAMETYPE: |
| 2647 |
return UI_GameType_HandleKey(flags, special, key, qtrue); |
| 2648 |
break; |
| 2649 |
case UI_NETGAMETYPE: |
| 2650 |
return UI_NetGameType_HandleKey(flags, special, key); |
| 2651 |
break; |
| 2652 |
case UI_JOINGAMETYPE: |
| 2653 |
return UI_JoinGameType_HandleKey(flags, special, key); |
| 2654 |
break; |
| 2655 |
case UI_SKILL: |
| 2656 |
return UI_Skill_HandleKey(flags, special, key); |
| 2657 |
break; |
| 2658 |
case UI_BLUETEAMNAME: |
| 2659 |
return UI_TeamName_HandleKey(flags, special, key, qtrue); |
| 2660 |
break; |
| 2661 |
case UI_REDTEAMNAME: |
| 2662 |
return UI_TeamName_HandleKey(flags, special, key, qfalse); |
| 2663 |
break; |
| 2664 |
case UI_BLUETEAM1: |
| 2665 |
case UI_BLUETEAM2: |
| 2666 |
case UI_BLUETEAM3: |
| 2667 |
case UI_BLUETEAM4: |
| 2668 |
case UI_BLUETEAM5: |
| 2669 |
UI_TeamMember_HandleKey(flags, special, key, qtrue, ownerDraw - UI_BLUETEAM1 + 1); |
| 2670 |
break; |
| 2671 |
case UI_REDTEAM1: |
| 2672 |
case UI_REDTEAM2: |
| 2673 |
case UI_REDTEAM3: |
| 2674 |
case UI_REDTEAM4: |
| 2675 |
case UI_REDTEAM5: |
| 2676 |
UI_TeamMember_HandleKey(flags, special, key, qfalse, ownerDraw - UI_REDTEAM1 + 1); |
| 2677 |
break; |
| 2678 |
case UI_NETSOURCE: |
| 2679 |
UI_NetSource_HandleKey(flags, special, key); |
| 2680 |
break; |
| 2681 |
case UI_NETFILTER: |
| 2682 |
UI_NetFilter_HandleKey(flags, special, key); |
| 2683 |
break; |
| 2684 |
case UI_OPPONENT_NAME: |
| 2685 |
UI_OpponentName_HandleKey(flags, special, key); |
| 2686 |
break; |
| 2687 |
case UI_BOTNAME: |
| 2688 |
return UI_BotName_HandleKey(flags, special, key); |
| 2689 |
break; |
| 2690 |
case UI_BOTSKILL: |
| 2691 |
return UI_BotSkill_HandleKey(flags, special, key); |
| 2692 |
break; |
| 2693 |
case UI_REDBLUE: |
| 2694 |
UI_RedBlue_HandleKey(flags, special, key); |
| 2695 |
break; |
| 2696 |
case UI_CROSSHAIR: |
| 2697 |
UI_Crosshair_HandleKey(flags, special, key); |
| 2698 |
break; |
| 2699 |
case UI_SELECTEDPLAYER: |
| 2700 |
UI_SelectedPlayer_HandleKey(flags, special, key); |
| 2701 |
break; |
| 2702 |
default: |
| 2703 |
break; |
| 2704 |
} |
| 2705 |
|
| 2706 |
return qfalse; |
| 2707 |
} |
| 2708 |
|
| 2709 |
|
| 2710 |
static float UI_GetValue(int ownerDraw) { |
| 2711 |
return 0; |
| 2712 |
} |
| 2713 |
|
| 2714 |
|
| 2715 |
|
| 2716 |
|
| 2717 |
|
| 2718 |
|
| 2719 |
static int QDECL UI_ServersQsortCompare( const void *arg1, const void *arg2 ) { |
| 2720 |
return trap_LAN_CompareServers( UI_SourceForLAN(), uiInfo.serverStatus.sortKey, uiInfo.serverStatus.sortDir, *(int*)arg1, *(int*)arg2); |
| 2721 |
} |
| 2722 |
|
| 2723 |
|
| 2724 |
|
| 2725 |
|
| 2726 |
|
| 2727 |
|
| 2728 |
|
| 2729 |
void UI_ServersSort(int column, qboolean force) { |
| 2730 |
|
| 2731 |
if ( !force ) { |
| 2732 |
if ( uiInfo.serverStatus.sortKey == column ) { |
| 2733 |
return; |
| 2734 |
} |
| 2735 |
} |
| 2736 |
|
| 2737 |
uiInfo.serverStatus.sortKey = column; |
| 2738 |
qsort( &uiInfo.serverStatus.displayServers[0], uiInfo.serverStatus.numDisplayServers, sizeof(int), UI_ServersQsortCompare); |
| 2739 |
|
| 2740 |
|
| 2741 |
UI_FeederSelection( FEEDER_SERVERS, uiInfo.serverStatus.currentServer ); |
| 2742 |
} |
| 2743 |
|
| 2744 |
|
| 2745 |
|
| 2746 |
|
| 2747 |
|
| 2748 |
|
| 2749 |
|
| 2750 |
|
| 2751 |
|
| 2752 |
|
| 2753 |
|
| 2754 |
|
| 2755 |
|
| 2756 |
|
| 2757 |
|
| 2758 |
|
| 2759 |
|
| 2760 |
|
| 2761 |
|
| 2762 |
|
| 2763 |
|
| 2764 |
|
| 2765 |
|
| 2766 |
|
| 2767 |
|
| 2768 |
|
| 2769 |
|
| 2770 |
|
| 2771 |
|
| 2772 |
|
| 2773 |
|
| 2774 |
|
| 2775 |
|
| 2776 |
|
| 2777 |
|
| 2778 |
|
| 2779 |
|
| 2780 |
|
| 2781 |
|
| 2782 |
|
| 2783 |
|
| 2784 |
|
| 2785 |
|
| 2786 |
|
| 2787 |
|
| 2788 |
|
| 2789 |
static void UI_LoadMods( void ) { |
| 2790 |
int numdirs; |
| 2791 |
char dirlist[2048]; |
| 2792 |
char *dirptr; |
| 2793 |
char *descptr; |
| 2794 |
int i; |
| 2795 |
int dirlen; |
| 2796 |
|
| 2797 |
uiInfo.modCount = 0; |
| 2798 |
numdirs = trap_FS_GetFileList( "$modlist", "", dirlist, sizeof(dirlist) ); |
| 2799 |
dirptr = dirlist; |
| 2800 |
for( i = 0; i < numdirs; i++ ) { |
| 2801 |
dirlen = strlen( dirptr ) + 1; |
| 2802 |
descptr = dirptr + dirlen; |
| 2803 |
uiInfo.modList[uiInfo.modCount].modName = String_Alloc(dirptr); |
| 2804 |
uiInfo.modList[uiInfo.modCount].modDescr = String_Alloc(descptr); |
| 2805 |
dirptr += dirlen + strlen(descptr) + 1; |
| 2806 |
uiInfo.modCount++; |
| 2807 |
if (uiInfo.modCount >= MAX_MODS) { |
| 2808 |
break; |
| 2809 |
} |
| 2810 |
} |
| 2811 |
|
| 2812 |
} |
| 2813 |
|
| 2814 |
|
| 2815 |
|
| 2816 |
|
| 2817 |
|
| 2818 |
|
| 2819 |
|
| 2820 |
static void UI_LoadTeams( void ) { |
| 2821 |
char teamList[4096]; |
| 2822 |
char *teamName; |
| 2823 |
int i, len, count; |
| 2824 |
|
| 2825 |
count = trap_FS_GetFileList( "", "team", teamList, 4096 ); |
| 2826 |
|
| 2827 |
if (count) { |
| 2828 |
teamName = teamList; |
| 2829 |
for ( i = 0; i < count; i++ ) { |
| 2830 |
len = strlen( teamName ); |
| 2831 |
UI_ParseTeamInfo(teamName); |
| 2832 |
teamName += len + 1; |
| 2833 |
} |
| 2834 |
} |
| 2835 |
|
| 2836 |
} |
| 2837 |
|
| 2838 |
|
| 2839 |
|
| 2840 |
|
| 2841 |
|
| 2842 |
|
| 2843 |
|
| 2844 |
static void UI_LoadMovies( void ) { |
| 2845 |
char movielist[4096]; |
| 2846 |
char *moviename; |
| 2847 |
int i, len; |
| 2848 |
|
| 2849 |
uiInfo.movieCount = trap_FS_GetFileList( "video", "roq", movielist, 4096 ); |
| 2850 |
|
| 2851 |
if (uiInfo.movieCount) { |
| 2852 |
if (uiInfo.movieCount > MAX_MOVIES) { |
| 2853 |
uiInfo.movieCount = MAX_MOVIES; |
| 2854 |
} |
| 2855 |
moviename = movielist; |
| 2856 |
for ( i = 0; i < uiInfo.movieCount; i++ ) { |
| 2857 |
len = strlen( moviename ); |
| 2858 |
if (!Q_stricmp(moviename + len - 4,".roq")) { |
| 2859 |
moviename[len-4] = '\0'; |
| 2860 |
} |
| 2861 |
Q_strupr(moviename); |
| 2862 |
uiInfo.movieList[i] = String_Alloc(moviename); |
| 2863 |
moviename += len + 1; |
| 2864 |
} |
| 2865 |
} |
| 2866 |
|
| 2867 |
} |
| 2868 |
|
| 2869 |
#define NAMEBUFSIZE (MAX_DEMOS * 32) |
| 2870 |
|
| 2871 |
|
| 2872 |
|
| 2873 |
|
| 2874 |
|
| 2875 |
|
| 2876 |
static void UI_LoadDemos( void ) { |
| 2877 |
char demolist[NAMEBUFSIZE]; |
| 2878 |
char demoExt[32]; |
| 2879 |
char *demoname; |
| 2880 |
int i, j, len; |
| 2881 |
int protocol, protocolLegacy; |
| 2882 |
|
| 2883 |
protocolLegacy = trap_Cvar_VariableValue("com_legacyprotocol"); |
| 2884 |
protocol = trap_Cvar_VariableValue("com_protocol"); |
| 2885 |
|
| 2886 |
if(!protocol) |
| 2887 |
protocol = trap_Cvar_VariableValue("protocol"); |
| 2888 |
if(protocolLegacy == protocol) |
| 2889 |
protocolLegacy = 0; |
| 2890 |
|
| 2891 |
Com_sprintf(demoExt, sizeof(demoExt), ".%s%d", DEMOEXT, protocol); |
| 2892 |
uiInfo.demoCount = trap_FS_GetFileList("demos", demoExt, demolist, ARRAY_LEN(demolist)); |
| 2893 |
|
| 2894 |
demoname = demolist; |
| 2895 |
i = 0; |
| 2896 |
|
| 2897 |
for(j = 0; j < 2; j++) |
| 2898 |
{ |
| 2899 |
if(uiInfo.demoCount > MAX_DEMOS) |
| 2900 |
uiInfo.demoCount = MAX_DEMOS; |
| 2901 |
|
| 2902 |
for(; i < uiInfo.demoCount; i++) |
| 2903 |
{ |
| 2904 |
len = strlen(demoname); |
| 2905 |
uiInfo.demoList[i] = String_Alloc(demoname); |
| 2906 |
demoname += len + 1; |
| 2907 |
} |
| 2908 |
|
| 2909 |
if(!j) |
| 2910 |
{ |
| 2911 |
if(protocolLegacy > 0 && uiInfo.demoCount < MAX_DEMOS) |
| 2912 |
{ |
| 2913 |
Com_sprintf(demoExt, sizeof(demoExt), ".%s%d", DEMOEXT, protocolLegacy); |
| 2914 |
uiInfo.demoCount += trap_FS_GetFileList("demos", demoExt, demolist, ARRAY_LEN(demolist)); |
| 2915 |
demoname = demolist; |
| 2916 |
} |
| 2917 |
else |
| 2918 |
break; |
| 2919 |
} |
| 2920 |
} |
| 2921 |
|
| 2922 |
} |
| 2923 |
|
| 2924 |
|
| 2925 |
static qboolean UI_SetNextMap(int actual, int index) { |
| 2926 |
int i; |
| 2927 |
for (i = actual + 1; i < uiInfo.mapCount; i++) { |
| 2928 |
if (uiInfo.mapList[i].active) { |
| 2929 |
Menu_SetFeederSelection(NULL, FEEDER_MAPS, index + 1, "skirmish"); |
| 2930 |
return qtrue; |
| 2931 |
} |
| 2932 |
} |
| 2933 |
return qfalse; |
| 2934 |
} |
| 2935 |
|
| 2936 |
|
| 2937 |
static void UI_StartSkirmish(qboolean next) { |
| 2938 |
int i, k, g, delay, temp; |
| 2939 |
float skill; |
| 2940 |
char buff[MAX_STRING_CHARS]; |
| 2941 |
|
| 2942 |
if (next) { |
| 2943 |
int actual; |
| 2944 |
int index = trap_Cvar_VariableValue("ui_mapIndex"); |
| 2945 |
UI_MapCountByGameType(qtrue); |
| 2946 |
UI_SelectedMap(index, &actual); |
| 2947 |
if (UI_SetNextMap(actual, index)) { |
| 2948 |
} else { |
| 2949 |
UI_GameType_HandleKey(0, NULL, K_MOUSE1, qfalse); |
| 2950 |
UI_MapCountByGameType(qtrue); |
| 2951 |
Menu_SetFeederSelection(NULL, FEEDER_MAPS, 0, "skirmish"); |
| 2952 |
} |
| 2953 |
} |
| 2954 |
|
| 2955 |
g = uiInfo.gameTypes[ui_gameType.integer].gtEnum; |
| 2956 |
trap_Cvar_SetValue( "g_gametype", g ); |
| 2957 |
trap_Cmd_ExecuteText( EXEC_APPEND, va( "wait ; wait ; map %s\n", uiInfo.mapList[ui_currentMap.integer].mapLoadName) ); |
| 2958 |
skill = trap_Cvar_VariableValue( "g_spSkill" ); |
| 2959 |
trap_Cvar_Set("ui_scoreMap", uiInfo.mapList[ui_currentMap.integer].mapName); |
| 2960 |
|
| 2961 |
k = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_opponentName")); |
| 2962 |
|
| 2963 |
trap_Cvar_Set("ui_singlePlayerActive", "1"); |
| 2964 |
|
| 2965 |
|
| 2966 |
temp = trap_Cvar_VariableValue( "capturelimit" ); |
| 2967 |
trap_Cvar_Set("ui_saveCaptureLimit", va("%i", temp)); |
| 2968 |
temp = trap_Cvar_VariableValue( "fraglimit" ); |
| 2969 |
trap_Cvar_Set("ui_saveFragLimit", va("%i", temp)); |
| 2970 |
|
| 2971 |
UI_SetCapFragLimits(qfalse); |
| 2972 |
|
| 2973 |
temp = trap_Cvar_VariableValue( "cg_drawTimer" ); |
| 2974 |
trap_Cvar_Set("ui_drawTimer", va("%i", temp)); |
| 2975 |
temp = trap_Cvar_VariableValue( "g_doWarmup" ); |
| 2976 |
trap_Cvar_Set("ui_doWarmup", va("%i", temp)); |
| 2977 |
temp = trap_Cvar_VariableValue( "g_friendlyFire" ); |
| 2978 |
trap_Cvar_Set("ui_friendlyFire", va("%i", temp)); |
| 2979 |
temp = trap_Cvar_VariableValue( "sv_maxClients" ); |
| 2980 |
trap_Cvar_Set("ui_maxClients", va("%i", temp)); |
| 2981 |
temp = trap_Cvar_VariableValue( "g_warmup" ); |
| 2982 |
trap_Cvar_Set("ui_Warmup", va("%i", temp)); |
| 2983 |
temp = trap_Cvar_VariableValue( "sv_pure" ); |
| 2984 |
trap_Cvar_Set("ui_pure", va("%i", temp)); |
| 2985 |
|
| 2986 |
trap_Cvar_Set("cg_cameraOrbit", "0"); |
| 2987 |
trap_Cvar_Set("cg_thirdPerson", "0"); |
| 2988 |
trap_Cvar_Set("cg_drawTimer", "1"); |
| 2989 |
trap_Cvar_Set("g_doWarmup", "1"); |
| 2990 |
trap_Cvar_Set("g_warmup", "15"); |
| 2991 |
trap_Cvar_Set("sv_pure", "0"); |
| 2992 |
trap_Cvar_Set("g_friendlyFire", "0"); |
| 2993 |
trap_Cvar_Set("g_redTeam", UI_Cvar_VariableString("ui_teamName")); |
| 2994 |
trap_Cvar_Set("g_blueTeam", UI_Cvar_VariableString("ui_opponentName")); |
| 2995 |
|
| 2996 |
if (trap_Cvar_VariableValue("ui_recordSPDemo")) { |
| 2997 |
Com_sprintf(buff, MAX_STRING_CHARS, "%s_%i", uiInfo.mapList[ui_currentMap.integer].mapLoadName, g); |
| 2998 |
trap_Cvar_Set("ui_recordSPDemoName", buff); |
| 2999 |
} |
| 3000 |
|
| 3001 |
delay = 500; |
| 3002 |
|
| 3003 |
if (g == GT_TOURNAMENT) { |
| 3004 |
trap_Cvar_Set("sv_maxClients", "2"); |
| 3005 |
Com_sprintf( buff, sizeof(buff), "wait ; addbot %s %f "", %i \n", uiInfo.mapList[ui_currentMap.integer].opponentName, skill, delay); |
| 3006 |
trap_Cmd_ExecuteText( EXEC_APPEND, buff ); |
| 3007 |
} else { |
| 3008 |
temp = uiInfo.mapList[ui_currentMap.integer].teamMembers * 2; |
| 3009 |
trap_Cvar_Set("sv_maxClients", va("%d", temp)); |
| 3010 |
for (i =0; i < uiInfo.mapList[ui_currentMap.integer].teamMembers; i++) { |
| 3011 |
Com_sprintf( buff, sizeof(buff), "addbot %s %f %s %i %s\n", UI_AIFromName(uiInfo.teamList[k].teamMembers[i]), skill, (g == GT_FFA) ? "" : "Blue", delay, uiInfo.teamList[k].teamMembers[i]); |
| 3012 |
trap_Cmd_ExecuteText( EXEC_APPEND, buff ); |
| 3013 |
delay += 500; |
| 3014 |
} |
| 3015 |
k = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_teamName")); |
| 3016 |
for (i =0; i < uiInfo.mapList[ui_currentMap.integer].teamMembers-1; i++) { |
| 3017 |
Com_sprintf( buff, sizeof(buff), "addbot %s %f %s %i %s\n", UI_AIFromName(uiInfo.teamList[k].teamMembers[i]), skill, (g == GT_FFA) ? "" : "Red", delay, uiInfo.teamList[k].teamMembers[i]); |
| 3018 |
trap_Cmd_ExecuteText( EXEC_APPEND, buff ); |
| 3019 |
delay += 500; |
| 3020 |
} |
| 3021 |
} |
| 3022 |
if (g >= GT_TEAM ) { |
| 3023 |
|
| 3024 |
trap_Cmd_ExecuteText( EXEC_APPEND, "wait 5; team Red\n" ); |
| 3025 |
|
| 3026 |
|
| 3027 |
trap_Cvar_Set( "g_localTeamPref", "Red" ); |
| 3028 |
} |
| 3029 |
} |
| 3030 |
|
| 3031 |
static void UI_Update(const char *name) { |
| 3032 |
int val = trap_Cvar_VariableValue(name); |
| 3033 |
|
| 3034 |
if (Q_stricmp(name, "ui_SetName") == 0) { |
| 3035 |
trap_Cvar_Set( "name", UI_Cvar_VariableString("ui_Name")); |
| 3036 |
} else if (Q_stricmp(name, "ui_setRate") == 0) { |
| 3037 |
float rate = trap_Cvar_VariableValue("rate"); |
| 3038 |
if (rate >= 5000) { |
| 3039 |
trap_Cvar_Set("cl_maxpackets", "30"); |
| 3040 |
trap_Cvar_Set("cl_packetdup", "1"); |
| 3041 |
} else if (rate >= 4000) { |
| 3042 |
trap_Cvar_Set("cl_maxpackets", "15"); |
| 3043 |
trap_Cvar_Set("cl_packetdup", "2"); |
| 3044 |
} else { |
| 3045 |
trap_Cvar_Set("cl_maxpackets", "15"); |
| 3046 |
trap_Cvar_Set("cl_packetdup", "1"); |
| 3047 |
} |
| 3048 |
} else if (Q_stricmp(name, "ui_GetName") == 0) { |
| 3049 |
trap_Cvar_Set( "ui_Name", UI_Cvar_VariableString("name")); |
| 3050 |
} else if (Q_stricmp(name, "r_colorbits") == 0) { |
| 3051 |
switch (val) { |
| 3052 |
case 0: |
| 3053 |
trap_Cvar_SetValue( "r_depthbits", 0 ); |
| 3054 |
trap_Cvar_Reset( "r_stencilbits" ); |
| 3055 |
break; |
| 3056 |
case 16: |
| 3057 |
trap_Cvar_SetValue( "r_depthbits", 16 ); |
| 3058 |
trap_Cvar_SetValue( "r_stencilbits", 0 ); |
| 3059 |
break; |
| 3060 |
case 32: |
| 3061 |
trap_Cvar_SetValue( "r_depthbits", 24 ); |
| 3062 |
trap_Cvar_SetValue( "r_stencilbits", 8 ); |
| 3063 |
break; |
| 3064 |
} |
| 3065 |
} else if (Q_stricmp(name, "r_lodbias") == 0) { |
| 3066 |
switch (val) { |
| 3067 |
case 0: |
| 3068 |
trap_Cvar_SetValue( "r_subdivisions", 4 ); |
| 3069 |
break; |
| 3070 |
case 1: |
| 3071 |
trap_Cvar_SetValue( "r_subdivisions", 12 ); |
| 3072 |
break; |
| 3073 |
case 2: |
| 3074 |
trap_Cvar_SetValue( "r_subdivisions", 20 ); |
| 3075 |
break; |
| 3076 |
} |
| 3077 |
} else if (Q_stricmp(name, "ui_glCustom") == 0) { |
| 3078 |
switch (val) { |
| 3079 |
case 0: |
| 3080 |
trap_Cvar_SetValue( "r_fullScreen", 1 ); |
| 3081 |
trap_Cvar_SetValue( "r_subdivisions", 4 ); |
| 3082 |
trap_Cvar_SetValue( "r_vertexlight", 0 ); |
| 3083 |
trap_Cvar_SetValue( "r_lodbias", 0 ); |
| 3084 |
trap_Cvar_SetValue( "r_colorbits", 32 ); |
| 3085 |
trap_Cvar_SetValue( "r_depthbits", 24 ); |
| 3086 |
trap_Cvar_SetValue( "r_stencilbits", 8 ); |
| 3087 |
trap_Cvar_SetValue( "r_picmip", 0 ); |
| 3088 |
trap_Cvar_SetValue( "r_mode", 4 ); |
| 3089 |
trap_Cvar_Set( "ui_videomode", "800x600" ); |
| 3090 |
trap_Cvar_SetValue( "r_texturebits", 32 ); |
| 3091 |
trap_Cvar_SetValue( "r_fastSky", 0 ); |
| 3092 |
trap_Cvar_SetValue( "r_inGameVideo", 1 ); |
| 3093 |
trap_Cvar_SetValue( "cg_shadows", 1 ); |
| 3094 |
trap_Cvar_SetValue( "cg_brassTime", 2500 ); |
| 3095 |
trap_Cvar_Set( "r_texturemode", "GL_LINEAR_MIPMAP_LINEAR" ); |
| 3096 |
break; |
| 3097 |
case 1: |
| 3098 |
trap_Cvar_SetValue( "r_fullScreen", 1 ); |
| 3099 |
trap_Cvar_SetValue( "r_subdivisions", 12 ); |
| 3100 |
trap_Cvar_SetValue( "r_vertexlight", 0 ); |
| 3101 |
trap_Cvar_SetValue( "r_lodbias", 0 ); |
| 3102 |
trap_Cvar_SetValue( "r_colorbits", 0 ); |
| 3103 |
trap_Cvar_SetValue( "r_depthbits", 0 ); |
| 3104 |
trap_Cvar_Reset( "r_stencilbits" ); |
| 3105 |
trap_Cvar_SetValue( "r_picmip", 1 ); |
| 3106 |
trap_Cvar_SetValue( "r_mode", 3 ); |
| 3107 |
trap_Cvar_Set( "ui_videomode", "640x480" ); |
| 3108 |
trap_Cvar_SetValue( "r_texturebits", 0 ); |
| 3109 |
trap_Cvar_SetValue( "r_fastSky", 0 ); |
| 3110 |
trap_Cvar_SetValue( "r_inGameVideo", 1 ); |
| 3111 |
trap_Cvar_SetValue( "cg_brassTime", 2500 ); |
| 3112 |
trap_Cvar_Set( "r_texturemode", "GL_LINEAR_MIPMAP_LINEAR" ); |
| 3113 |
trap_Cvar_SetValue( "cg_shadows", 0 ); |
| 3114 |
break; |
| 3115 |
case 2: |
| 3116 |
trap_Cvar_SetValue( "r_fullScreen", 1 ); |
| 3117 |
trap_Cvar_SetValue( "r_subdivisions", 8 ); |
| 3118 |
trap_Cvar_SetValue( "r_vertexlight", 0 ); |
| 3119 |
trap_Cvar_SetValue( "r_lodbias", 1 ); |
| 3120 |
trap_Cvar_SetValue( "r_colorbits", 0 ); |
| 3121 |
trap_Cvar_SetValue( "r_depthbits", 0 ); |
| 3122 |
trap_Cvar_Reset( "r_stencilbits" ); |
| 3123 |
trap_Cvar_SetValue( "r_picmip", 1 ); |
| 3124 |
trap_Cvar_SetValue( "r_mode", 3 ); |
| 3125 |
trap_Cvar_Set( "ui_videomode", "640x480" ); |
| 3126 |
trap_Cvar_SetValue( "r_texturebits", 0 ); |
| 3127 |
trap_Cvar_SetValue( "cg_shadows", 0 ); |
| 3128 |
trap_Cvar_SetValue( "r_fastSky", 1 ); |
| 3129 |
trap_Cvar_SetValue( "r_inGameVideo", 0 ); |
| 3130 |
trap_Cvar_SetValue( "cg_brassTime", 0 ); |
| 3131 |
trap_Cvar_Set( "r_texturemode", "GL_LINEAR_MIPMAP_NEAREST" ); |
| 3132 |
break; |
| 3133 |
case 3: |
| 3134 |
trap_Cvar_SetValue( "r_fullScreen", 1 ); |
| 3135 |
trap_Cvar_SetValue( "r_subdivisions", 20 ); |
| 3136 |
trap_Cvar_SetValue( "r_vertexlight", 1 ); |
| 3137 |
trap_Cvar_SetValue( "r_lodbias", 2 ); |
| 3138 |
trap_Cvar_SetValue( "r_colorbits", 16 ); |
| 3139 |
trap_Cvar_SetValue( "r_depthbits", 16 ); |
| 3140 |
trap_Cvar_SetValue( "r_stencilbits", 0 ); |
| 3141 |
trap_Cvar_SetValue( "r_mode", 3 ); |
| 3142 |
trap_Cvar_Set( "ui_videomode", "640x480" ); |
| 3143 |
trap_Cvar_SetValue( "r_picmip", 2 ); |
| 3144 |
trap_Cvar_SetValue( "r_texturebits", 16 ); |
| 3145 |
trap_Cvar_SetValue( "cg_shadows", 0 ); |
| 3146 |
trap_Cvar_SetValue( "cg_brassTime", 0 ); |
| 3147 |
trap_Cvar_SetValue( "r_fastSky", 1 ); |
| 3148 |
trap_Cvar_SetValue( "r_inGameVideo", 0 ); |
| 3149 |
trap_Cvar_Set( "r_texturemode", "GL_LINEAR_MIPMAP_NEAREST" ); |
| 3150 |
break; |
| 3151 |
} |
| 3152 |
} else if (Q_stricmp(name, "ui_mousePitch") == 0) { |
| 3153 |
if (val == 0) { |
| 3154 |
trap_Cvar_SetValue( "m_pitch", 0.022f ); |
| 3155 |
} else { |
| 3156 |
trap_Cvar_SetValue( "m_pitch", -0.022f ); |
| 3157 |
} |
| 3158 |
} |
| 3159 |
} |
| 3160 |
|
| 3161 |
static void UI_RunMenuScript(char **args) { |
| 3162 |
const char *command; |
| 3163 |
char buff[1024]; |
| 3164 |
|
| 3165 |
if (String_Parse(args, &command)) { |
| 3166 |
if (Q_stricmp(command, "StartServer") == 0) { |
| 3167 |
int i, clients, oldclients; |
| 3168 |
float skill; |
| 3169 |
trap_Cvar_Set("cg_thirdPerson", "0"); |
| 3170 |
trap_Cvar_Set("cg_cameraOrbit", "0"); |
| 3171 |
trap_Cvar_Set("ui_singlePlayerActive", "0"); |
| 3172 |
trap_Cvar_SetValue( "dedicated", Com_Clamp( 0, 2, ui_dedicated.integer ) ); |
| 3173 |
trap_Cvar_SetValue( "g_gametype", Com_Clamp( 0, GT_MAX_GAME_TYPE-1, uiInfo.gameTypes[ui_netGameType.integer].gtEnum ) ); |
| 3174 |
trap_Cvar_Set("g_redTeam", UI_Cvar_VariableString("ui_teamName")); |
| 3175 |
trap_Cvar_Set("g_blueTeam", UI_Cvar_VariableString("ui_opponentName")); |
| 3176 |
trap_Cmd_ExecuteText( EXEC_APPEND, va( "wait ; wait ; map %s\n", uiInfo.mapList[ui_currentNetMap.integer].mapLoadName ) ); |
| 3177 |
skill = trap_Cvar_VariableValue( "g_spSkill" ); |
| 3178 |
|
| 3179 |
oldclients = trap_Cvar_VariableValue( "sv_maxClients" ); |
| 3180 |
clients = 0; |
| 3181 |
for (i = 0; i < PLAYERS_PER_TEAM; i++) { |
| 3182 |
int bot = trap_Cvar_VariableValue( va("ui_blueteam%i", i+1)); |
| 3183 |
if (bot >= 0) { |
| 3184 |
clients++; |
| 3185 |
} |
| 3186 |
bot = trap_Cvar_VariableValue( va("ui_redteam%i", i+1)); |
| 3187 |
if (bot >= 0) { |
| 3188 |
clients++; |
| 3189 |
} |
| 3190 |
} |
| 3191 |
if (clients == 0) { |
| 3192 |
clients = 8; |
| 3193 |
} |
| 3194 |
|
| 3195 |
if (oldclients > clients) { |
| 3196 |
clients = oldclients; |
| 3197 |
} |
| 3198 |
|
| 3199 |
trap_Cvar_Set("sv_maxClients", va("%d",clients)); |
| 3200 |
|
| 3201 |
for (i = 0; i < PLAYERS_PER_TEAM; i++) { |
| 3202 |
int bot = trap_Cvar_VariableValue( va("ui_blueteam%i", i+1)); |
| 3203 |
if (bot > 1) { |
| 3204 |
if (ui_actualNetGameType.integer >= GT_TEAM) { |
| 3205 |
Com_sprintf( buff, sizeof(buff), "addbot %s %f %s\n", uiInfo.characterList[bot-2].name, skill, "Blue"); |
| 3206 |
} else { |
| 3207 |
Com_sprintf( buff, sizeof(buff), "addbot %s %f \n", UI_GetBotNameByNumber(bot-2), skill); |
| 3208 |
} |
| 3209 |
trap_Cmd_ExecuteText( EXEC_APPEND, buff ); |
| 3210 |
} |
| 3211 |
bot = trap_Cvar_VariableValue( va("ui_redteam%i", i+1)); |
| 3212 |
if (bot > 1) { |
| 3213 |
if (ui_actualNetGameType.integer >= GT_TEAM) { |
| 3214 |
Com_sprintf( buff, sizeof(buff), "addbot %s %f %s\n", uiInfo.characterList[bot-2].name, skill, "Red"); |
| 3215 |
} else { |
| 3216 |
Com_sprintf( buff, sizeof(buff), "addbot %s %f \n", UI_GetBotNameByNumber(bot-2), skill); |
| 3217 |
} |
| 3218 |
trap_Cmd_ExecuteText( EXEC_APPEND, buff ); |
| 3219 |
} |
| 3220 |
} |
| 3221 |
} else if (Q_stricmp(command, "updateSPMenu") == 0) { |
| 3222 |
UI_SetCapFragLimits(qtrue); |
| 3223 |
UI_MapCountByGameType(qtrue); |
| 3224 |
ui_mapIndex.integer = UI_GetIndexFromSelection(ui_currentMap.integer); |
| 3225 |
trap_Cvar_Set("ui_mapIndex", va("%d", ui_mapIndex.integer)); |
| 3226 |
Menu_SetFeederSelection(NULL, FEEDER_MAPS, ui_mapIndex.integer, "skirmish"); |
| 3227 |
UI_GameType_HandleKey(0, NULL, K_MOUSE1, qfalse); |
| 3228 |
UI_GameType_HandleKey(0, NULL, K_MOUSE2, qfalse); |
| 3229 |
} else if (Q_stricmp(command, "resetDefaults") == 0) { |
| 3230 |
trap_Cmd_ExecuteText( EXEC_APPEND, "exec default.cfg\n"); |
| 3231 |
trap_Cmd_ExecuteText( EXEC_APPEND, "cvar_restart\n"); |
| 3232 |
Controls_SetDefaults(); |
| 3233 |
#ifdef CINEMATICS_INTRO |
| 3234 |
trap_Cvar_Set("com_introPlayed", "1" ); |
| 3235 |
#endif |
| 3236 |
trap_Cmd_ExecuteText( EXEC_APPEND, "vid_restart\n" ); |
| 3237 |
} else if (Q_stricmp(command, "getCDKey") == 0) { |
| 3238 |
char out[17]; |
| 3239 |
trap_GetCDKey(buff, 17); |
| 3240 |
trap_Cvar_Set("cdkey1", ""); |
| 3241 |
trap_Cvar_Set("cdkey2", ""); |
| 3242 |
trap_Cvar_Set("cdkey3", ""); |
| 3243 |
trap_Cvar_Set("cdkey4", ""); |
| 3244 |
if (strlen(buff) == CDKEY_LEN) { |
| 3245 |
Q_strncpyz(out, buff, 5); |
| 3246 |
trap_Cvar_Set("cdkey1", out); |
| 3247 |
Q_strncpyz(out, buff + 4, 5); |
| 3248 |
trap_Cvar_Set("cdkey2", out); |
| 3249 |
Q_strncpyz(out, buff + 8, 5); |
| 3250 |
trap_Cvar_Set("cdkey3", out); |
| 3251 |
Q_strncpyz(out, buff + 12, 5); |
| 3252 |
trap_Cvar_Set("cdkey4", out); |
| 3253 |
} |
| 3254 |
|
| 3255 |
} else if (Q_stricmp(command, "verifyCDKey") == 0) { |
| 3256 |
buff[0] = '\0'; |
| 3257 |
Q_strcat(buff, 1024, UI_Cvar_VariableString("cdkey1")); |
| 3258 |
Q_strcat(buff, 1024, UI_Cvar_VariableString("cdkey2")); |
| 3259 |
Q_strcat(buff, 1024, UI_Cvar_VariableString("cdkey3")); |
| 3260 |
Q_strcat(buff, 1024, UI_Cvar_VariableString("cdkey4")); |
| 3261 |
trap_Cvar_Set("cdkey", buff); |
| 3262 |
if (trap_VerifyCDKey(buff, UI_Cvar_VariableString("cdkeychecksum"))) { |
| 3263 |
trap_Cvar_Set("ui_cdkeyvalid", "CD Key Appears to be valid."); |
| 3264 |
trap_SetCDKey(buff); |
| 3265 |
} else { |
| 3266 |
trap_Cvar_Set("ui_cdkeyvalid", "CD Key does not appear to be valid."); |
| 3267 |
} |
| 3268 |
} else if (Q_stricmp(command, "loadArenas") == 0) { |
| 3269 |
UI_LoadArenasIntoMapList(); |
| 3270 |
UI_MapCountByGameType(qfalse); |
| 3271 |
Menu_SetFeederSelection(NULL, FEEDER_ALLMAPS, 0, "createserver"); |
| 3272 |
} else if (Q_stricmp(command, "saveControls") == 0) { |
| 3273 |
Controls_SetConfig(qtrue); |
| 3274 |
} else if (Q_stricmp(command, "loadControls") == 0) { |
| 3275 |
Controls_GetConfig(); |
| 3276 |
} else if (Q_stricmp(command, "clearError") == 0) { |
| 3277 |
trap_Cvar_Set("com_errorMessage", ""); |
| 3278 |
} else if (Q_stricmp(command, "loadGameInfo") == 0) { |
| 3279 |
#ifdef PRE_RELEASE_TADEMO |
| 3280 |
UI_ParseGameInfo("demogameinfo.txt"); |
| 3281 |
#else |
| 3282 |
UI_ParseGameInfo("gameinfo.txt"); |
| 3283 |
#endif |
| 3284 |
UI_LoadBestScores(uiInfo.mapList[ui_currentMap.integer].mapLoadName, uiInfo.gameTypes[ui_gameType.integer].gtEnum); |
| 3285 |
} else if (Q_stricmp(command, "resetScores") == 0) { |
| 3286 |
UI_ClearScores(); |
| 3287 |
} else if (Q_stricmp(command, "RefreshServers") == 0) { |
| 3288 |
UI_StartServerRefresh(qtrue, qtrue); |
| 3289 |
UI_BuildServerDisplayList(qtrue); |
| 3290 |
} else if (Q_stricmp(command, "RefreshFilter") == 0) { |
| 3291 |
UI_StartServerRefresh(qfalse, qtrue); |
| 3292 |
UI_BuildServerDisplayList(qtrue); |
| 3293 |
} else if (Q_stricmp(command, "RunSPDemo") == 0) { |
| 3294 |
if (uiInfo.demoAvailable) { |
| 3295 |
trap_Cmd_ExecuteText( EXEC_APPEND, va("demo %s_%i\n", uiInfo.mapList[ui_currentMap.integer].mapLoadName, uiInfo.gameTypes[ui_gameType.integer].gtEnum)); |
| 3296 |
} |
| 3297 |
} else if (Q_stricmp(command, "LoadDemos") == 0) { |
| 3298 |
UI_LoadDemos(); |
| 3299 |
} else if (Q_stricmp(command, "LoadMovies") == 0) { |
| 3300 |
UI_LoadMovies(); |
| 3301 |
} else if (Q_stricmp(command, "LoadMods") == 0) { |
| 3302 |
UI_LoadMods(); |
| 3303 |
} else if (Q_stricmp(command, "playMovie") == 0) { |
| 3304 |
if (uiInfo.previewMovie >= 0) { |
| 3305 |
trap_CIN_StopCinematic(uiInfo.previewMovie); |
| 3306 |
} |
| 3307 |
trap_Cmd_ExecuteText( EXEC_APPEND, va("cinematic %s.roq 2\n", uiInfo.movieList[uiInfo.movieIndex])); |
| 3308 |
} else if (Q_stricmp(command, "RunMod") == 0) { |
| 3309 |
trap_Cvar_Set( "fs_game", uiInfo.modList[uiInfo.modIndex].modName); |
| 3310 |
trap_Cmd_ExecuteText( EXEC_APPEND, "vid_restart;" ); |
| 3311 |
} else if (Q_stricmp(command, "RunDemo") == 0) { |
| 3312 |
trap_Cmd_ExecuteText( EXEC_APPEND, va("demo %s\n", uiInfo.demoList[uiInfo.demoIndex])); |
| 3313 |
} else if (Q_stricmp(command, "Quake3") == 0) { |
| 3314 |
trap_Cvar_Set( "fs_game", ""); |
| 3315 |
trap_Cmd_ExecuteText( EXEC_APPEND, "vid_restart;" ); |
| 3316 |
} else if (Q_stricmp(command, "closeJoin") == 0) { |
| 3317 |
if (uiInfo.serverStatus.refreshActive) { |
| 3318 |
UI_StopServerRefresh(); |
| 3319 |
uiInfo.serverStatus.nextDisplayRefresh = 0; |
| 3320 |
uiInfo.nextServerStatusRefresh = 0; |
| 3321 |
uiInfo.nextFindPlayerRefresh = 0; |
| 3322 |
UI_BuildServerDisplayList(qtrue); |
| 3323 |
} else { |
| 3324 |
Menus_CloseByName("joinserver"); |
| 3325 |
Menus_OpenByName("main"); |
| 3326 |
} |
| 3327 |
} else if (Q_stricmp(command, "StopRefresh") == 0) { |
| 3328 |
UI_StopServerRefresh(); |
| 3329 |
uiInfo.serverStatus.nextDisplayRefresh = 0; |
| 3330 |
uiInfo.nextServerStatusRefresh = 0; |
| 3331 |
uiInfo.nextFindPlayerRefresh = 0; |
| 3332 |
} else if (Q_stricmp(command, "UpdateFilter") == 0) { |
| 3333 |
|
| 3334 |
UI_StartServerRefresh(qtrue, qfalse); |
| 3335 |
UI_BuildServerDisplayList(qtrue); |
| 3336 |
UI_FeederSelection(FEEDER_SERVERS, 0); |
| 3337 |
} else if (Q_stricmp(command, "ServerStatus") == 0) { |
| 3338 |
trap_LAN_GetServerAddressString(UI_SourceForLAN(), uiInfo.serverStatus.displayServers[uiInfo.serverStatus.currentServer], uiInfo.serverStatusAddress, sizeof(uiInfo.serverStatusAddress)); |
| 3339 |
UI_BuildServerStatus(qtrue); |
| 3340 |
} else if (Q_stricmp(command, "FoundPlayerServerStatus") == 0) { |
| 3341 |
Q_strncpyz(uiInfo.serverStatusAddress, uiInfo.foundPlayerServerAddresses[uiInfo.currentFoundPlayerServer], sizeof(uiInfo.serverStatusAddress)); |
| 3342 |
UI_BuildServerStatus(qtrue); |
| 3343 |
Menu_SetFeederSelection(NULL, FEEDER_FINDPLAYER, 0, NULL); |
| 3344 |
} else if (Q_stricmp(command, "FindPlayer") == 0) { |
| 3345 |
UI_BuildFindPlayerList(qtrue); |
| 3346 |
|
| 3347 |
uiInfo.serverStatusInfo.numLines = 0; |
| 3348 |
Menu_SetFeederSelection(NULL, FEEDER_FINDPLAYER, 0, NULL); |
| 3349 |
} else if (Q_stricmp(command, "JoinServer") == 0) { |
| 3350 |
trap_Cvar_Set("cg_thirdPerson", "0"); |
| 3351 |
trap_Cvar_Set("cg_cameraOrbit", "0"); |
| 3352 |
trap_Cvar_Set("ui_singlePlayerActive", "0"); |
| 3353 |
if (uiInfo.serverStatus.currentServer >= 0 && uiInfo.serverStatus.currentServer < uiInfo.serverStatus.numDisplayServers) { |
| 3354 |
trap_LAN_GetServerAddressString(UI_SourceForLAN(), uiInfo.serverStatus.displayServers[uiInfo.serverStatus.currentServer], buff, 1024); |
| 3355 |
trap_Cmd_ExecuteText( EXEC_APPEND, va( "connect %s\n", buff ) ); |
| 3356 |
} |
| 3357 |
} else if (Q_stricmp(command, "FoundPlayerJoinServer") == 0) { |
| 3358 |
trap_Cvar_Set("ui_singlePlayerActive", "0"); |
| 3359 |
if (uiInfo.currentFoundPlayerServer >= 0 && uiInfo.currentFoundPlayerServer < uiInfo.numFoundPlayerServers) { |
| 3360 |
trap_Cmd_ExecuteText( EXEC_APPEND, va( "connect %s\n", uiInfo.foundPlayerServerAddresses[uiInfo.currentFoundPlayerServer] ) ); |
| 3361 |
} |
| 3362 |
} else if (Q_stricmp(command, "Quit") == 0) { |
| 3363 |
trap_Cvar_Set("ui_singlePlayerActive", "0"); |
| 3364 |
trap_Cmd_ExecuteText( EXEC_NOW, "quit"); |
| 3365 |
} else if (Q_stricmp(command, "Controls") == 0) { |
| 3366 |
trap_Cvar_Set( "cl_paused", "1" ); |
| 3367 |
trap_Key_SetCatcher( KEYCATCH_UI ); |
| 3368 |
Menus_CloseAll(); |
| 3369 |
Menus_ActivateByName("setup_menu2"); |
| 3370 |
} else if (Q_stricmp(command, "Leave") == 0) { |
| 3371 |
trap_Cmd_ExecuteText( EXEC_APPEND, "disconnect\n" ); |
| 3372 |
trap_Key_SetCatcher( KEYCATCH_UI ); |
| 3373 |
Menus_CloseAll(); |
| 3374 |
Menus_ActivateByName("main"); |
| 3375 |
} else if (Q_stricmp(command, "ServerSort") == 0) { |
| 3376 |
int sortColumn; |
| 3377 |
if (Int_Parse(args, &sortColumn)) { |
| 3378 |
|
| 3379 |
if (sortColumn == uiInfo.serverStatus.sortKey) { |
| 3380 |
uiInfo.serverStatus.sortDir = !uiInfo.serverStatus.sortDir; |
| 3381 |
} |
| 3382 |
|
| 3383 |
UI_ServersSort(sortColumn, qtrue); |
| 3384 |
} |
| 3385 |
} else if (Q_stricmp(command, "nextSkirmish") == 0) { |
| 3386 |
UI_StartSkirmish(qtrue); |
| 3387 |
} else if (Q_stricmp(command, "SkirmishStart") == 0) { |
| 3388 |
UI_StartSkirmish(qfalse); |
| 3389 |
} else if (Q_stricmp(command, "closeingame") == 0) { |
| 3390 |
trap_Key_SetCatcher( trap_Key_GetCatcher() & ~KEYCATCH_UI ); |
| 3391 |
trap_Key_ClearStates(); |
| 3392 |
trap_Cvar_Set( "cl_paused", "0" ); |
| 3393 |
Menus_CloseAll(); |
| 3394 |
} else if (Q_stricmp(command, "voteMap") == 0) { |
| 3395 |
if (ui_currentNetMap.integer >=0 && ui_currentNetMap.integer < uiInfo.mapCount) { |
| 3396 |
trap_Cmd_ExecuteText( EXEC_APPEND, va("callvote map %s\n",uiInfo.mapList[ui_currentNetMap.integer].mapLoadName) ); |
| 3397 |
} |
| 3398 |
} else if (Q_stricmp(command, "voteKick") == 0) { |
| 3399 |
if (uiInfo.playerIndex >= 0 && uiInfo.playerIndex < uiInfo.playerCount) { |
| 3400 |
trap_Cmd_ExecuteText( EXEC_APPEND, va("callvote kick %s\n",uiInfo.playerNames[uiInfo.playerIndex]) ); |
| 3401 |
} |
| 3402 |
} else if (Q_stricmp(command, "voteGame") == 0) { |
| 3403 |
if (ui_netGameType.integer >= 0 && ui_netGameType.integer < uiInfo.numGameTypes) { |
| 3404 |
trap_Cmd_ExecuteText( EXEC_APPEND, va("callvote g_gametype %i\n",uiInfo.gameTypes[ui_netGameType.integer].gtEnum) ); |
| 3405 |
} |
| 3406 |
} else if (Q_stricmp(command, "voteLeader") == 0) { |
| 3407 |
if (uiInfo.teamIndex >= 0 && uiInfo.teamIndex < uiInfo.myTeamCount) { |
| 3408 |
trap_Cmd_ExecuteText( EXEC_APPEND, va("callteamvote leader %s\n",uiInfo.teamNames[uiInfo.teamIndex]) ); |
| 3409 |
} |
| 3410 |
} else if (Q_stricmp(command, "addBot") == 0) { |
| 3411 |
if (trap_Cvar_VariableValue("g_gametype") >= GT_TEAM) { |
| 3412 |
trap_Cmd_ExecuteText( EXEC_APPEND, va("addbot %s %i %s\n", uiInfo.characterList[uiInfo.botIndex].name, uiInfo.skillIndex+1, (uiInfo.redBlue == 0) ? "Red" : "Blue") ); |
| 3413 |
} else { |
| 3414 |
trap_Cmd_ExecuteText( EXEC_APPEND, va("addbot %s %i %s\n", UI_GetBotNameByNumber(uiInfo.botIndex), uiInfo.skillIndex+1, (uiInfo.redBlue == 0) ? "Red" : "Blue") ); |
| 3415 |
} |
| 3416 |
} else if (Q_stricmp(command, "addFavorite") == 0) { |
| 3417 |
if (ui_netSource.integer != UIAS_FAVORITES) { |
| 3418 |
char name[MAX_NAME_LENGTH]; |
| 3419 |
char addr[MAX_ADDRESSLENGTH]; |
| 3420 |
int res; |
| 3421 |
|
| 3422 |
trap_LAN_GetServerInfo(UI_SourceForLAN(), uiInfo.serverStatus.displayServers[uiInfo.serverStatus.currentServer], buff, MAX_STRING_CHARS); |
| 3423 |
name[0] = addr[0] = '\0'; |
| 3424 |
Q_strncpyz(name, Info_ValueForKey(buff, "hostname"), sizeof ( name ) ); |
| 3425 |
Q_strncpyz(addr, Info_ValueForKey(buff, "addr"), sizeof ( addr ) ); |
| 3426 |
if (strlen(name) > 0 && strlen(addr) > 0) { |
| 3427 |
res = trap_LAN_AddServer(AS_FAVORITES, name, addr); |
| 3428 |
if (res == 0) { |
| 3429 |
|
| 3430 |
Com_Printf("Favorite already in list\n"); |
| 3431 |
} |
| 3432 |
else if (res == -1) { |
| 3433 |
|
| 3434 |
Com_Printf("Favorite list full\n"); |
| 3435 |
} |
| 3436 |
else { |
| 3437 |
|
| 3438 |
Com_Printf("Added favorite server %s\n", addr); |
| 3439 |
} |
| 3440 |
} |
| 3441 |
} |
| 3442 |
} else if (Q_stricmp(command, "deleteFavorite") == 0) { |
| 3443 |
if (ui_netSource.integer == UIAS_FAVORITES) { |
| 3444 |
char addr[MAX_ADDRESSLENGTH]; |
| 3445 |
trap_LAN_GetServerInfo(AS_FAVORITES, uiInfo.serverStatus.displayServers[uiInfo.serverStatus.currentServer], buff, MAX_STRING_CHARS); |
| 3446 |
addr[0] = '\0'; |
| 3447 |
Q_strncpyz(addr, Info_ValueForKey(buff, "addr"), sizeof ( addr ) ); |
| 3448 |
if (strlen(addr) > 0) { |
| 3449 |
trap_LAN_RemoveServer(AS_FAVORITES, addr); |
| 3450 |
} |
| 3451 |
} |
| 3452 |
} else if (Q_stricmp(command, "createFavorite") == 0) { |
| 3453 |
char name[MAX_NAME_LENGTH]; |
| 3454 |
char addr[MAX_ADDRESSLENGTH]; |
| 3455 |
int res; |
| 3456 |
|
| 3457 |
name[0] = addr[0] = '\0'; |
| 3458 |
Q_strncpyz(name, UI_Cvar_VariableString("ui_favoriteName"), sizeof ( name ) ); |
| 3459 |
Q_strncpyz(addr, UI_Cvar_VariableString("ui_favoriteAddress"), sizeof ( addr ) ); |
| 3460 |
if (strlen(name) > 0 && strlen(addr) > 0) { |
| 3461 |
res = trap_LAN_AddServer(AS_FAVORITES, name, addr); |
| 3462 |
if (res == 0) { |
| 3463 |
|
| 3464 |
Com_Printf("Favorite already in list\n"); |
| 3465 |
} |
| 3466 |
else if (res == -1) { |
| 3467 |
|
| 3468 |
Com_Printf("Favorite list full\n"); |
| 3469 |
} |
| 3470 |
else { |
| 3471 |
|
| 3472 |
Com_Printf("Added favorite server %s\n", addr); |
| 3473 |
} |
| 3474 |
} |
| 3475 |
} else if (Q_stricmp(command, "orders") == 0) { |
| 3476 |
const char *orders; |
| 3477 |
if (String_Parse(args, &orders)) { |
| 3478 |
int selectedPlayer = trap_Cvar_VariableValue("cg_selectedPlayer"); |
| 3479 |
if (selectedPlayer < uiInfo.myTeamCount) { |
| 3480 |
Com_sprintf( buff, sizeof( buff ), orders, uiInfo.teamClientNums[selectedPlayer] ); |
| 3481 |
trap_Cmd_ExecuteText( EXEC_APPEND, buff ); |
| 3482 |
trap_Cmd_ExecuteText( EXEC_APPEND, "\n" ); |
| 3483 |
} else { |
| 3484 |
int i; |
| 3485 |
for (i = 0; i < uiInfo.myTeamCount; i++) { |
| 3486 |
if (uiInfo.playerNumber == uiInfo.teamClientNums[i]) { |
| 3487 |
continue; |
| 3488 |
} |
| 3489 |
Com_sprintf( buff, sizeof( buff ), orders, uiInfo.teamClientNums[i] ); |
| 3490 |
trap_Cmd_ExecuteText( EXEC_APPEND, buff ); |
| 3491 |
trap_Cmd_ExecuteText( EXEC_APPEND, "\n" ); |
| 3492 |
} |
| 3493 |
} |
| 3494 |
trap_Key_SetCatcher( trap_Key_GetCatcher() & ~KEYCATCH_UI ); |
| 3495 |
trap_Key_ClearStates(); |
| 3496 |
trap_Cvar_Set( "cl_paused", "0" ); |
| 3497 |
Menus_CloseAll(); |
| 3498 |
} |
| 3499 |
} else if (Q_stricmp(command, "voiceOrdersTeam") == 0) { |
| 3500 |
const char *orders; |
| 3501 |
if (String_Parse(args, &orders)) { |
| 3502 |
int selectedPlayer = trap_Cvar_VariableValue("cg_selectedPlayer"); |
| 3503 |
if (selectedPlayer == uiInfo.myTeamCount) { |
| 3504 |
trap_Cmd_ExecuteText( EXEC_APPEND, orders ); |
| 3505 |
trap_Cmd_ExecuteText( EXEC_APPEND, "\n" ); |
| 3506 |
} |
| 3507 |
trap_Key_SetCatcher( trap_Key_GetCatcher() & ~KEYCATCH_UI ); |
| 3508 |
trap_Key_ClearStates(); |
| 3509 |
trap_Cvar_Set( "cl_paused", "0" ); |
| 3510 |
Menus_CloseAll(); |
| 3511 |
} |
| 3512 |
} else if (Q_stricmp(command, "voiceOrders") == 0) { |
| 3513 |
const char *orders; |
| 3514 |
if (String_Parse(args, &orders)) { |
| 3515 |
int selectedPlayer = trap_Cvar_VariableValue("cg_selectedPlayer"); |
| 3516 |
if (selectedPlayer < uiInfo.myTeamCount) { |
| 3517 |
Com_sprintf( buff, sizeof( buff ), orders, uiInfo.teamClientNums[selectedPlayer] ); |
| 3518 |
trap_Cmd_ExecuteText( EXEC_APPEND, buff ); |
| 3519 |
trap_Cmd_ExecuteText( EXEC_APPEND, "\n" ); |
| 3520 |
} |
| 3521 |
trap_Key_SetCatcher( trap_Key_GetCatcher() & ~KEYCATCH_UI ); |
| 3522 |
trap_Key_ClearStates(); |
| 3523 |
trap_Cvar_Set( "cl_paused", "0" ); |
| 3524 |
Menus_CloseAll(); |
| 3525 |
} |
| 3526 |
} else if (Q_stricmp(command, "glCustom") == 0) { |
| 3527 |
trap_Cvar_Set("ui_glCustom", "4"); |
| 3528 |
} else if (Q_stricmp(command, "update") == 0) { |
| 3529 |
const char *name; |
| 3530 |
if (String_Parse(args, &name)) { |
| 3531 |
UI_Update(name); |
| 3532 |
} |
| 3533 |
} else if (Q_stricmp(command, "setPbClStatus") == 0) { |
| 3534 |
int stat; |
| 3535 |
if ( Int_Parse( args, &stat ) ) |
| 3536 |
trap_SetPbClStatus( stat ); |
| 3537 |
} |
| 3538 |
else { |
| 3539 |
Com_Printf("unknown UI script %s\n", command); |
| 3540 |
} |
| 3541 |
} |
| 3542 |
} |
| 3543 |
|
| 3544 |
static void UI_GetTeamColor(vec4_t *color) { |
| 3545 |
} |
| 3546 |
|
| 3547 |
|
| 3548 |
|
| 3549 |
|
| 3550 |
|
| 3551 |
|
| 3552 |
static int UI_MapCountByGameType(qboolean singlePlayer) { |
| 3553 |
int i, c, game; |
| 3554 |
c = 0; |
| 3555 |
game = singlePlayer ? uiInfo.gameTypes[ui_gameType.integer].gtEnum : uiInfo.gameTypes[ui_netGameType.integer].gtEnum; |
| 3556 |
if (game == GT_SINGLE_PLAYER) { |
| 3557 |
game++; |
| 3558 |
} |
| 3559 |
if (game == GT_TEAM) { |
| 3560 |
game = GT_FFA; |
| 3561 |
} |
| 3562 |
|
| 3563 |
for (i = 0; i < uiInfo.mapCount; i++) { |
| 3564 |
uiInfo.mapList[i].active = qfalse; |
| 3565 |
if ( uiInfo.mapList[i].typeBits & (1 << game)) { |
| 3566 |
if (singlePlayer) { |
| 3567 |
if (!(uiInfo.mapList[i].typeBits & (1 << GT_SINGLE_PLAYER))) { |
| 3568 |
continue; |
| 3569 |
} |
| 3570 |
} |
| 3571 |
c++; |
| 3572 |
uiInfo.mapList[i].active = qtrue; |
| 3573 |
} |
| 3574 |
} |
| 3575 |
return c; |
| 3576 |
} |
| 3577 |
|
| 3578 |
qboolean UI_hasSkinForBase(const char *base, const char *team) { |
| 3579 |
char test[MAX_QPATH]; |
| 3580 |
|
| 3581 |
Com_sprintf( test, sizeof( test ), "models/players/%s/%s/lower_default.skin", base, team ); |
| 3582 |
|
| 3583 |
if (trap_FS_FOpenFile(test, NULL, FS_READ)) { |
| 3584 |
return qtrue; |
| 3585 |
} |
| 3586 |
Com_sprintf( test, sizeof( test ), "models/players/characters/%s/%s/lower_default.skin", base, team ); |
| 3587 |
|
| 3588 |
if (trap_FS_FOpenFile(test, NULL, FS_READ)) { |
| 3589 |
return qtrue; |
| 3590 |
} |
| 3591 |
return qfalse; |
| 3592 |
} |
| 3593 |
|
| 3594 |
|
| 3595 |
|
| 3596 |
|
| 3597 |
|
| 3598 |
|
| 3599 |
static int UI_HeadCountByTeam(void) { |
| 3600 |
static int init = 0; |
| 3601 |
int i, j, k, c, tIndex; |
| 3602 |
|
| 3603 |
c = 0; |
| 3604 |
if (!init) { |
| 3605 |
for (i = 0; i < uiInfo.characterCount; i++) { |
| 3606 |
uiInfo.characterList[i].reference = 0; |
| 3607 |
for (j = 0; j < uiInfo.teamCount; j++) { |
| 3608 |
if (UI_hasSkinForBase(uiInfo.characterList[i].base, uiInfo.teamList[j].teamName)) { |
| 3609 |
uiInfo.characterList[i].reference |= (1<<j); |
| 3610 |
} |
| 3611 |
} |
| 3612 |
} |
| 3613 |
init = 1; |
| 3614 |
} |
| 3615 |
|
| 3616 |
tIndex = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_teamName")); |
| 3617 |
|
| 3618 |
|
| 3619 |
for (i = 0; i < uiInfo.characterCount; i++) { |
| 3620 |
uiInfo.characterList[i].active = qfalse; |
| 3621 |
for(j = 0; j < TEAM_MEMBERS; j++) { |
| 3622 |
if (uiInfo.teamList[tIndex].teamMembers[j] != NULL) { |
| 3623 |
if (uiInfo.characterList[i].reference&(1<<tIndex)) { |
| 3624 |
uiInfo.characterList[i].active = qtrue; |
| 3625 |
c++; |
| 3626 |
break; |
| 3627 |
} |
| 3628 |
} |
| 3629 |
} |
| 3630 |
} |
| 3631 |
|
| 3632 |
|
| 3633 |
for(j = 0; j < TEAM_MEMBERS; j++) { |
| 3634 |
for(k = 0; k < uiInfo.aliasCount; k++) { |
| 3635 |
if (uiInfo.aliasList[k].name != NULL) { |
| 3636 |
if (Q_stricmp(uiInfo.teamList[tIndex].teamMembers[j], uiInfo.aliasList[k].name)==0) { |
| 3637 |
for (i = 0; i < uiInfo.characterCount; i++) { |
| 3638 |
if (uiInfo.characterList[i].headImage != -1 && uiInfo.characterList[i].reference&(1<<tIndex) && Q_stricmp(uiInfo.aliasList[k].ai, uiInfo.characterList[i].name)==0) { |
| 3639 |
if (uiInfo.characterList[i].active == qfalse) { |
| 3640 |
uiInfo.characterList[i].active = qtrue; |
| 3641 |
c++; |
| 3642 |
} |
| 3643 |
break; |
| 3644 |
} |
| 3645 |
} |
| 3646 |
} |
| 3647 |
} |
| 3648 |
} |
| 3649 |
} |
| 3650 |
return c; |
| 3651 |
} |
| 3652 |
|
| 3653 |
|
| 3654 |
|
| 3655 |
|
| 3656 |
|
| 3657 |
|
| 3658 |
static void UI_InsertServerIntoDisplayList(int num, int position) { |
| 3659 |
int i; |
| 3660 |
|
| 3661 |
if (position < 0 || position > uiInfo.serverStatus.numDisplayServers ) { |
| 3662 |
return; |
| 3663 |
} |
| 3664 |
|
| 3665 |
uiInfo.serverStatus.numDisplayServers++; |
| 3666 |
for (i = uiInfo.serverStatus.numDisplayServers; i > position; i--) { |
| 3667 |
uiInfo.serverStatus.displayServers[i] = uiInfo.serverStatus.displayServers[i-1]; |
| 3668 |
} |
| 3669 |
uiInfo.serverStatus.displayServers[position] = num; |
| 3670 |
|
| 3671 |
|
| 3672 |
if ( position == uiInfo.serverStatus.currentServer ) { |
| 3673 |
UI_FeederSelection( FEEDER_SERVERS, uiInfo.serverStatus.currentServer ); |
| 3674 |
} |
| 3675 |
} |
| 3676 |
|
| 3677 |
|
| 3678 |
|
| 3679 |
|
| 3680 |
|
| 3681 |
|
| 3682 |
static void UI_RemoveServerFromDisplayList(int num) { |
| 3683 |
int i, j; |
| 3684 |
|
| 3685 |
for (i = 0; i < uiInfo.serverStatus.numDisplayServers; i++) { |
| 3686 |
if (uiInfo.serverStatus.displayServers[i] == num) { |
| 3687 |
uiInfo.serverStatus.numDisplayServers--; |
| 3688 |
for (j = i; j < uiInfo.serverStatus.numDisplayServers; j++) { |
| 3689 |
uiInfo.serverStatus.displayServers[j] = uiInfo.serverStatus.displayServers[j+1]; |
| 3690 |
} |
| 3691 |
return; |
| 3692 |
} |
| 3693 |
} |
| 3694 |
} |
| 3695 |
|
| 3696 |
|
| 3697 |
|
| 3698 |
|
| 3699 |
|
| 3700 |
|
| 3701 |
static void UI_BinaryServerInsertion(int num) { |
| 3702 |
int mid, offset, res, len; |
| 3703 |
|
| 3704 |
|
| 3705 |
len = uiInfo.serverStatus.numDisplayServers; |
| 3706 |
mid = len; |
| 3707 |
offset = 0; |
| 3708 |
res = 0; |
| 3709 |
while(mid > 0) { |
| 3710 |
mid = len >> 1; |
| 3711 |
|
| 3712 |
res = trap_LAN_CompareServers( UI_SourceForLAN(), uiInfo.serverStatus.sortKey, |
| 3713 |
uiInfo.serverStatus.sortDir, num, uiInfo.serverStatus.displayServers[offset+mid]); |
| 3714 |
|
| 3715 |
if (res == 0) { |
| 3716 |
UI_InsertServerIntoDisplayList(num, offset+mid); |
| 3717 |
return; |
| 3718 |
} |
| 3719 |
|
| 3720 |
else if (res == 1) { |
| 3721 |
offset += mid; |
| 3722 |
len -= mid; |
| 3723 |
} |
| 3724 |
|
| 3725 |
else { |
| 3726 |
len -= mid; |
| 3727 |
} |
| 3728 |
} |
| 3729 |
if (res == 1) { |
| 3730 |
offset++; |
| 3731 |
} |
| 3732 |
UI_InsertServerIntoDisplayList(num, offset); |
| 3733 |
} |
| 3734 |
|
| 3735 |
|
| 3736 |
|
| 3737 |
|
| 3738 |
|
| 3739 |
|
| 3740 |
static void UI_BuildServerDisplayList(int force) { |
| 3741 |
int i, count, clients, maxClients, ping, game, len, visible; |
| 3742 |
char info[MAX_STRING_CHARS]; |
| 3743 |
|
| 3744 |
int lanSource; |
| 3745 |
|
| 3746 |
if (!(force || uiInfo.uiDC.realTime > uiInfo.serverStatus.nextDisplayRefresh)) { |
| 3747 |
return; |
| 3748 |
} |
| 3749 |
|
| 3750 |
if ( force == 2 ) { |
| 3751 |
force = 0; |
| 3752 |
} |
| 3753 |
|
| 3754 |
|
| 3755 |
trap_Cvar_VariableStringBuffer( "cl_motdString", uiInfo.serverStatus.motd, sizeof(uiInfo.serverStatus.motd) ); |
| 3756 |
len = strlen(uiInfo.serverStatus.motd); |
| 3757 |
if (len == 0) { |
| 3758 |
strcpy(uiInfo.serverStatus.motd, "Welcome to Team Arena!"); |
| 3759 |
len = strlen(uiInfo.serverStatus.motd); |
| 3760 |
} |
| 3761 |
if (len != uiInfo.serverStatus.motdLen) { |
| 3762 |
uiInfo.serverStatus.motdLen = len; |
| 3763 |
uiInfo.serverStatus.motdWidth = -1; |
| 3764 |
} |
| 3765 |
|
| 3766 |
lanSource = UI_SourceForLAN(); |
| 3767 |
|
| 3768 |
if (force) { |
| 3769 |
|
| 3770 |
uiInfo.serverStatus.numDisplayServers = 0; |
| 3771 |
uiInfo.serverStatus.numPlayersOnServers = 0; |
| 3772 |
|
| 3773 |
Menu_SetFeederSelection(NULL, FEEDER_SERVERS, 0, NULL); |
| 3774 |
|
| 3775 |
trap_LAN_MarkServerVisible(lanSource, -1, qtrue); |
| 3776 |
} |
| 3777 |
|
| 3778 |
|
| 3779 |
count = trap_LAN_GetServerCount(lanSource); |
| 3780 |
if (count == -1 || (ui_netSource.integer == UIAS_LOCAL && count == 0) ) { |
| 3781 |
|
| 3782 |
uiInfo.serverStatus.numDisplayServers = 0; |
| 3783 |
uiInfo.serverStatus.numPlayersOnServers = 0; |
| 3784 |
uiInfo.serverStatus.nextDisplayRefresh = uiInfo.uiDC.realTime + 500; |
| 3785 |
return; |
| 3786 |
} |
| 3787 |
|
| 3788 |
visible = qfalse; |
| 3789 |
for (i = 0; i < count; i++) { |
| 3790 |
|
| 3791 |
if (!trap_LAN_ServerIsVisible(lanSource, i)) { |
| 3792 |
continue; |
| 3793 |
} |
| 3794 |
visible = qtrue; |
| 3795 |
|
| 3796 |
ping = trap_LAN_GetServerPing(lanSource, i); |
| 3797 |
if (ping > 0 || ui_netSource.integer == UIAS_FAVORITES) { |
| 3798 |
|
| 3799 |
|
| 3800 |
|
| 3801 |
if (ui_netSource.integer == UIAS_FAVORITES) { |
| 3802 |
UI_RemoveServerFromDisplayList(i); |
| 3803 |
} |
| 3804 |
|
| 3805 |
trap_LAN_GetServerInfo(lanSource, i, info, MAX_STRING_CHARS); |
| 3806 |
|
| 3807 |
clients = atoi(Info_ValueForKey(info, "clients")); |
| 3808 |
|
| 3809 |
if (ui_browserShowEmpty.integer == 0) { |
| 3810 |
if (clients == 0) { |
| 3811 |
if (ping > 0) { |
| 3812 |
trap_LAN_MarkServerVisible(lanSource, i, qfalse); |
| 3813 |
} |
| 3814 |
continue; |
| 3815 |
} |
| 3816 |
} |
| 3817 |
|
| 3818 |
if (ui_browserShowFull.integer == 0) { |
| 3819 |
maxClients = atoi(Info_ValueForKey(info, "sv_maxclients")); |
| 3820 |
if (clients == maxClients) { |
| 3821 |
if (ping > 0) { |
| 3822 |
trap_LAN_MarkServerVisible(lanSource, i, qfalse); |
| 3823 |
} |
| 3824 |
continue; |
| 3825 |
} |
| 3826 |
} |
| 3827 |
|
| 3828 |
if (uiInfo.joinGameTypes[ui_joinGameType.integer].gtEnum != -1) { |
| 3829 |
game = atoi(Info_ValueForKey(info, "gametype")); |
| 3830 |
if (game != uiInfo.joinGameTypes[ui_joinGameType.integer].gtEnum) { |
| 3831 |
if (ping > 0) { |
| 3832 |
trap_LAN_MarkServerVisible(lanSource, i, qfalse); |
| 3833 |
} |
| 3834 |
continue; |
| 3835 |
} |
| 3836 |
} |
| 3837 |
|
| 3838 |
if (ui_serverFilterType.integer > 0) { |
| 3839 |
if (Q_stricmp(Info_ValueForKey(info, "game"), serverFilters[ui_serverFilterType.integer].basedir) != 0) { |
| 3840 |
if (ping > 0) { |
| 3841 |
trap_LAN_MarkServerVisible(lanSource, i, qfalse); |
| 3842 |
} |
| 3843 |
continue; |
| 3844 |
} |
| 3845 |
} |
| 3846 |
|
| 3847 |
UI_BinaryServerInsertion(i); |
| 3848 |
|
| 3849 |
if (ping > 0) { |
| 3850 |
trap_LAN_MarkServerVisible(lanSource, i, qfalse); |
| 3851 |
uiInfo.serverStatus.numPlayersOnServers += clients; |
| 3852 |
} |
| 3853 |
} |
| 3854 |
} |
| 3855 |
|
| 3856 |
uiInfo.serverStatus.refreshtime = uiInfo.uiDC.realTime; |
| 3857 |
|
| 3858 |
|
| 3859 |
if (!visible) { |
| 3860 |
|
| 3861 |
|
| 3862 |
} |
| 3863 |
} |
| 3864 |
|
| 3865 |
typedef struct |
| 3866 |
{ |
| 3867 |
char *name, *altName; |
| 3868 |
} serverStatusCvar_t; |
| 3869 |
|
| 3870 |
serverStatusCvar_t serverStatusCvars[] = { |
| 3871 |
{"sv_hostname", "Name"}, |
| 3872 |
{"Address", ""}, |
| 3873 |
{"gamename", "Game name"}, |
| 3874 |
{"g_gametype", "Game type"}, |
| 3875 |
{"mapname", "Map"}, |
| 3876 |
{"version", ""}, |
| 3877 |
{"protocol", ""}, |
| 3878 |
{"timelimit", ""}, |
| 3879 |
{"fraglimit", ""}, |
| 3880 |
{NULL, NULL} |
| 3881 |
}; |
| 3882 |
|
| 3883 |
|
| 3884 |
|
| 3885 |
|
| 3886 |
|
| 3887 |
|
| 3888 |
static void UI_SortServerStatusInfo( serverStatusInfo_t *info ) { |
| 3889 |
int i, j, index; |
| 3890 |
char *tmp1, *tmp2; |
| 3891 |
|
| 3892 |
|
| 3893 |
|
| 3894 |
|
| 3895 |
index = 0; |
| 3896 |
for (i = 0; serverStatusCvars[i].name; i++) { |
| 3897 |
for (j = 0; j < info->numLines; j++) { |
| 3898 |
if ( !info->lines[j][1] || info->lines[j][1][0] ) { |
| 3899 |
continue; |
| 3900 |
} |
| 3901 |
if ( !Q_stricmp(serverStatusCvars[i].name, info->lines[j][0]) ) { |
| 3902 |
|
| 3903 |
tmp1 = info->lines[index][0]; |
| 3904 |
tmp2 = info->lines[index][3]; |
| 3905 |
info->lines[index][0] = info->lines[j][0]; |
| 3906 |
info->lines[index][3] = info->lines[j][3]; |
| 3907 |
info->lines[j][0] = tmp1; |
| 3908 |
info->lines[j][3] = tmp2; |
| 3909 |
|
| 3910 |
if ( strlen(serverStatusCvars[i].altName) ) { |
| 3911 |
info->lines[index][0] = serverStatusCvars[i].altName; |
| 3912 |
} |
| 3913 |
index++; |
| 3914 |
} |
| 3915 |
} |
| 3916 |
} |
| 3917 |
} |
| 3918 |
|
| 3919 |
|
| 3920 |
|
| 3921 |
|
| 3922 |
|
| 3923 |
|
| 3924 |
static int UI_GetServerStatusInfo( const char *serverAddress, serverStatusInfo_t *info ) { |
| 3925 |
char *p, *score, *ping, *name; |
| 3926 |
int i, len; |
| 3927 |
|
| 3928 |
if (info) { |
| 3929 |
memset(info, 0, sizeof(*info)); |
| 3930 |
} |
| 3931 |
|
| 3932 |
|
| 3933 |
if (serverAddress && *serverAddress == '\0') { |
| 3934 |
return qfalse; |
| 3935 |
} |
| 3936 |
|
| 3937 |
|
| 3938 |
if (!info) { |
| 3939 |
trap_LAN_ServerStatus( serverAddress, NULL, 0); |
| 3940 |
return qfalse; |
| 3941 |
} |
| 3942 |
|
| 3943 |
if ( trap_LAN_ServerStatus( serverAddress, info->text, sizeof(info->text)) ) { |
| 3944 |
Q_strncpyz(info->address, serverAddress, sizeof(info->address)); |
| 3945 |
p = info->text; |
| 3946 |
info->numLines = 0; |
| 3947 |
info->lines[info->numLines][0] = "Address"; |
| 3948 |
info->lines[info->numLines][1] = ""; |
| 3949 |
info->lines[info->numLines][2] = ""; |
| 3950 |
info->lines[info->numLines][3] = info->address; |
| 3951 |
info->numLines++; |
| 3952 |
|
| 3953 |
while (p && *p) { |
| 3954 |
p = strchr(p, '\\'); |
| 3955 |
if (!p) break; |
| 3956 |
*p++ = '\0'; |
| 3957 |
if (*p == '\\') |
| 3958 |
break; |
| 3959 |
info->lines[info->numLines][0] = p; |
| 3960 |
info->lines[info->numLines][1] = ""; |
| 3961 |
info->lines[info->numLines][2] = ""; |
| 3962 |
p = strchr(p, '\\'); |
| 3963 |
if (!p) break; |
| 3964 |
*p++ = '\0'; |
| 3965 |
info->lines[info->numLines][3] = p; |
| 3966 |
|
| 3967 |
info->numLines++; |
| 3968 |
if (info->numLines >= MAX_SERVERSTATUS_LINES) |
| 3969 |
break; |
| 3970 |
} |
| 3971 |
|
| 3972 |
if (info->numLines < MAX_SERVERSTATUS_LINES-3) { |
| 3973 |
|
| 3974 |
info->lines[info->numLines][0] = ""; |
| 3975 |
info->lines[info->numLines][1] = ""; |
| 3976 |
info->lines[info->numLines][2] = ""; |
| 3977 |
info->lines[info->numLines][3] = ""; |
| 3978 |
info->numLines++; |
| 3979 |
|
| 3980 |
info->lines[info->numLines][0] = "num"; |
| 3981 |
info->lines[info->numLines][1] = "score"; |
| 3982 |
info->lines[info->numLines][2] = "ping"; |
| 3983 |
info->lines[info->numLines][3] = "name"; |
| 3984 |
info->numLines++; |
| 3985 |
|
| 3986 |
i = 0; |
| 3987 |
len = 0; |
| 3988 |
while (p && *p) { |
| 3989 |
if (*p == '\\') |
| 3990 |
*p++ = '\0'; |
| 3991 |
score = p; |
| 3992 |
p = strchr(p, ' '); |
| 3993 |
if (!p) |
| 3994 |
break; |
| 3995 |
*p++ = '\0'; |
| 3996 |
ping = p; |
| 3997 |
p = strchr(p, ' '); |
| 3998 |
if (!p) |
| 3999 |
break; |
| 4000 |
*p++ = '\0'; |
| 4001 |
name = p; |
| 4002 |
Com_sprintf(&info->pings[len], sizeof(info->pings)-len, "%d", i); |
| 4003 |
info->lines[info->numLines][0] = &info->pings[len]; |
| 4004 |
len += strlen(&info->pings[len]) + 1; |
| 4005 |
info->lines[info->numLines][1] = score; |
| 4006 |
info->lines[info->numLines][2] = ping; |
| 4007 |
info->lines[info->numLines][3] = name; |
| 4008 |
info->numLines++; |
| 4009 |
if (info->numLines >= MAX_SERVERSTATUS_LINES) |
| 4010 |
break; |
| 4011 |
p = strchr(p, '\\'); |
| 4012 |
if (!p) |
| 4013 |
break; |
| 4014 |
*p++ = '\0'; |
| 4015 |
|
| 4016 |
i++; |
| 4017 |
} |
| 4018 |
} |
| 4019 |
UI_SortServerStatusInfo( info ); |
| 4020 |
return qtrue; |
| 4021 |
} |
| 4022 |
return qfalse; |
| 4023 |
} |
| 4024 |
|
| 4025 |
|
| 4026 |
|
| 4027 |
|
| 4028 |
|
| 4029 |
|
| 4030 |
static char *stristr(char *str, char *charset) { |
| 4031 |
int i; |
| 4032 |
|
| 4033 |
while(*str) { |
| 4034 |
for (i = 0; charset[i] && str[i]; i++) { |
| 4035 |
if (toupper(charset[i]) != toupper(str[i])) break; |
| 4036 |
} |
| 4037 |
if (!charset[i]) return str; |
| 4038 |
str++; |
| 4039 |
} |
| 4040 |
return NULL; |
| 4041 |
} |
| 4042 |
|
| 4043 |
|
| 4044 |
|
| 4045 |
|
| 4046 |
|
| 4047 |
|
| 4048 |
static void UI_BuildFindPlayerList(qboolean force) { |
| 4049 |
static int numFound; |
| 4050 |
int i, j, resend; |
| 4051 |
serverStatusInfo_t info; |
| 4052 |
char name[MAX_NAME_LENGTH+2]; |
| 4053 |
char infoString[MAX_STRING_CHARS]; |
| 4054 |
int lanSource; |
| 4055 |
|
| 4056 |
if (!force) { |
| 4057 |
if (!uiInfo.nextFindPlayerRefresh || uiInfo.nextFindPlayerRefresh > uiInfo.uiDC.realTime) { |
| 4058 |
return; |
| 4059 |
} |
| 4060 |
} |
| 4061 |
else { |
| 4062 |
memset(&uiInfo.pendingServerStatus, 0, sizeof(uiInfo.pendingServerStatus)); |
| 4063 |
uiInfo.numFoundPlayerServers = 0; |
| 4064 |
uiInfo.currentFoundPlayerServer = 0; |
| 4065 |
trap_Cvar_VariableStringBuffer( "ui_findPlayer", uiInfo.findPlayerName, sizeof(uiInfo.findPlayerName)); |
| 4066 |
Q_CleanStr(uiInfo.findPlayerName); |
| 4067 |
|
| 4068 |
if (!strlen(uiInfo.findPlayerName)) { |
| 4069 |
uiInfo.nextFindPlayerRefresh = 0; |
| 4070 |
return; |
| 4071 |
} |
| 4072 |
|
| 4073 |
resend = ui_serverStatusTimeOut.integer / 2 - 10; |
| 4074 |
if (resend < 50) { |
| 4075 |
resend = 50; |
| 4076 |
} |
| 4077 |
trap_Cvar_Set("cl_serverStatusResendTime", va("%d", resend)); |
| 4078 |
|
| 4079 |
trap_LAN_ServerStatus( NULL, NULL, 0); |
| 4080 |
|
| 4081 |
uiInfo.numFoundPlayerServers = 1; |
| 4082 |
Com_sprintf(uiInfo.foundPlayerServerNames[uiInfo.numFoundPlayerServers-1], |
| 4083 |
sizeof(uiInfo.foundPlayerServerNames[uiInfo.numFoundPlayerServers-1]), |
| 4084 |
"searching %d...", uiInfo.pendingServerStatus.num); |
| 4085 |
numFound = 0; |
| 4086 |
} |
| 4087 |
for (i = 0; i < MAX_SERVERSTATUSREQUESTS; i++) { |
| 4088 |
|
| 4089 |
if (uiInfo.pendingServerStatus.server[i].valid) { |
| 4090 |
|
| 4091 |
if (UI_GetServerStatusInfo( uiInfo.pendingServerStatus.server[i].adrstr, &info ) ) { |
| 4092 |
|
| 4093 |
numFound++; |
| 4094 |
|
| 4095 |
for (j = 0; j < info.numLines; j++) { |
| 4096 |
|
| 4097 |
if ( !info.lines[j][2] || !info.lines[j][2][0] ) { |
| 4098 |
continue; |
| 4099 |
} |
| 4100 |
|
| 4101 |
Q_strncpyz(name, info.lines[j][3], sizeof(name)); |
| 4102 |
Q_CleanStr(name); |
| 4103 |
|
| 4104 |
if (stristr(name, uiInfo.findPlayerName)) { |
| 4105 |
|
| 4106 |
if (uiInfo.numFoundPlayerServers < MAX_FOUNDPLAYER_SERVERS-1) { |
| 4107 |
|
| 4108 |
Q_strncpyz(uiInfo.foundPlayerServerAddresses[uiInfo.numFoundPlayerServers-1], |
| 4109 |
uiInfo.pendingServerStatus.server[i].adrstr, |
| 4110 |
sizeof(uiInfo.foundPlayerServerAddresses[0])); |
| 4111 |
Q_strncpyz(uiInfo.foundPlayerServerNames[uiInfo.numFoundPlayerServers-1], |
| 4112 |
uiInfo.pendingServerStatus.server[i].name, |
| 4113 |
sizeof(uiInfo.foundPlayerServerNames[0])); |
| 4114 |
uiInfo.numFoundPlayerServers++; |
| 4115 |
} |
| 4116 |
else { |
| 4117 |
|
| 4118 |
uiInfo.pendingServerStatus.num = uiInfo.serverStatus.numDisplayServers; |
| 4119 |
} |
| 4120 |
} |
| 4121 |
} |
| 4122 |
Com_sprintf(uiInfo.foundPlayerServerNames[uiInfo.numFoundPlayerServers-1], |
| 4123 |
sizeof(uiInfo.foundPlayerServerNames[uiInfo.numFoundPlayerServers-1]), |
| 4124 |
"searching %d/%d...", uiInfo.pendingServerStatus.num, numFound); |
| 4125 |
|
| 4126 |
uiInfo.pendingServerStatus.server[i].valid = qfalse; |
| 4127 |
} |
| 4128 |
} |
| 4129 |
|
| 4130 |
if (!uiInfo.pendingServerStatus.server[i].valid || |
| 4131 |
uiInfo.pendingServerStatus.server[i].startTime < uiInfo.uiDC.realTime - ui_serverStatusTimeOut.integer) { |
| 4132 |
|
| 4133 |
UI_GetServerStatusInfo( uiInfo.pendingServerStatus.server[i].adrstr, NULL ); |
| 4134 |
|
| 4135 |
uiInfo.pendingServerStatus.server[i].valid = qfalse; |
| 4136 |
|
| 4137 |
if (uiInfo.pendingServerStatus.num < uiInfo.serverStatus.numDisplayServers) { |
| 4138 |
uiInfo.pendingServerStatus.server[i].startTime = uiInfo.uiDC.realTime; |
| 4139 |
lanSource = UI_SourceForLAN(); |
| 4140 |
trap_LAN_GetServerAddressString(lanSource, uiInfo.serverStatus.displayServers[uiInfo.pendingServerStatus.num], |
| 4141 |
uiInfo.pendingServerStatus.server[i].adrstr, sizeof(uiInfo.pendingServerStatus.server[i].adrstr)); |
| 4142 |
trap_LAN_GetServerInfo(lanSource, uiInfo.serverStatus.displayServers[uiInfo.pendingServerStatus.num], infoString, sizeof(infoString)); |
| 4143 |
Q_strncpyz(uiInfo.pendingServerStatus.server[i].name, Info_ValueForKey(infoString, "hostname"), sizeof(uiInfo.pendingServerStatus.server[0].name)); |
| 4144 |
uiInfo.pendingServerStatus.server[i].valid = qtrue; |
| 4145 |
uiInfo.pendingServerStatus.num++; |
| 4146 |
Com_sprintf(uiInfo.foundPlayerServerNames[uiInfo.numFoundPlayerServers-1], |
| 4147 |
sizeof(uiInfo.foundPlayerServerNames[uiInfo.numFoundPlayerServers-1]), |
| 4148 |
"searching %d/%d...", uiInfo.pendingServerStatus.num, numFound); |
| 4149 |
} |
| 4150 |
} |
| 4151 |
} |
| 4152 |
for (i = 0; i < MAX_SERVERSTATUSREQUESTS; i++) { |
| 4153 |
if (uiInfo.pendingServerStatus.server[i].valid) { |
| 4154 |
break; |
| 4155 |
} |
| 4156 |
} |
| 4157 |
|
| 4158 |
if (i < MAX_SERVERSTATUSREQUESTS) { |
| 4159 |
uiInfo.nextFindPlayerRefresh = uiInfo.uiDC.realTime + 25; |
| 4160 |
} |
| 4161 |
else { |
| 4162 |
|
| 4163 |
if (!uiInfo.numFoundPlayerServers) { |
| 4164 |
Com_sprintf(uiInfo.foundPlayerServerNames[0], sizeof(uiInfo.foundPlayerServerNames[0]), "no servers found"); |
| 4165 |
} |
| 4166 |
else { |
| 4167 |
Com_sprintf(uiInfo.foundPlayerServerNames[uiInfo.numFoundPlayerServers-1], sizeof(uiInfo.foundPlayerServerNames[0]), |
| 4168 |
"%d server%s found with player %s", uiInfo.numFoundPlayerServers-1, |
| 4169 |
uiInfo.numFoundPlayerServers == 2 ? "":"s", uiInfo.findPlayerName); |
| 4170 |
} |
| 4171 |
uiInfo.nextFindPlayerRefresh = 0; |
| 4172 |
|
| 4173 |
UI_FeederSelection(FEEDER_FINDPLAYER, uiInfo.currentFoundPlayerServer); |
| 4174 |
} |
| 4175 |
} |
| 4176 |
|
| 4177 |
|
| 4178 |
|
| 4179 |
|
| 4180 |
|
| 4181 |
|
| 4182 |
static void UI_BuildServerStatus(qboolean force) { |
| 4183 |
|
| 4184 |
if (uiInfo.nextFindPlayerRefresh) { |
| 4185 |
return; |
| 4186 |
} |
| 4187 |
if (!force) { |
| 4188 |
if (!uiInfo.nextServerStatusRefresh || uiInfo.nextServerStatusRefresh > uiInfo.uiDC.realTime) { |
| 4189 |
return; |
| 4190 |
} |
| 4191 |
} |
| 4192 |
else { |
| 4193 |
Menu_SetFeederSelection(NULL, FEEDER_SERVERSTATUS, 0, NULL); |
| 4194 |
uiInfo.serverStatusInfo.numLines = 0; |
| 4195 |
|
| 4196 |
trap_LAN_ServerStatus( NULL, NULL, 0); |
| 4197 |
} |
| 4198 |
if (uiInfo.serverStatus.currentServer < 0 || uiInfo.serverStatus.currentServer > uiInfo.serverStatus.numDisplayServers || uiInfo.serverStatus.numDisplayServers == 0) { |
| 4199 |
return; |
| 4200 |
} |
| 4201 |
if (UI_GetServerStatusInfo( uiInfo.serverStatusAddress, &uiInfo.serverStatusInfo ) ) { |
| 4202 |
uiInfo.nextServerStatusRefresh = 0; |
| 4203 |
UI_GetServerStatusInfo( uiInfo.serverStatusAddress, NULL ); |
| 4204 |
} |
| 4205 |
else { |
| 4206 |
uiInfo.nextServerStatusRefresh = uiInfo.uiDC.realTime + 500; |
| 4207 |
} |
| 4208 |
} |
| 4209 |
|
| 4210 |
|
| 4211 |
|
| 4212 |
|
| 4213 |
|
| 4214 |
|
| 4215 |
static int UI_FeederCount(float feederID) { |
| 4216 |
if (feederID == FEEDER_HEADS) { |
| 4217 |
return UI_HeadCountByTeam(); |
| 4218 |
} else if (feederID == FEEDER_Q3HEADS) { |
| 4219 |
return uiInfo.q3HeadCount; |
| 4220 |
} else if (feederID == FEEDER_CINEMATICS) { |
| 4221 |
return uiInfo.movieCount; |
| 4222 |
} else if (feederID == FEEDER_MAPS || feederID == FEEDER_ALLMAPS) { |
| 4223 |
return UI_MapCountByGameType(feederID == FEEDER_MAPS ? qtrue : qfalse); |
| 4224 |
} else if (feederID == FEEDER_SERVERS) { |
| 4225 |
return uiInfo.serverStatus.numDisplayServers; |
| 4226 |
} else if (feederID == FEEDER_SERVERSTATUS) { |
| 4227 |
return uiInfo.serverStatusInfo.numLines; |
| 4228 |
} else if (feederID == FEEDER_FINDPLAYER) { |
| 4229 |
return uiInfo.numFoundPlayerServers; |
| 4230 |
} else if (feederID == FEEDER_PLAYER_LIST) { |
| 4231 |
if (uiInfo.uiDC.realTime > uiInfo.playerRefresh) { |
| 4232 |
uiInfo.playerRefresh = uiInfo.uiDC.realTime + 3000; |
| 4233 |
UI_BuildPlayerList(); |
| 4234 |
} |
| 4235 |
return uiInfo.playerCount; |
| 4236 |
} else if (feederID == FEEDER_TEAM_LIST) { |
| 4237 |
if (uiInfo.uiDC.realTime > uiInfo.playerRefresh) { |
| 4238 |
uiInfo.playerRefresh = uiInfo.uiDC.realTime + 3000; |
| 4239 |
UI_BuildPlayerList(); |
| 4240 |
} |
| 4241 |
return uiInfo.myTeamCount; |
| 4242 |
} else if (feederID == FEEDER_MODS) { |
| 4243 |
return uiInfo.modCount; |
| 4244 |
} else if (feederID == FEEDER_DEMOS) { |
| 4245 |
return uiInfo.demoCount; |
| 4246 |
} |
| 4247 |
return 0; |
| 4248 |
} |
| 4249 |
|
| 4250 |
static const char *UI_SelectedMap(int index, int *actual) { |
| 4251 |
int i, c; |
| 4252 |
c = 0; |
| 4253 |
*actual = 0; |
| 4254 |
for (i = 0; i < uiInfo.mapCount; i++) { |
| 4255 |
if (uiInfo.mapList[i].active) { |
| 4256 |
if (c == index) { |
| 4257 |
*actual = i; |
| 4258 |
return uiInfo.mapList[i].mapName; |
| 4259 |
} else { |
| 4260 |
c++; |
| 4261 |
} |
| 4262 |
} |
| 4263 |
} |
| 4264 |
return ""; |
| 4265 |
} |
| 4266 |
|
| 4267 |
static const char *UI_SelectedHead(int index, int *actual) { |
| 4268 |
int i, c; |
| 4269 |
c = 0; |
| 4270 |
*actual = 0; |
| 4271 |
for (i = 0; i < uiInfo.characterCount; i++) { |
| 4272 |
if (uiInfo.characterList[i].active) { |
| 4273 |
if (c == index) { |
| 4274 |
*actual = i; |
| 4275 |
return uiInfo.characterList[i].name; |
| 4276 |
} else { |
| 4277 |
c++; |
| 4278 |
} |
| 4279 |
} |
| 4280 |
} |
| 4281 |
return ""; |
| 4282 |
} |
| 4283 |
|
| 4284 |
static int UI_GetIndexFromSelection(int actual) { |
| 4285 |
int i, c; |
| 4286 |
c = 0; |
| 4287 |
for (i = 0; i < uiInfo.mapCount; i++) { |
| 4288 |
if (uiInfo.mapList[i].active) { |
| 4289 |
if (i == actual) { |
| 4290 |
return c; |
| 4291 |
} |
| 4292 |
c++; |
| 4293 |
} |
| 4294 |
} |
| 4295 |
return 0; |
| 4296 |
} |
| 4297 |
|
| 4298 |
static void UI_UpdatePendingPings( void ) { |
| 4299 |
trap_LAN_ResetPings(UI_SourceForLAN()); |
| 4300 |
uiInfo.serverStatus.refreshActive = qtrue; |
| 4301 |
uiInfo.serverStatus.refreshtime = uiInfo.uiDC.realTime + 1000; |
| 4302 |
|
| 4303 |
} |
| 4304 |
|
| 4305 |
static const char *UI_FeederItemText(float feederID, int index, int column, qhandle_t *handle) { |
| 4306 |
static char info[MAX_STRING_CHARS]; |
| 4307 |
static char hostname[1024]; |
| 4308 |
static char clientBuff[32]; |
| 4309 |
static int lastColumn = -1; |
| 4310 |
static int lastTime = 0; |
| 4311 |
*handle = -1; |
| 4312 |
if (feederID == FEEDER_HEADS) { |
| 4313 |
int actual; |
| 4314 |
return UI_SelectedHead(index, &actual); |
| 4315 |
} else if (feederID == FEEDER_Q3HEADS) { |
| 4316 |
if (index >= 0 && index < uiInfo.q3HeadCount) { |
| 4317 |
return uiInfo.q3HeadNames[index]; |
| 4318 |
} |
| 4319 |
} else if (feederID == FEEDER_MAPS || feederID == FEEDER_ALLMAPS) { |
| 4320 |
int actual; |
| 4321 |
return UI_SelectedMap(index, &actual); |
| 4322 |
} else if (feederID == FEEDER_SERVERS) { |
| 4323 |
if (index >= 0 && index < uiInfo.serverStatus.numDisplayServers) { |
| 4324 |
int ping, game, punkbuster; |
| 4325 |
if (lastColumn != column || lastTime > uiInfo.uiDC.realTime + 5000) { |
| 4326 |
trap_LAN_GetServerInfo(UI_SourceForLAN(), uiInfo.serverStatus.displayServers[index], info, MAX_STRING_CHARS); |
| 4327 |
lastColumn = column; |
| 4328 |
lastTime = uiInfo.uiDC.realTime; |
| 4329 |
} |
| 4330 |
ping = atoi(Info_ValueForKey(info, "ping")); |
| 4331 |
if (ping == -1) { |
| 4332 |
|
| 4333 |
|
| 4334 |
} |
| 4335 |
switch (column) { |
| 4336 |
case SORT_HOST : |
| 4337 |
if (ping <= 0) { |
| 4338 |
return Info_ValueForKey(info, "addr"); |
| 4339 |
} else { |
| 4340 |
if ( ui_netSource.integer == UIAS_LOCAL ) { |
| 4341 |
int nettype = atoi(Info_ValueForKey(info, "nettype")); |
| 4342 |
|
| 4343 |
if (nettype < 0 || nettype >= ARRAY_LEN(netnames)) { |
| 4344 |
nettype = 0; |
| 4345 |
} |
| 4346 |
|
| 4347 |
Com_sprintf( hostname, sizeof(hostname), "%s [%s]", |
| 4348 |
Info_ValueForKey(info, "hostname"), |
| 4349 |
netnames[nettype] ); |
| 4350 |
return hostname; |
| 4351 |
} |
| 4352 |
else { |
| 4353 |
Com_sprintf( hostname, sizeof(hostname), "%s", Info_ValueForKey(info, "hostname")); |
| 4354 |
return hostname; |
| 4355 |
} |
| 4356 |
} |
| 4357 |
case SORT_MAP : return Info_ValueForKey(info, "mapname"); |
| 4358 |
case SORT_CLIENTS : |
| 4359 |
Com_sprintf( clientBuff, sizeof(clientBuff), "%s (%s)", Info_ValueForKey(info, "clients"), Info_ValueForKey(info, "sv_maxclients")); |
| 4360 |
return clientBuff; |
| 4361 |
case SORT_GAME : |
| 4362 |
game = atoi(Info_ValueForKey(info, "gametype")); |
| 4363 |
if (game >= 0 && game < numTeamArenaGameTypes) { |
| 4364 |
return teamArenaGameTypes[game]; |
| 4365 |
} else { |
| 4366 |
return "Unknown"; |
| 4367 |
} |
| 4368 |
case SORT_PING : |
| 4369 |
if (ping <= 0) { |
| 4370 |
return "..."; |
| 4371 |
} else { |
| 4372 |
return Info_ValueForKey(info, "ping"); |
| 4373 |
} |
| 4374 |
case SORT_PUNKBUSTER: |
| 4375 |
punkbuster = atoi(Info_ValueForKey(info, "punkbuster")); |
| 4376 |
if ( punkbuster ) { |
| 4377 |
return "Yes"; |
| 4378 |
} else { |
| 4379 |
return "No"; |
| 4380 |
} |
| 4381 |
} |
| 4382 |
} |
| 4383 |
} else if (feederID == FEEDER_SERVERSTATUS) { |
| 4384 |
if ( index >= 0 && index < uiInfo.serverStatusInfo.numLines ) { |
| 4385 |
if ( column >= 0 && column < 4 ) { |
| 4386 |
return uiInfo.serverStatusInfo.lines[index][column]; |
| 4387 |
} |
| 4388 |
} |
| 4389 |
} else if (feederID == FEEDER_FINDPLAYER) { |
| 4390 |
if ( index >= 0 && index < uiInfo.numFoundPlayerServers ) { |
| 4391 |
|
| 4392 |
return uiInfo.foundPlayerServerNames[index]; |
| 4393 |
} |
| 4394 |
} else if (feederID == FEEDER_PLAYER_LIST) { |
| 4395 |
if (index >= 0 && index < uiInfo.playerCount) { |
| 4396 |
return uiInfo.playerNames[index]; |
| 4397 |
} |
| 4398 |
} else if (feederID == FEEDER_TEAM_LIST) { |
| 4399 |
if (index >= 0 && index < uiInfo.myTeamCount) { |
| 4400 |
return uiInfo.teamNames[index]; |
| 4401 |
} |
| 4402 |
} else if (feederID == FEEDER_MODS) { |
| 4403 |
if (index >= 0 && index < uiInfo.modCount) { |
| 4404 |
if (uiInfo.modList[index].modDescr && *uiInfo.modList[index].modDescr) { |
| 4405 |
return uiInfo.modList[index].modDescr; |
| 4406 |
} else { |
| 4407 |
return uiInfo.modList[index].modName; |
| 4408 |
} |
| 4409 |
} |
| 4410 |
} else if (feederID == FEEDER_CINEMATICS) { |
| 4411 |
if (index >= 0 && index < uiInfo.movieCount) { |
| 4412 |
return uiInfo.movieList[index]; |
| 4413 |
} |
| 4414 |
} else if (feederID == FEEDER_DEMOS) { |
| 4415 |
if (index >= 0 && index < uiInfo.demoCount) { |
| 4416 |
return uiInfo.demoList[index]; |
| 4417 |
} |
| 4418 |
} |
| 4419 |
return ""; |
| 4420 |
} |
| 4421 |
|
| 4422 |
|
| 4423 |
static qhandle_t UI_FeederItemImage(float feederID, int index) { |
| 4424 |
if (feederID == FEEDER_HEADS) { |
| 4425 |
int actual; |
| 4426 |
UI_SelectedHead(index, &actual); |
| 4427 |
index = actual; |
| 4428 |
if (index >= 0 && index < uiInfo.characterCount) { |
| 4429 |
if (uiInfo.characterList[index].headImage == -1) { |
| 4430 |
uiInfo.characterList[index].headImage = trap_R_RegisterShaderNoMip(uiInfo.characterList[index].imageName); |
| 4431 |
} |
| 4432 |
return uiInfo.characterList[index].headImage; |
| 4433 |
} |
| 4434 |
} else if (feederID == FEEDER_Q3HEADS) { |
| 4435 |
if (index >= 0 && index < uiInfo.q3HeadCount) { |
| 4436 |
return uiInfo.q3HeadIcons[index]; |
| 4437 |
} |
| 4438 |
} else if (feederID == FEEDER_ALLMAPS || feederID == FEEDER_MAPS) { |
| 4439 |
int actual; |
| 4440 |
UI_SelectedMap(index, &actual); |
| 4441 |
index = actual; |
| 4442 |
if (index >= 0 && index < uiInfo.mapCount) { |
| 4443 |
if (uiInfo.mapList[index].levelShot == -1) { |
| 4444 |
uiInfo.mapList[index].levelShot = trap_R_RegisterShaderNoMip(uiInfo.mapList[index].imageName); |
| 4445 |
} |
| 4446 |
return uiInfo.mapList[index].levelShot; |
| 4447 |
} |
| 4448 |
} |
| 4449 |
return 0; |
| 4450 |
} |
| 4451 |
|
| 4452 |
static void UI_FeederSelection(float feederID, int index) { |
| 4453 |
static char info[MAX_STRING_CHARS]; |
| 4454 |
if (feederID == FEEDER_HEADS) { |
| 4455 |
int actual; |
| 4456 |
UI_SelectedHead(index, &actual); |
| 4457 |
index = actual; |
| 4458 |
if (index >= 0 && index < uiInfo.characterCount) { |
| 4459 |
trap_Cvar_Set( "team_model", uiInfo.characterList[index].base); |
| 4460 |
trap_Cvar_Set( "team_headmodel", va("*%s", uiInfo.characterList[index].name)); |
| 4461 |
updateModel = qtrue; |
| 4462 |
} |
| 4463 |
} else if (feederID == FEEDER_Q3HEADS) { |
| 4464 |
if (index >= 0 && index < uiInfo.q3HeadCount) { |
| 4465 |
trap_Cvar_Set( "model", uiInfo.q3HeadNames[index]); |
| 4466 |
trap_Cvar_Set( "headmodel", uiInfo.q3HeadNames[index]); |
| 4467 |
updateModel = qtrue; |
| 4468 |
} |
| 4469 |
} else if (feederID == FEEDER_MAPS || feederID == FEEDER_ALLMAPS) { |
| 4470 |
int actual, map; |
| 4471 |
map = (feederID == FEEDER_ALLMAPS) ? ui_currentNetMap.integer : ui_currentMap.integer; |
| 4472 |
if (uiInfo.mapList[map].cinematic >= 0) { |
| 4473 |
trap_CIN_StopCinematic(uiInfo.mapList[map].cinematic); |
| 4474 |
uiInfo.mapList[map].cinematic = -1; |
| 4475 |
} |
| 4476 |
UI_SelectedMap(index, &actual); |
| 4477 |
trap_Cvar_Set("ui_mapIndex", va("%d", index)); |
| 4478 |
ui_mapIndex.integer = index; |
| 4479 |
|
| 4480 |
if (feederID == FEEDER_MAPS) { |
| 4481 |
ui_currentMap.integer = actual; |
| 4482 |
trap_Cvar_Set("ui_currentMap", va("%d", actual)); |
| 4483 |
uiInfo.mapList[ui_currentMap.integer].cinematic = trap_CIN_PlayCinematic(va("%s.roq", uiInfo.mapList[ui_currentMap.integer].mapLoadName), 0, 0, 0, 0, (CIN_loop | CIN_silent) ); |
| 4484 |
UI_LoadBestScores(uiInfo.mapList[ui_currentMap.integer].mapLoadName, uiInfo.gameTypes[ui_gameType.integer].gtEnum); |
| 4485 |
trap_Cvar_Set("ui_opponentModel", uiInfo.mapList[ui_currentMap.integer].opponentName); |
| 4486 |
updateOpponentModel = qtrue; |
| 4487 |
} else { |
| 4488 |
ui_currentNetMap.integer = actual; |
| 4489 |
trap_Cvar_Set("ui_currentNetMap", va("%d", actual)); |
| 4490 |
uiInfo.mapList[ui_currentNetMap.integer].cinematic = trap_CIN_PlayCinematic(va("%s.roq", uiInfo.mapList[ui_currentNetMap.integer].mapLoadName), 0, 0, 0, 0, (CIN_loop | CIN_silent) ); |
| 4491 |
} |
| 4492 |
|
| 4493 |
} else if (feederID == FEEDER_SERVERS) { |
| 4494 |
const char *mapName = NULL; |
| 4495 |
uiInfo.serverStatus.currentServer = index; |
| 4496 |
trap_LAN_GetServerInfo(UI_SourceForLAN(), uiInfo.serverStatus.displayServers[index], info, MAX_STRING_CHARS); |
| 4497 |
uiInfo.serverStatus.currentServerPreview = trap_R_RegisterShaderNoMip(va("levelshots/%s", Info_ValueForKey(info, "mapname"))); |
| 4498 |
if (uiInfo.serverStatus.currentServerCinematic >= 0) { |
| 4499 |
trap_CIN_StopCinematic(uiInfo.serverStatus.currentServerCinematic); |
| 4500 |
uiInfo.serverStatus.currentServerCinematic = -1; |
| 4501 |
} |
| 4502 |
mapName = Info_ValueForKey(info, "mapname"); |
| 4503 |
if (mapName && *mapName) { |
| 4504 |
uiInfo.serverStatus.currentServerCinematic = trap_CIN_PlayCinematic(va("%s.roq", mapName), 0, 0, 0, 0, (CIN_loop | CIN_silent) ); |
| 4505 |
} |
| 4506 |
} else if (feederID == FEEDER_SERVERSTATUS) { |
| 4507 |
|
| 4508 |
} else if (feederID == FEEDER_FINDPLAYER) { |
| 4509 |
uiInfo.currentFoundPlayerServer = index; |
| 4510 |
|
| 4511 |
if ( index < uiInfo.numFoundPlayerServers-1) { |
| 4512 |
|
| 4513 |
Q_strncpyz(uiInfo.serverStatusAddress, uiInfo.foundPlayerServerAddresses[uiInfo.currentFoundPlayerServer], sizeof(uiInfo.serverStatusAddress)); |
| 4514 |
Menu_SetFeederSelection(NULL, FEEDER_SERVERSTATUS, 0, NULL); |
| 4515 |
UI_BuildServerStatus(qtrue); |
| 4516 |
} |
| 4517 |
} else if (feederID == FEEDER_PLAYER_LIST) { |
| 4518 |
uiInfo.playerIndex = index; |
| 4519 |
} else if (feederID == FEEDER_TEAM_LIST) { |
| 4520 |
uiInfo.teamIndex = index; |
| 4521 |
} else if (feederID == FEEDER_MODS) { |
| 4522 |
uiInfo.modIndex = index; |
| 4523 |
} else if (feederID == FEEDER_CINEMATICS) { |
| 4524 |
uiInfo.movieIndex = index; |
| 4525 |
if (uiInfo.previewMovie >= 0) { |
| 4526 |
trap_CIN_StopCinematic(uiInfo.previewMovie); |
| 4527 |
} |
| 4528 |
uiInfo.previewMovie = -1; |
| 4529 |
} else if (feederID == FEEDER_DEMOS) { |
| 4530 |
uiInfo.demoIndex = index; |
| 4531 |
} |
| 4532 |
} |
| 4533 |
|
| 4534 |
static qboolean Team_Parse(char **p) { |
| 4535 |
char *token; |
| 4536 |
const char *tempStr; |
| 4537 |
int i; |
| 4538 |
|
| 4539 |
token = COM_ParseExt(p, qtrue); |
| 4540 |
|
| 4541 |
if (token[0] != '{') { |
| 4542 |
return qfalse; |
| 4543 |
} |
| 4544 |
|
| 4545 |
while ( 1 ) { |
| 4546 |
|
| 4547 |
token = COM_ParseExt(p, qtrue); |
| 4548 |
|
| 4549 |
if (Q_stricmp(token, "}") == 0) { |
| 4550 |
return qtrue; |
| 4551 |
} |
| 4552 |
|
| 4553 |
if (!token[0]) { |
| 4554 |
return qfalse; |
| 4555 |
} |
| 4556 |
|
| 4557 |
if (token[0] == '{') { |
| 4558 |
if (uiInfo.teamCount == MAX_TEAMS) { |
| 4559 |
uiInfo.teamCount--; |
| 4560 |
Com_Printf("Too many teams, last team replaced!\n"); |
| 4561 |
} |
| 4562 |
|
| 4563 |
|
| 4564 |
if (!String_Parse(p, &uiInfo.teamList[uiInfo.teamCount].teamName) || !String_Parse(p, &tempStr)) { |
| 4565 |
return qfalse; |
| 4566 |
} |
| 4567 |
|
| 4568 |
|
| 4569 |
uiInfo.teamList[uiInfo.teamCount].imageName = tempStr; |
| 4570 |
uiInfo.teamList[uiInfo.teamCount].teamIcon = trap_R_RegisterShaderNoMip(uiInfo.teamList[uiInfo.teamCount].imageName); |
| 4571 |
uiInfo.teamList[uiInfo.teamCount].teamIcon_Metal = trap_R_RegisterShaderNoMip(va("%s_metal",uiInfo.teamList[uiInfo.teamCount].imageName)); |
| 4572 |
uiInfo.teamList[uiInfo.teamCount].teamIcon_Name = trap_R_RegisterShaderNoMip(va("%s_name", uiInfo.teamList[uiInfo.teamCount].imageName)); |
| 4573 |
|
| 4574 |
uiInfo.teamList[uiInfo.teamCount].cinematic = -1; |
| 4575 |
|
| 4576 |
for (i = 0; i < TEAM_MEMBERS; i++) { |
| 4577 |
uiInfo.teamList[uiInfo.teamCount].teamMembers[i] = NULL; |
| 4578 |
if (!String_Parse(p, &uiInfo.teamList[uiInfo.teamCount].teamMembers[i])) { |
| 4579 |
return qfalse; |
| 4580 |
} |
| 4581 |
} |
| 4582 |
|
| 4583 |
Com_Printf("Loaded team %s with team icon %s.\n", uiInfo.teamList[uiInfo.teamCount].teamName, tempStr); |
| 4584 |
uiInfo.teamCount++; |
| 4585 |
|
| 4586 |
token = COM_ParseExt(p, qtrue); |
| 4587 |
if (token[0] != '}') { |
| 4588 |
return qfalse; |
| 4589 |
} |
| 4590 |
} |
| 4591 |
} |
| 4592 |
|
| 4593 |
return qfalse; |
| 4594 |
} |
| 4595 |
|
| 4596 |
static qboolean Character_Parse(char **p) { |
| 4597 |
char *token; |
| 4598 |
const char *tempStr; |
| 4599 |
|
| 4600 |
token = COM_ParseExt(p, qtrue); |
| 4601 |
|
| 4602 |
if (token[0] != '{') { |
| 4603 |
return qfalse; |
| 4604 |
} |
| 4605 |
|
| 4606 |
|
| 4607 |
while ( 1 ) { |
| 4608 |
token = COM_ParseExt(p, qtrue); |
| 4609 |
|
| 4610 |
if (Q_stricmp(token, "}") == 0) { |
| 4611 |
return qtrue; |
| 4612 |
} |
| 4613 |
|
| 4614 |
if (!token[0]) { |
| 4615 |
return qfalse; |
| 4616 |
} |
| 4617 |
|
| 4618 |
if (token[0] == '{') { |
| 4619 |
if (uiInfo.characterCount == MAX_HEADS) { |
| 4620 |
uiInfo.characterCount--; |
| 4621 |
Com_Printf("Too many characters, last character replaced!\n"); |
| 4622 |
} |
| 4623 |
|
| 4624 |
|
| 4625 |
if (!String_Parse(p, &uiInfo.characterList[uiInfo.characterCount].name) || !String_Parse(p, &tempStr)) { |
| 4626 |
return qfalse; |
| 4627 |
} |
| 4628 |
|
| 4629 |
uiInfo.characterList[uiInfo.characterCount].headImage = -1; |
| 4630 |
uiInfo.characterList[uiInfo.characterCount].imageName = String_Alloc(va("models/players/heads/%s/icon_default.tga", uiInfo.characterList[uiInfo.characterCount].name)); |
| 4631 |
|
| 4632 |
if (tempStr && (!Q_stricmp(tempStr, "female"))) { |
| 4633 |
uiInfo.characterList[uiInfo.characterCount].base = String_Alloc("Janet"); |
| 4634 |
} else if (tempStr && (!Q_stricmp(tempStr, "male"))) { |
| 4635 |
uiInfo.characterList[uiInfo.characterCount].base = String_Alloc("James"); |
| 4636 |
} else { |
| 4637 |
uiInfo.characterList[uiInfo.characterCount].base = String_Alloc(tempStr); |
| 4638 |
} |
| 4639 |
|
| 4640 |
Com_Printf("Loaded %s character %s.\n", uiInfo.characterList[uiInfo.characterCount].base, uiInfo.characterList[uiInfo.characterCount].name); |
| 4641 |
uiInfo.characterCount++; |
| 4642 |
|
| 4643 |
token = COM_ParseExt(p, qtrue); |
| 4644 |
if (token[0] != '}') { |
| 4645 |
return qfalse; |
| 4646 |
} |
| 4647 |
} |
| 4648 |
} |
| 4649 |
|
| 4650 |
return qfalse; |
| 4651 |
} |
| 4652 |
|
| 4653 |
|
| 4654 |
static qboolean Alias_Parse(char **p) { |
| 4655 |
char *token; |
| 4656 |
|
| 4657 |
token = COM_ParseExt(p, qtrue); |
| 4658 |
|
| 4659 |
if (token[0] != '{') { |
| 4660 |
return qfalse; |
| 4661 |
} |
| 4662 |
|
| 4663 |
while ( 1 ) { |
| 4664 |
token = COM_ParseExt(p, qtrue); |
| 4665 |
|
| 4666 |
if (Q_stricmp(token, "}") == 0) { |
| 4667 |
return qtrue; |
| 4668 |
} |
| 4669 |
|
| 4670 |
if (!token[0]) { |
| 4671 |
return qfalse; |
| 4672 |
} |
| 4673 |
|
| 4674 |
if (token[0] == '{') { |
| 4675 |
if (uiInfo.aliasCount == MAX_ALIASES) { |
| 4676 |
uiInfo.aliasCount--; |
| 4677 |
Com_Printf("Too many aliases, last alias replaced!\n"); |
| 4678 |
} |
| 4679 |
|
| 4680 |
|
| 4681 |
if (!String_Parse(p, &uiInfo.aliasList[uiInfo.aliasCount].name) || !String_Parse(p, &uiInfo.aliasList[uiInfo.aliasCount].ai) || !String_Parse(p, &uiInfo.aliasList[uiInfo.aliasCount].action)) { |
| 4682 |
return qfalse; |
| 4683 |
} |
| 4684 |
|
| 4685 |
Com_Printf("Loaded character alias %s using character ai %s.\n", uiInfo.aliasList[uiInfo.aliasCount].name, uiInfo.aliasList[uiInfo.aliasCount].ai); |
| 4686 |
uiInfo.aliasCount++; |
| 4687 |
|
| 4688 |
token = COM_ParseExt(p, qtrue); |
| 4689 |
if (token[0] != '}') { |
| 4690 |
return qfalse; |
| 4691 |
} |
| 4692 |
} |
| 4693 |
} |
| 4694 |
|
| 4695 |
return qfalse; |
| 4696 |
} |
| 4697 |
|
| 4698 |
|
| 4699 |
|
| 4700 |
|
| 4701 |
|
| 4702 |
|
| 4703 |
|
| 4704 |
static void UI_ParseTeamInfo(const char *teamFile) { |
| 4705 |
char *token; |
| 4706 |
char *p; |
| 4707 |
char *buff = NULL; |
| 4708 |
|
| 4709 |
|
| 4710 |
buff = GetMenuBuffer(teamFile); |
| 4711 |
if (!buff) { |
| 4712 |
return; |
| 4713 |
} |
| 4714 |
|
| 4715 |
p = buff; |
| 4716 |
|
| 4717 |
while ( 1 ) { |
| 4718 |
token = COM_ParseExt( &p, qtrue ); |
| 4719 |
if (!token[0] || token[0] == '}') { |
| 4720 |
break; |
| 4721 |
} |
| 4722 |
|
| 4723 |
if ( Q_stricmp( token, "}" ) == 0 ) { |
| 4724 |
break; |
| 4725 |
} |
| 4726 |
|
| 4727 |
if (Q_stricmp(token, "teams") == 0) { |
| 4728 |
|
| 4729 |
if (Team_Parse(&p)) { |
| 4730 |
continue; |
| 4731 |
} else { |
| 4732 |
break; |
| 4733 |
} |
| 4734 |
} |
| 4735 |
|
| 4736 |
if (Q_stricmp(token, "characters") == 0) { |
| 4737 |
Character_Parse(&p); |
| 4738 |
} |
| 4739 |
|
| 4740 |
if (Q_stricmp(token, "aliases") == 0) { |
| 4741 |
Alias_Parse(&p); |
| 4742 |
} |
| 4743 |
|
| 4744 |
} |
| 4745 |
|
| 4746 |
} |
| 4747 |
|
| 4748 |
|
| 4749 |
static qboolean GameType_Parse(char **p, qboolean join) { |
| 4750 |
char *token; |
| 4751 |
|
| 4752 |
token = COM_ParseExt(p, qtrue); |
| 4753 |
|
| 4754 |
if (token[0] != '{') { |
| 4755 |
return qfalse; |
| 4756 |
} |
| 4757 |
|
| 4758 |
if (join) { |
| 4759 |
uiInfo.numJoinGameTypes = 0; |
| 4760 |
} else { |
| 4761 |
uiInfo.numGameTypes = 0; |
| 4762 |
} |
| 4763 |
|
| 4764 |
while ( 1 ) { |
| 4765 |
token = COM_ParseExt(p, qtrue); |
| 4766 |
|
| 4767 |
if (Q_stricmp(token, "}") == 0) { |
| 4768 |
return qtrue; |
| 4769 |
} |
| 4770 |
|
| 4771 |
if (!token[0]) { |
| 4772 |
return qfalse; |
| 4773 |
} |
| 4774 |
|
| 4775 |
if (token[0] == '{') { |
| 4776 |
|
| 4777 |
if (join) { |
| 4778 |
if (!String_Parse(p, &uiInfo.joinGameTypes[uiInfo.numJoinGameTypes].gameType) || !Int_Parse(p, &uiInfo.joinGameTypes[uiInfo.numJoinGameTypes].gtEnum)) { |
| 4779 |
return qfalse; |
| 4780 |
} |
| 4781 |
} else { |
| 4782 |
if (!String_Parse(p, &uiInfo.gameTypes[uiInfo.numGameTypes].gameType) || !Int_Parse(p, &uiInfo.gameTypes[uiInfo.numGameTypes].gtEnum)) { |
| 4783 |
return qfalse; |
| 4784 |
} |
| 4785 |
} |
| 4786 |
|
| 4787 |
if (join) { |
| 4788 |
if (uiInfo.numJoinGameTypes < MAX_GAMETYPES) { |
| 4789 |
uiInfo.numJoinGameTypes++; |
| 4790 |
} else { |
| 4791 |
Com_Printf("Too many net game types, last one replace!\n"); |
| 4792 |
} |
| 4793 |
} else { |
| 4794 |
if (uiInfo.numGameTypes < MAX_GAMETYPES) { |
| 4795 |
uiInfo.numGameTypes++; |
| 4796 |
} else { |
| 4797 |
Com_Printf("Too many game types, last one replace!\n"); |
| 4798 |
} |
| 4799 |
} |
| 4800 |
|
| 4801 |
token = COM_ParseExt(p, qtrue); |
| 4802 |
if (token[0] != '}') { |
| 4803 |
return qfalse; |
| 4804 |
} |
| 4805 |
} |
| 4806 |
} |
| 4807 |
return qfalse; |
| 4808 |
} |
| 4809 |
|
| 4810 |
static qboolean MapList_Parse(char **p) { |
| 4811 |
char *token; |
| 4812 |
|
| 4813 |
token = COM_ParseExt(p, qtrue); |
| 4814 |
|
| 4815 |
if (token[0] != '{') { |
| 4816 |
return qfalse; |
| 4817 |
} |
| 4818 |
|
| 4819 |
uiInfo.mapCount = 0; |
| 4820 |
|
| 4821 |
while ( 1 ) { |
| 4822 |
token = COM_ParseExt(p, qtrue); |
| 4823 |
|
| 4824 |
if (Q_stricmp(token, "}") == 0) { |
| 4825 |
return qtrue; |
| 4826 |
} |
| 4827 |
|
| 4828 |
if (!token[0]) { |
| 4829 |
return qfalse; |
| 4830 |
} |
| 4831 |
|
| 4832 |
if (token[0] == '{') { |
| 4833 |
if (!String_Parse(p, &uiInfo.mapList[uiInfo.mapCount].mapName) || !String_Parse(p, &uiInfo.mapList[uiInfo.mapCount].mapLoadName) |
| 4834 |
||!Int_Parse(p, &uiInfo.mapList[uiInfo.mapCount].teamMembers) ) { |
| 4835 |
return qfalse; |
| 4836 |
} |
| 4837 |
|
| 4838 |
if (!String_Parse(p, &uiInfo.mapList[uiInfo.mapCount].opponentName)) { |
| 4839 |
return qfalse; |
| 4840 |
} |
| 4841 |
|
| 4842 |
uiInfo.mapList[uiInfo.mapCount].typeBits = 0; |
| 4843 |
|
| 4844 |
while (1) { |
| 4845 |
token = COM_ParseExt(p, qtrue); |
| 4846 |
if (token[0] >= '0' && token[0] <= '9') { |
| 4847 |
uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << (token[0] - 0x030)); |
| 4848 |
if (!Int_Parse(p, &uiInfo.mapList[uiInfo.mapCount].timeToBeat[token[0] - 0x30])) { |
| 4849 |
return qfalse; |
| 4850 |
} |
| 4851 |
} else { |
| 4852 |
break; |
| 4853 |
} |
| 4854 |
} |
| 4855 |
|
| 4856 |
|
| 4857 |
|
| 4858 |
|
| 4859 |
|
| 4860 |
|
| 4861 |
uiInfo.mapList[uiInfo.mapCount].cinematic = -1; |
| 4862 |
uiInfo.mapList[uiInfo.mapCount].levelShot = trap_R_RegisterShaderNoMip(va("levelshots/%s_small", uiInfo.mapList[uiInfo.mapCount].mapLoadName)); |
| 4863 |
|
| 4864 |
if (uiInfo.mapCount < MAX_MAPS) { |
| 4865 |
uiInfo.mapCount++; |
| 4866 |
} else { |
| 4867 |
Com_Printf("Too many maps, last one replaced!\n"); |
| 4868 |
} |
| 4869 |
} |
| 4870 |
} |
| 4871 |
return qfalse; |
| 4872 |
} |
| 4873 |
|
| 4874 |
static void UI_ParseGameInfo(const char *teamFile) { |
| 4875 |
char *token; |
| 4876 |
char *p; |
| 4877 |
char *buff = NULL; |
| 4878 |
|
| 4879 |
|
| 4880 |
buff = GetMenuBuffer(teamFile); |
| 4881 |
if (!buff) { |
| 4882 |
return; |
| 4883 |
} |
| 4884 |
|
| 4885 |
p = buff; |
| 4886 |
|
| 4887 |
while ( 1 ) { |
| 4888 |
token = COM_ParseExt( &p, qtrue ); |
| 4889 |
if (!token[0] || token[0] == '}') { |
| 4890 |
break; |
| 4891 |
} |
| 4892 |
|
| 4893 |
if ( Q_stricmp( token, "}" ) == 0 ) { |
| 4894 |
break; |
| 4895 |
} |
| 4896 |
|
| 4897 |
if (Q_stricmp(token, "gametypes") == 0) { |
| 4898 |
|
| 4899 |
if (GameType_Parse(&p, qfalse)) { |
| 4900 |
continue; |
| 4901 |
} else { |
| 4902 |
break; |
| 4903 |
} |
| 4904 |
} |
| 4905 |
|
| 4906 |
if (Q_stricmp(token, "joingametypes") == 0) { |
| 4907 |
|
| 4908 |
if (GameType_Parse(&p, qtrue)) { |
| 4909 |
continue; |
| 4910 |
} else { |
| 4911 |
break; |
| 4912 |
} |
| 4913 |
} |
| 4914 |
|
| 4915 |
if (Q_stricmp(token, "maps") == 0) { |
| 4916 |
|
| 4917 |
MapList_Parse(&p); |
| 4918 |
} |
| 4919 |
|
| 4920 |
} |
| 4921 |
} |
| 4922 |
|
| 4923 |
static void UI_Pause(qboolean b) { |
| 4924 |
if (b) { |
| 4925 |
|
| 4926 |
trap_Cvar_Set( "cl_paused", "1" ); |
| 4927 |
trap_Key_SetCatcher( KEYCATCH_UI ); |
| 4928 |
} else { |
| 4929 |
|
| 4930 |
trap_Key_SetCatcher( trap_Key_GetCatcher() & ~KEYCATCH_UI ); |
| 4931 |
trap_Key_ClearStates(); |
| 4932 |
trap_Cvar_Set( "cl_paused", "0" ); |
| 4933 |
} |
| 4934 |
} |
| 4935 |
|
| 4936 |
#ifndef MISSIONPACK |
| 4937 |
static int UI_OwnerDraw_Width(int ownerDraw) { |
| 4938 |
return 0; |
| 4939 |
} |
| 4940 |
#endif |
| 4941 |
|
| 4942 |
static int UI_PlayCinematic(const char *name, float x, float y, float w, float h) { |
| 4943 |
return trap_CIN_PlayCinematic(name, x, y, w, h, (CIN_loop | CIN_silent)); |
| 4944 |
} |
| 4945 |
|
| 4946 |
static void UI_StopCinematic(int handle) { |
| 4947 |
if (handle >= 0) { |
| 4948 |
trap_CIN_StopCinematic(handle); |
| 4949 |
} else { |
| 4950 |
handle = abs(handle); |
| 4951 |
if (handle == UI_MAPCINEMATIC) { |
| 4952 |
if (uiInfo.mapList[ui_currentMap.integer].cinematic >= 0) { |
| 4953 |
trap_CIN_StopCinematic(uiInfo.mapList[ui_currentMap.integer].cinematic); |
| 4954 |
uiInfo.mapList[ui_currentMap.integer].cinematic = -1; |
| 4955 |
} |
| 4956 |
} else if (handle == UI_NETMAPCINEMATIC) { |
| 4957 |
if (uiInfo.serverStatus.currentServerCinematic >= 0) { |
| 4958 |
trap_CIN_StopCinematic(uiInfo.serverStatus.currentServerCinematic); |
| 4959 |
uiInfo.serverStatus.currentServerCinematic = -1; |
| 4960 |
} |
| 4961 |
} else if (handle == UI_CLANCINEMATIC) { |
| 4962 |
int i = UI_TeamIndexFromName(UI_Cvar_VariableString("ui_teamName")); |
| 4963 |
if (i >= 0 && i < uiInfo.teamCount) { |
| 4964 |
if (uiInfo.teamList[i].cinematic >= 0) { |
| 4965 |
trap_CIN_StopCinematic(uiInfo.teamList[i].cinematic); |
| 4966 |
uiInfo.teamList[i].cinematic = -1; |
| 4967 |
} |
| 4968 |
} |
| 4969 |
} |
| 4970 |
} |
| 4971 |
} |
| 4972 |
|
| 4973 |
static void UI_DrawCinematic(int handle, float x, float y, float w, float h) { |
| 4974 |
|
| 4975 |
UI_AdjustFrom640( &x, &y, &w, &h ); |
| 4976 |
|
| 4977 |
|
| 4978 |
x *= SCREEN_WIDTH / (float)uiInfo.uiDC.glconfig.vidWidth; |
| 4979 |
w *= SCREEN_WIDTH / (float)uiInfo.uiDC.glconfig.vidWidth; |
| 4980 |
y *= SCREEN_HEIGHT / (float)uiInfo.uiDC.glconfig.vidHeight; |
| 4981 |
h *= SCREEN_HEIGHT / (float)uiInfo.uiDC.glconfig.vidHeight; |
| 4982 |
|
| 4983 |
trap_CIN_SetExtents(handle, x, y, w, h); |
| 4984 |
trap_CIN_DrawCinematic(handle); |
| 4985 |
} |
| 4986 |
|
| 4987 |
static void UI_RunCinematicFrame(int handle) { |
| 4988 |
trap_CIN_RunCinematic(handle); |
| 4989 |
} |
| 4990 |
|
| 4991 |
|
| 4992 |
|
| 4993 |
|
| 4994 |
|
| 4995 |
|
| 4996 |
|
| 4997 |
|
| 4998 |
static void UI_BuildQ3Model_List( void ) |
| 4999 |
{ |
| 5000 |
int numdirs; |
| 5001 |
int numfiles; |
| 5002 |
char dirlist[2048]; |
| 5003 |
char filelist[2048]; |
| 5004 |
char skinname[MAX_QPATH]; |
| 5005 |
char scratch[256]; |
| 5006 |
char* dirptr; |
| 5007 |
char* fileptr; |
| 5008 |
int i; |
| 5009 |
int j, k, dirty; |
| 5010 |
int dirlen; |
| 5011 |
int filelen; |
| 5012 |
|
| 5013 |
uiInfo.q3HeadCount = 0; |
| 5014 |
|
| 5015 |
|
| 5016 |
numdirs = trap_FS_GetFileList("models/players", "/", dirlist, 2048 ); |
| 5017 |
dirptr = dirlist; |
| 5018 |
for (i=0; i<numdirs && uiInfo.q3HeadCount < MAX_PLAYERMODELS; i++,dirptr+=dirlen+1) |
| 5019 |
{ |
| 5020 |
dirlen = strlen(dirptr); |
| 5021 |
|
| 5022 |
if (dirlen && dirptr[dirlen-1]=='/') dirptr[dirlen-1]='\0'; |
| 5023 |
|
| 5024 |
if (!strcmp(dirptr,".") || !strcmp(dirptr,"..")) |
| 5025 |
continue; |
| 5026 |
|
| 5027 |
|
| 5028 |
numfiles = trap_FS_GetFileList( va("models/players/%s",dirptr), "tga", filelist, 2048 ); |
| 5029 |
fileptr = filelist; |
| 5030 |
for (j=0; j<numfiles && uiInfo.q3HeadCount < MAX_PLAYERMODELS;j++,fileptr+=filelen+1) |
| 5031 |
{ |
| 5032 |
filelen = strlen(fileptr); |
| 5033 |
|
| 5034 |
COM_StripExtension(fileptr, skinname, sizeof(skinname)); |
| 5035 |
|
| 5036 |
|
| 5037 |
if (Q_stricmpn(skinname, "icon_", 5) == 0 && !(Q_stricmp(skinname,"icon_blue") == 0 || Q_stricmp(skinname,"icon_red") == 0)) |
| 5038 |
{ |
| 5039 |
if (Q_stricmp(skinname, "icon_default") == 0) { |
| 5040 |
Com_sprintf( scratch, sizeof(scratch), "%s", dirptr); |
| 5041 |
} else { |
| 5042 |
Com_sprintf( scratch, sizeof(scratch), "%s/%s",dirptr, skinname + 5); |
| 5043 |
} |
| 5044 |
dirty = 0; |
| 5045 |
for(k=0;k<uiInfo.q3HeadCount;k++) { |
| 5046 |
if (!Q_stricmp(scratch, uiInfo.q3HeadNames[uiInfo.q3HeadCount])) { |
| 5047 |
dirty = 1; |
| 5048 |
break; |
| 5049 |
} |
| 5050 |
} |
| 5051 |
if (!dirty) { |
| 5052 |
Com_sprintf( uiInfo.q3HeadNames[uiInfo.q3HeadCount], sizeof(uiInfo.q3HeadNames[uiInfo.q3HeadCount]), "%s", scratch); |
| 5053 |
uiInfo.q3HeadIcons[uiInfo.q3HeadCount++] = trap_R_RegisterShaderNoMip(va("models/players/%s/%s",dirptr,skinname)); |
| 5054 |
} |
| 5055 |
} |
| 5056 |
|
| 5057 |
} |
| 5058 |
} |
| 5059 |
|
| 5060 |
} |
| 5061 |
|
| 5062 |
|
| 5063 |
|
| 5064 |
|
| 5065 |
|
| 5066 |
|
| 5067 |
|
| 5068 |
|
| 5069 |
void _UI_Init( qboolean inGameLoad ) { |
| 5070 |
const char *menuSet; |
| 5071 |
|
| 5072 |
|
| 5073 |
|
| 5074 |
UI_RegisterCvars(); |
| 5075 |
UI_InitMemory(); |
| 5076 |
|
| 5077 |
|
| 5078 |
trap_GetGlconfig( &uiInfo.uiDC.glconfig ); |
| 5079 |
|
| 5080 |
trap_Cvar_Set("ui_videomode", va( "%dx%d", uiInfo.uiDC.glconfig.vidWidth, uiInfo.uiDC.glconfig.vidHeight ) ); |
| 5081 |
|
| 5082 |
|
| 5083 |
uiInfo.uiDC.yscale = uiInfo.uiDC.glconfig.vidHeight * (1.0/480.0); |
| 5084 |
uiInfo.uiDC.xscale = uiInfo.uiDC.glconfig.vidWidth * (1.0/640.0); |
| 5085 |
if ( uiInfo.uiDC.glconfig.vidWidth * 480 > uiInfo.uiDC.glconfig.vidHeight * 640 ) { |
| 5086 |
|
| 5087 |
uiInfo.uiDC.bias = 0.5 * ( uiInfo.uiDC.glconfig.vidWidth - ( uiInfo.uiDC.glconfig.vidHeight * (640.0/480.0) ) ); |
| 5088 |
uiInfo.uiDC.xscale = uiInfo.uiDC.yscale; |
| 5089 |
} |
| 5090 |
else { |
| 5091 |
|
| 5092 |
uiInfo.uiDC.bias = 0; |
| 5093 |
} |
| 5094 |
|
| 5095 |
|
| 5096 |
|
| 5097 |
uiInfo.uiDC.registerShaderNoMip = &trap_R_RegisterShaderNoMip; |
| 5098 |
uiInfo.uiDC.setColor = &UI_SetColor; |
| 5099 |
uiInfo.uiDC.drawHandlePic = &UI_DrawHandlePic; |
| 5100 |
uiInfo.uiDC.drawStretchPic = &trap_R_DrawStretchPic; |
| 5101 |
uiInfo.uiDC.drawText = &Text_Paint; |
| 5102 |
uiInfo.uiDC.textWidth = &Text_Width; |
| 5103 |
uiInfo.uiDC.textHeight = &Text_Height; |
| 5104 |
uiInfo.uiDC.registerModel = &trap_R_RegisterModel; |
| 5105 |
uiInfo.uiDC.modelBounds = &trap_R_ModelBounds; |
| 5106 |
uiInfo.uiDC.fillRect = &UI_FillRect; |
| 5107 |
uiInfo.uiDC.drawRect = &_UI_DrawRect; |
| 5108 |
uiInfo.uiDC.drawSides = &_UI_DrawSides; |
| 5109 |
uiInfo.uiDC.drawTopBottom = &_UI_DrawTopBottom; |
| 5110 |
uiInfo.uiDC.clearScene = &trap_R_ClearScene; |
| 5111 |
uiInfo.uiDC.addRefEntityToScene = &trap_R_AddRefEntityToScene; |
| 5112 |
uiInfo.uiDC.renderScene = &trap_R_RenderScene; |
| 5113 |
uiInfo.uiDC.registerFont = &trap_R_RegisterFont; |
| 5114 |
uiInfo.uiDC.ownerDrawItem = &UI_OwnerDraw; |
| 5115 |
uiInfo.uiDC.getValue = &UI_GetValue; |
| 5116 |
uiInfo.uiDC.ownerDrawVisible = &UI_OwnerDrawVisible; |
| 5117 |
uiInfo.uiDC.runScript = &UI_RunMenuScript; |
| 5118 |
uiInfo.uiDC.getTeamColor = &UI_GetTeamColor; |
| 5119 |
uiInfo.uiDC.setCVar = trap_Cvar_Set; |
| 5120 |
uiInfo.uiDC.getCVarString = trap_Cvar_VariableStringBuffer; |
| 5121 |
uiInfo.uiDC.getCVarValue = trap_Cvar_VariableValue; |
| 5122 |
uiInfo.uiDC.drawTextWithCursor = &Text_PaintWithCursor; |
| 5123 |
uiInfo.uiDC.setOverstrikeMode = &trap_Key_SetOverstrikeMode; |
| 5124 |
uiInfo.uiDC.getOverstrikeMode = &trap_Key_GetOverstrikeMode; |
| 5125 |
uiInfo.uiDC.startLocalSound = &trap_S_StartLocalSound; |
| 5126 |
uiInfo.uiDC.ownerDrawHandleKey = &UI_OwnerDrawHandleKey; |
| 5127 |
uiInfo.uiDC.feederCount = &UI_FeederCount; |
| 5128 |
uiInfo.uiDC.feederItemImage = &UI_FeederItemImage; |
| 5129 |
uiInfo.uiDC.feederItemText = &UI_FeederItemText; |
| 5130 |
uiInfo.uiDC.feederSelection = &UI_FeederSelection; |
| 5131 |
uiInfo.uiDC.setBinding = &trap_Key_SetBinding; |
| 5132 |
uiInfo.uiDC.getBindingBuf = &trap_Key_GetBindingBuf; |
| 5133 |
uiInfo.uiDC.keynumToStringBuf = &trap_Key_KeynumToStringBuf; |
| 5134 |
uiInfo.uiDC.executeText = &trap_Cmd_ExecuteText; |
| 5135 |
uiInfo.uiDC.Error = &Com_Error; |
| 5136 |
uiInfo.uiDC.Print = &Com_Printf; |
| 5137 |
uiInfo.uiDC.Pause = &UI_Pause; |
| 5138 |
uiInfo.uiDC.ownerDrawWidth = &UI_OwnerDrawWidth; |
| 5139 |
uiInfo.uiDC.registerSound = &trap_S_RegisterSound; |
| 5140 |
uiInfo.uiDC.startBackgroundTrack = &trap_S_StartBackgroundTrack; |
| 5141 |
uiInfo.uiDC.stopBackgroundTrack = &trap_S_StopBackgroundTrack; |
| 5142 |
uiInfo.uiDC.playCinematic = &UI_PlayCinematic; |
| 5143 |
uiInfo.uiDC.stopCinematic = &UI_StopCinematic; |
| 5144 |
uiInfo.uiDC.drawCinematic = &UI_DrawCinematic; |
| 5145 |
uiInfo.uiDC.runCinematicFrame = &UI_RunCinematicFrame; |
| 5146 |
|
| 5147 |
Init_Display(&uiInfo.uiDC); |
| 5148 |
|
| 5149 |
String_Init(); |
| 5150 |
|
| 5151 |
uiInfo.uiDC.cursor = trap_R_RegisterShaderNoMip( "menu/art/3_cursor2" ); |
| 5152 |
uiInfo.uiDC.whiteShader = trap_R_RegisterShaderNoMip( "white" ); |
| 5153 |
|
| 5154 |
AssetCache(); |
| 5155 |
|
| 5156 |
uiInfo.teamCount = 0; |
| 5157 |
uiInfo.characterCount = 0; |
| 5158 |
uiInfo.aliasCount = 0; |
| 5159 |
|
| 5160 |
#ifdef PRE_RELEASE_TADEMO |
| 5161 |
UI_ParseTeamInfo("demoteaminfo.txt"); |
| 5162 |
UI_ParseGameInfo("demogameinfo.txt"); |
| 5163 |
#else |
| 5164 |
UI_ParseTeamInfo("teaminfo.txt"); |
| 5165 |
UI_LoadTeams(); |
| 5166 |
UI_ParseGameInfo("gameinfo.txt"); |
| 5167 |
UI_LoadArenas(); |
| 5168 |
#endif |
| 5169 |
|
| 5170 |
menuSet = UI_Cvar_VariableString("ui_menuFiles"); |
| 5171 |
if (menuSet == NULL || menuSet[0] == '\0') { |
| 5172 |
menuSet = "ui/menus.txt"; |
| 5173 |
} |
| 5174 |
|
| 5175 |
#if 0 |
| 5176 |
if (uiInfo.inGameLoad) { |
| 5177 |
UI_LoadMenus("ui/ingame.txt", qtrue); |
| 5178 |
} else { |
| 5179 |
} |
| 5180 |
#else |
| 5181 |
UI_LoadMenus(menuSet, qtrue); |
| 5182 |
UI_LoadMenus("ui/ingame.txt", qfalse); |
| 5183 |
#endif |
| 5184 |
|
| 5185 |
Menus_CloseAll(); |
| 5186 |
|
| 5187 |
trap_LAN_LoadCachedServers(); |
| 5188 |
UI_LoadBestScores(uiInfo.mapList[ui_currentMap.integer].mapLoadName, uiInfo.gameTypes[ui_gameType.integer].gtEnum); |
| 5189 |
|
| 5190 |
UI_BuildQ3Model_List(); |
| 5191 |
UI_LoadBots(); |
| 5192 |
|
| 5193 |
|
| 5194 |
uiInfo.effectsColor = gamecodetoui[(int)trap_Cvar_VariableValue("color1")-1]; |
| 5195 |
uiInfo.currentCrosshair = (int)trap_Cvar_VariableValue("cg_drawCrosshair") % NUM_CROSSHAIRS; |
| 5196 |
if (uiInfo.currentCrosshair < 0) { |
| 5197 |
uiInfo.currentCrosshair = 0; |
| 5198 |
} |
| 5199 |
trap_Cvar_Set("ui_mousePitch", (trap_Cvar_VariableValue("m_pitch") >= 0) ? "0" : "1"); |
| 5200 |
|
| 5201 |
uiInfo.serverStatus.currentServerCinematic = -1; |
| 5202 |
uiInfo.previewMovie = -1; |
| 5203 |
|
| 5204 |
if (trap_Cvar_VariableValue("ui_TeamArenaFirstRun") == 0) { |
| 5205 |
trap_Cvar_Set("s_volume", "0.8"); |
| 5206 |
trap_Cvar_Set("s_musicvolume", "0.5"); |
| 5207 |
trap_Cvar_Set("ui_TeamArenaFirstRun", "1"); |
| 5208 |
} |
| 5209 |
|
| 5210 |
trap_Cvar_Register(NULL, "debug_protocol", "", 0 ); |
| 5211 |
|
| 5212 |
trap_Cvar_Set("ui_actualNetGameType", va("%d", ui_netGameType.integer)); |
| 5213 |
} |
| 5214 |
|
| 5215 |
|
| 5216 |
|
| 5217 |
|
| 5218 |
|
| 5219 |
|
| 5220 |
|
| 5221 |
void _UI_KeyEvent( int key, qboolean down ) { |
| 5222 |
|
| 5223 |
if (Menu_Count() > 0) { |
| 5224 |
menuDef_t *menu = Menu_GetFocused(); |
| 5225 |
if (menu) { |
| 5226 |
if (key == K_ESCAPE && down && !Menus_AnyFullScreenVisible()) { |
| 5227 |
Menus_CloseAll(); |
| 5228 |
} else { |
| 5229 |
Menu_HandleKey(menu, key, down ); |
| 5230 |
} |
| 5231 |
} else { |
| 5232 |
trap_Key_SetCatcher( trap_Key_GetCatcher() & ~KEYCATCH_UI ); |
| 5233 |
trap_Key_ClearStates(); |
| 5234 |
trap_Cvar_Set( "cl_paused", "0" ); |
| 5235 |
} |
| 5236 |
} |
| 5237 |
|
| 5238 |
|
| 5239 |
|
| 5240 |
|
| 5241 |
} |
| 5242 |
|
| 5243 |
|
| 5244 |
|
| 5245 |
|
| 5246 |
|
| 5247 |
|
| 5248 |
void _UI_MouseEvent( int dx, int dy ) |
| 5249 |
{ |
| 5250 |
int bias; |
| 5251 |
|
| 5252 |
|
| 5253 |
bias = uiInfo.uiDC.bias / uiInfo.uiDC.xscale; |
| 5254 |
|
| 5255 |
|
| 5256 |
uiInfo.uiDC.cursorx += dx; |
| 5257 |
if (uiInfo.uiDC.cursorx < -bias) |
| 5258 |
uiInfo.uiDC.cursorx = -bias; |
| 5259 |
else if (uiInfo.uiDC.cursorx > SCREEN_WIDTH+bias) |
| 5260 |
uiInfo.uiDC.cursorx = SCREEN_WIDTH+bias; |
| 5261 |
|
| 5262 |
uiInfo.uiDC.cursory += dy; |
| 5263 |
if (uiInfo.uiDC.cursory < 0) |
| 5264 |
uiInfo.uiDC.cursory = 0; |
| 5265 |
else if (uiInfo.uiDC.cursory > SCREEN_HEIGHT) |
| 5266 |
uiInfo.uiDC.cursory = SCREEN_HEIGHT; |
| 5267 |
|
| 5268 |
if (Menu_Count() > 0) { |
| 5269 |
|
| 5270 |
|
| 5271 |
Display_MouseMove(NULL, uiInfo.uiDC.cursorx, uiInfo.uiDC.cursory); |
| 5272 |
} |
| 5273 |
|
| 5274 |
} |
| 5275 |
|
| 5276 |
void UI_LoadNonIngame( void ) { |
| 5277 |
const char *menuSet = UI_Cvar_VariableString("ui_menuFiles"); |
| 5278 |
if (menuSet == NULL || menuSet[0] == '\0') { |
| 5279 |
menuSet = "ui/menus.txt"; |
| 5280 |
} |
| 5281 |
UI_LoadMenus(menuSet, qfalse); |
| 5282 |
uiInfo.inGameLoad = qfalse; |
| 5283 |
} |
| 5284 |
|
| 5285 |
void _UI_SetActiveMenu( uiMenuCommand_t menu ) { |
| 5286 |
char buf[256]; |
| 5287 |
|
| 5288 |
|
| 5289 |
|
| 5290 |
if (Menu_Count() > 0) { |
| 5291 |
vec3_t v; |
| 5292 |
v[0] = v[1] = v[2] = 0; |
| 5293 |
switch ( menu ) { |
| 5294 |
case UIMENU_NONE: |
| 5295 |
trap_Key_SetCatcher( trap_Key_GetCatcher() & ~KEYCATCH_UI ); |
| 5296 |
trap_Key_ClearStates(); |
| 5297 |
trap_Cvar_Set( "cl_paused", "0" ); |
| 5298 |
Menus_CloseAll(); |
| 5299 |
|
| 5300 |
return; |
| 5301 |
case UIMENU_MAIN: |
| 5302 |
trap_Cvar_Set( "sv_killserver", "1" ); |
| 5303 |
trap_Key_SetCatcher( KEYCATCH_UI ); |
| 5304 |
|
| 5305 |
|
| 5306 |
if (uiInfo.inGameLoad) { |
| 5307 |
UI_LoadNonIngame(); |
| 5308 |
} |
| 5309 |
Menus_CloseAll(); |
| 5310 |
Menus_ActivateByName("main"); |
| 5311 |
trap_Cvar_VariableStringBuffer("com_errorMessage", buf, sizeof(buf)); |
| 5312 |
if (strlen(buf)) { |
| 5313 |
if (!ui_singlePlayerActive.integer) { |
| 5314 |
Menus_ActivateByName("error_popmenu"); |
| 5315 |
} else { |
| 5316 |
trap_Cvar_Set("com_errorMessage", ""); |
| 5317 |
} |
| 5318 |
} |
| 5319 |
return; |
| 5320 |
case UIMENU_TEAM: |
| 5321 |
trap_Key_SetCatcher( KEYCATCH_UI ); |
| 5322 |
Menus_ActivateByName("team"); |
| 5323 |
return; |
| 5324 |
case UIMENU_NEED_CD: |
| 5325 |
|
| 5326 |
|
| 5327 |
|
| 5328 |
|
| 5329 |
return; |
| 5330 |
case UIMENU_BAD_CD_KEY: |
| 5331 |
|
| 5332 |
|
| 5333 |
|
| 5334 |
|
| 5335 |
return; |
| 5336 |
case UIMENU_POSTGAME: |
| 5337 |
trap_Cvar_Set( "sv_killserver", "1" ); |
| 5338 |
trap_Key_SetCatcher( KEYCATCH_UI ); |
| 5339 |
if (uiInfo.inGameLoad) { |
| 5340 |
UI_LoadNonIngame(); |
| 5341 |
} |
| 5342 |
Menus_CloseAll(); |
| 5343 |
Menus_ActivateByName("endofgame"); |
| 5344 |
|
| 5345 |
return; |
| 5346 |
case UIMENU_INGAME: |
| 5347 |
trap_Cvar_Set( "cl_paused", "1" ); |
| 5348 |
trap_Key_SetCatcher( KEYCATCH_UI ); |
| 5349 |
UI_BuildPlayerList(); |
| 5350 |
Menus_CloseAll(); |
| 5351 |
Menus_ActivateByName("ingame"); |
| 5352 |
return; |
| 5353 |
} |
| 5354 |
} |
| 5355 |
} |
| 5356 |
|
| 5357 |
qboolean _UI_IsFullscreen( void ) { |
| 5358 |
return Menus_AnyFullScreenVisible(); |
| 5359 |
} |
| 5360 |
|
| 5361 |
|
| 5362 |
|
| 5363 |
static connstate_t lastConnState; |
| 5364 |
static char lastLoadingText[MAX_INFO_VALUE]; |
| 5365 |
|
| 5366 |
static void UI_ReadableSize ( char *buf, int bufsize, int value ) |
| 5367 |
{ |
| 5368 |
if (value > 1024*1024*1024 ) { |
| 5369 |
Com_sprintf( buf, bufsize, "%d", value / (1024*1024*1024) ); |
| 5370 |
Com_sprintf( buf+strlen(buf), bufsize-strlen(buf), ".%02d GB", |
| 5371 |
(value % (1024*1024*1024))*100 / (1024*1024*1024) ); |
| 5372 |
} else if (value > 1024*1024 ) { |
| 5373 |
Com_sprintf( buf, bufsize, "%d", value / (1024*1024) ); |
| 5374 |
Com_sprintf( buf+strlen(buf), bufsize-strlen(buf), ".%02d MB", |
| 5375 |
(value % (1024*1024))*100 / (1024*1024) ); |
| 5376 |
} else if (value > 1024 ) { |
| 5377 |
Com_sprintf( buf, bufsize, "%d KB", value / 1024 ); |
| 5378 |
} else { |
| 5379 |
Com_sprintf( buf, bufsize, "%d bytes", value ); |
| 5380 |
} |
| 5381 |
} |
| 5382 |
|
| 5383 |
|
| 5384 |
static void UI_PrintTime ( char *buf, int bufsize, int time ) { |
| 5385 |
time /= 1000; |
| 5386 |
|
| 5387 |
if (time > 3600) { |
| 5388 |
Com_sprintf( buf, bufsize, "%d hr %d min", time / 3600, (time % 3600) / 60 ); |
| 5389 |
} else if (time > 60) { |
| 5390 |
Com_sprintf( buf, bufsize, "%d min %d sec", time / 60, time % 60 ); |
| 5391 |
} else { |
| 5392 |
Com_sprintf( buf, bufsize, "%d sec", time ); |
| 5393 |
} |
| 5394 |
} |
| 5395 |
|
| 5396 |
void Text_PaintCenter(float x, float y, float scale, vec4_t color, const char *text, float adjust) { |
| 5397 |
int len = Text_Width(text, scale, 0); |
| 5398 |
Text_Paint(x - len / 2, y, scale, color, text, 0, 0, ITEM_TEXTSTYLE_SHADOWEDMORE); |
| 5399 |
} |
| 5400 |
|
| 5401 |
void Text_PaintCenter_AutoWrapped(float x, float y, float xmax, float ystep, float scale, vec4_t color, const char *str, float adjust) { |
| 5402 |
int width; |
| 5403 |
char *s1,*s2,*s3; |
| 5404 |
char c_bcp; |
| 5405 |
char buf[1024]; |
| 5406 |
|
| 5407 |
if (!str || str[0]=='\0') |
| 5408 |
return; |
| 5409 |
|
| 5410 |
Q_strncpyz(buf, str, sizeof(buf)); |
| 5411 |
s1 = s2 = s3 = buf; |
| 5412 |
|
| 5413 |
while (1) { |
| 5414 |
do { |
| 5415 |
s3++; |
| 5416 |
} while (*s3!=' ' && *s3!='\0'); |
| 5417 |
c_bcp = *s3; |
| 5418 |
*s3 = '\0'; |
| 5419 |
width = Text_Width(s1, scale, 0); |
| 5420 |
*s3 = c_bcp; |
| 5421 |
if (width > xmax) { |
| 5422 |
if (s1==s2) |
| 5423 |
{ |
| 5424 |
|
| 5425 |
s2 = s3; |
| 5426 |
} |
| 5427 |
*s2 = '\0'; |
| 5428 |
Text_PaintCenter(x, y, scale, color, s1, adjust); |
| 5429 |
y += ystep; |
| 5430 |
if (c_bcp == '\0') |
| 5431 |
{ |
| 5432 |
|
| 5433 |
|
| 5434 |
|
| 5435 |
|
| 5436 |
s2++; |
| 5437 |
if (*s2 != '\0') |
| 5438 |
Text_PaintCenter(x, y, scale, color, s2, adjust); |
| 5439 |
break; |
| 5440 |
} |
| 5441 |
s2++; |
| 5442 |
s1 = s2; |
| 5443 |
s3 = s2; |
| 5444 |
} |
| 5445 |
else |
| 5446 |
{ |
| 5447 |
s2 = s3; |
| 5448 |
if (c_bcp == '\0') |
| 5449 |
{ |
| 5450 |
Text_PaintCenter(x, y, scale, color, s1, adjust); |
| 5451 |
break; |
| 5452 |
} |
| 5453 |
} |
| 5454 |
} |
| 5455 |
} |
| 5456 |
|
| 5457 |
static void UI_DisplayDownloadInfo( const char *downloadName, float centerPoint, float yStart, float scale ) { |
| 5458 |
static char dlText[] = "Downloading:"; |
| 5459 |
static char etaText[] = "Estimated time left:"; |
| 5460 |
static char xferText[] = "Transfer rate:"; |
| 5461 |
|
| 5462 |
int downloadSize, downloadCount, downloadTime; |
| 5463 |
char dlSizeBuf[64], totalSizeBuf[64], xferRateBuf[64], dlTimeBuf[64]; |
| 5464 |
int xferRate; |
| 5465 |
int leftWidth; |
| 5466 |
const char *s; |
| 5467 |
|
| 5468 |
downloadSize = trap_Cvar_VariableValue( "cl_downloadSize" ); |
| 5469 |
downloadCount = trap_Cvar_VariableValue( "cl_downloadCount" ); |
| 5470 |
downloadTime = trap_Cvar_VariableValue( "cl_downloadTime" ); |
| 5471 |
|
| 5472 |
leftWidth = 320; |
| 5473 |
|
| 5474 |
UI_SetColor(colorWhite); |
| 5475 |
Text_PaintCenter(centerPoint, yStart + 112, scale, colorWhite, dlText, 0); |
| 5476 |
Text_PaintCenter(centerPoint, yStart + 192, scale, colorWhite, etaText, 0); |
| 5477 |
Text_PaintCenter(centerPoint, yStart + 248, scale, colorWhite, xferText, 0); |
| 5478 |
|
| 5479 |
if (downloadSize > 0) { |
| 5480 |
s = va( "%s (%d%%)", downloadName, |
| 5481 |
(int)( (float)downloadCount * 100.0f / downloadSize ) ); |
| 5482 |
} else { |
| 5483 |
s = downloadName; |
| 5484 |
} |
| 5485 |
|
| 5486 |
Text_PaintCenter(centerPoint, yStart+136, scale, colorWhite, s, 0); |
| 5487 |
|
| 5488 |
UI_ReadableSize( dlSizeBuf, sizeof dlSizeBuf, downloadCount ); |
| 5489 |
UI_ReadableSize( totalSizeBuf, sizeof totalSizeBuf, downloadSize ); |
| 5490 |
|
| 5491 |
if (downloadCount < 4096 || !downloadTime) { |
| 5492 |
Text_PaintCenter(leftWidth, yStart+216, scale, colorWhite, "estimating", 0); |
| 5493 |
Text_PaintCenter(leftWidth, yStart+160, scale, colorWhite, va("(%s of %s copied)", dlSizeBuf, totalSizeBuf), 0); |
| 5494 |
} else { |
| 5495 |
if ((uiInfo.uiDC.realTime - downloadTime) / 1000) { |
| 5496 |
xferRate = downloadCount / ((uiInfo.uiDC.realTime - downloadTime) / 1000); |
| 5497 |
} else { |
| 5498 |
xferRate = 0; |
| 5499 |
} |
| 5500 |
UI_ReadableSize( xferRateBuf, sizeof xferRateBuf, xferRate ); |
| 5501 |
|
| 5502 |
|
| 5503 |
if (downloadSize && xferRate) { |
| 5504 |
int n = downloadSize / xferRate; |
| 5505 |
|
| 5506 |
|
| 5507 |
UI_PrintTime ( dlTimeBuf, sizeof dlTimeBuf, |
| 5508 |
(n - (((downloadCount/1024) * n) / (downloadSize/1024))) * 1000); |
| 5509 |
|
| 5510 |
Text_PaintCenter(leftWidth, yStart+216, scale, colorWhite, dlTimeBuf, 0); |
| 5511 |
Text_PaintCenter(leftWidth, yStart+160, scale, colorWhite, va("(%s of %s copied)", dlSizeBuf, totalSizeBuf), 0); |
| 5512 |
} else { |
| 5513 |
Text_PaintCenter(leftWidth, yStart+216, scale, colorWhite, "estimating", 0); |
| 5514 |
if (downloadSize) { |
| 5515 |
Text_PaintCenter(leftWidth, yStart+160, scale, colorWhite, va("(%s of %s copied)", dlSizeBuf, totalSizeBuf), 0); |
| 5516 |
} else { |
| 5517 |
Text_PaintCenter(leftWidth, yStart+160, scale, colorWhite, va("(%s copied)", dlSizeBuf), 0); |
| 5518 |
} |
| 5519 |
} |
| 5520 |
|
| 5521 |
if (xferRate) { |
| 5522 |
Text_PaintCenter(leftWidth, yStart+272, scale, colorWhite, va("%s/Sec", xferRateBuf), 0); |
| 5523 |
} |
| 5524 |
} |
| 5525 |
} |
| 5526 |
|
| 5527 |
|
| 5528 |
|
| 5529 |
|
| 5530 |
|
| 5531 |
|
| 5532 |
|
| 5533 |
|
| 5534 |
|
| 5535 |
void UI_DrawConnectScreen( qboolean overlay ) { |
| 5536 |
char *s; |
| 5537 |
uiClientState_t cstate; |
| 5538 |
char info[MAX_INFO_VALUE]; |
| 5539 |
char text[256]; |
| 5540 |
float centerPoint, yStart, scale; |
| 5541 |
|
| 5542 |
menuDef_t *menu = Menus_FindByName("Connect"); |
| 5543 |
|
| 5544 |
|
| 5545 |
if ( !overlay && menu ) { |
| 5546 |
Menu_Paint(menu, qtrue); |
| 5547 |
} |
| 5548 |
|
| 5549 |
if (!overlay) { |
| 5550 |
centerPoint = 320; |
| 5551 |
yStart = 130; |
| 5552 |
scale = 0.5f; |
| 5553 |
} else { |
| 5554 |
return; |
| 5555 |
} |
| 5556 |
|
| 5557 |
|
| 5558 |
trap_GetClientState( &cstate ); |
| 5559 |
|
| 5560 |
info[0] = '\0'; |
| 5561 |
if( trap_GetConfigString( CS_SERVERINFO, info, sizeof(info) ) ) { |
| 5562 |
Text_PaintCenter(centerPoint, yStart, scale, colorWhite, va( "Loading %s", Info_ValueForKey( info, "mapname" )), 0); |
| 5563 |
} |
| 5564 |
|
| 5565 |
if (!Q_stricmp(cstate.servername,"localhost")) { |
| 5566 |
Text_PaintCenter(centerPoint, yStart + 48, scale, colorWhite, "Starting up...", ITEM_TEXTSTYLE_SHADOWEDMORE); |
| 5567 |
} else { |
| 5568 |
Com_sprintf(text, sizeof(text), "Connecting to %s", cstate.servername); |
| 5569 |
Text_PaintCenter(centerPoint, yStart + 48, scale, colorWhite,text , ITEM_TEXTSTYLE_SHADOWEDMORE); |
| 5570 |
} |
| 5571 |
|
| 5572 |
|
| 5573 |
Text_PaintCenter(centerPoint, 600, scale, colorWhite, Info_ValueForKey( cstate.updateInfoString, "motd" ), 0); |
| 5574 |
|
| 5575 |
if ( cstate.connState < CA_CONNECTED ) { |
| 5576 |
Text_PaintCenter_AutoWrapped(centerPoint, yStart + 176, 630, 20, scale, colorWhite, cstate.messageString, 0); |
| 5577 |
} |
| 5578 |
|
| 5579 |
if ( lastConnState > cstate.connState ) { |
| 5580 |
lastLoadingText[0] = '\0'; |
| 5581 |
} |
| 5582 |
lastConnState = cstate.connState; |
| 5583 |
|
| 5584 |
switch ( cstate.connState ) { |
| 5585 |
case CA_CONNECTING: |
| 5586 |
s = va("Awaiting connection...%i", cstate.connectPacketCount); |
| 5587 |
break; |
| 5588 |
case CA_CHALLENGING: |
| 5589 |
s = va("Awaiting challenge...%i", cstate.connectPacketCount); |
| 5590 |
break; |
| 5591 |
case CA_CONNECTED: { |
| 5592 |
char downloadName[MAX_INFO_VALUE]; |
| 5593 |
|
| 5594 |
trap_Cvar_VariableStringBuffer( "cl_downloadName", downloadName, sizeof(downloadName) ); |
| 5595 |
if (*downloadName) { |
| 5596 |
UI_DisplayDownloadInfo( downloadName, centerPoint, yStart, scale ); |
| 5597 |
return; |
| 5598 |
} |
| 5599 |
} |
| 5600 |
s = "Awaiting gamestate..."; |
| 5601 |
break; |
| 5602 |
case CA_LOADING: |
| 5603 |
return; |
| 5604 |
case CA_PRIMED: |
| 5605 |
return; |
| 5606 |
default: |
| 5607 |
return; |
| 5608 |
} |
| 5609 |
|
| 5610 |
|
| 5611 |
if (Q_stricmp(cstate.servername,"localhost")) { |
| 5612 |
Text_PaintCenter(centerPoint, yStart + 80, scale, colorWhite, s, 0); |
| 5613 |
} |
| 5614 |
|
| 5615 |
|
| 5616 |
} |
| 5617 |
|
| 5618 |
|
| 5619 |
|
| 5620 |
|
| 5621 |
|
| 5622 |
|
| 5623 |
|
| 5624 |
|
| 5625 |
typedef struct { |
| 5626 |
vmCvar_t *vmCvar; |
| 5627 |
char *cvarName; |
| 5628 |
char *defaultString; |
| 5629 |
int cvarFlags; |
| 5630 |
} cvarTable_t; |
| 5631 |
|
| 5632 |
vmCvar_t ui_ffa_fraglimit; |
| 5633 |
vmCvar_t ui_ffa_timelimit; |
| 5634 |
|
| 5635 |
vmCvar_t ui_tourney_fraglimit; |
| 5636 |
vmCvar_t ui_tourney_timelimit; |
| 5637 |
|
| 5638 |
vmCvar_t ui_team_fraglimit; |
| 5639 |
vmCvar_t ui_team_timelimit; |
| 5640 |
vmCvar_t ui_team_friendly; |
| 5641 |
|
| 5642 |
vmCvar_t ui_ctf_capturelimit; |
| 5643 |
vmCvar_t ui_ctf_timelimit; |
| 5644 |
vmCvar_t ui_ctf_friendly; |
| 5645 |
|
| 5646 |
vmCvar_t ui_arenasFile; |
| 5647 |
vmCvar_t ui_botsFile; |
| 5648 |
vmCvar_t ui_spScores1; |
| 5649 |
vmCvar_t ui_spScores2; |
| 5650 |
vmCvar_t ui_spScores3; |
| 5651 |
vmCvar_t ui_spScores4; |
| 5652 |
vmCvar_t ui_spScores5; |
| 5653 |
vmCvar_t ui_spAwards; |
| 5654 |
vmCvar_t ui_spVideos; |
| 5655 |
vmCvar_t ui_spSkill; |
| 5656 |
|
| 5657 |
vmCvar_t ui_spSelection; |
| 5658 |
|
| 5659 |
vmCvar_t ui_browserMaster; |
| 5660 |
vmCvar_t ui_browserGameType; |
| 5661 |
vmCvar_t ui_browserShowFull; |
| 5662 |
vmCvar_t ui_browserShowEmpty; |
| 5663 |
|
| 5664 |
vmCvar_t ui_brassTime; |
| 5665 |
vmCvar_t ui_drawCrosshair; |
| 5666 |
vmCvar_t ui_drawCrosshairNames; |
| 5667 |
vmCvar_t ui_marks; |
| 5668 |
|
| 5669 |
vmCvar_t ui_server1; |
| 5670 |
vmCvar_t ui_server2; |
| 5671 |
vmCvar_t ui_server3; |
| 5672 |
vmCvar_t ui_server4; |
| 5673 |
vmCvar_t ui_server5; |
| 5674 |
vmCvar_t ui_server6; |
| 5675 |
vmCvar_t ui_server7; |
| 5676 |
vmCvar_t ui_server8; |
| 5677 |
vmCvar_t ui_server9; |
| 5678 |
vmCvar_t ui_server10; |
| 5679 |
vmCvar_t ui_server11; |
| 5680 |
vmCvar_t ui_server12; |
| 5681 |
vmCvar_t ui_server13; |
| 5682 |
vmCvar_t ui_server14; |
| 5683 |
vmCvar_t ui_server15; |
| 5684 |
vmCvar_t ui_server16; |
| 5685 |
|
| 5686 |
vmCvar_t ui_cdkeychecked; |
| 5687 |
|
| 5688 |
vmCvar_t ui_redteam; |
| 5689 |
vmCvar_t ui_redteam1; |
| 5690 |
vmCvar_t ui_redteam2; |
| 5691 |
vmCvar_t ui_redteam3; |
| 5692 |
vmCvar_t ui_redteam4; |
| 5693 |
vmCvar_t ui_redteam5; |
| 5694 |
vmCvar_t ui_blueteam; |
| 5695 |
vmCvar_t ui_blueteam1; |
| 5696 |
vmCvar_t ui_blueteam2; |
| 5697 |
vmCvar_t ui_blueteam3; |
| 5698 |
vmCvar_t ui_blueteam4; |
| 5699 |
vmCvar_t ui_blueteam5; |
| 5700 |
vmCvar_t ui_teamName; |
| 5701 |
vmCvar_t ui_dedicated; |
| 5702 |
vmCvar_t ui_gameType; |
| 5703 |
vmCvar_t ui_netGameType; |
| 5704 |
vmCvar_t ui_actualNetGameType; |
| 5705 |
vmCvar_t ui_joinGameType; |
| 5706 |
vmCvar_t ui_netSource; |
| 5707 |
vmCvar_t ui_serverFilterType; |
| 5708 |
vmCvar_t ui_opponentName; |
| 5709 |
vmCvar_t ui_menuFiles; |
| 5710 |
vmCvar_t ui_currentTier; |
| 5711 |
vmCvar_t ui_currentMap; |
| 5712 |
vmCvar_t ui_currentNetMap; |
| 5713 |
vmCvar_t ui_mapIndex; |
| 5714 |
vmCvar_t ui_currentOpponent; |
| 5715 |
vmCvar_t ui_selectedPlayer; |
| 5716 |
vmCvar_t ui_selectedPlayerName; |
| 5717 |
vmCvar_t ui_lastServerRefresh_0; |
| 5718 |
vmCvar_t ui_lastServerRefresh_1; |
| 5719 |
vmCvar_t ui_lastServerRefresh_2; |
| 5720 |
vmCvar_t ui_lastServerRefresh_3; |
| 5721 |
vmCvar_t ui_lastServerRefresh_4; |
| 5722 |
vmCvar_t ui_lastServerRefresh_5; |
| 5723 |
vmCvar_t ui_lastServerRefresh_6; |
| 5724 |
vmCvar_t ui_singlePlayerActive; |
| 5725 |
vmCvar_t ui_scoreAccuracy; |
| 5726 |
vmCvar_t ui_scoreImpressives; |
| 5727 |
vmCvar_t ui_scoreExcellents; |
| 5728 |
vmCvar_t ui_scoreCaptures; |
| 5729 |
vmCvar_t ui_scoreDefends; |
| 5730 |
vmCvar_t ui_scoreAssists; |
| 5731 |
vmCvar_t ui_scoreGauntlets; |
| 5732 |
vmCvar_t ui_scoreScore; |
| 5733 |
vmCvar_t ui_scorePerfect; |
| 5734 |
vmCvar_t ui_scoreTeam; |
| 5735 |
vmCvar_t ui_scoreBase; |
| 5736 |
vmCvar_t ui_scoreTimeBonus; |
| 5737 |
vmCvar_t ui_scoreSkillBonus; |
| 5738 |
vmCvar_t ui_scoreShutoutBonus; |
| 5739 |
vmCvar_t ui_scoreTime; |
| 5740 |
vmCvar_t ui_captureLimit; |
| 5741 |
vmCvar_t ui_fragLimit; |
| 5742 |
vmCvar_t ui_smallFont; |
| 5743 |
vmCvar_t ui_bigFont; |
| 5744 |
vmCvar_t ui_findPlayer; |
| 5745 |
vmCvar_t ui_Q3Model; |
| 5746 |
vmCvar_t ui_hudFiles; |
| 5747 |
vmCvar_t ui_recordSPDemo; |
| 5748 |
vmCvar_t ui_realCaptureLimit; |
| 5749 |
vmCvar_t ui_realWarmUp; |
| 5750 |
vmCvar_t ui_serverStatusTimeOut; |
| 5751 |
|
| 5752 |
static cvarTable_t cvarTable[] = { |
| 5753 |
{ &ui_ffa_fraglimit, "ui_ffa_fraglimit", "20", CVAR_ARCHIVE }, |
| 5754 |
{ &ui_ffa_timelimit, "ui_ffa_timelimit", "0", CVAR_ARCHIVE }, |
| 5755 |
|
| 5756 |
{ &ui_tourney_fraglimit, "ui_tourney_fraglimit", "0", CVAR_ARCHIVE }, |
| 5757 |
{ &ui_tourney_timelimit, "ui_tourney_timelimit", "15", CVAR_ARCHIVE }, |
| 5758 |
|
| 5759 |
{ &ui_team_fraglimit, "ui_team_fraglimit", "0", CVAR_ARCHIVE }, |
| 5760 |
{ &ui_team_timelimit, "ui_team_timelimit", "20", CVAR_ARCHIVE }, |
| 5761 |
{ &ui_team_friendly, "ui_team_friendly", "1", CVAR_ARCHIVE }, |
| 5762 |
|
| 5763 |
{ &ui_ctf_capturelimit, "ui_ctf_capturelimit", "8", CVAR_ARCHIVE }, |
| 5764 |
{ &ui_ctf_timelimit, "ui_ctf_timelimit", "30", CVAR_ARCHIVE }, |
| 5765 |
{ &ui_ctf_friendly, "ui_ctf_friendly", "0", CVAR_ARCHIVE }, |
| 5766 |
|
| 5767 |
{ &ui_arenasFile, "g_arenasFile", "", CVAR_INIT|CVAR_ROM }, |
| 5768 |
{ &ui_botsFile, "g_botsFile", "", CVAR_INIT|CVAR_ROM }, |
| 5769 |
{ &ui_spScores1, "g_spScores1", "", CVAR_ARCHIVE }, |
| 5770 |
{ &ui_spScores2, "g_spScores2", "", CVAR_ARCHIVE }, |
| 5771 |
{ &ui_spScores3, "g_spScores3", "", CVAR_ARCHIVE }, |
| 5772 |
{ &ui_spScores4, "g_spScores4", "", CVAR_ARCHIVE }, |
| 5773 |
{ &ui_spScores5, "g_spScores5", "", CVAR_ARCHIVE }, |
| 5774 |
{ &ui_spAwards, "g_spAwards", "", CVAR_ARCHIVE }, |
| 5775 |
{ &ui_spVideos, "g_spVideos", "", CVAR_ARCHIVE }, |
| 5776 |
{ &ui_spSkill, "g_spSkill", "2", CVAR_ARCHIVE }, |
| 5777 |
|
| 5778 |
{ &ui_spSelection, "ui_spSelection", "", CVAR_ROM }, |
| 5779 |
|
| 5780 |
{ &ui_browserMaster, "ui_browserMaster", "0", CVAR_ARCHIVE }, |
| 5781 |
{ &ui_browserGameType, "ui_browserGameType", "0", CVAR_ARCHIVE }, |
| 5782 |
{ &ui_browserShowFull, "ui_browserShowFull", "1", CVAR_ARCHIVE }, |
| 5783 |
{ &ui_browserShowEmpty, "ui_browserShowEmpty", "1", CVAR_ARCHIVE }, |
| 5784 |
|
| 5785 |
{ &ui_brassTime, "cg_brassTime", "2500", CVAR_ARCHIVE }, |
| 5786 |
{ &ui_drawCrosshair, "cg_drawCrosshair", "4", CVAR_ARCHIVE }, |
| 5787 |
{ &ui_drawCrosshairNames, "cg_drawCrosshairNames", "1", CVAR_ARCHIVE }, |
| 5788 |
{ &ui_marks, "cg_marks", "1", CVAR_ARCHIVE }, |
| 5789 |
|
| 5790 |
{ &ui_server1, "server1", "", CVAR_ARCHIVE }, |
| 5791 |
{ &ui_server2, "server2", "", CVAR_ARCHIVE }, |
| 5792 |
{ &ui_server3, "server3", "", CVAR_ARCHIVE }, |
| 5793 |
{ &ui_server4, "server4", "", CVAR_ARCHIVE }, |
| 5794 |
{ &ui_server5, "server5", "", CVAR_ARCHIVE }, |
| 5795 |
{ &ui_server6, "server6", "", CVAR_ARCHIVE }, |
| 5796 |
{ &ui_server7, "server7", "", CVAR_ARCHIVE }, |
| 5797 |
{ &ui_server8, "server8", "", CVAR_ARCHIVE }, |
| 5798 |
{ &ui_server9, "server9", "", CVAR_ARCHIVE }, |
| 5799 |
{ &ui_server10, "server10", "", CVAR_ARCHIVE }, |
| 5800 |
{ &ui_server11, "server11", "", CVAR_ARCHIVE }, |
| 5801 |
{ &ui_server12, "server12", "", CVAR_ARCHIVE }, |
| 5802 |
{ &ui_server13, "server13", "", CVAR_ARCHIVE }, |
| 5803 |
{ &ui_server14, "server14", "", CVAR_ARCHIVE }, |
| 5804 |
{ &ui_server15, "server15", "", CVAR_ARCHIVE }, |
| 5805 |
{ &ui_server16, "server16", "", CVAR_ARCHIVE }, |
| 5806 |
{ &ui_cdkeychecked, "ui_cdkeychecked", "0", CVAR_ROM }, |
| 5807 |
{ &ui_new, "ui_new", "0", CVAR_TEMP }, |
| 5808 |
{ &ui_debug, "ui_debug", "0", CVAR_TEMP }, |
| 5809 |
{ &ui_initialized, "ui_initialized", "0", CVAR_TEMP }, |
| 5810 |
{ &ui_teamName, "ui_teamName", "Pagans", CVAR_ARCHIVE }, |
| 5811 |
{ &ui_opponentName, "ui_opponentName", "Stroggs", CVAR_ARCHIVE }, |
| 5812 |
{ &ui_redteam, "ui_redteam", "Pagans", CVAR_ARCHIVE }, |
| 5813 |
{ &ui_blueteam, "ui_blueteam", "Stroggs", CVAR_ARCHIVE }, |
| 5814 |
{ &ui_dedicated, "ui_dedicated", "0", CVAR_ARCHIVE }, |
| 5815 |
{ &ui_gameType, "ui_gametype", "3", CVAR_ARCHIVE }, |
| 5816 |
{ &ui_joinGameType, "ui_joinGametype", "0", CVAR_ARCHIVE }, |
| 5817 |
{ &ui_netGameType, "ui_netGametype", "3", CVAR_ARCHIVE }, |
| 5818 |
{ &ui_actualNetGameType, "ui_actualNetGametype", "3", CVAR_ARCHIVE }, |
| 5819 |
{ &ui_redteam1, "ui_redteam1", "0", CVAR_ARCHIVE }, |
| 5820 |
{ &ui_redteam2, "ui_redteam2", "0", CVAR_ARCHIVE }, |
| 5821 |
{ &ui_redteam3, "ui_redteam3", "0", CVAR_ARCHIVE }, |
| 5822 |
{ &ui_redteam4, "ui_redteam4", "0", CVAR_ARCHIVE }, |
| 5823 |
{ &ui_redteam5, "ui_redteam5", "0", CVAR_ARCHIVE }, |
| 5824 |
{ &ui_blueteam1, "ui_blueteam1", "0", CVAR_ARCHIVE }, |
| 5825 |
{ &ui_blueteam2, "ui_blueteam2", "0", CVAR_ARCHIVE }, |
| 5826 |
{ &ui_blueteam3, "ui_blueteam3", "0", CVAR_ARCHIVE }, |
| 5827 |
{ &ui_blueteam4, "ui_blueteam4", "0", CVAR_ARCHIVE }, |
| 5828 |
{ &ui_blueteam5, "ui_blueteam5", "0", CVAR_ARCHIVE }, |
| 5829 |
{ &ui_netSource, "ui_netSource", "1", CVAR_ARCHIVE }, |
| 5830 |
{ &ui_menuFiles, "ui_menuFiles", "ui/menus.txt", CVAR_ARCHIVE }, |
| 5831 |
{ &ui_currentTier, "ui_currentTier", "0", CVAR_ARCHIVE }, |
| 5832 |
{ &ui_currentMap, "ui_currentMap", "0", CVAR_ARCHIVE }, |
| 5833 |
{ &ui_currentNetMap, "ui_currentNetMap", "0", CVAR_ARCHIVE }, |
| 5834 |
{ &ui_mapIndex, "ui_mapIndex", "0", CVAR_ARCHIVE }, |
| 5835 |
{ &ui_currentOpponent, "ui_currentOpponent", "0", CVAR_ARCHIVE }, |
| 5836 |
{ &ui_selectedPlayer, "cg_selectedPlayer", "0", CVAR_ARCHIVE}, |
| 5837 |
{ &ui_selectedPlayerName, "cg_selectedPlayerName", "", CVAR_ARCHIVE}, |
| 5838 |
{ &ui_lastServerRefresh_0, "ui_lastServerRefresh_0", "", CVAR_ARCHIVE}, |
| 5839 |
{ &ui_lastServerRefresh_1, "ui_lastServerRefresh_1", "", CVAR_ARCHIVE}, |
| 5840 |
{ &ui_lastServerRefresh_2, "ui_lastServerRefresh_2", "", CVAR_ARCHIVE}, |
| 5841 |
{ &ui_lastServerRefresh_3, "ui_lastServerRefresh_3", "", CVAR_ARCHIVE}, |
| 5842 |
{ &ui_lastServerRefresh_4, "ui_lastServerRefresh_4", "", CVAR_ARCHIVE}, |
| 5843 |
{ &ui_lastServerRefresh_5, "ui_lastServerRefresh_5", "", CVAR_ARCHIVE}, |
| 5844 |
{ &ui_lastServerRefresh_6, "ui_lastServerRefresh_6", "", CVAR_ARCHIVE}, |
| 5845 |
{ &ui_singlePlayerActive, "ui_singlePlayerActive", "0", 0}, |
| 5846 |
{ &ui_scoreAccuracy, "ui_scoreAccuracy", "0", CVAR_ARCHIVE}, |
| 5847 |
{ &ui_scoreImpressives, "ui_scoreImpressives", "0", CVAR_ARCHIVE}, |
| 5848 |
{ &ui_scoreExcellents, "ui_scoreExcellents", "0", CVAR_ARCHIVE}, |
| 5849 |
{ &ui_scoreCaptures, "ui_scoreCaptures", "0", CVAR_ARCHIVE}, |
| 5850 |
{ &ui_scoreDefends, "ui_scoreDefends", "0", CVAR_ARCHIVE}, |
| 5851 |
{ &ui_scoreAssists, "ui_scoreAssists", "0", CVAR_ARCHIVE}, |
| 5852 |
{ &ui_scoreGauntlets, "ui_scoreGauntlets", "0",CVAR_ARCHIVE}, |
| 5853 |
{ &ui_scoreScore, "ui_scoreScore", "0", CVAR_ARCHIVE}, |
| 5854 |
{ &ui_scorePerfect, "ui_scorePerfect", "0", CVAR_ARCHIVE}, |
| 5855 |
{ &ui_scoreTeam, "ui_scoreTeam", "0 to 0", CVAR_ARCHIVE}, |
| 5856 |
{ &ui_scoreBase, "ui_scoreBase", "0", CVAR_ARCHIVE}, |
| 5857 |
{ &ui_scoreTime, "ui_scoreTime", "00:00", CVAR_ARCHIVE}, |
| 5858 |
{ &ui_scoreTimeBonus, "ui_scoreTimeBonus", "0", CVAR_ARCHIVE}, |
| 5859 |
{ &ui_scoreSkillBonus, "ui_scoreSkillBonus", "0", CVAR_ARCHIVE}, |
| 5860 |
{ &ui_scoreShutoutBonus, "ui_scoreShutoutBonus", "0", CVAR_ARCHIVE}, |
| 5861 |
{ &ui_fragLimit, "ui_fragLimit", "10", 0}, |
| 5862 |
{ &ui_captureLimit, "ui_captureLimit", "5", 0}, |
| 5863 |
{ &ui_smallFont, "ui_smallFont", "0.25", CVAR_ARCHIVE}, |
| 5864 |
{ &ui_bigFont, "ui_bigFont", "0.4", CVAR_ARCHIVE}, |
| 5865 |
{ &ui_findPlayer, "ui_findPlayer", "Sarge", CVAR_ARCHIVE}, |
| 5866 |
{ &ui_Q3Model, "ui_q3model", "0", CVAR_ARCHIVE}, |
| 5867 |
{ &ui_hudFiles, "cg_hudFiles", "ui/hud.txt", CVAR_ARCHIVE}, |
| 5868 |
{ &ui_recordSPDemo, "ui_recordSPDemo", "0", CVAR_ARCHIVE}, |
| 5869 |
{ &ui_teamArenaFirstRun, "ui_teamArenaFirstRun", "0", CVAR_ARCHIVE}, |
| 5870 |
{ &ui_realWarmUp, "g_warmup", "20", CVAR_ARCHIVE}, |
| 5871 |
{ &ui_realCaptureLimit, "capturelimit", "8", CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_NORESTART}, |
| 5872 |
{ &ui_serverStatusTimeOut, "ui_serverStatusTimeOut", "7000", CVAR_ARCHIVE}, |
| 5873 |
|
| 5874 |
{ NULL, "ui_videomode", "", CVAR_ROM }, |
| 5875 |
{ NULL, "g_localTeamPref", "", 0 }, |
| 5876 |
}; |
| 5877 |
|
| 5878 |
static int cvarTableSize = ARRAY_LEN( cvarTable ); |
| 5879 |
|
| 5880 |
|
| 5881 |
|
| 5882 |
|
| 5883 |
|
| 5884 |
|
| 5885 |
|
| 5886 |
void UI_RegisterCvars( void ) { |
| 5887 |
int i; |
| 5888 |
cvarTable_t *cv; |
| 5889 |
|
| 5890 |
for ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) { |
| 5891 |
trap_Cvar_Register( cv->vmCvar, cv->cvarName, cv->defaultString, cv->cvarFlags ); |
| 5892 |
} |
| 5893 |
} |
| 5894 |
|
| 5895 |
|
| 5896 |
|
| 5897 |
|
| 5898 |
|
| 5899 |
|
| 5900 |
void UI_UpdateCvars( void ) { |
| 5901 |
int i; |
| 5902 |
cvarTable_t *cv; |
| 5903 |
|
| 5904 |
for ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) { |
| 5905 |
if ( !cv->vmCvar ) { |
| 5906 |
continue; |
| 5907 |
} |
| 5908 |
|
| 5909 |
trap_Cvar_Update( cv->vmCvar ); |
| 5910 |
} |
| 5911 |
} |
| 5912 |
|
| 5913 |
|
| 5914 |
|
| 5915 |
|
| 5916 |
|
| 5917 |
|
| 5918 |
|
| 5919 |
static void UI_StopServerRefresh( void ) |
| 5920 |
{ |
| 5921 |
int count; |
| 5922 |
|
| 5923 |
if (!uiInfo.serverStatus.refreshActive) { |
| 5924 |
|
| 5925 |
return; |
| 5926 |
} |
| 5927 |
uiInfo.serverStatus.refreshActive = qfalse; |
| 5928 |
Com_Printf("%d servers listed in browser with %d players.\n", |
| 5929 |
uiInfo.serverStatus.numDisplayServers, |
| 5930 |
uiInfo.serverStatus.numPlayersOnServers); |
| 5931 |
count = trap_LAN_GetServerCount(UI_SourceForLAN()); |
| 5932 |
if (count - uiInfo.serverStatus.numDisplayServers > 0) { |
| 5933 |
Com_Printf("%d servers not listed due to packet loss or pings higher than %d\n", |
| 5934 |
count - uiInfo.serverStatus.numDisplayServers, |
| 5935 |
(int) trap_Cvar_VariableValue("cl_maxPing")); |
| 5936 |
} |
| 5937 |
|
| 5938 |
} |
| 5939 |
|
| 5940 |
|
| 5941 |
|
| 5942 |
|
| 5943 |
|
| 5944 |
|
| 5945 |
#ifndef MISSIONPACK |
| 5946 |
static int ArenaServers_MaxPing( void ) { |
| 5947 |
int maxPing; |
| 5948 |
|
| 5949 |
maxPing = (int)trap_Cvar_VariableValue( "cl_maxPing" ); |
| 5950 |
if( maxPing < 100 ) { |
| 5951 |
maxPing = 100; |
| 5952 |
} |
| 5953 |
return maxPing; |
| 5954 |
} |
| 5955 |
#endif |
| 5956 |
|
| 5957 |
|
| 5958 |
|
| 5959 |
|
| 5960 |
|
| 5961 |
|
| 5962 |
static void UI_DoServerRefresh( void ) |
| 5963 |
{ |
| 5964 |
qboolean wait = qfalse; |
| 5965 |
|
| 5966 |
if (!uiInfo.serverStatus.refreshActive) { |
| 5967 |
return; |
| 5968 |
} |
| 5969 |
if (ui_netSource.integer != UIAS_FAVORITES) { |
| 5970 |
if (ui_netSource.integer == UIAS_LOCAL) { |
| 5971 |
if (!trap_LAN_GetServerCount(AS_LOCAL)) { |
| 5972 |
wait = qtrue; |
| 5973 |
} |
| 5974 |
} else { |
| 5975 |
if (trap_LAN_GetServerCount(AS_GLOBAL) < 0) { |
| 5976 |
wait = qtrue; |
| 5977 |
} |
| 5978 |
} |
| 5979 |
} |
| 5980 |
|
| 5981 |
if (uiInfo.uiDC.realTime < uiInfo.serverStatus.refreshtime) { |
| 5982 |
if (wait) { |
| 5983 |
return; |
| 5984 |
} |
| 5985 |
} |
| 5986 |
|
| 5987 |
|
| 5988 |
if (trap_LAN_UpdateVisiblePings(UI_SourceForLAN())) { |
| 5989 |
uiInfo.serverStatus.refreshtime = uiInfo.uiDC.realTime + 1000; |
| 5990 |
} else if (!wait) { |
| 5991 |
|
| 5992 |
UI_BuildServerDisplayList(2); |
| 5993 |
|
| 5994 |
UI_StopServerRefresh(); |
| 5995 |
} else if ( ui_netSource.integer == UIAS_LOCAL ) { |
| 5996 |
|
| 5997 |
trap_Cmd_ExecuteText( EXEC_NOW, "localservers\n" ); |
| 5998 |
uiInfo.serverStatus.refreshtime = uiInfo.uiDC.realTime + 5000; |
| 5999 |
} |
| 6000 |
|
| 6001 |
UI_BuildServerDisplayList(qfalse); |
| 6002 |
} |
| 6003 |
|
| 6004 |
|
| 6005 |
|
| 6006 |
|
| 6007 |
|
| 6008 |
|
| 6009 |
static void UI_StartServerRefresh(qboolean full, qboolean force) |
| 6010 |
{ |
| 6011 |
char *ptr; |
| 6012 |
int lanSource; |
| 6013 |
qtime_t q; |
| 6014 |
|
| 6015 |
|
| 6016 |
|
| 6017 |
|
| 6018 |
if ( !force && ( ui_netSource.integer >= UIAS_GLOBAL0 && ui_netSource.integer <= UIAS_GLOBAL5 ) ) { |
| 6019 |
if ( trap_LAN_GetServerCount( UI_SourceForLAN() ) > 0 ) { |
| 6020 |
return; |
| 6021 |
} |
| 6022 |
} |
| 6023 |
|
| 6024 |
trap_RealTime(&q); |
| 6025 |
trap_Cvar_Set( va("ui_lastServerRefresh_%i", ui_netSource.integer), va("%s-%i, %i at %i:%02i", MonthAbbrev[q.tm_mon],q.tm_mday, 1900+q.tm_year,q.tm_hour,q.tm_min)); |
| 6026 |
|
| 6027 |
if (!full) { |
| 6028 |
UI_UpdatePendingPings(); |
| 6029 |
return; |
| 6030 |
} |
| 6031 |
|
| 6032 |
uiInfo.serverStatus.refreshActive = qtrue; |
| 6033 |
uiInfo.serverStatus.nextDisplayRefresh = uiInfo.uiDC.realTime + 1000; |
| 6034 |
|
| 6035 |
uiInfo.serverStatus.numDisplayServers = 0; |
| 6036 |
uiInfo.serverStatus.numPlayersOnServers = 0; |
| 6037 |
|
| 6038 |
lanSource = UI_SourceForLAN(); |
| 6039 |
|
| 6040 |
trap_LAN_MarkServerVisible(lanSource, -1, qtrue); |
| 6041 |
|
| 6042 |
trap_LAN_ResetPings(lanSource); |
| 6043 |
|
| 6044 |
if( ui_netSource.integer == UIAS_LOCAL ) { |
| 6045 |
trap_Cmd_ExecuteText( EXEC_NOW, "localservers\n" ); |
| 6046 |
uiInfo.serverStatus.refreshtime = uiInfo.uiDC.realTime + 5000; |
| 6047 |
return; |
| 6048 |
} |
| 6049 |
|
| 6050 |
uiInfo.serverStatus.refreshtime = uiInfo.uiDC.realTime + 5000; |
| 6051 |
if( ui_netSource.integer >= UIAS_GLOBAL0 && ui_netSource.integer <= UIAS_GLOBAL5 ) { |
| 6052 |
|
| 6053 |
ptr = UI_Cvar_VariableString("debug_protocol"); |
| 6054 |
if (strlen(ptr)) { |
| 6055 |
trap_Cmd_ExecuteText( EXEC_NOW, va( "globalservers %d %s full empty\n", ui_netSource.integer - UIAS_GLOBAL0, ptr ) ); |
| 6056 |
} |
| 6057 |
else { |
| 6058 |
trap_Cmd_ExecuteText( EXEC_NOW, va( "globalservers %d %d full empty\n", ui_netSource.integer - UIAS_GLOBAL0, (int)trap_Cvar_VariableValue( "protocol" ) ) ); |
| 6059 |
} |
| 6060 |
} |
| 6061 |
} |
| 6062 |
|