//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void COptionsSubAudio::OnCommand( const char *command ) { if ( !stricmp( command, "TestSpeakers" ) ) { // ask them if they REALLY want to test the speakers if they're in a game already. if (engine->IsConnected()) { QueryBox *qb = new QueryBox("#GameUI_TestSpeakersWarning_Title", "#GameUI_TestSpeakersWarning_Info" ); if (qb != NULL) { qb->SetOKCommand(new KeyValues("RunTestSpeakers")); qb->SetOKButtonText("#GameUI_TestSpeakersWarning_OkButton"); qb->SetCancelButtonText("#GameUI_TestSpeakersWarning_CancelButton"); qb->AddActionSignalTarget( this ); qb->DoModal(); } else { // couldn't create the warning dialog for some reason, so just test the speakers. RunTestSpeakers(); } } else { // player isn't connected to a game so there's no reason to warn them about being disconnected. // create the command to execute RunTestSpeakers(); } } else if ( !stricmp( command, "ShowThirdPartyAudioCredits" ) ) { OpenThirdPartySoundCreditsDialog(); } BaseClass::OnCommand( command ); }
//----------------------------------------------------------------------------- // Purpose: Applies changes //----------------------------------------------------------------------------- void COptionsSubAudio::OnApplyChanges() { m_pSFXSlider->ApplyChanges(); m_pMusicSlider->ApplyChanges(); // set the cvars appropriately // Tracker 28933: Note we can't do this because closecaption is marked // FCVAR_USERINFO and it won't get sent to server is we direct set it, we // need to pass it along to the engine parser!!! // ConVar *closecaption = (ConVar *)cvar->FindVar("closecaption"); int closecaption_value = 0; CGameUIConVarRef cc_subtitles( "cc_subtitles" ); switch (m_pCloseCaptionCombo->GetActiveItem()) { default: case 0: closecaption_value = 0; cc_subtitles.SetValue( 0 ); break; case 1: closecaption_value = 1; cc_subtitles.SetValue( 0 ); break; case 2: closecaption_value = 1; cc_subtitles.SetValue( 1 ); break; } // Stuff the close caption change to the console so that it can be // sent to the server (FCVAR_USERINFO) so that you don't have to restart // the level for the change to take effect. char cmd[ 64 ]; Q_snprintf( cmd, sizeof( cmd ), "closecaption %i\n", closecaption_value ); engine->ClientCmd_Unrestricted( cmd ); CGameUIConVarRef snd_surround_speakers( "Snd_Surround_Speakers" ); int speakers = m_pSpeakerSetupCombo->GetActiveItemUserData()->GetInt( "speakers" ); snd_surround_speakers.SetValue( speakers ); // quality CGameUIConVarRef Snd_PitchQuality( "Snd_PitchQuality" ); CGameUIConVarRef dsp_slow_cpu( "dsp_slow_cpu" ); int quality = m_pSoundQualityCombo->GetActiveItemUserData()->GetInt( "quality" ); switch ( quality ) { case SOUNDQUALITY_LOW: dsp_slow_cpu.SetValue(true); Snd_PitchQuality.SetValue(false); break; case SOUNDQUALITY_MEDIUM: dsp_slow_cpu.SetValue(false); Snd_PitchQuality.SetValue(false); break; default: Assert("Undefined sound quality setting."); case SOUNDQUALITY_HIGH: dsp_slow_cpu.SetValue(false); Snd_PitchQuality.SetValue(true); break; }; // headphones at high quality get enhanced stereo turned on CGameUIConVarRef dsp_enhance_stereo( "dsp_enhance_stereo" ); if (speakers == 0 && quality == SOUNDQUALITY_HIGH) { dsp_enhance_stereo.SetValue( 1 ); } else { dsp_enhance_stereo.SetValue( 0 ); } // Audio spoken language KeyValues *kv = m_pSpokenLanguageCombo->GetItemUserData( m_pSpokenLanguageCombo->GetActiveItem() ); const ELanguage nUpdatedAudioLanguage = (ELanguage)( kv ? kv->GetInt( "language" ) : k_Lang_English ); if ( nUpdatedAudioLanguage != m_nCurrentAudioLanguage ) { // Store new language in static member so that it can be accessed during shutdown when this instance is gone m_pchUpdatedAudioLanguage = (char *) GetLanguageShortName( nUpdatedAudioLanguage ); // Inform user that they need to restart in order change language at this time QueryBox *qb = new QueryBox( "#GameUI_ChangeLanguageRestart_Title", "#GameUI_ChangeLanguageRestart_Info", GetParent()->GetParent()->GetParent() ); if (qb != NULL) { qb->SetOKCommand( new KeyValues( "Command", "command", "RestartWithNewLanguage" ) ); qb->SetOKButtonText( "#GameUI_ChangeLanguageRestart_OkButton" ); qb->SetCancelButtonText( "#GameUI_ChangeLanguageRestart_CancelButton" ); qb->AddActionSignalTarget( GetParent()->GetParent()->GetParent() ); qb->DoModal(); } } }