void CSoundEmitterSystemBase::RenameSound( const char *soundname, const char *newname )
{
	// Same name?
	if ( !Q_stricmp( soundname, newname ) )
	{
		return;
	}

	int oldindex = GetSoundIndex( soundname );
	if ( !IsValidIndex( oldindex ) )
	{
		Msg( "Can't rename %s, no such sound\n", soundname );
		return;
	}

	int check = GetSoundIndex( newname );
	if ( IsValidIndex( check ) )
	{
		Msg( "Can't rename %s to %s, new name already in list\n", soundname, newname );
		return;
	}

	// Copy out old entry
	CSoundEntry entry = m_Sounds[ oldindex ];
	// Remove it
	m_Sounds.Remove( soundname );
	// Re-insert in new spot
	m_Sounds.Insert( newname, entry );

	// Mark associated script as dirty
	m_SoundKeyValues[ entry.m_nScriptFileIndex ].dirty = true;
}
Esempio n. 2
0
void SoundManager::PlaySound(char* p_sound)
{
	if (!s_playing.playing)
	{

 		this->m_sounds->at(GetSoundIndex(p_sound))->sound->play();

		s_playing.playing = true;

	}
	else
	{

		printf("%c, is currently playing, switching to %c\n", this->m_sounds->at(GetSoundIndex(s_playing.name))->name,p_sound);


		setSoundStatus(s_playing.name, Paused);

		this->m_sounds->at(GetSoundIndex(p_sound))->sound->play();


		s_playing.name = p_sound;


	}


}
Esempio n. 3
0
float SoundManager::getSoundDuration(char* name)
{


	return this->m_sounds->at(GetSoundIndex(name))->buffer->getDuration().asSeconds();


}
Esempio n. 4
0
void SoundManager::setSoundVolume(char *name, float value)
{


	this->m_sounds->at(GetSoundIndex(name))->sound->setVolume(value);


}
Esempio n. 5
0
void SoundManager::PauseSound(char *name)
{


	this->m_sounds->at(GetSoundIndex(name))->sound->pause();


}
Esempio n. 6
0
void SoundManager::StopSound(char *name)
{


	this->m_sounds->at(GetSoundIndex(name))->sound->stop();


}
Esempio n. 7
0
float SoundManager::getSoundVolume(char *name)
{


	return this->m_sounds->at(GetSoundIndex(name))->sound->getVolume();


}
Esempio n. 8
0
void SoundManager::setSoundPitch(char *name, float value)
{


	this->m_sounds->at(GetSoundIndex(name))->sound->setPitch(value);


}
Esempio n. 9
0
void SoundManager::setSoundLoop(char *name, bool value)
{

	this->PlaySound(name);


	this->m_sounds->at(GetSoundIndex(name))->sound->setLoop(value);

}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *soundname - 
//			params - 
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool CSoundEmitterSystemBase::GetParametersForSound( const char *soundname, CSoundParameters& params )
{
	int index = GetSoundIndex( soundname );
	if ( index == -1 )
	{
		DevMsg( "CSoundEmitterSystemBase::GetParametersForSound:  No such sound %s\n", soundname );
		return false;
	}

	CSoundParametersInternal *internal = InternalGetParametersForSound( index );
	if ( !internal )
	{
		Assert( 0 );
		DevMsg( "CSoundEmitterSystemBase::GetParametersForSound:  No such sound %s\n", soundname );
		return false;
	}

	params.channel = internal->channel;
	params.volume = RandomInterval( internal->volume );
	params.pitch = RandomInterval( internal->pitch );
	params.pitchlow = internal->pitch.start;
	params.pitchhigh = params.pitchlow + internal->pitch.range;
	params.count = internal->soundnames.Count();
	params.soundname[ 0 ] = 0;
	if ( params.count >= 1 )
	{
		CUtlSymbol sym = internal->soundnames[ random->RandomInt( 0, params.count - 1 ) ];

		Q_strncpy( params.soundname, m_Waves.String( sym ), sizeof( params.soundname ) );
	}

	params.soundlevel = (soundlevel_t)(int)RandomInterval( internal->soundlevel );
	params.play_to_owner_only = internal->play_to_owner_only;

	if ( !params.soundname[ 0 ] )
	{
		DevMsg( "CSoundEmitterSystemBase::GetParametersForSound:  sound %s has no wave or rndwave key!\n", soundname );
		return false;
	}

	if ( internal->had_missing_wave_files &&
		params.soundname[ 0 ] != CHAR_SENTENCE )
	{
		char testfile[ 256 ];
		Q_snprintf( testfile, sizeof( testfile ), "sound/%s", PSkipSoundChars( params.soundname ) );

		if ( !filesystem->FileExists( testfile ) )
		{
			DevMsg( "CSoundEmitterSystemBase::GetParametersForSound:  sound '%s' references wave '%s' which doesn't exist on disk!\n", 
				soundname,
				params.soundname );
			return false;
		}
	}

	return true;
}
Esempio n. 11
0
float SoundManager::getSoundOffset(char *name)
{


	return this->m_sounds->at(GetSoundIndex(name))->sound->getPlayingOffset().asSeconds();



}
Esempio n. 12
0
void SoundManager::setSoundStatus(char* name, Status status)
{
	switch (status)
	{
	case Stopped:
		this->m_sounds->at(GetSoundIndex(name))->sound->stop();
		break;
	case Paused:
		this->m_sounds->at(GetSoundIndex(name))->sound->pause();
		break;
	case Playing:
		this->m_sounds->at(GetSoundIndex(name))->sound->play();
		break;
	default:
		break;
	}


}
Esempio n. 13
0
void SoundManager::SetSoundOffset(char* name, float value)
{

	sf::Time time;

	time = sf::seconds(value);


	this->m_sounds->at(GetSoundIndex(name))->sound->setPlayingOffset(time);


}
void CSoundEmitterSystemBase::RemoveSound( const char *soundname )
{
	int idx = GetSoundIndex( soundname );
	if ( !IsValidIndex( idx ) )
	{
		Warning( "Can't remove %s, no such sound!\n", soundname );
		return;
	}

	m_Sounds[ idx ].m_bRemoved = true;

	// Mark script as dirty
	int scriptindex = m_Sounds[ idx ].m_nScriptFileIndex;
	if ( scriptindex < 0 || scriptindex >= m_SoundKeyValues.Count() )
	{
		Assert( 0 );
		return;
	}

	m_SoundKeyValues[ scriptindex ].dirty = true;
}
bool CSoundEmitterSystemBase::AddSound( const char *soundname, const char *scriptfile, const CSoundParametersInternal& params )
{
	int idx = GetSoundIndex( soundname );


	int i = FindSoundScript( scriptfile );
	if ( i == m_SoundKeyValues.InvalidIndex() )
	{
		Warning( "CSoundEmitterSystemBase::AddSound( '%s', '%s', ... ), script file not list in manifest '%s'\n",
			soundname, scriptfile, MANIFEST_FILE );
		return false;
	}

	// More like an update...
	if ( IsValidIndex( idx ) )
	{
		CSoundEntry *entry = &m_Sounds[ idx ];

		entry->m_bRemoved				= false;
		entry->m_nScriptFileIndex		= i;
		entry->m_bPrecacheAlways		= m_SoundKeyValues[ i ].precachealways;
		entry->m_SoundParams			= params;

		m_SoundKeyValues[ i ].dirty = true;

		return true;
	}

	CSoundEntry entry;
	entry.m_bRemoved			= false;
	entry.m_nScriptFileIndex	= i;
	entry.m_bPrecacheAlways		= m_SoundKeyValues[ i ].precachealways;
	entry.m_SoundParams			= params;

	m_Sounds.Insert( soundname, entry );

	m_SoundKeyValues[ i ].dirty = true;

	return true;
}
void CSoundEmitterSystemBase::UpdateSoundParameters( const char *soundname, const CSoundParametersInternal& params )
{
	int idx = GetSoundIndex( soundname );
	if ( !IsValidIndex( idx ) )
	{
		Msg( "Can't UpdateSoundParameters %s, no such sound\n", soundname );
		return;
	}

	CSoundEntry *entry = &m_Sounds[ idx ];

	if ( entry->m_SoundParams == params )
	{
		// No changes
		return;
	}

	// Update parameters
	entry->m_SoundParams = params;
	// Set dirty flag
	m_SoundKeyValues[ entry->m_nScriptFileIndex ].dirty = true;
}
void CSoundEmitterSystemBase::MoveSound( const char *soundname, const char *newscript )
{
	int idx = GetSoundIndex( soundname );
	if ( !IsValidIndex( idx ) )
	{
		Warning( "Can't move '%s', no such sound!\n", soundname );
		return;
	}

	int oldscriptindex = m_Sounds[ idx ].m_nScriptFileIndex;
	if ( oldscriptindex < 0 || oldscriptindex >= m_SoundKeyValues.Count() )
	{
		Assert( 0 );
		return;
	}

	int newscriptindex = FindSoundScript( newscript );
	if ( newscriptindex == m_SoundKeyValues.InvalidIndex() )
	{
		Warning( "CSoundEmitterSystemBase::MoveSound( '%s', '%s' ), script file not list in manifest '%s'\n",
			soundname, newscript, MANIFEST_FILE );
		return;
	}

	// No actual change
	if ( oldscriptindex == newscriptindex )
	{
		return;
	}

	// Move it
	m_Sounds[ idx ].m_nScriptFileIndex = newscriptindex;

	// Mark both scripts as dirty
	m_SoundKeyValues[ oldscriptindex ].dirty = true;
	m_SoundKeyValues[ newscriptindex ].dirty = true;
}
Esempio n. 18
0
bool SoundManager::getSoundLoop(char *name)
{

	return this->m_sounds->at(GetSoundIndex(name))->sound->getLoop();

}
Esempio n. 19
0
int SoundManager::getSoundStatus(char* name)
{

	return this->m_sounds->at(GetSoundIndex(name))->sound->getStatus();

}