| 1 |
/* |
| 2 |
=========================================================================== |
| 3 |
Copyright (C) 1999-2005 Id Software, Inc. |
| 4 |
|
| 5 |
This file is part of Quake III Arena source code. |
| 6 |
|
| 7 |
Quake III Arena source code is free software; you can redistribute it |
| 8 |
and/or modify it under the terms of the GNU General Public License as |
| 9 |
published by the Free Software Foundation; either version 2 of the License, |
| 10 |
or (at your option) any later version. |
| 11 |
|
| 12 |
Quake III Arena source code is distributed in the hope that it will be |
| 13 |
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
GNU General Public License for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU General Public License |
| 18 |
along with Quake III Arena source code; if not, write to the Free Software |
| 19 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 |
=========================================================================== |
| 21 |
*/ |
| 22 |
// |
| 23 |
#include "ui_local.h" |
| 24 |
|
| 25 |
void GraphicsOptions_MenuInit( void ); |
| 26 |
|
| 27 |
/* |
| 28 |
======================================================================= |
| 29 |
|
| 30 |
DRIVER INFORMATION MENU |
| 31 |
|
| 32 |
======================================================================= |
| 33 |
*/ |
| 34 |
|
| 35 |
|
| 36 |
#define DRIVERINFO_FRAMEL "menu/art_blueish/frame2_l" |
| 37 |
#define DRIVERINFO_FRAMER "menu/art_blueish/frame1_r" |
| 38 |
#define DRIVERINFO_BACK0 "menu/art_blueish/back_0" |
| 39 |
#define DRIVERINFO_BACK1 "menu/art_blueish/back_1" |
| 40 |
|
| 41 |
static char* driverinfo_artlist[] = |
| 42 |
{ |
| 43 |
DRIVERINFO_FRAMEL, |
| 44 |
DRIVERINFO_FRAMER, |
| 45 |
DRIVERINFO_BACK0, |
| 46 |
DRIVERINFO_BACK1, |
| 47 |
NULL, |
| 48 |
}; |
| 49 |
|
| 50 |
#define ID_DRIVERINFOBACK 100 |
| 51 |
|
| 52 |
typedef struct |
| 53 |
{ |
| 54 |
menuframework_s menu; |
| 55 |
menutext_s banner; |
| 56 |
menubitmap_s back; |
| 57 |
menubitmap_s framel; |
| 58 |
menubitmap_s framer; |
| 59 |
char stringbuff[1024]; |
| 60 |
char* strings[64]; |
| 61 |
int numstrings; |
| 62 |
} driverinfo_t; |
| 63 |
|
| 64 |
static driverinfo_t s_driverinfo; |
| 65 |
|
| 66 |
/* |
| 67 |
================= |
| 68 |
DriverInfo_Event |
| 69 |
================= |
| 70 |
*/ |
| 71 |
static void DriverInfo_Event( void* ptr, int event ) |
| 72 |
{ |
| 73 |
if (event != QM_ACTIVATED) |
| 74 |
return; |
| 75 |
|
| 76 |
switch (((menucommon_s*)ptr)->id) |
| 77 |
{ |
| 78 |
case ID_DRIVERINFOBACK: |
| 79 |
UI_PopMenu(); |
| 80 |
break; |
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
/* |
| 85 |
================= |
| 86 |
DriverInfo_MenuDraw |
| 87 |
================= |
| 88 |
*/ |
| 89 |
static void DriverInfo_MenuDraw( void ) |
| 90 |
{ |
| 91 |
int i; |
| 92 |
int y; |
| 93 |
|
| 94 |
Menu_Draw( &s_driverinfo.menu ); |
| 95 |
|
| 96 |
UI_DrawString( 320, 80, "VENDOR", UI_CENTER|UI_SMALLFONT, color_red ); |
| 97 |
UI_DrawString( 320, 152, "PIXELFORMAT", UI_CENTER|UI_SMALLFONT, color_red ); |
| 98 |
UI_DrawString( 320, 192, "EXTENSIONS", UI_CENTER|UI_SMALLFONT, color_red ); |
| 99 |
|
| 100 |
UI_DrawString( 320, 80+16, uis.glconfig.vendor_string, UI_CENTER|UI_SMALLFONT, text_color_normal ); |
| 101 |
UI_DrawString( 320, 96+16, uis.glconfig.version_string, UI_CENTER|UI_SMALLFONT, text_color_normal ); |
| 102 |
UI_DrawString( 320, 112+16, uis.glconfig.renderer_string, UI_CENTER|UI_SMALLFONT, text_color_normal ); |
| 103 |
UI_DrawString( 320, 152+16, va ("color(%d-bits) Z(%d-bits) stencil(%d-bits)", uis.glconfig.colorBits, uis.glconfig.depthBits, uis.glconfig.stencilBits), UI_CENTER|UI_SMALLFONT, text_color_normal ); |
| 104 |
|
| 105 |
// double column |
| 106 |
y = 192+16; |
| 107 |
for (i=0; i<s_driverinfo.numstrings/2; i++) { |
| 108 |
UI_DrawString( 320-4, y, s_driverinfo.strings[i*2], UI_RIGHT|UI_SMALLFONT, text_color_normal ); |
| 109 |
UI_DrawString( 320+4, y, s_driverinfo.strings[i*2+1], UI_LEFT|UI_SMALLFONT, text_color_normal ); |
| 110 |
y += SMALLCHAR_HEIGHT; |
| 111 |
} |
| 112 |
|
| 113 |
if (s_driverinfo.numstrings & 1) |
| 114 |
UI_DrawString( 320, y, s_driverinfo.strings[s_driverinfo.numstrings-1], UI_CENTER|UI_SMALLFONT, text_color_normal ); |
| 115 |
} |
| 116 |
|
| 117 |
/* |
| 118 |
================= |
| 119 |
DriverInfo_Cache |
| 120 |
================= |
| 121 |
*/ |
| 122 |
void DriverInfo_Cache( void ) |
| 123 |
{ |
| 124 |
int i; |
| 125 |
|
| 126 |
// touch all our pics |
| 127 |
for (i=0; ;i++) |
| 128 |
{ |
| 129 |
if (!driverinfo_artlist[i]) |
| 130 |
break; |
| 131 |
trap_R_RegisterShaderNoMip(driverinfo_artlist[i]); |
| 132 |
} |
| 133 |
} |
| 134 |
|
| 135 |
/* |
| 136 |
================= |
| 137 |
UI_DriverInfo_Menu |
| 138 |
================= |
| 139 |
*/ |
| 140 |
static void UI_DriverInfo_Menu( void ) |
| 141 |
{ |
| 142 |
char* eptr; |
| 143 |
int i; |
| 144 |
int len; |
| 145 |
|
| 146 |
// zero set all our globals |
| 147 |
memset( &s_driverinfo, 0 ,sizeof(driverinfo_t) ); |
| 148 |
|
| 149 |
DriverInfo_Cache(); |
| 150 |
|
| 151 |
s_driverinfo.menu.fullscreen = qtrue; |
| 152 |
s_driverinfo.menu.draw = DriverInfo_MenuDraw; |
| 153 |
|
| 154 |
s_driverinfo.banner.generic.type = MTYPE_BTEXT; |
| 155 |
s_driverinfo.banner.generic.x = 320; |
| 156 |
s_driverinfo.banner.generic.y = 16; |
| 157 |
s_driverinfo.banner.string = "DRIVER INFO"; |
| 158 |
s_driverinfo.banner.color = color_white; |
| 159 |
s_driverinfo.banner.style = UI_CENTER; |
| 160 |
|
| 161 |
s_driverinfo.framel.generic.type = MTYPE_BITMAP; |
| 162 |
s_driverinfo.framel.generic.name = DRIVERINFO_FRAMEL; |
| 163 |
s_driverinfo.framel.generic.flags = QMF_INACTIVE; |
| 164 |
s_driverinfo.framel.generic.x = 0; |
| 165 |
s_driverinfo.framel.generic.y = 78; |
| 166 |
s_driverinfo.framel.width = 256; |
| 167 |
s_driverinfo.framel.height = 329; |
| 168 |
|
| 169 |
s_driverinfo.framer.generic.type = MTYPE_BITMAP; |
| 170 |
s_driverinfo.framer.generic.name = DRIVERINFO_FRAMER; |
| 171 |
s_driverinfo.framer.generic.flags = QMF_INACTIVE; |
| 172 |
s_driverinfo.framer.generic.x = 376; |
| 173 |
s_driverinfo.framer.generic.y = 76; |
| 174 |
s_driverinfo.framer.width = 256; |
| 175 |
s_driverinfo.framer.height = 334; |
| 176 |
|
| 177 |
s_driverinfo.back.generic.type = MTYPE_BITMAP; |
| 178 |
s_driverinfo.back.generic.name = DRIVERINFO_BACK0; |
| 179 |
s_driverinfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS; |
| 180 |
s_driverinfo.back.generic.callback = DriverInfo_Event; |
| 181 |
s_driverinfo.back.generic.id = ID_DRIVERINFOBACK; |
| 182 |
s_driverinfo.back.generic.x = 0; |
| 183 |
s_driverinfo.back.generic.y = 480-64; |
| 184 |
s_driverinfo.back.width = 128; |
| 185 |
s_driverinfo.back.height = 64; |
| 186 |
s_driverinfo.back.focuspic = DRIVERINFO_BACK1; |
| 187 |
|
| 188 |
// TTimo: overflow with particularly long GL extensions (such as the gf3) |
| 189 |
// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=399 |
| 190 |
// NOTE: could have pushed the size of stringbuff, but the list is already out of the screen |
| 191 |
// (no matter what your resolution) |
| 192 |
Q_strncpyz(s_driverinfo.stringbuff, uis.glconfig.extensions_string, 1024); |
| 193 |
|
| 194 |
// build null terminated extension strings |
| 195 |
eptr = s_driverinfo.stringbuff; |
| 196 |
while ( s_driverinfo.numstrings<40 && *eptr ) |
| 197 |
{ |
| 198 |
while ( *eptr && *eptr == ' ' ) |
| 199 |
*eptr++ = '\0'; |
| 200 |
|
| 201 |
// track start of valid string |
| 202 |
if (*eptr && *eptr != ' ') |
| 203 |
s_driverinfo.strings[s_driverinfo.numstrings++] = eptr; |
| 204 |
|
| 205 |
while ( *eptr && *eptr != ' ' ) |
| 206 |
eptr++; |
| 207 |
} |
| 208 |
|
| 209 |
// safety length strings for display |
| 210 |
for (i=0; i<s_driverinfo.numstrings; i++) { |
| 211 |
len = strlen(s_driverinfo.strings[i]); |
| 212 |
if (len > 32) { |
| 213 |
s_driverinfo.strings[i][len-1] = '>'; |
| 214 |
s_driverinfo.strings[i][len] = '\0'; |
| 215 |
} |
| 216 |
} |
| 217 |
|
| 218 |
Menu_AddItem( &s_driverinfo.menu, &s_driverinfo.banner ); |
| 219 |
Menu_AddItem( &s_driverinfo.menu, &s_driverinfo.framel ); |
| 220 |
Menu_AddItem( &s_driverinfo.menu, &s_driverinfo.framer ); |
| 221 |
Menu_AddItem( &s_driverinfo.menu, &s_driverinfo.back ); |
| 222 |
|
| 223 |
UI_PushMenu( &s_driverinfo.menu ); |
| 224 |
} |
| 225 |
|
| 226 |
/* |
| 227 |
======================================================================= |
| 228 |
|
| 229 |
GRAPHICS OPTIONS MENU |
| 230 |
|
| 231 |
======================================================================= |
| 232 |
*/ |
| 233 |
|
| 234 |
#define GRAPHICSOPTIONS_FRAMEL "menu/art_blueish/frame2_l" |
| 235 |
#define GRAPHICSOPTIONS_FRAMER "menu/art_blueish/frame1_r" |
| 236 |
#define GRAPHICSOPTIONS_BACK0 "menu/art_blueish/back_0" |
| 237 |
#define GRAPHICSOPTIONS_BACK1 "menu/art_blueish/back_1" |
| 238 |
#define GRAPHICSOPTIONS_ACCEPT0 "menu/art_blueish/accept_0" |
| 239 |
#define GRAPHICSOPTIONS_ACCEPT1 "menu/art_blueish/accept_1" |
| 240 |
|
| 241 |
#define ID_BACK2 101 |
| 242 |
#define ID_FULLSCREEN 102 |
| 243 |
#define ID_LIST 103 |
| 244 |
#define ID_MODE 104 |
| 245 |
#define ID_DRIVERINFO 105 |
| 246 |
#define ID_GRAPHICS 106 |
| 247 |
#define ID_DISPLAY 107 |
| 248 |
#define ID_SOUND 108 |
| 249 |
#define ID_NETWORK 109 |
| 250 |
#define ID_RATIO 110 |
| 251 |
|
| 252 |
typedef struct { |
| 253 |
menuframework_s menu; |
| 254 |
|
| 255 |
menutext_s banner; |
| 256 |
menubitmap_s framel; |
| 257 |
menubitmap_s framer; |
| 258 |
|
| 259 |
menutext_s graphics; |
| 260 |
menutext_s display; |
| 261 |
menutext_s sound; |
| 262 |
menutext_s network; |
| 263 |
|
| 264 |
menulist_s list; |
| 265 |
menulist_s ratio; |
| 266 |
menulist_s mode; |
| 267 |
menulist_s driver; |
| 268 |
menuslider_s tq; |
| 269 |
menulist_s fs; |
| 270 |
menulist_s lighting; |
| 271 |
menulist_s flares; |
| 272 |
menulist_s bloom; |
| 273 |
menulist_s allow_extensions; |
| 274 |
menulist_s texturebits; |
| 275 |
menulist_s geometry; |
| 276 |
menulist_s filter; |
| 277 |
menulist_s aniso; |
| 278 |
menutext_s driverinfo; |
| 279 |
|
| 280 |
menubitmap_s apply; |
| 281 |
menubitmap_s back; |
| 282 |
} graphicsoptions_t; |
| 283 |
|
| 284 |
typedef struct |
| 285 |
{ |
| 286 |
int mode; |
| 287 |
qboolean fullscreen; |
| 288 |
int tq; |
| 289 |
int lighting; |
| 290 |
qboolean flares; |
| 291 |
qboolean bloom; |
| 292 |
int texturebits; |
| 293 |
int geometry; |
| 294 |
int filter; |
| 295 |
int aniso; |
| 296 |
int driver; |
| 297 |
qboolean extensions; |
| 298 |
} InitialVideoOptions_s; |
| 299 |
|
| 300 |
static InitialVideoOptions_s s_ivo; |
| 301 |
static graphicsoptions_t s_graphicsoptions; |
| 302 |
|
| 303 |
static InitialVideoOptions_s s_ivo_templates[] = |
| 304 |
{ |
| 305 |
{ |
| 306 |
6, qtrue, 3, 0, qfalse,qfalse, 2, 2, 1, 0, 0, qtrue |
| 307 |
}, |
| 308 |
{ |
| 309 |
4, qtrue, 2, 0, qfalse,qfalse, 2, 1, 1, 0, 0, qtrue // JDC: this was tq 3 |
| 310 |
}, |
| 311 |
{ |
| 312 |
3, qtrue, 2, 0, qfalse,qfalse, 0, 1, 0, 0, 0, qtrue |
| 313 |
}, |
| 314 |
{ |
| 315 |
2, qtrue, 1, 0, qfalse,qfalse, 0, 0, 0, 0, 0, qtrue |
| 316 |
}, |
| 317 |
{ |
| 318 |
2, qtrue, 1, 1, qfalse,qfalse, 0, 0, 0, 0, 0, qtrue |
| 319 |
}, |
| 320 |
{ |
| 321 |
3, qtrue, 1, 0, qfalse,qfalse, 0, 1, 0, 0, 0, qtrue |
| 322 |
} |
| 323 |
}; |
| 324 |
|
| 325 |
#define NUM_IVO_TEMPLATES ( sizeof( s_ivo_templates ) / sizeof( s_ivo_templates[0] ) ) |
| 326 |
|
| 327 |
static const char *builtinResolutions[ ] = |
| 328 |
{ |
| 329 |
"320x240", |
| 330 |
"400x300", |
| 331 |
"512x384", |
| 332 |
"640x480", |
| 333 |
"800x600", |
| 334 |
"960x720", |
| 335 |
"1024x768", |
| 336 |
"1152x864", |
| 337 |
"1280x1024", |
| 338 |
"1600x1200", |
| 339 |
"2048x1536", |
| 340 |
"856x480", |
| 341 |
NULL |
| 342 |
}; |
| 343 |
|
| 344 |
static const char *knownRatios[ ][2] = |
| 345 |
{ |
| 346 |
{ "1.25:1", "5:4" }, |
| 347 |
{ "1.33:1", "4:3" }, |
| 348 |
{ "1.50:1", "3:2" }, |
| 349 |
{ "1.56:1", "14:9" }, |
| 350 |
{ "1.60:1", "16:10" }, |
| 351 |
{ "1.67:1", "5:3" }, |
| 352 |
{ "1.78:1", "16:9" }, |
| 353 |
{ NULL , NULL } |
| 354 |
}; |
| 355 |
|
| 356 |
#define MAX_RESOLUTIONS 32 |
| 357 |
|
| 358 |
static const char* ratios[ MAX_RESOLUTIONS ]; |
| 359 |
static char ratioBuf[ MAX_RESOLUTIONS ][ 8 ]; |
| 360 |
static int ratioToRes[ MAX_RESOLUTIONS ]; |
| 361 |
static int resToRatio[ MAX_RESOLUTIONS ]; |
| 362 |
|
| 363 |
static char resbuf[ MAX_STRING_CHARS ]; |
| 364 |
static const char* detectedResolutions[ MAX_RESOLUTIONS ]; |
| 365 |
|
| 366 |
static const char** resolutions = builtinResolutions; |
| 367 |
static qboolean resolutionsDetected = qfalse; |
| 368 |
|
| 369 |
/* |
| 370 |
================= |
| 371 |
GraphicsOptions_FindBuiltinResolution |
| 372 |
================= |
| 373 |
*/ |
| 374 |
static int GraphicsOptions_FindBuiltinResolution( int mode ) |
| 375 |
{ |
| 376 |
int i; |
| 377 |
|
| 378 |
if( !resolutionsDetected ) |
| 379 |
return mode; |
| 380 |
|
| 381 |
if( mode < 0 ) |
| 382 |
return -1; |
| 383 |
|
| 384 |
for( i = 0; builtinResolutions[ i ]; i++ ) |
| 385 |
{ |
| 386 |
if( !Q_stricmp( builtinResolutions[ i ], detectedResolutions[ mode ] ) ) |
| 387 |
return i; |
| 388 |
} |
| 389 |
|
| 390 |
return -1; |
| 391 |
} |
| 392 |
|
| 393 |
/* |
| 394 |
================= |
| 395 |
GraphicsOptions_FindDetectedResolution |
| 396 |
================= |
| 397 |
*/ |
| 398 |
static int GraphicsOptions_FindDetectedResolution( int mode ) |
| 399 |
{ |
| 400 |
int i; |
| 401 |
|
| 402 |
if( !resolutionsDetected ) |
| 403 |
return mode; |
| 404 |
|
| 405 |
if( mode < 0 ) |
| 406 |
return -1; |
| 407 |
|
| 408 |
for( i = 0; detectedResolutions[ i ]; i++ ) |
| 409 |
{ |
| 410 |
if( !Q_stricmp( builtinResolutions[ mode ], detectedResolutions[ i ] ) ) |
| 411 |
return i; |
| 412 |
} |
| 413 |
|
| 414 |
return -1; |
| 415 |
} |
| 416 |
|
| 417 |
/* |
| 418 |
================= |
| 419 |
GraphicsOptions_GetAspectRatios |
| 420 |
================= |
| 421 |
*/ |
| 422 |
static void GraphicsOptions_GetAspectRatios( void ) |
| 423 |
{ |
| 424 |
int i, r; |
| 425 |
|
| 426 |
// build ratio list from resolutions |
| 427 |
for( r = 0; resolutions[r]; r++ ) |
| 428 |
{ |
| 429 |
int w, h; |
| 430 |
char *x; |
| 431 |
char str[ sizeof(ratioBuf[0]) ]; |
| 432 |
|
| 433 |
// calculate resolution's aspect ratio |
| 434 |
x = strchr( resolutions[r], 'x' )+1; |
| 435 |
|
| 436 |
|
| 437 |
Q_strncpyz( str, resolutions[r], x-resolutions[r] ); |
| 438 |
w = atoi( str ); |
| 439 |
h = atoi( x ); |
| 440 |
Com_sprintf( str, sizeof(str), "%.2f:1", (float)w / (float)h ); |
| 441 |
|
| 442 |
// rename common ratios ("1.33:1" -> "4:3") |
| 443 |
for( i = 0; knownRatios[i][0]; i++ ) { |
| 444 |
if( !Q_stricmp( str, knownRatios[i][0] ) ) { |
| 445 |
Q_strncpyz( str, knownRatios[i][1], sizeof( str ) ); |
| 446 |
break; |
| 447 |
} |
| 448 |
} |
| 449 |
|
| 450 |
// add ratio to list if it is new |
| 451 |
// establish res/ratio relationship |
| 452 |
for( i = 0; ratioBuf[i][0]; i++ ) |
| 453 |
{ |
| 454 |
if( !Q_stricmp( str, ratioBuf[i] ) ) |
| 455 |
break; |
| 456 |
} |
| 457 |
if( !ratioBuf[i][0] ) |
| 458 |
{ |
| 459 |
Q_strncpyz( ratioBuf[i], str, sizeof(ratioBuf[i]) ); |
| 460 |
ratioToRes[i] = r; |
| 461 |
} |
| 462 |
ratios[r] = ratioBuf[r]; |
| 463 |
resToRatio[r] = i; |
| 464 |
} |
| 465 |
ratios[r] = NULL; |
| 466 |
} |
| 467 |
|
| 468 |
/* |
| 469 |
================= |
| 470 |
GraphicsOptions_GetInitialVideo |
| 471 |
================= |
| 472 |
*/ |
| 473 |
static void GraphicsOptions_GetInitialVideo( void ) |
| 474 |
{ |
| 475 |
s_ivo.driver = s_graphicsoptions.driver.curvalue; |
| 476 |
s_ivo.mode = s_graphicsoptions.mode.curvalue; |
| 477 |
s_ivo.fullscreen = s_graphicsoptions.fs.curvalue; |
| 478 |
s_ivo.extensions = s_graphicsoptions.allow_extensions.curvalue; |
| 479 |
s_ivo.tq = s_graphicsoptions.tq.curvalue; |
| 480 |
s_ivo.lighting = s_graphicsoptions.lighting.curvalue; |
| 481 |
s_ivo.flares = s_graphicsoptions.flares.curvalue; |
| 482 |
s_ivo.bloom = s_graphicsoptions.bloom.curvalue; |
| 483 |
s_ivo.geometry = s_graphicsoptions.geometry.curvalue; |
| 484 |
s_ivo.filter = s_graphicsoptions.filter.curvalue; |
| 485 |
s_ivo.aniso = s_graphicsoptions.aniso.curvalue; |
| 486 |
s_ivo.texturebits = s_graphicsoptions.texturebits.curvalue; |
| 487 |
} |
| 488 |
|
| 489 |
/* |
| 490 |
================= |
| 491 |
GraphicsOptions_GetResolutions |
| 492 |
================= |
| 493 |
*/ |
| 494 |
static void GraphicsOptions_GetResolutions( void ) |
| 495 |
{ |
| 496 |
Q_strncpyz(resbuf, UI_Cvar_VariableString("r_availableModes"), sizeof(resbuf)); |
| 497 |
if(*resbuf) |
| 498 |
{ |
| 499 |
char* s = resbuf; |
| 500 |
unsigned int i = 0; |
| 501 |
while( s && i < sizeof(detectedResolutions)/sizeof(detectedResolutions[0])-1) |
| 502 |
{ |
| 503 |
detectedResolutions[i++] = s; |
| 504 |
s = strchr(s, ' '); |
| 505 |
if( s ) |
| 506 |
*s++ = '\0'; |
| 507 |
} |
| 508 |
detectedResolutions[ i ] = NULL; |
| 509 |
|
| 510 |
if( i > 0 ) |
| 511 |
{ |
| 512 |
resolutions = detectedResolutions; |
| 513 |
resolutionsDetected = qtrue; |
| 514 |
} |
| 515 |
} |
| 516 |
} |
| 517 |
|
| 518 |
/* |
| 519 |
================= |
| 520 |
GraphicsOptions_CheckConfig |
| 521 |
================= |
| 522 |
*/ |
| 523 |
static void GraphicsOptions_CheckConfig( void ) |
| 524 |
{ |
| 525 |
int i; |
| 526 |
|
| 527 |
for ( i = 0; i < NUM_IVO_TEMPLATES-1; i++ ) |
| 528 |
{ |
| 529 |
if ( s_ivo_templates[i].driver != s_graphicsoptions.driver.curvalue ) |
| 530 |
continue; |
| 531 |
if ( GraphicsOptions_FindDetectedResolution(s_ivo_templates[i].mode) != s_graphicsoptions.mode.curvalue ) |
| 532 |
continue; |
| 533 |
if ( s_ivo_templates[i].fullscreen != s_graphicsoptions.fs.curvalue ) |
| 534 |
continue; |
| 535 |
if ( s_ivo_templates[i].tq != s_graphicsoptions.tq.curvalue ) |
| 536 |
continue; |
| 537 |
if ( s_ivo_templates[i].lighting != s_graphicsoptions.lighting.curvalue ) |
| 538 |
continue; |
| 539 |
if ( s_ivo_templates[i].flares != s_graphicsoptions.flares.curvalue ) |
| 540 |
continue; |
| 541 |
if ( s_ivo_templates[i].bloom != s_graphicsoptions.bloom.curvalue ) |
| 542 |
continue; |
| 543 |
if ( s_ivo_templates[i].geometry != s_graphicsoptions.geometry.curvalue ) |
| 544 |
continue; |
| 545 |
if ( s_ivo_templates[i].filter != s_graphicsoptions.filter.curvalue ) |
| 546 |
continue; |
| 547 |
if ( s_ivo_templates[i].aniso != s_graphicsoptions.aniso.curvalue ) |
| 548 |
continue; |
| 549 |
// if ( s_ivo_templates[i].texturebits != s_graphicsoptions.texturebits.curvalue ) |
| 550 |
// continue; |
| 551 |
s_graphicsoptions.list.curvalue = i; |
| 552 |
return; |
| 553 |
} |
| 554 |
|
| 555 |
// return 'Custom' ivo template |
| 556 |
s_graphicsoptions.list.curvalue = NUM_IVO_TEMPLATES - 1; |
| 557 |
} |
| 558 |
|
| 559 |
/* |
| 560 |
================= |
| 561 |
GraphicsOptions_UpdateMenuItems |
| 562 |
================= |
| 563 |
*/ |
| 564 |
static void GraphicsOptions_UpdateMenuItems( void ) |
| 565 |
{ |
| 566 |
if ( s_graphicsoptions.driver.curvalue == 1 ) |
| 567 |
{ |
| 568 |
s_graphicsoptions.fs.curvalue = 1; |
| 569 |
s_graphicsoptions.fs.generic.flags |= QMF_GRAYED; |
| 570 |
} |
| 571 |
else |
| 572 |
{ |
| 573 |
s_graphicsoptions.fs.generic.flags &= ~QMF_GRAYED; |
| 574 |
} |
| 575 |
|
| 576 |
if ( s_graphicsoptions.allow_extensions.curvalue == 0 ) |
| 577 |
{ |
| 578 |
if ( s_graphicsoptions.texturebits.curvalue == 0 ) |
| 579 |
{ |
| 580 |
s_graphicsoptions.texturebits.curvalue = 1; |
| 581 |
} |
| 582 |
} |
| 583 |
|
| 584 |
s_graphicsoptions.apply.generic.flags |= QMF_HIDDEN|QMF_INACTIVE; |
| 585 |
|
| 586 |
if ( s_ivo.mode != s_graphicsoptions.mode.curvalue ) |
| 587 |
{ |
| 588 |
s_graphicsoptions.apply.generic.flags &= ~(QMF_HIDDEN|QMF_INACTIVE); |
| 589 |
} |
| 590 |
if ( s_ivo.fullscreen != s_graphicsoptions.fs.curvalue ) |
| 591 |
{ |
| 592 |
s_graphicsoptions.apply.generic.flags &= ~(QMF_HIDDEN|QMF_INACTIVE); |
| 593 |
} |
| 594 |
if ( s_ivo.extensions != s_graphicsoptions.allow_extensions.curvalue ) |
| 595 |
{ |
| 596 |
s_graphicsoptions.apply.generic.flags &= ~(QMF_HIDDEN|QMF_INACTIVE); |
| 597 |
} |
| 598 |
if ( s_ivo.tq != s_graphicsoptions.tq.curvalue ) |
| 599 |
{ |
| 600 |
s_graphicsoptions.apply.generic.flags &= ~(QMF_HIDDEN|QMF_INACTIVE); |
| 601 |
} |
| 602 |
if ( s_ivo.lighting != s_graphicsoptions.lighting.curvalue ) |
| 603 |
{ |
| 604 |
s_graphicsoptions.apply.generic.flags &= ~(QMF_HIDDEN|QMF_INACTIVE); |
| 605 |
} |
| 606 |
if ( s_ivo.flares != s_graphicsoptions.flares.curvalue ) |
| 607 |
{ |
| 608 |
s_graphicsoptions.apply.generic.flags &= ~(QMF_HIDDEN|QMF_INACTIVE); |
| 609 |
} |
| 610 |
if ( s_ivo.bloom != s_graphicsoptions.bloom.curvalue ) |
| 611 |
{ |
| 612 |
s_graphicsoptions.apply.generic.flags &= ~(QMF_HIDDEN|QMF_INACTIVE); |
| 613 |
} |
| 614 |
if ( s_ivo.driver != s_graphicsoptions.driver.curvalue ) |
| 615 |
{ |
| 616 |
s_graphicsoptions.apply.generic.flags &= ~(QMF_HIDDEN|QMF_INACTIVE); |
| 617 |
} |
| 618 |
if ( s_ivo.texturebits != s_graphicsoptions.texturebits.curvalue ) |
| 619 |
{ |
| 620 |
s_graphicsoptions.apply.generic.flags &= ~(QMF_HIDDEN|QMF_INACTIVE); |
| 621 |
} |
| 622 |
if ( s_ivo.geometry != s_graphicsoptions.geometry.curvalue ) |
| 623 |
{ |
| 624 |
s_graphicsoptions.apply.generic.flags &= ~(QMF_HIDDEN|QMF_INACTIVE); |
| 625 |
} |
| 626 |
if ( s_ivo.filter != s_graphicsoptions.filter.curvalue ) |
| 627 |
{ |
| 628 |
s_graphicsoptions.apply.generic.flags &= ~(QMF_HIDDEN|QMF_INACTIVE); |
| 629 |
} |
| 630 |
if ( s_ivo.aniso != s_graphicsoptions.aniso.curvalue ) |
| 631 |
{ |
| 632 |
s_graphicsoptions.apply.generic.flags &= ~(QMF_HIDDEN|QMF_INACTIVE); |
| 633 |
} |
| 634 |
|
| 635 |
GraphicsOptions_CheckConfig(); |
| 636 |
} |
| 637 |
|
| 638 |
/* |
| 639 |
================= |
| 640 |
GraphicsOptions_ApplyChanges |
| 641 |
================= |
| 642 |
*/ |
| 643 |
static void GraphicsOptions_ApplyChanges( void *unused, int notification ) |
| 644 |
{ |
| 645 |
if (notification != QM_ACTIVATED) |
| 646 |
return; |
| 647 |
|
| 648 |
switch ( s_graphicsoptions.texturebits.curvalue ) |
| 649 |
{ |
| 650 |
case 0: |
| 651 |
trap_Cvar_SetValue( "r_texturebits", 0 ); |
| 652 |
break; |
| 653 |
case 1: |
| 654 |
trap_Cvar_SetValue( "r_texturebits", 16 ); |
| 655 |
break; |
| 656 |
case 2: |
| 657 |
trap_Cvar_SetValue( "r_texturebits", 32 ); |
| 658 |
break; |
| 659 |
} |
| 660 |
trap_Cvar_SetValue( "r_picmip", 3 - s_graphicsoptions.tq.curvalue ); |
| 661 |
trap_Cvar_SetValue( "r_allowExtensions", s_graphicsoptions.allow_extensions.curvalue ); |
| 662 |
|
| 663 |
if( resolutionsDetected ) |
| 664 |
{ |
| 665 |
// search for builtin mode that matches the detected mode |
| 666 |
int mode; |
| 667 |
if ( s_graphicsoptions.mode.curvalue == -1 |
| 668 |
|| s_graphicsoptions.mode.curvalue >= sizeof(detectedResolutions)/sizeof(detectedResolutions[0]) ) |
| 669 |
s_graphicsoptions.mode.curvalue = 0; |
| 670 |
|
| 671 |
mode = GraphicsOptions_FindBuiltinResolution( s_graphicsoptions.mode.curvalue ); |
| 672 |
if( mode == -1 ) |
| 673 |
{ |
| 674 |
char w[ 16 ], h[ 16 ]; |
| 675 |
Q_strncpyz( w, detectedResolutions[ s_graphicsoptions.mode.curvalue ], sizeof( w ) ); |
| 676 |
*strchr( w, 'x' ) = 0; |
| 677 |
Q_strncpyz( h, |
| 678 |
strchr( detectedResolutions[ s_graphicsoptions.mode.curvalue ], 'x' ) + 1, sizeof( h ) ); |
| 679 |
trap_Cvar_Set( "r_customwidth", w ); |
| 680 |
trap_Cvar_Set( "r_customheight", h ); |
| 681 |
} |
| 682 |
|
| 683 |
trap_Cvar_SetValue( "r_mode", mode ); |
| 684 |
} |
| 685 |
else |
| 686 |
trap_Cvar_SetValue( "r_mode", s_graphicsoptions.mode.curvalue ); |
| 687 |
|
| 688 |
trap_Cvar_SetValue( "r_fullscreen", s_graphicsoptions.fs.curvalue ); |
| 689 |
trap_Cvar_SetValue( "r_colorbits", 0 ); |
| 690 |
trap_Cvar_SetValue( "r_depthbits", 0 ); |
| 691 |
trap_Cvar_SetValue( "r_stencilbits", 0 ); |
| 692 |
trap_Cvar_SetValue( "r_vertexLight", s_graphicsoptions.lighting.curvalue ); |
| 693 |
trap_Cvar_SetValue( "cg_autovertex", s_graphicsoptions.lighting.curvalue ); |
| 694 |
trap_Cvar_SetValue( "r_flares", s_graphicsoptions.flares.curvalue ); |
| 695 |
trap_Cvar_SetValue( "r_bloom", s_graphicsoptions.bloom.curvalue ); |
| 696 |
|
| 697 |
//r_ext_texture_filter_anisotropic is special |
| 698 |
if(s_graphicsoptions.aniso.curvalue) { |
| 699 |
trap_Cvar_SetValue( "r_ext_max_anisotropy", s_graphicsoptions.aniso.curvalue*2 ); |
| 700 |
trap_Cvar_SetValue( "r_ext_texture_filter_anisotropic", qtrue ); |
| 701 |
} |
| 702 |
else |
| 703 |
trap_Cvar_SetValue( "r_ext_texture_filter_anisotropic", qfalse ); |
| 704 |
|
| 705 |
trap_Cvar_SetValue( "com_hunkmegs", 128 ); |
| 706 |
|
| 707 |
|
| 708 |
if ( s_graphicsoptions.geometry.curvalue == 2 ) |
| 709 |
{ |
| 710 |
trap_Cvar_SetValue( "r_lodBias", 0 ); |
| 711 |
trap_Cvar_SetValue( "r_subdivisions", 4 ); |
| 712 |
} |
| 713 |
else if ( s_graphicsoptions.geometry.curvalue == 1 ) |
| 714 |
{ |
| 715 |
trap_Cvar_SetValue( "r_lodBias", 1 ); |
| 716 |
trap_Cvar_SetValue( "r_subdivisions", 12 ); |
| 717 |
} |
| 718 |
else |
| 719 |
{ |
| 720 |
trap_Cvar_SetValue( "r_lodBias", 1 ); |
| 721 |
trap_Cvar_SetValue( "r_subdivisions", 20 ); |
| 722 |
} |
| 723 |
|
| 724 |
if ( s_graphicsoptions.filter.curvalue ) |
| 725 |
{ |
| 726 |
trap_Cvar_Set( "r_textureMode", "GL_LINEAR_MIPMAP_LINEAR" ); |
| 727 |
} |
| 728 |
else |
| 729 |
{ |
| 730 |
trap_Cvar_Set( "r_textureMode", "GL_LINEAR_MIPMAP_NEAREST" ); |
| 731 |
} |
| 732 |
|
| 733 |
trap_Cmd_ExecuteText( EXEC_APPEND, "vid_restart\n" ); |
| 734 |
} |
| 735 |
|
| 736 |
/* |
| 737 |
================= |
| 738 |
GraphicsOptions_Event |
| 739 |
================= |
| 740 |
*/ |
| 741 |
static void GraphicsOptions_Event( void* ptr, int event ) { |
| 742 |
InitialVideoOptions_s *ivo; |
| 743 |
|
| 744 |
if( event != QM_ACTIVATED ) { |
| 745 |
return; |
| 746 |
} |
| 747 |
|
| 748 |
switch( ((menucommon_s*)ptr)->id ) { |
| 749 |
case ID_RATIO: |
| 750 |
s_graphicsoptions.mode.curvalue = ratioToRes[ s_graphicsoptions.ratio.curvalue ]; |
| 751 |
// fall through to apply mode constraints |
| 752 |
case ID_MODE: |
| 753 |
// clamp 3dfx video modes |
| 754 |
if ( s_graphicsoptions.driver.curvalue == 1 ) |
| 755 |
{ |
| 756 |
if ( s_graphicsoptions.mode.curvalue < 2 ) |
| 757 |
s_graphicsoptions.mode.curvalue = 2; |
| 758 |
else if ( s_graphicsoptions.mode.curvalue > 6 ) |
| 759 |
s_graphicsoptions.mode.curvalue = 6; |
| 760 |
} |
| 761 |
s_graphicsoptions.ratio.curvalue = resToRatio[ s_graphicsoptions.mode.curvalue ]; |
| 762 |
break; |
| 763 |
|
| 764 |
case ID_LIST: |
| 765 |
ivo = &s_ivo_templates[s_graphicsoptions.list.curvalue]; |
| 766 |
|
| 767 |
s_graphicsoptions.mode.curvalue = GraphicsOptions_FindDetectedResolution(ivo->mode); |
| 768 |
s_graphicsoptions.ratio.curvalue = resToRatio[ s_graphicsoptions.mode.curvalue ]; |
| 769 |
s_graphicsoptions.tq.curvalue = ivo->tq; |
| 770 |
s_graphicsoptions.lighting.curvalue = ivo->lighting; |
| 771 |
s_graphicsoptions.texturebits.curvalue = ivo->texturebits; |
| 772 |
s_graphicsoptions.geometry.curvalue = ivo->geometry; |
| 773 |
s_graphicsoptions.filter.curvalue = ivo->filter; |
| 774 |
s_graphicsoptions.aniso.curvalue = ivo->aniso; |
| 775 |
s_graphicsoptions.fs.curvalue = ivo->fullscreen; |
| 776 |
s_graphicsoptions.flares.curvalue = ivo->flares; |
| 777 |
s_graphicsoptions.bloom.curvalue = ivo->bloom; |
| 778 |
break; |
| 779 |
|
| 780 |
case ID_DRIVERINFO: |
| 781 |
UI_DriverInfo_Menu(); |
| 782 |
break; |
| 783 |
|
| 784 |
case ID_BACK2: |
| 785 |
UI_PopMenu(); |
| 786 |
break; |
| 787 |
|
| 788 |
case ID_GRAPHICS: |
| 789 |
break; |
| 790 |
|
| 791 |
case ID_DISPLAY: |
| 792 |
UI_PopMenu(); |
| 793 |
UI_DisplayOptionsMenu(); |
| 794 |
break; |
| 795 |
|
| 796 |
case ID_SOUND: |
| 797 |
UI_PopMenu(); |
| 798 |
UI_SoundOptionsMenu(); |
| 799 |
break; |
| 800 |
|
| 801 |
case ID_NETWORK: |
| 802 |
UI_PopMenu(); |
| 803 |
UI_NetworkOptionsMenu(); |
| 804 |
break; |
| 805 |
} |
| 806 |
} |
| 807 |
|
| 808 |
|
| 809 |
/* |
| 810 |
================ |
| 811 |
GraphicsOptions_TQEvent |
| 812 |
================ |
| 813 |
*/ |
| 814 |
static void GraphicsOptions_TQEvent( void *ptr, int event ) { |
| 815 |
if( event != QM_ACTIVATED ) { |
| 816 |
return; |
| 817 |
} |
| 818 |
s_graphicsoptions.tq.curvalue = (int)(s_graphicsoptions.tq.curvalue + 0.5); |
| 819 |
} |
| 820 |
|
| 821 |
|
| 822 |
/* |
| 823 |
================ |
| 824 |
GraphicsOptions_MenuDraw |
| 825 |
================ |
| 826 |
*/ |
| 827 |
void GraphicsOptions_MenuDraw (void) |
| 828 |
{ |
| 829 |
//APSFIX - rework this |
| 830 |
GraphicsOptions_UpdateMenuItems(); |
| 831 |
|
| 832 |
Menu_Draw( &s_graphicsoptions.menu ); |
| 833 |
} |
| 834 |
|
| 835 |
/* |
| 836 |
================= |
| 837 |
GraphicsOptions_SetMenuItems |
| 838 |
================= |
| 839 |
*/ |
| 840 |
static void GraphicsOptions_SetMenuItems( void ) |
| 841 |
{ |
| 842 |
s_graphicsoptions.mode.curvalue = |
| 843 |
GraphicsOptions_FindDetectedResolution( trap_Cvar_VariableValue( "r_mode" ) ); |
| 844 |
|
| 845 |
if ( s_graphicsoptions.mode.curvalue < 0 ) |
| 846 |
{ |
| 847 |
if( resolutionsDetected ) |
| 848 |
{ |
| 849 |
int i; |
| 850 |
char buf[MAX_STRING_CHARS]; |
| 851 |
trap_Cvar_VariableStringBuffer("r_customwidth", buf, sizeof(buf)-2); |
| 852 |
buf[strlen(buf)+1] = 0; |
| 853 |
buf[strlen(buf)] = 'x'; |
| 854 |
trap_Cvar_VariableStringBuffer("r_customheight", buf+strlen(buf), sizeof(buf)-strlen(buf)); |
| 855 |
|
| 856 |
for(i = 0; detectedResolutions[i]; ++i) |
| 857 |
{ |
| 858 |
if(!Q_stricmp(buf, detectedResolutions[i])) |
| 859 |
{ |
| 860 |
s_graphicsoptions.mode.curvalue = i; |
| 861 |
break; |
| 862 |
} |
| 863 |
} |
| 864 |
if ( s_graphicsoptions.mode.curvalue < 0 ) |
| 865 |
s_graphicsoptions.mode.curvalue = 0; |
| 866 |
} |
| 867 |
else |
| 868 |
{ |
| 869 |
s_graphicsoptions.mode.curvalue = 3; |
| 870 |
} |
| 871 |
} |
| 872 |
s_graphicsoptions.fs.curvalue = trap_Cvar_VariableValue("r_fullscreen"); |
| 873 |
s_graphicsoptions.allow_extensions.curvalue = trap_Cvar_VariableValue("r_allowExtensions"); |
| 874 |
s_graphicsoptions.flares.curvalue = trap_Cvar_VariableValue("r_flares"); |
| 875 |
s_graphicsoptions.bloom.curvalue = trap_Cvar_VariableValue("r_bloom"); |
| 876 |
if(trap_Cvar_VariableValue("r_ext_texture_filter_anisotropic")) { |
| 877 |
s_graphicsoptions.aniso.curvalue = trap_Cvar_VariableValue("r_ext_max_anisotropy")/2; |
| 878 |
} |
| 879 |
s_graphicsoptions.tq.curvalue = 3-trap_Cvar_VariableValue( "r_picmip"); |
| 880 |
if ( s_graphicsoptions.tq.curvalue < 0 ) |
| 881 |
{ |
| 882 |
s_graphicsoptions.tq.curvalue = 0; |
| 883 |
} |
| 884 |
else if ( s_graphicsoptions.tq.curvalue > 3 ) |
| 885 |
{ |
| 886 |
s_graphicsoptions.tq.curvalue = 3; |
| 887 |
} |
| 888 |
|
| 889 |
s_graphicsoptions.lighting.curvalue = trap_Cvar_VariableValue( "r_vertexLight" ) != 0; |
| 890 |
switch ( ( int ) trap_Cvar_VariableValue( "r_texturebits" ) ) |
| 891 |
{ |
| 892 |
default: |
| 893 |
case 0: |
| 894 |
s_graphicsoptions.texturebits.curvalue = 0; |
| 895 |
break; |
| 896 |
case 16: |
| 897 |
s_graphicsoptions.texturebits.curvalue = 1; |
| 898 |
break; |
| 899 |
case 32: |
| 900 |
s_graphicsoptions.texturebits.curvalue = 2; |
| 901 |
break; |
| 902 |
} |
| 903 |
|
| 904 |
if ( !Q_stricmp( UI_Cvar_VariableString( "r_textureMode" ), "GL_LINEAR_MIPMAP_NEAREST" ) ) |
| 905 |
{ |
| 906 |
s_graphicsoptions.filter.curvalue = 0; |
| 907 |
} |
| 908 |
else |
| 909 |
{ |
| 910 |
s_graphicsoptions.filter.curvalue = 1; |
| 911 |
} |
| 912 |
|
| 913 |
if ( trap_Cvar_VariableValue( "r_lodBias" ) > 0 ) |
| 914 |
{ |
| 915 |
if ( trap_Cvar_VariableValue( "r_subdivisions" ) >= 20 ) |
| 916 |
{ |
| 917 |
s_graphicsoptions.geometry.curvalue = 0; |
| 918 |
} |
| 919 |
else |
| 920 |
{ |
| 921 |
s_graphicsoptions.geometry.curvalue = 1; |
| 922 |
} |
| 923 |
} |
| 924 |
else |
| 925 |
{ |
| 926 |
s_graphicsoptions.geometry.curvalue = 2; |
| 927 |
} |
| 928 |
} |
| 929 |
|
| 930 |
/* |
| 931 |
================ |
| 932 |
GraphicsOptions_MenuInit |
| 933 |
================ |
| 934 |
*/ |
| 935 |
void GraphicsOptions_MenuInit( void ) |
| 936 |
{ |
| 937 |
static const char *s_driver_names[] = |
| 938 |
{ |
| 939 |
"Default", |
| 940 |
"Voodoo", |
| 941 |
NULL |
| 942 |
}; |
| 943 |
|
| 944 |
static const char *tq_names[] = |
| 945 |
{ |
| 946 |
"Default", |
| 947 |
"16 bit", |
| 948 |
"32 bit", |
| 949 |
NULL |
| 950 |
}; |
| 951 |
|
| 952 |
static const char *s_graphics_options_names[] = |
| 953 |
{ |
| 954 |
"Very High Quality", |
| 955 |
"High Quality", |
| 956 |
"Normal", |
| 957 |
"Fast", |
| 958 |
"Fastest", |
| 959 |
"Custom", |
| 960 |
NULL |
| 961 |
}; |
| 962 |
|
| 963 |
static const char *lighting_names[] = |
| 964 |
{ |
| 965 |
"Lightmap (Normal)", |
| 966 |
"Vertex (Low)", |
| 967 |
NULL |
| 968 |
}; |
| 969 |
|
| 970 |
|
| 971 |
static const char *filter_names[] = |
| 972 |
{ |
| 973 |
"Bilinear", |
| 974 |
"Trilinear", |
| 975 |
NULL |
| 976 |
}; |
| 977 |
|
| 978 |
static const char *aniso_names[] = |
| 979 |
{ |
| 980 |
"Off", |
| 981 |
"2x", |
| 982 |
"4x", |
| 983 |
"6x", |
| 984 |
"8x", |
| 985 |
NULL |
| 986 |
}; |
| 987 |
|
| 988 |
static const char *quality_names[] = |
| 989 |
{ |
| 990 |
"Low", |
| 991 |
"Medium", |
| 992 |
"High", |
| 993 |
NULL |
| 994 |
}; |
| 995 |
static const char *enabled_names[] = |
| 996 |
{ |
| 997 |
"Off", |
| 998 |
"On", |
| 999 |
NULL |
| 1000 |
}; |
| 1001 |
|
| 1002 |
int y; |
| 1003 |
|
| 1004 |
// zero set all our globals |
| 1005 |
memset( &s_graphicsoptions, 0 ,sizeof(graphicsoptions_t) ); |
| 1006 |
|
| 1007 |
|
| 1008 |
GraphicsOptions_GetResolutions(); |
| 1009 |
GraphicsOptions_GetAspectRatios(); |
| 1010 |
|
| 1011 |
GraphicsOptions_Cache(); |
| 1012 |
|
| 1013 |
s_graphicsoptions.menu.wrapAround = qtrue; |
| 1014 |
s_graphicsoptions.menu.fullscreen = qtrue; |
| 1015 |
s_graphicsoptions.menu.draw = GraphicsOptions_MenuDraw; |
| 1016 |
|
| 1017 |
s_graphicsoptions.banner.generic.type = MTYPE_BTEXT; |
| 1018 |
s_graphicsoptions.banner.generic.x = 320; |
| 1019 |
s_graphicsoptions.banner.generic.y = 16; |
| 1020 |
s_graphicsoptions.banner.string = "SYSTEM SETUP"; |
| 1021 |
s_graphicsoptions.banner.color = color_white; |
| 1022 |
s_graphicsoptions.banner.style = UI_CENTER; |
| 1023 |
|
| 1024 |
s_graphicsoptions.framel.generic.type = MTYPE_BITMAP; |
| 1025 |
s_graphicsoptions.framel.generic.name = GRAPHICSOPTIONS_FRAMEL; |
| 1026 |
s_graphicsoptions.framel.generic.flags = QMF_INACTIVE; |
| 1027 |
s_graphicsoptions.framel.generic.x = 0; |
| 1028 |
s_graphicsoptions.framel.generic.y = 78; |
| 1029 |
s_graphicsoptions.framel.width = 256; |
| 1030 |
s_graphicsoptions.framel.height = 329; |
| 1031 |
|
| 1032 |
s_graphicsoptions.framer.generic.type = MTYPE_BITMAP; |
| 1033 |
s_graphicsoptions.framer.generic.name = GRAPHICSOPTIONS_FRAMER; |
| 1034 |
s_graphicsoptions.framer.generic.flags = QMF_INACTIVE; |
| 1035 |
s_graphicsoptions.framer.generic.x = 376; |
| 1036 |
s_graphicsoptions.framer.generic.y = 76; |
| 1037 |
s_graphicsoptions.framer.width = 256; |
| 1038 |
s_graphicsoptions.framer.height = 334; |
| 1039 |
|
| 1040 |
s_graphicsoptions.graphics.generic.type = MTYPE_PTEXT; |
| 1041 |
s_graphicsoptions.graphics.generic.flags = QMF_RIGHT_JUSTIFY; |
| 1042 |
s_graphicsoptions.graphics.generic.id = ID_GRAPHICS; |
| 1043 |
s_graphicsoptions.graphics.generic.callback = GraphicsOptions_Event; |
| 1044 |
s_graphicsoptions.graphics.generic.x = 216; |
| 1045 |
s_graphicsoptions.graphics.generic.y = 240 - 2 * PROP_HEIGHT; |
| 1046 |
s_graphicsoptions.graphics.string = "GRAPHICS"; |
| 1047 |
s_graphicsoptions.graphics.style = UI_RIGHT; |
| 1048 |
s_graphicsoptions.graphics.color = color_red; |
| 1049 |
|
| 1050 |
s_graphicsoptions.display.generic.type = MTYPE_PTEXT; |
| 1051 |
s_graphicsoptions.display.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS; |
| 1052 |
s_graphicsoptions.display.generic.id = ID_DISPLAY; |
| 1053 |
s_graphicsoptions.display.generic.callback = GraphicsOptions_Event; |
| 1054 |
s_graphicsoptions.display.generic.x = 216; |
| 1055 |
s_graphicsoptions.display.generic.y = 240 - PROP_HEIGHT; |
| 1056 |
s_graphicsoptions.display.string = "DISPLAY"; |
| 1057 |
s_graphicsoptions.display.style = UI_RIGHT; |
| 1058 |
s_graphicsoptions.display.color = color_red; |
| 1059 |
|
| 1060 |
s_graphicsoptions.sound.generic.type = MTYPE_PTEXT; |
| 1061 |
s_graphicsoptions.sound.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS; |
| 1062 |
s_graphicsoptions.sound.generic.id = ID_SOUND; |
| 1063 |
s_graphicsoptions.sound.generic.callback = GraphicsOptions_Event; |
| 1064 |
s_graphicsoptions.sound.generic.x = 216; |
| 1065 |
s_graphicsoptions.sound.generic.y = 240; |
| 1066 |
s_graphicsoptions.sound.string = "SOUND"; |
| 1067 |
s_graphicsoptions.sound.style = UI_RIGHT; |
| 1068 |
s_graphicsoptions.sound.color = color_red; |
| 1069 |
|
| 1070 |
s_graphicsoptions.network.generic.type = MTYPE_PTEXT; |
| 1071 |
s_graphicsoptions.network.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS; |
| 1072 |
s_graphicsoptions.network.generic.id = ID_NETWORK; |
| 1073 |
s_graphicsoptions.network.generic.callback = GraphicsOptions_Event; |
| 1074 |
s_graphicsoptions.network.generic.x = 216; |
| 1075 |
s_graphicsoptions.network.generic.y = 240 + PROP_HEIGHT; |
| 1076 |
s_graphicsoptions.network.string = "NETWORK"; |
| 1077 |
s_graphicsoptions.network.style = UI_RIGHT; |
| 1078 |
s_graphicsoptions.network.color = color_red; |
| 1079 |
|
| 1080 |
y = 240 - 7 * (BIGCHAR_HEIGHT + 2); |
| 1081 |
s_graphicsoptions.list.generic.type = MTYPE_SPINCONTROL; |
| 1082 |
s_graphicsoptions.list.generic.name = "Graphics Settings:"; |
| 1083 |
s_graphicsoptions.list.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT; |
| 1084 |
s_graphicsoptions.list.generic.x = 400; |
| 1085 |
s_graphicsoptions.list.generic.y = y; |
| 1086 |
s_graphicsoptions.list.generic.callback = GraphicsOptions_Event; |
| 1087 |
s_graphicsoptions.list.generic.id = ID_LIST; |
| 1088 |
s_graphicsoptions.list.itemnames = s_graphics_options_names; |
| 1089 |
y += 2 * ( BIGCHAR_HEIGHT + 2 ); |
| 1090 |
|
| 1091 |
s_graphicsoptions.driver.generic.type = MTYPE_SPINCONTROL; |
| 1092 |
s_graphicsoptions.driver.generic.name = "GL Driver:"; |
| 1093 |
s_graphicsoptions.driver.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT; |
| 1094 |
s_graphicsoptions.driver.generic.x = 400; |
| 1095 |
s_graphicsoptions.driver.generic.y = y; |
| 1096 |
s_graphicsoptions.driver.itemnames = s_driver_names; |
| 1097 |
s_graphicsoptions.driver.curvalue = (uis.glconfig.driverType == GLDRV_VOODOO); |
| 1098 |
y += BIGCHAR_HEIGHT+2; |
| 1099 |
|
| 1100 |
// references/modifies "r_allowExtensions" |
| 1101 |
s_graphicsoptions.allow_extensions.generic.type = MTYPE_SPINCONTROL; |
| 1102 |
s_graphicsoptions.allow_extensions.generic.name = "GL Extensions:"; |
| 1103 |
s_graphicsoptions.allow_extensions.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT; |
| 1104 |
s_graphicsoptions.allow_extensions.generic.x = 400; |
| 1105 |
s_graphicsoptions.allow_extensions.generic.y = y; |
| 1106 |
s_graphicsoptions.allow_extensions.itemnames = enabled_names; |
| 1107 |
y += BIGCHAR_HEIGHT+2; |
| 1108 |
|
| 1109 |
s_graphicsoptions.ratio.generic.type = MTYPE_SPINCONTROL; |
| 1110 |
s_graphicsoptions.ratio.generic.name = "Aspect Ratio:"; |
| 1111 |
s_graphicsoptions.ratio.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT; |
| 1112 |
s_graphicsoptions.ratio.generic.x = 400; |
| 1113 |
s_graphicsoptions.ratio.generic.y = y; |
| 1114 |
s_graphicsoptions.ratio.itemnames = ratios; |
| 1115 |
s_graphicsoptions.ratio.generic.callback = GraphicsOptions_Event; |
| 1116 |
s_graphicsoptions.ratio.generic.id = ID_RATIO; |
| 1117 |
y += BIGCHAR_HEIGHT+2; |
| 1118 |
|
| 1119 |
|
| 1120 |
// references/modifies "r_mode" |
| 1121 |
s_graphicsoptions.mode.generic.type = MTYPE_SPINCONTROL; |
| 1122 |
s_graphicsoptions.mode.generic.name = "Resolution:"; |
| 1123 |
s_graphicsoptions.mode.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT; |
| 1124 |
s_graphicsoptions.mode.generic.x = 400; |
| 1125 |
s_graphicsoptions.mode.generic.y = y; |
| 1126 |
s_graphicsoptions.mode.itemnames = resolutions; |
| 1127 |
s_graphicsoptions.mode.generic.callback = GraphicsOptions_Event; |
| 1128 |
s_graphicsoptions.mode.generic.id = ID_MODE; |
| 1129 |
y += BIGCHAR_HEIGHT+2; |
| 1130 |
|
| 1131 |
// references/modifies "r_fullscreen" |
| 1132 |
s_graphicsoptions.fs.generic.type = MTYPE_SPINCONTROL; |
| 1133 |
s_graphicsoptions.fs.generic.name = "Fullscreen:"; |
| 1134 |
s_graphicsoptions.fs.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT; |
| 1135 |
s_graphicsoptions.fs.generic.x = 400; |
| 1136 |
s_graphicsoptions.fs.generic.y = y; |
| 1137 |
s_graphicsoptions.fs.itemnames = enabled_names; |
| 1138 |
y += BIGCHAR_HEIGHT+2; |
| 1139 |
|
| 1140 |
// references/modifies "r_vertexLight" |
| 1141 |
s_graphicsoptions.lighting.generic.type = MTYPE_SPINCONTROL; |
| 1142 |
s_graphicsoptions.lighting.generic.name = "Lighting:"; |
| 1143 |
s_graphicsoptions.lighting.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT; |
| 1144 |
s_graphicsoptions.lighting.generic.x = 400; |
| 1145 |
s_graphicsoptions.lighting.generic.y = y; |
| 1146 |
s_graphicsoptions.lighting.itemnames = lighting_names; |
| 1147 |
y += BIGCHAR_HEIGHT+2; |
| 1148 |
|
| 1149 |
// references/modifies "r_flares" |
| 1150 |
s_graphicsoptions.flares.generic.type = MTYPE_SPINCONTROL; |
| 1151 |
s_graphicsoptions.flares.generic.name = "Flares:"; |
| 1152 |
s_graphicsoptions.flares.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT; |
| 1153 |
s_graphicsoptions.flares.generic.x = 400; |
| 1154 |
s_graphicsoptions.flares.generic.y = y; |
| 1155 |
s_graphicsoptions.flares.itemnames = enabled_names; |
| 1156 |
y += BIGCHAR_HEIGHT+2; |
| 1157 |
|
| 1158 |
// references/modifies "r_bloom" |
| 1159 |
s_graphicsoptions.bloom.generic.type = MTYPE_SPINCONTROL; |
| 1160 |
s_graphicsoptions.bloom.generic.name = "Bloom:"; |
| 1161 |
s_graphicsoptions.bloom.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT; |
| 1162 |
s_graphicsoptions.bloom.generic.x = 400; |
| 1163 |
s_graphicsoptions.bloom.generic.y = y; |
| 1164 |
s_graphicsoptions.bloom.itemnames = enabled_names; |
| 1165 |
y += BIGCHAR_HEIGHT+2; |
| 1166 |
|
| 1167 |
// references/modifies "r_lodBias" & "subdivisions" |
| 1168 |
s_graphicsoptions.geometry.generic.type = MTYPE_SPINCONTROL; |
| 1169 |
s_graphicsoptions.geometry.generic.name = "Geometric Detail:"; |
| 1170 |
s_graphicsoptions.geometry.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT; |
| 1171 |
s_graphicsoptions.geometry.generic.x = 400; |
| 1172 |
s_graphicsoptions.geometry.generic.y = y; |
| 1173 |
s_graphicsoptions.geometry.itemnames = quality_names; |
| 1174 |
y += BIGCHAR_HEIGHT+2; |
| 1175 |
|
| 1176 |
// references/modifies "r_picmip" |
| 1177 |
s_graphicsoptions.tq.generic.type = MTYPE_SLIDER; |
| 1178 |
s_graphicsoptions.tq.generic.name = "Texture Detail:"; |
| 1179 |
s_graphicsoptions.tq.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT; |
| 1180 |
s_graphicsoptions.tq.generic.x = 400; |
| 1181 |
s_graphicsoptions.tq.generic.y = y; |
| 1182 |
s_graphicsoptions.tq.minvalue = 0; |
| 1183 |
s_graphicsoptions.tq.maxvalue = 3; |
| 1184 |
s_graphicsoptions.tq.generic.callback = GraphicsOptions_TQEvent; |
| 1185 |
y += BIGCHAR_HEIGHT+2; |
| 1186 |
|
| 1187 |
// references/modifies "r_textureBits" |
| 1188 |
s_graphicsoptions.texturebits.generic.type = MTYPE_SPINCONTROL; |
| 1189 |
s_graphicsoptions.texturebits.generic.name = "Texture Quality:"; |
| 1190 |
s_graphicsoptions.texturebits.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT; |
| 1191 |
s_graphicsoptions.texturebits.generic.x = 400; |
| 1192 |
s_graphicsoptions.texturebits.generic.y = y; |
| 1193 |
s_graphicsoptions.texturebits.itemnames = tq_names; |
| 1194 |
y += BIGCHAR_HEIGHT+2; |
| 1195 |
|
| 1196 |
// references/modifies "r_textureMode" |
| 1197 |
s_graphicsoptions.filter.generic.type = MTYPE_SPINCONTROL; |
| 1198 |
s_graphicsoptions.filter.generic.name = "Texture Filter:"; |
| 1199 |
s_graphicsoptions.filter.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT; |
| 1200 |
s_graphicsoptions.filter.generic.x = 400; |
| 1201 |
s_graphicsoptions.filter.generic.y = y; |
| 1202 |
s_graphicsoptions.filter.itemnames = filter_names; |
| 1203 |
y += 2+BIGCHAR_HEIGHT; |
| 1204 |
|
| 1205 |
s_graphicsoptions.aniso.generic.type = MTYPE_SPINCONTROL; |
| 1206 |
s_graphicsoptions.aniso.generic.name = "Anisotropy:"; |
| 1207 |
s_graphicsoptions.aniso.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT; |
| 1208 |
s_graphicsoptions.aniso.generic.x = 400; |
| 1209 |
s_graphicsoptions.aniso.generic.y = y; |
| 1210 |
s_graphicsoptions.aniso.itemnames = aniso_names; |
| 1211 |
y += 2*BIGCHAR_HEIGHT; |
| 1212 |
|
| 1213 |
s_graphicsoptions.driverinfo.generic.type = MTYPE_PTEXT; |
| 1214 |
s_graphicsoptions.driverinfo.generic.flags = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS; |
| 1215 |
s_graphicsoptions.driverinfo.generic.callback = GraphicsOptions_Event; |
| 1216 |
s_graphicsoptions.driverinfo.generic.id = ID_DRIVERINFO; |
| 1217 |
s_graphicsoptions.driverinfo.generic.x = 320; |
| 1218 |
s_graphicsoptions.driverinfo.generic.y = y; |
| 1219 |
s_graphicsoptions.driverinfo.string = "Driver Info"; |
| 1220 |
s_graphicsoptions.driverinfo.style = UI_CENTER|UI_SMALLFONT; |
| 1221 |
s_graphicsoptions.driverinfo.color = color_red; |
| 1222 |
y += BIGCHAR_HEIGHT+2; |
| 1223 |
|
| 1224 |
s_graphicsoptions.back.generic.type = MTYPE_BITMAP; |
| 1225 |
s_graphicsoptions.back.generic.name = GRAPHICSOPTIONS_BACK0; |
| 1226 |
s_graphicsoptions.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS; |
| 1227 |
s_graphicsoptions.back.generic.callback = GraphicsOptions_Event; |
| 1228 |
s_graphicsoptions.back.generic.id = ID_BACK2; |
| 1229 |
s_graphicsoptions.back.generic.x = 0; |
| 1230 |
s_graphicsoptions.back.generic.y = 480-64; |
| 1231 |
s_graphicsoptions.back.width = 128; |
| 1232 |
s_graphicsoptions.back.height = 64; |
| 1233 |
s_graphicsoptions.back.focuspic = GRAPHICSOPTIONS_BACK1; |
| 1234 |
|
| 1235 |
s_graphicsoptions.apply.generic.type = MTYPE_BITMAP; |
| 1236 |
s_graphicsoptions.apply.generic.name = GRAPHICSOPTIONS_ACCEPT0; |
| 1237 |
s_graphicsoptions.apply.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_HIDDEN|QMF_INACTIVE; |
| 1238 |
s_graphicsoptions.apply.generic.callback = GraphicsOptions_ApplyChanges; |
| 1239 |
s_graphicsoptions.apply.generic.x = 640; |
| 1240 |
s_graphicsoptions.apply.generic.y = 480-64; |
| 1241 |
s_graphicsoptions.apply.width = 128; |
| 1242 |
s_graphicsoptions.apply.height = 64; |
| 1243 |
s_graphicsoptions.apply.focuspic = GRAPHICSOPTIONS_ACCEPT1; |
| 1244 |
|
| 1245 |
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.banner ); |
| 1246 |
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.framel ); |
| 1247 |
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.framer ); |
| 1248 |
|
| 1249 |
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.graphics ); |
| 1250 |
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.display ); |
| 1251 |
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.sound ); |
| 1252 |
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.network ); |
| 1253 |
|
| 1254 |
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.list ); |
| 1255 |
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.driver ); |
| 1256 |
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.allow_extensions ); |
| 1257 |
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.ratio ); |
| 1258 |
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.mode ); |
| 1259 |
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.fs ); |
| 1260 |
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.lighting ); |
| 1261 |
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.flares ); |
| 1262 |
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.bloom ); |
| 1263 |
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.geometry ); |
| 1264 |
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.tq ); |
| 1265 |
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.texturebits ); |
| 1266 |
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.filter ); |
| 1267 |
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.aniso ); |
| 1268 |
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.driverinfo ); |
| 1269 |
|
| 1270 |
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.back ); |
| 1271 |
Menu_AddItem( &s_graphicsoptions.menu, ( void * ) &s_graphicsoptions.apply ); |
| 1272 |
|
| 1273 |
GraphicsOptions_SetMenuItems(); |
| 1274 |
GraphicsOptions_GetInitialVideo(); |
| 1275 |
|
| 1276 |
if ( uis.glconfig.driverType == GLDRV_ICD && |
| 1277 |
uis.glconfig.hardwareType == GLHW_3DFX_2D3D ) |
| 1278 |
{ |
| 1279 |
s_graphicsoptions.driver.generic.flags |= QMF_HIDDEN|QMF_INACTIVE; |
| 1280 |
} |
| 1281 |
} |
| 1282 |
|
| 1283 |
|
| 1284 |
/* |
| 1285 |
================= |
| 1286 |
GraphicsOptions_Cache |
| 1287 |
================= |
| 1288 |
*/ |
| 1289 |
void GraphicsOptions_Cache( void ) { |
| 1290 |
trap_R_RegisterShaderNoMip( GRAPHICSOPTIONS_FRAMEL ); |
| 1291 |
trap_R_RegisterShaderNoMip( GRAPHICSOPTIONS_FRAMER ); |
| 1292 |
trap_R_RegisterShaderNoMip( GRAPHICSOPTIONS_BACK0 ); |
| 1293 |
trap_R_RegisterShaderNoMip( GRAPHICSOPTIONS_BACK1 ); |
| 1294 |
trap_R_RegisterShaderNoMip( GRAPHICSOPTIONS_ACCEPT0 ); |
| 1295 |
trap_R_RegisterShaderNoMip( GRAPHICSOPTIONS_ACCEPT1 ); |
| 1296 |
} |
| 1297 |
|
| 1298 |
|
| 1299 |
/* |
| 1300 |
================= |
| 1301 |
UI_GraphicsOptionsMenu |
| 1302 |
================= |
| 1303 |
*/ |
| 1304 |
void UI_GraphicsOptionsMenu( void ) { |
| 1305 |
GraphicsOptions_MenuInit(); |
| 1306 |
UI_PushMenu( &s_graphicsoptions.menu ); |
| 1307 |
Menu_SetCursorToItem( &s_graphicsoptions.menu, &s_graphicsoptions.graphics ); |
| 1308 |
} |