| 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 |
/* |
| 24 |
======================================================================= |
| 25 |
|
| 26 |
SOUND OPTIONS MENU |
| 27 |
|
| 28 |
======================================================================= |
| 29 |
*/ |
| 30 |
|
| 31 |
#include "ui_local.h" |
| 32 |
|
| 33 |
|
| 34 |
#define ART_FRAMEL "menu/art_blueish/frame2_l" |
| 35 |
#define ART_FRAMER "menu/art_blueish/frame1_r" |
| 36 |
#define ART_BACK0 "menu/art_blueish/back_0" |
| 37 |
#define ART_BACK1 "menu/art_blueish/back_1" |
| 38 |
|
| 39 |
#define ID_GRAPHICS 10 |
| 40 |
#define ID_DISPLAY 11 |
| 41 |
#define ID_SOUND 12 |
| 42 |
#define ID_NETWORK 13 |
| 43 |
#define ID_EFFECTSVOLUME 14 |
| 44 |
#define ID_MUSICVOLUME 15 |
| 45 |
#define ID_QUALITY 16 |
| 46 |
//#define ID_A3D 17 |
| 47 |
//Sago: Here I do some stuff! |
| 48 |
#define ID_OPENAL 18 |
| 49 |
#define ID_BACK 19 |
| 50 |
|
| 51 |
|
| 52 |
static const char *quality_items[] = { |
| 53 |
"Low", "High", NULL |
| 54 |
}; |
| 55 |
|
| 56 |
typedef struct { |
| 57 |
menuframework_s menu; |
| 58 |
|
| 59 |
menutext_s banner; |
| 60 |
menubitmap_s framel; |
| 61 |
menubitmap_s framer; |
| 62 |
|
| 63 |
menutext_s graphics; |
| 64 |
menutext_s display; |
| 65 |
menutext_s sound; |
| 66 |
menutext_s network; |
| 67 |
|
| 68 |
menuslider_s sfxvolume; |
| 69 |
menuslider_s musicvolume; |
| 70 |
menulist_s quality; |
| 71 |
// menuradiobutton_s a3d; |
| 72 |
menuradiobutton_s openal; |
| 73 |
|
| 74 |
menubitmap_s back; |
| 75 |
} soundOptionsInfo_t; |
| 76 |
|
| 77 |
static soundOptionsInfo_t soundOptionsInfo; |
| 78 |
|
| 79 |
|
| 80 |
/* |
| 81 |
================= |
| 82 |
UI_SoundOptionsMenu_Event |
| 83 |
================= |
| 84 |
*/ |
| 85 |
static void UI_SoundOptionsMenu_Event( void* ptr, int event ) { |
| 86 |
if( event != QM_ACTIVATED ) { |
| 87 |
return; |
| 88 |
} |
| 89 |
|
| 90 |
switch( ((menucommon_s*)ptr)->id ) { |
| 91 |
case ID_GRAPHICS: |
| 92 |
UI_PopMenu(); |
| 93 |
UI_GraphicsOptionsMenu(); |
| 94 |
break; |
| 95 |
|
| 96 |
case ID_DISPLAY: |
| 97 |
UI_PopMenu(); |
| 98 |
UI_DisplayOptionsMenu(); |
| 99 |
break; |
| 100 |
|
| 101 |
case ID_SOUND: |
| 102 |
break; |
| 103 |
|
| 104 |
case ID_NETWORK: |
| 105 |
UI_PopMenu(); |
| 106 |
UI_NetworkOptionsMenu(); |
| 107 |
break; |
| 108 |
|
| 109 |
case ID_EFFECTSVOLUME: |
| 110 |
trap_Cvar_SetValue( "s_volume", soundOptionsInfo.sfxvolume.curvalue / 10 ); |
| 111 |
break; |
| 112 |
|
| 113 |
case ID_MUSICVOLUME: |
| 114 |
trap_Cvar_SetValue( "s_musicvolume", soundOptionsInfo.musicvolume.curvalue / 10 ); |
| 115 |
break; |
| 116 |
|
| 117 |
case ID_QUALITY: |
| 118 |
if( soundOptionsInfo.quality.curvalue ) { |
| 119 |
trap_Cvar_SetValue( "s_khz", 22 ); |
| 120 |
trap_Cvar_SetValue( "s_compression", 0 ); |
| 121 |
} |
| 122 |
else { |
| 123 |
trap_Cvar_SetValue( "s_khz", 11 ); |
| 124 |
trap_Cvar_SetValue( "s_compression", 1 ); |
| 125 |
} |
| 126 |
UI_ForceMenuOff(); |
| 127 |
trap_Cmd_ExecuteText( EXEC_APPEND, "snd_restart\n" ); |
| 128 |
break; |
| 129 |
/* |
| 130 |
case ID_A3D: |
| 131 |
if( soundOptionsInfo.a3d.curvalue ) { |
| 132 |
trap_Cmd_ExecuteText( EXEC_NOW, "s_enable_a3d\n" ); |
| 133 |
} |
| 134 |
else { |
| 135 |
trap_Cmd_ExecuteText( EXEC_NOW, "s_disable_a3d\n" ); |
| 136 |
} |
| 137 |
soundOptionsInfo.a3d.curvalue = (int)trap_Cvar_VariableValue( "s_usingA3D" ); |
| 138 |
break; |
| 139 |
*/ |
| 140 |
|
| 141 |
case ID_OPENAL: |
| 142 |
if( soundOptionsInfo.openal.curvalue ) { |
| 143 |
trap_Cmd_ExecuteText( EXEC_NOW, "s_useopenal 1\n" ); |
| 144 |
} |
| 145 |
else { |
| 146 |
trap_Cmd_ExecuteText( EXEC_NOW, "s_useopenal 0\n" ); |
| 147 |
} |
| 148 |
soundOptionsInfo.openal.curvalue = (int)trap_Cvar_VariableValue( "s_useopenal" ); |
| 149 |
break; |
| 150 |
|
| 151 |
case ID_BACK: |
| 152 |
UI_PopMenu(); |
| 153 |
break; |
| 154 |
} |
| 155 |
} |
| 156 |
|
| 157 |
|
| 158 |
/* |
| 159 |
=============== |
| 160 |
UI_SoundOptionsMenu_Init |
| 161 |
=============== |
| 162 |
*/ |
| 163 |
static void UI_SoundOptionsMenu_Init( void ) { |
| 164 |
int y; |
| 165 |
|
| 166 |
memset( &soundOptionsInfo, 0, sizeof(soundOptionsInfo) ); |
| 167 |
|
| 168 |
UI_SoundOptionsMenu_Cache(); |
| 169 |
soundOptionsInfo.menu.wrapAround = qtrue; |
| 170 |
soundOptionsInfo.menu.fullscreen = qtrue; |
| 171 |
|
| 172 |
soundOptionsInfo.banner.generic.type = MTYPE_BTEXT; |
| 173 |
soundOptionsInfo.banner.generic.flags = QMF_CENTER_JUSTIFY; |
| 174 |
soundOptionsInfo.banner.generic.x = 320; |
| 175 |
soundOptionsInfo.banner.generic.y = 16; |
| 176 |
soundOptionsInfo.banner.string = "SYSTEM SETUP"; |
| 177 |
soundOptionsInfo.banner.color = color_white; |
| 178 |
soundOptionsInfo.banner.style = UI_CENTER; |
| 179 |
|
| 180 |
soundOptionsInfo.framel.generic.type = MTYPE_BITMAP; |
| 181 |
soundOptionsInfo.framel.generic.name = ART_FRAMEL; |
| 182 |
soundOptionsInfo.framel.generic.flags = QMF_INACTIVE; |
| 183 |
soundOptionsInfo.framel.generic.x = 0; |
| 184 |
soundOptionsInfo.framel.generic.y = 78; |
| 185 |
soundOptionsInfo.framel.width = 256; |
| 186 |
soundOptionsInfo.framel.height = 329; |
| 187 |
|
| 188 |
soundOptionsInfo.framer.generic.type = MTYPE_BITMAP; |
| 189 |
soundOptionsInfo.framer.generic.name = ART_FRAMER; |
| 190 |
soundOptionsInfo.framer.generic.flags = QMF_INACTIVE; |
| 191 |
soundOptionsInfo.framer.generic.x = 376; |
| 192 |
soundOptionsInfo.framer.generic.y = 76; |
| 193 |
soundOptionsInfo.framer.width = 256; |
| 194 |
soundOptionsInfo.framer.height = 334; |
| 195 |
|
| 196 |
soundOptionsInfo.graphics.generic.type = MTYPE_PTEXT; |
| 197 |
soundOptionsInfo.graphics.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS; |
| 198 |
soundOptionsInfo.graphics.generic.id = ID_GRAPHICS; |
| 199 |
soundOptionsInfo.graphics.generic.callback = UI_SoundOptionsMenu_Event; |
| 200 |
soundOptionsInfo.graphics.generic.x = 216; |
| 201 |
soundOptionsInfo.graphics.generic.y = 240 - 2 * PROP_HEIGHT; |
| 202 |
soundOptionsInfo.graphics.string = "GRAPHICS"; |
| 203 |
soundOptionsInfo.graphics.style = UI_RIGHT; |
| 204 |
soundOptionsInfo.graphics.color = color_red; |
| 205 |
|
| 206 |
soundOptionsInfo.display.generic.type = MTYPE_PTEXT; |
| 207 |
soundOptionsInfo.display.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS; |
| 208 |
soundOptionsInfo.display.generic.id = ID_DISPLAY; |
| 209 |
soundOptionsInfo.display.generic.callback = UI_SoundOptionsMenu_Event; |
| 210 |
soundOptionsInfo.display.generic.x = 216; |
| 211 |
soundOptionsInfo.display.generic.y = 240 - PROP_HEIGHT; |
| 212 |
soundOptionsInfo.display.string = "DISPLAY"; |
| 213 |
soundOptionsInfo.display.style = UI_RIGHT; |
| 214 |
soundOptionsInfo.display.color = color_red; |
| 215 |
|
| 216 |
soundOptionsInfo.sound.generic.type = MTYPE_PTEXT; |
| 217 |
soundOptionsInfo.sound.generic.flags = QMF_RIGHT_JUSTIFY; |
| 218 |
soundOptionsInfo.sound.generic.id = ID_SOUND; |
| 219 |
soundOptionsInfo.sound.generic.callback = UI_SoundOptionsMenu_Event; |
| 220 |
soundOptionsInfo.sound.generic.x = 216; |
| 221 |
soundOptionsInfo.sound.generic.y = 240; |
| 222 |
soundOptionsInfo.sound.string = "SOUND"; |
| 223 |
soundOptionsInfo.sound.style = UI_RIGHT; |
| 224 |
soundOptionsInfo.sound.color = color_red; |
| 225 |
|
| 226 |
soundOptionsInfo.network.generic.type = MTYPE_PTEXT; |
| 227 |
soundOptionsInfo.network.generic.flags = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS; |
| 228 |
soundOptionsInfo.network.generic.id = ID_NETWORK; |
| 229 |
soundOptionsInfo.network.generic.callback = UI_SoundOptionsMenu_Event; |
| 230 |
soundOptionsInfo.network.generic.x = 216; |
| 231 |
soundOptionsInfo.network.generic.y = 240 + PROP_HEIGHT; |
| 232 |
soundOptionsInfo.network.string = "NETWORK"; |
| 233 |
soundOptionsInfo.network.style = UI_RIGHT; |
| 234 |
soundOptionsInfo.network.color = color_red; |
| 235 |
|
| 236 |
y = 240 - 1.5 * (BIGCHAR_HEIGHT + 2); |
| 237 |
soundOptionsInfo.sfxvolume.generic.type = MTYPE_SLIDER; |
| 238 |
soundOptionsInfo.sfxvolume.generic.name = "Effects Volume:"; |
| 239 |
soundOptionsInfo.sfxvolume.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT; |
| 240 |
soundOptionsInfo.sfxvolume.generic.callback = UI_SoundOptionsMenu_Event; |
| 241 |
soundOptionsInfo.sfxvolume.generic.id = ID_EFFECTSVOLUME; |
| 242 |
soundOptionsInfo.sfxvolume.generic.x = 400; |
| 243 |
soundOptionsInfo.sfxvolume.generic.y = y; |
| 244 |
soundOptionsInfo.sfxvolume.minvalue = 0; |
| 245 |
soundOptionsInfo.sfxvolume.maxvalue = 10; |
| 246 |
|
| 247 |
y += BIGCHAR_HEIGHT+2; |
| 248 |
soundOptionsInfo.musicvolume.generic.type = MTYPE_SLIDER; |
| 249 |
soundOptionsInfo.musicvolume.generic.name = "Music Volume:"; |
| 250 |
soundOptionsInfo.musicvolume.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT; |
| 251 |
soundOptionsInfo.musicvolume.generic.callback = UI_SoundOptionsMenu_Event; |
| 252 |
soundOptionsInfo.musicvolume.generic.id = ID_MUSICVOLUME; |
| 253 |
soundOptionsInfo.musicvolume.generic.x = 400; |
| 254 |
soundOptionsInfo.musicvolume.generic.y = y; |
| 255 |
soundOptionsInfo.musicvolume.minvalue = 0; |
| 256 |
soundOptionsInfo.musicvolume.maxvalue = 10; |
| 257 |
|
| 258 |
y += BIGCHAR_HEIGHT+2; |
| 259 |
soundOptionsInfo.quality.generic.type = MTYPE_SPINCONTROL; |
| 260 |
soundOptionsInfo.quality.generic.name = "Sound Quality:"; |
| 261 |
soundOptionsInfo.quality.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT; |
| 262 |
soundOptionsInfo.quality.generic.callback = UI_SoundOptionsMenu_Event; |
| 263 |
soundOptionsInfo.quality.generic.id = ID_QUALITY; |
| 264 |
soundOptionsInfo.quality.generic.x = 400; |
| 265 |
soundOptionsInfo.quality.generic.y = y; |
| 266 |
soundOptionsInfo.quality.itemnames = quality_items; |
| 267 |
/* |
| 268 |
y += BIGCHAR_HEIGHT+2; |
| 269 |
soundOptionsInfo.a3d.generic.type = MTYPE_RADIOBUTTON; |
| 270 |
soundOptionsInfo.a3d.generic.name = "A3D:"; |
| 271 |
soundOptionsInfo.a3d.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT; |
| 272 |
soundOptionsInfo.a3d.generic.callback = UI_SoundOptionsMenu_Event; |
| 273 |
soundOptionsInfo.a3d.generic.id = ID_A3D; |
| 274 |
soundOptionsInfo.a3d.generic.x = 400; |
| 275 |
soundOptionsInfo.a3d.generic.y = y; |
| 276 |
*/ |
| 277 |
y += BIGCHAR_HEIGHT+2; |
| 278 |
soundOptionsInfo.openal.generic.type = MTYPE_RADIOBUTTON; |
| 279 |
soundOptionsInfo.openal.generic.name = "OpenAL:"; |
| 280 |
soundOptionsInfo.openal.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT; |
| 281 |
soundOptionsInfo.openal.generic.callback = UI_SoundOptionsMenu_Event; |
| 282 |
soundOptionsInfo.openal.generic.id = ID_OPENAL; |
| 283 |
soundOptionsInfo.openal.generic.x = 400; |
| 284 |
soundOptionsInfo.openal.generic.y = y; |
| 285 |
|
| 286 |
soundOptionsInfo.back.generic.type = MTYPE_BITMAP; |
| 287 |
soundOptionsInfo.back.generic.name = ART_BACK0; |
| 288 |
soundOptionsInfo.back.generic.flags = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS; |
| 289 |
soundOptionsInfo.back.generic.callback = UI_SoundOptionsMenu_Event; |
| 290 |
soundOptionsInfo.back.generic.id = ID_BACK; |
| 291 |
soundOptionsInfo.back.generic.x = 0; |
| 292 |
soundOptionsInfo.back.generic.y = 480-64; |
| 293 |
soundOptionsInfo.back.width = 128; |
| 294 |
soundOptionsInfo.back.height = 64; |
| 295 |
soundOptionsInfo.back.focuspic = ART_BACK1; |
| 296 |
|
| 297 |
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.banner ); |
| 298 |
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.framel ); |
| 299 |
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.framer ); |
| 300 |
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.graphics ); |
| 301 |
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.display ); |
| 302 |
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.sound ); |
| 303 |
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.network ); |
| 304 |
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.sfxvolume ); |
| 305 |
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.musicvolume ); |
| 306 |
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.quality ); |
| 307 |
// Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.a3d ); |
| 308 |
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.openal ); |
| 309 |
Menu_AddItem( &soundOptionsInfo.menu, ( void * ) &soundOptionsInfo.back ); |
| 310 |
|
| 311 |
soundOptionsInfo.sfxvolume.curvalue = trap_Cvar_VariableValue( "s_volume" ) * 10; |
| 312 |
soundOptionsInfo.musicvolume.curvalue = trap_Cvar_VariableValue( "s_musicvolume" ) * 10; |
| 313 |
soundOptionsInfo.quality.curvalue = !trap_Cvar_VariableValue( "s_compression" ); |
| 314 |
// soundOptionsInfo.a3d.curvalue = (int)trap_Cvar_VariableValue( "s_usingA3D" ); |
| 315 |
soundOptionsInfo.openal.curvalue = (int)trap_Cvar_VariableValue( "s_useopenal" ); |
| 316 |
} |
| 317 |
|
| 318 |
|
| 319 |
/* |
| 320 |
=============== |
| 321 |
UI_SoundOptionsMenu_Cache |
| 322 |
=============== |
| 323 |
*/ |
| 324 |
void UI_SoundOptionsMenu_Cache( void ) { |
| 325 |
trap_R_RegisterShaderNoMip( ART_FRAMEL ); |
| 326 |
trap_R_RegisterShaderNoMip( ART_FRAMER ); |
| 327 |
trap_R_RegisterShaderNoMip( ART_BACK0 ); |
| 328 |
trap_R_RegisterShaderNoMip( ART_BACK1 ); |
| 329 |
} |
| 330 |
|
| 331 |
|
| 332 |
/* |
| 333 |
=============== |
| 334 |
UI_SoundOptionsMenu |
| 335 |
=============== |
| 336 |
*/ |
| 337 |
void UI_SoundOptionsMenu( void ) { |
| 338 |
UI_SoundOptionsMenu_Init(); |
| 339 |
UI_PushMenu( &soundOptionsInfo.menu ); |
| 340 |
Menu_SetCursorToItem( &soundOptionsInfo.menu, &soundOptionsInfo.sound ); |
| 341 |
} |