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