Exemple #1
0
void AGE_Frame::ListSounds(bool all)
{
	searchText = Sounds_Sounds_Search->GetValue().Lower();
	excludeText = Sounds_Sounds_Search_R->GetValue().Lower();

	list<void*> dataPointers;
	wxArrayString names, filteredNames;
	if(all) names.Alloc(GenieFile->Sounds.size());

	for(short loop = 0; loop < GenieFile->Sounds.size(); ++loop)
	{
		wxString Name = " "+lexical_cast<string>(loop)+" - "+GetSoundName(loop);
		if(SearchMatches(Name.Lower()))
		{
			filteredNames.Add(Name);
			dataPointers.push_back((void*)&GenieFile->Sounds[loop]);
		}
		if(all) names.Add(Name);
	}

	Listing(Sounds_Sounds_List, filteredNames, dataPointers);
	if(all) FillLists(SoundComboBoxList, names);

	wxCommandEvent E;
	OnSoundsSelect(E);
}
void CModelSoundsCache::PrecacheSoundList()
{
	for ( int i = 0; i < sounds.Count(); ++i )
	{
		ModelSoundsCache_PrecacheScriptSound( GetSoundName( i ) );
	}
}
void CModelSoundsCache::Save( CUtlBuffer& buf  )
{
	buf.PutShort( sounds.Count() );
	
	for ( int i = 0; i < sounds.Count(); ++i )
	{
		buf.PutString( GetSoundName( i ) );
	}
}
Exemple #4
0
void CSceneCache::Save( CUtlBuffer& buf  )
{
	buf.PutUnsignedInt( msecs );

	unsigned short c = GetSoundCount();
	buf.PutShort( c );
	
	Assert( sounds.Count() <= 65536 );

	for ( int i = 0; i < c; ++i )
	{
		buf.PutString( GetSoundName( i ) );
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
int CSoundEmitterSystemBase::CheckForMissingWavFiles( bool verbose )
{
	int missing = 0;

	int c = GetSoundCount();
	int i;
	char testfile[ 512 ];

	for ( i = 0; i < c; i++ )
	{
		CSoundParametersInternal *internal = InternalGetParametersForSound( i );
		if ( !internal )
		{
			Assert( 0 );
			continue;
		}

		int waveCount = internal->soundnames.Count();
		for ( int wave = 0; wave < waveCount; wave++ )
		{
			CUtlSymbol sym = internal->soundnames[ wave ];
			const char *name = m_Waves.String( sym );
			if ( !name || !name[ 0 ] )
			{
				Assert( 0 );
				continue;
			}

			// Skip ! sentence stuff
			if ( name[0] == CHAR_SENTENCE )
				continue;

			Q_snprintf( testfile, sizeof( testfile ), "sound/%s", PSkipSoundChars( name ) );

			if ( filesystem->FileExists( testfile ) )
				continue;

			internal->had_missing_wave_files = true;

			++missing;

			if ( verbose )
			{
				DevMsg( "Sound %s references missing file %s\n", GetSoundName( i ), name );
			}
		}
	}

	return missing;
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CDemoActionPlaySoundStart::FireAction( void )
{
	Vector vDummyOrigin;
	vDummyOrigin.Init();

	CSfxTable *pSound = (CSfxTable*)S_PrecacheSound(GetSoundName());
	if ( pSound )
	{
		StartSoundParams_t params;
		params.staticsound = false;
		params.soundsource = cl.m_nViewEntity;
		params.entchannel = CHAN_AUTO;
		params.pSfx = pSound;
		params.origin = vDummyOrigin;
		params.fvol = 1.0f;
		params.soundlevel = SNDLVL_IDLE;
		params.flags = 0;
		params.pitch = PITCH_NORM;

		S_StartSound( params );
	}

	SetFinishedAction( true );
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : buf - 
//-----------------------------------------------------------------------------
void CDemoActionPlaySoundStart::SaveKeysToBuffer( int depth, CUtlBuffer& buf )
{
	BaseClass::SaveKeysToBuffer( depth, buf );

	BufPrintf( depth, buf, "sound \"%s\"\n", GetSoundName() );
}
void CSoundEmitterSystemBase::SaveChangesToSoundScript( int scriptindex )
{
	const char *outfile = GetSoundScriptName( scriptindex );
	if ( !outfile )
	{
		Msg( "CSoundEmitterSystemBase::SaveChangesToSoundScript:  No script file for index %i\n", scriptindex );
		return;
	}

	if ( filesystem->FileExists( outfile ) &&
		 !filesystem->IsFileWritable( outfile ) )
	{
		Warning( "%s is not writable, can't save data to file\n", outfile );
		return;
	}

	CUtlBuffer buf( 0, 0, true );

	// FIXME:  Write sound script header
	if ( filesystem->FileExists( GAME_SOUNDS_HEADER_BLOCK ) )
	{
		FileHandle_t header = filesystem->Open( GAME_SOUNDS_HEADER_BLOCK, "rt", NULL );
		if ( header != FILESYSTEM_INVALID_HANDLE )
		{
			int len = filesystem->Size( header );
			
			unsigned char *data = new unsigned char[ len + 1 ];
			Q_memset( data, 0, len + 1 );
			
			filesystem->Read( data, len, header );
			filesystem->Close( header );

			data[ len ] = 0;

			buf.Put( data, Q_strlen( (char *)data ) );

			delete[] data;
		}

		buf.Printf( "\n" );
	}


	int c = GetSoundCount();
	for ( int i = 0; i < c; i++ )
	{
		if ( Q_stricmp( outfile, GetSourceFileForSound( i ) ) )
			continue;

		// It's marked for deletion, just skip it
		if ( m_Sounds[ i ].m_bRemoved )
			continue;

		CSoundEmitterSystemBase::CSoundParametersInternal *p = InternalGetParametersForSound( i );
		if ( !p )
			continue;
		
		buf.Printf( "\"%s\"\n{\n", GetSoundName( i ) );

		buf.Printf( "\t\"channel\"\t\t\"%s\"\n", p->m_szChannel );
		buf.Printf( "\t\"volume\"\t\t\"%s\"\n", p->m_szVolume );
		buf.Printf( "\t\"pitch\"\t\t\t\"%s\"\n", p->m_szPitch );
		buf.Printf( "\n" );
		buf.Printf( "\t\"soundlevel\"\t\"%s\"\n", p->m_szSoundLevel );

		if ( p->play_to_owner_only )
		{
			buf.Printf( "\t\"play_to_owner_only\"\t\"1\"\n" );
		}
		if ( !p->precache )
		{
			buf.Printf( "\t\"precache\"\t\"0\"\n" );

		}

		int waveCount = p->soundnames.Count();

		if  ( waveCount > 0 )
		{
			buf.Printf( "\n" );

			if ( waveCount == 1 )
			{
				buf.Printf( "\t\"wave\"\t\t\t\"%s\"\n", GetWaveName( p->soundnames[ 0 ] ) );
			}
			else
			{
				buf.Printf( "\t\"rndwave\"\n" );
				buf.Printf( "\t{\n" );

				for ( int wave = 0; wave < waveCount; wave++ )
				{
					buf.Printf( "\t\t\"wave\"\t\"%s\"\n", GetWaveName( p->soundnames[ wave ] ) );
				}

				buf.Printf( "\t}\n" );
			}

		}

		buf.Printf( "}\n" );

		if ( i != c - 1 )
		{
			buf.Printf( "\n" );
		}
	}

	// Write it out baby
	FileHandle_t fh = filesystem->Open( outfile, "wt" );
	if (fh)
	{
		filesystem->Write( buf.Base(), buf.TellPut(), fh );
		filesystem->Close(fh);

		// Changed saved successfully
		m_SoundKeyValues[ scriptindex ].dirty = false;
	}
	else
	{
		Warning( "SceneManager_SaveSoundsToScriptFile:  Unable to write file %s!!!\n", outfile );
	}
}