From b240e59c4aea94a81e1a47311776689f017a8654 Mon Sep 17 00:00:00 2001 From: shawn king Date: Thu, 24 Feb 2011 14:19:40 +1000 Subject: [PATCH 1/2] Added code to select devices in the ui qvm --- assets/ui/ingame_options.menu | 102 +++++++++++++++++++++++++++---- assets/ui/menudef.h | 4 +- src/AL/alctypes.h | 1 + src/client/snd_openal.c | 47 +++++++++++++-- src/ui/ui_local.h | 9 +++ src/ui/ui_main.c | 137 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 282 insertions(+), 18 deletions(-) diff --git a/assets/ui/ingame_options.menu b/assets/ui/ingame_options.menu index f99eee8..cca85ad 100644 --- a/assets/ui/ingame_options.menu +++ b/assets/ui/ingame_options.menu @@ -2258,9 +2258,10 @@ { name netsound group optionsGrp - type ITEM_TYPE_YESNO - text "OpenAL:" - cvar "s_useOpenAL" + type ITEM_TYPE_MULTI + text "Sound Quality:" + cvar "s_khz" + cvarFloatList { "44 khz (very high)" 44 "22 khz (high)" 22 "11 khz (low)" 11 } rect SCONTENT_X (SCONTENT_Y+(3*ELEM_H)) SCONTENT_W ELEM_H textalign ALIGN_RIGHT textvalign VALIGN_CENTER @@ -2278,10 +2279,9 @@ { name netsound group optionsGrp - type ITEM_TYPE_MULTI - text "Sound Quality:" - cvar "s_khz" - cvarFloatList { "44 khz (very high)" 44 "22 khz (high)" 22 "11 khz (low)" 11 } + type ITEM_TYPE_YESNO + text "Doppler Sound:" + cvar "s_doppler" rect SCONTENT_X (SCONTENT_Y+(4*ELEM_H)) SCONTENT_W ELEM_H textalign ALIGN_RIGHT textvalign VALIGN_CENTER @@ -2300,8 +2300,8 @@ name netsound group optionsGrp type ITEM_TYPE_YESNO - text "Doppler Sound:" - cvar "s_doppler" + text "OpenAL:" + cvar "s_useOpenAL" rect SCONTENT_X (SCONTENT_Y+(5*ELEM_H)) SCONTENT_W ELEM_H textalign ALIGN_RIGHT textvalign VALIGN_CENTER @@ -2319,10 +2319,88 @@ { name netsound group optionsGrp + type ITEM_TYPE_TEXT + text "AL Output Device:" + rect SCONTENT_X (SCONTENT_Y+(6*ELEM_H)) (SCONTENT_W/2) ELEM_H + textalign ALIGN_RIGHT + textvalign VALIGN_CENTER + textscale .25 + forecolor 1 1 1 1 + visible MENU_TRUE + } + + itemDef + { + name netsound + group optionsGrp + rect (SCONTENT_X+(SCONTENT_W/2)+RESCOMBO_OFF) (SCONTENT_Y+(6*ELEM_H)) ((SCONTENT_W/2)-(2*RESCOMBO_OFF)) ELEM_H + type ITEM_TYPE_COMBOBOX + style WINDOW_STYLE_FILLED + elementwidth ((SCONTENT_W/2)-(2*BORDER)) + elementheight ELEM_H + dropitems 5 + textscale .25 + elementtype LISTBOX_TEXT + feeder FEEDER_QALDEVICES + border WINDOW_BORDER_FULL + borderColor 0.5 0.5 0.5 1 + forecolor 1 1 1 1 + backcolor 0 0 0 1 + outlinecolor 0.1 0.1 0.1 0.5 + visible MENU_TRUE + doubleclick + { + play "sound/misc/menu1.wav"; + } + } + + itemDef + { + name netsound + group optionsGrp + type ITEM_TYPE_TEXT + text "AL Input Device:" + rect SCONTENT_X (SCONTENT_Y+(8*ELEM_H)) (SCONTENT_W/2) ELEM_H + textalign ALIGN_RIGHT + textvalign VALIGN_CENTER + textscale .25 + forecolor 1 1 1 1 + visible MENU_TRUE + } + + itemDef + { + name netsound + group optionsGrp + rect (SCONTENT_X+(SCONTENT_W/2)+RESCOMBO_OFF) (SCONTENT_Y+(8*ELEM_H)) ((SCONTENT_W/2)-(2*RESCOMBO_OFF)) ELEM_H + type ITEM_TYPE_COMBOBOX + style WINDOW_STYLE_FILLED + elementwidth ((SCONTENT_W/2)-(2*BORDER)) + elementheight ELEM_H + dropitems 5 + textscale .25 + elementtype LISTBOX_TEXT + feeder FEEDER_QALINPUTDEVICES + border WINDOW_BORDER_FULL + borderColor 0.5 0.5 0.5 1 + forecolor 1 1 1 1 + backcolor 0 0 0 1 + outlinecolor 0.1 0.1 0.1 0.5 + visible MENU_TRUE + doubleclick + { + play "sound/misc/menu1.wav"; + } + } + + itemDef + { + name netsound + group optionsGrp style WINDOW_STYLE_FILLED type ITEM_TYPE_TEXT text "Network" - rect SCONTENT_X (SCONTENT_Y+(7*ELEM_H)) SCONTENT_W ELEM_H + rect SCONTENT_X (SCONTENT_Y+(10*ELEM_H)) SCONTENT_W ELEM_H textalign ALIGN_CENTER textvalign VALIGN_CENTER textscale .25 @@ -2343,7 +2421,7 @@ text "Net Data Rate:" cvar "rate" cvarFloatList { "<=28.8k" 2500 "33.6k" 3000 "56k" 4000 "ISDN" 5000 "LAN/CABLE/xDSl" 25000 } - rect SCONTENT_X (SCONTENT_Y+(8*ELEM_H)) SCONTENT_W ELEM_H + rect SCONTENT_X (SCONTENT_Y+(11*ELEM_H)) SCONTENT_W ELEM_H textalign ALIGN_RIGHT textvalign VALIGN_CENTER textalignx SCONTENT_OFF @@ -2364,7 +2442,7 @@ text "APPLY" textscale .25 style WINDOW_STYLE_EMPTY - rect SCONTENT_X (SCONTENT_Y+(10*ELEM_H)) SCONTENT_W ELEM_H + rect SCONTENT_X (SCONTENT_Y+(12*ELEM_H)) SCONTENT_W ELEM_H textalign ALIGN_CENTER textvalign VALIGN_CENTER forecolor 1 1 1 1 diff --git a/assets/ui/menudef.h b/assets/ui/menudef.h index cd30f77..465b25c 100644 --- a/assets/ui/menudef.h +++ b/assets/ui/menudef.h @@ -114,7 +114,9 @@ enum FEEDER_TREMHUMANBUILD, // human buildables FEEDER_IGNORE_LIST, // ignored players FEEDER_HELP_LIST, // help topics - FEEDER_RESOLUTIONS // display resolutions + FEEDER_RESOLUTIONS, // display resolutions + FEEDER_QALDEVICES, // OpenAL Device list + FEEDER_QALINPUTDEVICES // OpenAL Input Device list }; // display flags diff --git a/src/ui/ui_local.h b/src/ui/ui_local.h index 2c78e26..da0632d 100644 --- a/src/ui/ui_local.h +++ b/src/ui/ui_local.h @@ -62,6 +62,7 @@ void UI_DrawConnectScreen( qboolean overlay ); #define MAX_MOVIES 256 #define MAX_HELP_INFOPANES 32 #define MAX_RESOLUTIONS 32 +#define MAX_QALDEVICES 16 typedef struct { @@ -294,6 +295,14 @@ typedef struct int numResolutions; int resolutionIndex; + int qalDeviceCount; + char qalDeviceList[MAX_QALDEVICES][MAX_STRING_CHARS]; + int qalDeviceIndex; + + int qalInputDeviceCount; + char qalInputDeviceList[MAX_QALDEVICES][MAX_STRING_CHARS]; + int qalInputDeviceIndex; + qboolean inGameLoad; qboolean chatTeam; diff --git a/src/ui/ui_main.c b/src/ui/ui_main.c index b776521..efa322a 100644 --- a/src/ui/ui_main.c +++ b/src/ui/ui_main.c @@ -3484,6 +3484,20 @@ static int UI_FeederCount( int feederID ) else return uiInfo.numResolutions; } + else if( feederID == FEEDER_QALDEVICES ) + { + if( UI_FeederInitialise( feederID ) == uiInfo.qalDeviceCount ) + return uiInfo.qalDeviceCount + 1; + else + return uiInfo.qalDeviceCount; + } + else if( feederID == FEEDER_QALINPUTDEVICES ) + { + if( UI_FeederInitialise( feederID ) == uiInfo.qalInputDeviceCount ) + return uiInfo.qalInputDeviceCount + 1; + else + return uiInfo.qalInputDeviceCount; + } return 0; } @@ -3772,6 +3786,16 @@ static const char *UI_FeederItemText( int feederID, int index, int column, qhand return resolution; } + else if( feederID == FEEDER_QALDEVICES ) + { + if( index >= 0 && index < uiInfo.qalDeviceCount ) + return uiInfo.qalDeviceList[index]; + } + else if( feederID == FEEDER_QALINPUTDEVICES ) + { + if( index >= 0 && index < uiInfo.qalInputDeviceCount ) + return uiInfo.qalInputDeviceList[index]; + } return ""; } @@ -3909,6 +3933,24 @@ static void UI_FeederSelection( int feederID, int index ) uiInfo.resolutionIndex = index; } + else if( feederID == FEEDER_QALDEVICES ) + { + if( index >= 0 && index < uiInfo.qalDeviceCount ) + { + trap_Cvar_Set( "s_alDevice", va( "%s", uiInfo.qalDeviceList[ index ] ) ); + } + + uiInfo.qalDeviceIndex = index; + } + else if( feederID == FEEDER_QALINPUTDEVICES ) + { + if( index >= 0 && index < uiInfo.qalInputDeviceCount ) + { + trap_Cvar_Set( "s_alInputDevice", va( "%s", uiInfo.qalInputDeviceList[ index ] ) ); + } + + uiInfo.qalInputDeviceIndex = index; + } } static int UI_FeederInitialise( int feederID ) @@ -3927,6 +3969,34 @@ static int UI_FeederInitialise( int feederID ) return uiInfo.numResolutions; } + else if( feederID == FEEDER_QALDEVICES) + { + int i; + char device[ MAX_STRING_CHARS ]; + trap_Cvar_VariableStringBuffer( "s_alDevice", device, sizeof( device ) ); + + for( i = 0; i < uiInfo.qalDeviceCount; i++ ) + { + if( strcmp( device, uiInfo.qalDeviceList[ i ] ) == 0 ) + return i; + } + + return uiInfo.qalDeviceCount; + } + else if( feederID == FEEDER_QALINPUTDEVICES) + { + int i; + char inputdevice[ MAX_STRING_CHARS ]; + trap_Cvar_VariableStringBuffer( "s_alInputDevice", inputdevice, sizeof( inputdevice ) ); + + for( i = 0; i < uiInfo.qalInputDeviceCount; i++ ) + { + if( strcmp( inputdevice, uiInfo.qalInputDeviceList[ i ] ) == 0 ) + return i; + } + + return uiInfo.qalInputDeviceCount; + } return 0; } @@ -4023,6 +4093,71 @@ void UI_ParseResolutions( void ) /* ================= +UI_ParseQalDevices +================= +*/ +void UI_ParseQalDevices( void ) +{ + char buf[ MAX_STRING_CHARS ]; + char *tmp; + int i, linepos; + + trap_Cvar_VariableStringBuffer( "s_alAvailableDevices", buf, sizeof( buf ) ); + uiInfo.qalDeviceCount = 0; + + tmp = buf; + linepos = 0; + + for(i = 0; i < strlen(buf); i++) + { + if(buf[i] == '\n') + { + uiInfo.qalDeviceList[uiInfo.qalDeviceCount][linepos + 1] = '\0'; + if(uiInfo.qalDeviceCount >= MAX_QALDEVICES) + break; + uiInfo.qalDeviceCount++; + linepos = 0; + continue; + } + uiInfo.qalDeviceList[uiInfo.qalDeviceCount][linepos] = buf[i]; + linepos++; + } +} +/* +================= +UI_ParseQalInputDevices +================= +*/ +void UI_ParseQalInputDevices( void ) +{ + char buf[ MAX_STRING_CHARS ]; + char *tmp; + int i, linepos; + + trap_Cvar_VariableStringBuffer( "s_alAvailableInputDevices", buf, sizeof( buf ) ); + uiInfo.qalInputDeviceCount = 0; + + tmp = buf; + linepos = 0; + + for(i = 0; i < strlen(buf); i++) + { + if(buf[i] == '\n') + { + uiInfo.qalInputDeviceList[uiInfo.qalInputDeviceCount][linepos + 1] = '\0'; + if(uiInfo.qalInputDeviceCount >= MAX_QALDEVICES) + break; + uiInfo.qalInputDeviceCount++; + linepos = 0; + continue; + } + uiInfo.qalInputDeviceList[uiInfo.qalInputDeviceCount][linepos] = buf[i]; + linepos++; + } +} + +/* +================= UI_Init ================= */ @@ -4128,6 +4263,8 @@ void UI_Init( qboolean inGameLoad ) trap_Cvar_Register( NULL, "debug_protocol", "", 0 ); UI_ParseResolutions( ); + UI_ParseQalDevices( ); + UI_ParseQalInputDevices( ); } -- 1.7.1