static void SoundProperties_Multiple_OnOK( HWND hwndDlg ) { int c = g_Params.items.Count(); for ( int i = 0; i < c; i++ ) { // Gather info and make changes CSoundEntry *item = g_Params.items[ i ]; Assert( item ); if ( !item ) continue; int idx = g_pSoundEmitterSystem->GetSoundIndex( item->GetName() ); if ( !g_pSoundEmitterSystem->IsValidIndex( idx ) ) { continue; } CSoundParametersInternal *baseparams = g_pSoundEmitterSystem->InternalGetParametersForSound( idx ); if ( !baseparams ) return; // Start with old settings CSoundParametersInternal outparams; outparams.CopyFrom( *baseparams ); char sz[ 128 ]; GetDlgItemText( hwndDlg, IDC_CHANNEL, sz, sizeof( sz ) ); outparams.ChannelFromString( sz ); GetDlgItemText( hwndDlg, IDC_VOLUME, sz, sizeof( sz ) ); outparams.VolumeFromString( sz ); GetDlgItemText( hwndDlg, IDC_SOUNDLEVEL, sz, sizeof( sz ) ); outparams.SoundLevelFromString( sz ); GetDlgItemText( hwndDlg, IDC_PITCH, sz, sizeof( sz ) ); outparams.PitchFromString( sz ); bool owneronly = SendMessage( GetDlgItem( hwndDlg, IDC_OWNERONLY ), BM_GETCHECK, 0, 0 ) == BST_CHECKED ? true : false; outparams.SetOnlyPlayToOwner( owneronly ); g_pSoundEmitterSystem->UpdateSoundParameters( item->GetName(), outparams ); } // Repopulate things GetWorkspaceManager()->RefreshBrowsers(); }
//----------------------------------------------------------------------------- // Purpose: // Input : *soundname - // params - // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- bool CSoundEmitterSystemBase::InitSoundInternalParameters( const char *soundname, KeyValues *kv, CSoundParametersInternal& params ) { KeyValues *pKey = kv->GetFirstSubKey(); while ( pKey ) { if ( !Q_strcasecmp( pKey->GetName(), "channel" ) ) { params.ChannelFromString( pKey->GetString() ); } else if ( !Q_strcasecmp( pKey->GetName(), "volume" ) ) { params.VolumeFromString( pKey->GetString() ); } else if ( !Q_strcasecmp( pKey->GetName(), "pitch" ) ) { params.PitchFromString( pKey->GetString() ); } else if ( !Q_strcasecmp( pKey->GetName(), "wave" ) ) { CUtlSymbol sym = m_Waves.AddString( pKey->GetString() ); params.soundnames.AddToTail( sym ); } else if ( !Q_strcasecmp( pKey->GetName(), "rndwave" ) ) { KeyValues *pWaves = pKey->GetFirstSubKey(); while ( pWaves ) { CUtlSymbol sym = m_Waves.AddString( pWaves->GetString() ); params.soundnames.AddToTail( sym ); pWaves = pWaves->GetNextKey(); } } else if ( !Q_strcasecmp( pKey->GetName(), "attenuation" ) ) { if ( !Q_strncasecmp( pKey->GetString(), "SNDLVL_", strlen( "SNDLVL_" ) ) ) { DevMsg( "CSoundEmitterSystemBase::GetParametersForSound: sound %s has \"attenuation\" with %s value!\n", soundname, pKey->GetString() ); } if ( !Q_strncasecmp( pKey->GetString(), "ATTN_", strlen( "ATTN_" ) ) ) { params.soundlevel.start = ATTN_TO_SNDLVL( TranslateAttenuation( pKey->GetString() ) ); params.soundlevel.range = 0.0f; } else { interval_t interval; interval = ReadInterval( pKey->GetString() ); // Translate from attenuation to soundlevel float start = interval.start; float end = interval.start + interval.range; params.soundlevel.start = ATTN_TO_SNDLVL( start ); params.soundlevel.range = ATTN_TO_SNDLVL( end ) - ATTN_TO_SNDLVL( start ); } } else if ( !Q_strcasecmp( pKey->GetName(), "soundlevel" ) ) { if ( !Q_strncasecmp( pKey->GetString(), "ATTN_", strlen( "ATTN_" ) ) ) { DevMsg( "CSoundEmitterSystemBase::GetParametersForSound: sound %s has \"soundlevel\" with %s value!\n", soundname, pKey->GetString() ); } params.SoundLevelFromString( pKey->GetString() ); } else if ( !Q_strcasecmp( pKey->GetName(), "play_to_owner_only" ) ) { params.play_to_owner_only = pKey->GetInt() ? true : false; } else if ( !Q_strcasecmp( pKey->GetName(), "precache" ) ) { params.precache = pKey->GetInt() ? true : false; } pKey = pKey->GetNextKey(); } return true; }