|
|
1.1.1.2 ! root 1: /* ! 2: Copyright (C) 1997-2001 Id Software, Inc. ! 3: ! 4: This program is free software; you can redistribute it and/or ! 5: modify it under the terms of the GNU General Public License ! 6: as published by the Free Software Foundation; either version 2 ! 7: of the License, or (at your option) any later version. ! 8: ! 9: This program is distributed in the hope that it will be useful, ! 10: but WITHOUT ANY WARRANTY; without even the implied warranty of ! 11: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! 12: ! 13: See the GNU General Public License for more details. ! 14: ! 15: You should have received a copy of the GNU General Public License ! 16: along with this program; if not, write to the Free Software ! 17: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! 18: ! 19: */ 1.1 root 20: #include "../client/client.h" 21: #include "../client/qmenu.h" 22: 23: #define REF_SOFT 0 24: #define REF_SOFTX11 1 1.1.1.2 ! root 25: #define REF_MESA3D 2 ! 26: #define REF_3DFXGL 3 ! 27: #define REF_OPENGLX 4 ! 28: #define REF_MESA3DGLX 5 1.1 root 29: 30: extern cvar_t *vid_ref; 31: extern cvar_t *vid_fullscreen; 32: extern cvar_t *vid_gamma; 33: extern cvar_t *scr_viewsize; 34: 35: static cvar_t *gl_mode; 36: static cvar_t *gl_driver; 37: static cvar_t *gl_picmip; 38: static cvar_t *gl_ext_palettedtexture; 39: 40: static cvar_t *sw_mode; 41: static cvar_t *sw_stipplealpha; 42: 43: static cvar_t *_windowed_mouse; 44: 45: extern void M_ForceMenuOff( void ); 46: 47: /* 48: ==================================================================== 49: 50: MENU INTERACTION 51: 52: ==================================================================== 53: */ 54: #define SOFTWARE_MENU 0 55: #define OPENGL_MENU 1 56: 57: static menuframework_s s_software_menu; 58: static menuframework_s s_opengl_menu; 59: static menuframework_s *s_current_menu; 60: static int s_current_menu_index; 61: 62: static menulist_s s_mode_list[2]; 63: static menulist_s s_ref_list[2]; 64: static menuslider_s s_tq_slider; 65: static menuslider_s s_screensize_slider[2]; 66: static menuslider_s s_brightness_slider[2]; 67: static menulist_s s_fs_box[2]; 68: static menulist_s s_stipple_box; 69: static menulist_s s_paletted_texture_box; 70: static menulist_s s_windowed_mouse; 71: static menuaction_s s_apply_action[2]; 72: static menuaction_s s_defaults_action[2]; 73: 74: static void DriverCallback( void *unused ) 75: { 76: s_ref_list[!s_current_menu_index].curvalue = s_ref_list[s_current_menu_index].curvalue; 77: 78: if ( s_ref_list[s_current_menu_index].curvalue < 2 ) 79: { 80: s_current_menu = &s_software_menu; 81: s_current_menu_index = 0; 82: } 83: else 84: { 85: s_current_menu = &s_opengl_menu; 86: s_current_menu_index = 1; 87: } 88: 89: } 90: 91: static void ScreenSizeCallback( void *s ) 92: { 93: menuslider_s *slider = ( menuslider_s * ) s; 94: 95: Cvar_SetValue( "viewsize", slider->curvalue * 10 ); 96: } 97: 98: static void BrightnessCallback( void *s ) 99: { 100: menuslider_s *slider = ( menuslider_s * ) s; 101: 102: if ( s_current_menu_index == 0) 103: s_brightness_slider[1].curvalue = s_brightness_slider[0].curvalue; 104: else 105: s_brightness_slider[0].curvalue = s_brightness_slider[1].curvalue; 106: 107: if ( stricmp( vid_ref->string, "soft" ) == 0 || 108: stricmp( vid_ref->string, "softx" ) == 0 ) 109: { 110: float gamma = ( 0.8 - ( slider->curvalue/10.0 - 0.5 ) ) + 0.5; 111: 112: Cvar_SetValue( "vid_gamma", gamma ); 113: } 114: } 115: 116: static void ResetDefaults( void *unused ) 117: { 118: VID_MenuInit(); 119: } 120: 121: static void ApplyChanges( void *unused ) 122: { 123: float gamma; 124: 125: /* 126: ** make values consistent 127: */ 128: s_fs_box[!s_current_menu_index].curvalue = s_fs_box[s_current_menu_index].curvalue; 129: s_brightness_slider[!s_current_menu_index].curvalue = s_brightness_slider[s_current_menu_index].curvalue; 130: s_ref_list[!s_current_menu_index].curvalue = s_ref_list[s_current_menu_index].curvalue; 131: 132: /* 133: ** invert sense so greater = brighter, and scale to a range of 0.5 to 1.3 134: */ 135: gamma = ( 0.8 - ( s_brightness_slider[s_current_menu_index].curvalue/10.0 - 0.5 ) ) + 0.5; 136: 137: Cvar_SetValue( "vid_gamma", gamma ); 138: Cvar_SetValue( "sw_stipplealpha", s_stipple_box.curvalue ); 139: Cvar_SetValue( "gl_picmip", 3 - s_tq_slider.curvalue ); 140: Cvar_SetValue( "vid_fullscreen", s_fs_box[s_current_menu_index].curvalue ); 141: Cvar_SetValue( "gl_ext_palettedtexture", s_paletted_texture_box.curvalue ); 142: Cvar_SetValue( "sw_mode", s_mode_list[SOFTWARE_MENU].curvalue ); 143: Cvar_SetValue( "gl_mode", s_mode_list[OPENGL_MENU].curvalue ); 144: Cvar_SetValue( "_windowed_mouse", s_windowed_mouse.curvalue); 145: 146: switch ( s_ref_list[s_current_menu_index].curvalue ) 147: { 148: case REF_SOFT: 149: Cvar_Set( "vid_ref", "soft" ); 150: break; 151: case REF_SOFTX11: 152: Cvar_Set( "vid_ref", "softx" ); 153: break; 1.1.1.2 ! root 154: ! 155: case REF_MESA3D : ! 156: Cvar_Set( "vid_ref", "gl" ); ! 157: Cvar_Set( "gl_driver", "libMesaGL.so.2" ); ! 158: if (gl_driver->modified) ! 159: vid_ref->modified = true; ! 160: break; ! 161: ! 162: case REF_OPENGLX : ! 163: Cvar_Set( "vid_ref", "glx" ); ! 164: Cvar_Set( "gl_driver", "libGL.so" ); ! 165: if (gl_driver->modified) ! 166: vid_ref->modified = true; ! 167: break; ! 168: ! 169: case REF_MESA3DGLX : ! 170: Cvar_Set( "vid_ref", "glx" ); ! 171: Cvar_Set( "gl_driver", "libMesaGL.so.2" ); ! 172: if (gl_driver->modified) ! 173: vid_ref->modified = true; ! 174: break; ! 175: ! 176: case REF_3DFXGL : 1.1 root 177: Cvar_Set( "vid_ref", "gl" ); 1.1.1.2 ! root 178: Cvar_Set( "gl_driver", "lib3dfxgl.so" ); ! 179: if (gl_driver->modified) ! 180: vid_ref->modified = true; 1.1 root 181: break; 182: } 183: 184: #if 0 185: /* 186: ** update appropriate stuff if we're running OpenGL and gamma 187: ** has been modified 188: */ 189: if ( stricmp( vid_ref->string, "gl" ) == 0 ) 190: { 191: if ( vid_gamma->modified ) 192: { 193: vid_ref->modified = true; 194: if ( stricmp( gl_driver->string, "3dfxgl" ) == 0 ) 195: { 196: char envbuffer[1024]; 197: float g; 198: 199: vid_ref->modified = true; 200: 201: g = 2.00 * ( 0.8 - ( vid_gamma->value - 0.5 ) ) + 1.0F; 202: Com_sprintf( envbuffer, sizeof(envbuffer), "SST_GAMMA=%f", g ); 203: putenv( envbuffer ); 204: 205: vid_gamma->modified = false; 206: } 207: } 208: } 209: #endif 210: 211: M_ForceMenuOff(); 212: } 213: 214: /* 215: ** VID_MenuInit 216: */ 217: void VID_MenuInit( void ) 218: { 219: static const char *resolutions[] = 220: { 221: "[320 240 ]", 222: "[400 300 ]", 223: "[512 384 ]", 224: "[640 480 ]", 225: "[800 600 ]", 226: "[960 720 ]", 227: "[1024 768 ]", 228: "[1152 864 ]", 229: "[1280 1024]", 230: "[1600 1200]", 1.1.1.2 ! root 231: "[2048 1536]", 1.1 root 232: 0 233: }; 234: static const char *refs[] = 235: { 1.1.1.2 ! root 236: "[software ]", ! 237: "[software X11 ]", ! 238: "[Mesa 3-D 3DFX ]", ! 239: "[3DFXGL Miniport]", ! 240: "[OpenGL glX ]", ! 241: "[Mesa 3-D glX ]", 1.1 root 242: 0 243: }; 244: static const char *yesno_names[] = 245: { 246: "no", 247: "yes", 248: 0 249: }; 250: int i; 251: 252: if ( !gl_driver ) 1.1.1.2 ! root 253: gl_driver = Cvar_Get( "gl_driver", "libMesaGL.so.2", 0 ); 1.1 root 254: if ( !gl_picmip ) 255: gl_picmip = Cvar_Get( "gl_picmip", "0", 0 ); 256: if ( !gl_mode ) 257: gl_mode = Cvar_Get( "gl_mode", "3", 0 ); 258: if ( !sw_mode ) 259: sw_mode = Cvar_Get( "sw_mode", "0", 0 ); 260: if ( !gl_ext_palettedtexture ) 261: gl_ext_palettedtexture = Cvar_Get( "gl_ext_palettedtexture", "1", CVAR_ARCHIVE ); 262: 263: if ( !sw_stipplealpha ) 264: sw_stipplealpha = Cvar_Get( "sw_stipplealpha", "0", CVAR_ARCHIVE ); 265: 266: if ( !_windowed_mouse) 267: _windowed_mouse = Cvar_Get( "_windowed_mouse", "0", CVAR_ARCHIVE ); 268: 269: s_mode_list[SOFTWARE_MENU].curvalue = sw_mode->value; 270: s_mode_list[OPENGL_MENU].curvalue = gl_mode->value; 271: 272: if ( !scr_viewsize ) 273: scr_viewsize = Cvar_Get ("viewsize", "100", CVAR_ARCHIVE); 274: 275: s_screensize_slider[SOFTWARE_MENU].curvalue = scr_viewsize->value/10; 276: s_screensize_slider[OPENGL_MENU].curvalue = scr_viewsize->value/10; 277: 278: if ( strcmp( vid_ref->string, "soft" ) == 0) 279: { 280: s_current_menu_index = SOFTWARE_MENU; 281: s_ref_list[0].curvalue = s_ref_list[1].curvalue = REF_SOFT; 282: } 283: else if (strcmp( vid_ref->string, "softx" ) == 0 ) 284: { 285: s_current_menu_index = SOFTWARE_MENU; 286: s_ref_list[0].curvalue = s_ref_list[1].curvalue = REF_SOFTX11; 287: } 288: else if ( strcmp( vid_ref->string, "gl" ) == 0 ) 289: { 290: s_current_menu_index = OPENGL_MENU; 1.1.1.2 ! root 291: if ( strcmp( gl_driver->string, "lib3dfxgl.so" ) == 0 ) ! 292: s_ref_list[s_current_menu_index].curvalue = REF_3DFXGL; 1.1 root 293: else 1.1.1.2 ! root 294: s_ref_list[s_current_menu_index].curvalue = REF_MESA3D; ! 295: } ! 296: else if ( strcmp( vid_ref->string, "glx" ) == 0 ) ! 297: { ! 298: s_current_menu_index = OPENGL_MENU; ! 299: if ( strcmp( gl_driver->string, "libMesaGL.so.2" ) == 0 ) ! 300: s_ref_list[s_current_menu_index].curvalue = REF_MESA3DGLX; ! 301: else ! 302: s_ref_list[s_current_menu_index].curvalue = REF_OPENGLX; 1.1 root 303: } 304: 305: s_software_menu.x = viddef.width * 0.50; 306: s_software_menu.nitems = 0; 307: s_opengl_menu.x = viddef.width * 0.50; 308: s_opengl_menu.nitems = 0; 309: 310: for ( i = 0; i < 2; i++ ) 311: { 312: s_ref_list[i].generic.type = MTYPE_SPINCONTROL; 313: s_ref_list[i].generic.name = "driver"; 314: s_ref_list[i].generic.x = 0; 315: s_ref_list[i].generic.y = 0; 316: s_ref_list[i].generic.callback = DriverCallback; 317: s_ref_list[i].itemnames = refs; 318: 319: s_mode_list[i].generic.type = MTYPE_SPINCONTROL; 320: s_mode_list[i].generic.name = "video mode"; 321: s_mode_list[i].generic.x = 0; 322: s_mode_list[i].generic.y = 10; 323: s_mode_list[i].itemnames = resolutions; 324: 325: s_screensize_slider[i].generic.type = MTYPE_SLIDER; 326: s_screensize_slider[i].generic.x = 0; 327: s_screensize_slider[i].generic.y = 20; 328: s_screensize_slider[i].generic.name = "screen size"; 329: s_screensize_slider[i].minvalue = 3; 330: s_screensize_slider[i].maxvalue = 12; 331: s_screensize_slider[i].generic.callback = ScreenSizeCallback; 332: 333: s_brightness_slider[i].generic.type = MTYPE_SLIDER; 334: s_brightness_slider[i].generic.x = 0; 335: s_brightness_slider[i].generic.y = 30; 336: s_brightness_slider[i].generic.name = "brightness"; 337: s_brightness_slider[i].generic.callback = BrightnessCallback; 338: s_brightness_slider[i].minvalue = 5; 339: s_brightness_slider[i].maxvalue = 13; 340: s_brightness_slider[i].curvalue = ( 1.3 - vid_gamma->value + 0.5 ) * 10; 341: 342: s_fs_box[i].generic.type = MTYPE_SPINCONTROL; 343: s_fs_box[i].generic.x = 0; 344: s_fs_box[i].generic.y = 40; 345: s_fs_box[i].generic.name = "fullscreen"; 346: s_fs_box[i].itemnames = yesno_names; 347: s_fs_box[i].curvalue = vid_fullscreen->value; 348: 349: s_defaults_action[i].generic.type = MTYPE_ACTION; 350: s_defaults_action[i].generic.name = "reset to default"; 351: s_defaults_action[i].generic.x = 0; 352: s_defaults_action[i].generic.y = 90; 353: s_defaults_action[i].generic.callback = ResetDefaults; 354: 355: s_apply_action[i].generic.type = MTYPE_ACTION; 356: s_apply_action[i].generic.name = "apply"; 357: s_apply_action[i].generic.x = 0; 358: s_apply_action[i].generic.y = 100; 359: s_apply_action[i].generic.callback = ApplyChanges; 360: } 361: 362: s_stipple_box.generic.type = MTYPE_SPINCONTROL; 363: s_stipple_box.generic.x = 0; 364: s_stipple_box.generic.y = 60; 365: s_stipple_box.generic.name = "stipple alpha"; 366: s_stipple_box.curvalue = sw_stipplealpha->value; 367: s_stipple_box.itemnames = yesno_names; 368: 369: s_windowed_mouse.generic.type = MTYPE_SPINCONTROL; 370: s_windowed_mouse.generic.x = 0; 371: s_windowed_mouse.generic.y = 72; 372: s_windowed_mouse.generic.name = "windowed mouse"; 373: s_windowed_mouse.curvalue = _windowed_mouse->value; 374: s_windowed_mouse.itemnames = yesno_names; 375: 376: s_tq_slider.generic.type = MTYPE_SLIDER; 377: s_tq_slider.generic.x = 0; 378: s_tq_slider.generic.y = 60; 379: s_tq_slider.generic.name = "texture quality"; 380: s_tq_slider.minvalue = 0; 381: s_tq_slider.maxvalue = 3; 382: s_tq_slider.curvalue = 3-gl_picmip->value; 383: 384: s_paletted_texture_box.generic.type = MTYPE_SPINCONTROL; 385: s_paletted_texture_box.generic.x = 0; 386: s_paletted_texture_box.generic.y = 70; 387: s_paletted_texture_box.generic.name = "8-bit textures"; 388: s_paletted_texture_box.itemnames = yesno_names; 389: s_paletted_texture_box.curvalue = gl_ext_palettedtexture->value; 390: 391: Menu_AddItem( &s_software_menu, ( void * ) &s_ref_list[SOFTWARE_MENU] ); 392: Menu_AddItem( &s_software_menu, ( void * ) &s_mode_list[SOFTWARE_MENU] ); 393: Menu_AddItem( &s_software_menu, ( void * ) &s_screensize_slider[SOFTWARE_MENU] ); 394: Menu_AddItem( &s_software_menu, ( void * ) &s_brightness_slider[SOFTWARE_MENU] ); 395: Menu_AddItem( &s_software_menu, ( void * ) &s_fs_box[SOFTWARE_MENU] ); 396: Menu_AddItem( &s_software_menu, ( void * ) &s_stipple_box ); 397: Menu_AddItem( &s_software_menu, ( void * ) &s_windowed_mouse ); 398: 399: Menu_AddItem( &s_opengl_menu, ( void * ) &s_ref_list[OPENGL_MENU] ); 400: Menu_AddItem( &s_opengl_menu, ( void * ) &s_mode_list[OPENGL_MENU] ); 401: Menu_AddItem( &s_opengl_menu, ( void * ) &s_screensize_slider[OPENGL_MENU] ); 402: Menu_AddItem( &s_opengl_menu, ( void * ) &s_brightness_slider[OPENGL_MENU] ); 403: Menu_AddItem( &s_opengl_menu, ( void * ) &s_fs_box[OPENGL_MENU] ); 404: Menu_AddItem( &s_opengl_menu, ( void * ) &s_tq_slider ); 405: Menu_AddItem( &s_opengl_menu, ( void * ) &s_paletted_texture_box ); 406: 407: Menu_AddItem( &s_software_menu, ( void * ) &s_defaults_action[SOFTWARE_MENU] ); 408: Menu_AddItem( &s_software_menu, ( void * ) &s_apply_action[SOFTWARE_MENU] ); 409: Menu_AddItem( &s_opengl_menu, ( void * ) &s_defaults_action[OPENGL_MENU] ); 410: Menu_AddItem( &s_opengl_menu, ( void * ) &s_apply_action[OPENGL_MENU] ); 411: 412: Menu_Center( &s_software_menu ); 413: Menu_Center( &s_opengl_menu ); 414: s_opengl_menu.x -= 8; 415: s_software_menu.x -= 8; 416: } 417: 418: /* 419: ================ 420: VID_MenuDraw 421: ================ 422: */ 423: void VID_MenuDraw (void) 424: { 425: int w, h; 426: 427: if ( s_current_menu_index == 0 ) 428: s_current_menu = &s_software_menu; 429: else 430: s_current_menu = &s_opengl_menu; 431: 432: /* 433: ** draw the banner 434: */ 435: re.DrawGetPicSize( &w, &h, "m_banner_video" ); 436: re.DrawPic( viddef.width / 2 - w / 2, viddef.height /2 - 110, "m_banner_video" ); 437: 438: /* 439: ** move cursor to a reasonable starting position 440: */ 441: Menu_AdjustCursor( s_current_menu, 1 ); 442: 443: /* 444: ** draw the menu 445: */ 446: Menu_Draw( s_current_menu ); 447: } 448: 449: /* 450: ================ 451: VID_MenuKey 452: ================ 453: */ 454: const char *VID_MenuKey( int key ) 455: { 456: extern void M_PopMenu( void ); 457: 458: menuframework_s *m = s_current_menu; 459: static const char *sound = "misc/menu1.wav"; 460: 461: switch ( key ) 462: { 463: case K_ESCAPE: 464: M_PopMenu(); 465: return NULL; 466: case K_UPARROW: 467: m->cursor--; 468: Menu_AdjustCursor( m, -1 ); 469: break; 470: case K_DOWNARROW: 471: m->cursor++; 472: Menu_AdjustCursor( m, 1 ); 473: break; 474: case K_LEFTARROW: 475: Menu_SlideItem( m, -1 ); 476: break; 477: case K_RIGHTARROW: 478: Menu_SlideItem( m, 1 ); 479: break; 480: case K_ENTER: 481: Menu_SelectItem( m ); 482: break; 483: } 484: 485: return sound; 486: } 487: 488:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.