Пример #1
0
//------------------------------------------------------------------------//
bool SoundManager::LoadSound(ScriptNode* pNode)
{
	FN("SoundManager::LoadSound()");
	// We use string ids in this scripting system
	if(pNode->GetDataType() != Script::STRING)
		return Error::Handle("No id found for sound identifier");

	// Just return true if the sound is already registered
	if(IsSoundRegistered(pNode->GetString()))
		return true;

	SoundPool pool;
	ScriptNode* pChildNode = pNode->GetChild();
	while(pChildNode)
	{
		if(SNDMGR_STRCMP(pChildNode->GetName(), "FileName") == 0)
			pool.m_Init.m_sFileName = pChildNode->GetString();
		else if(SNDMGR_STRCMP(pChildNode->GetName(), "Looping") == 0)
			pool.m_Init.m_bLooping = pChildNode->GetBool();
		else if(SNDMGR_STRCMP(pChildNode->GetName(), "Streaming") == 0)
			pool.m_Init.m_bStreaming = pChildNode->GetBool();
		else if(SNDMGR_STRCMP(pChildNode->GetName(), "Music") == 0)
			pool.m_Init.m_bMusic = pChildNode->GetBool();
		else if(SNDMGR_STRCMP(pChildNode->GetName(), "Volume") == 0)
			pool.m_Init.m_Prop.m_fVolume = pChildNode->GetReal();
		else if(SNDMGR_STRCMP(pChildNode->GetName(), "Pan") == 0)
			pool.m_Init.m_Prop.m_fPan = pChildNode->GetReal();
		else if(SNDMGR_STRCMP(pChildNode->GetName(), "Pitch") == 0)
			pool.m_Init.m_Prop.m_fPitch = pChildNode->GetReal();
		else if(SNDMGR_STRCMP(pChildNode->GetName(), "ReadCursor") == 0)
			pool.m_Init.m_Prop.m_nReadCursor = pChildNode->GetInteger();
		else
			return Error::Handle("Syntax error in Sound definition");
		pChildNode = pChildNode->GetSibling();
	}

	// Insert the sound definition into the map
	m_SndMap.insert(make_pair(pNode->GetString(), pool));
	DebugOut(4, "Registering Sound \"%s\" in sound manager", pNode->GetString());
	return true;
}
Пример #2
0
//------------------------------------------------------------------------//
bool SoundManager::LoadSound3D(ScriptNode* pNode)
{
	FN("SoundManager::LoadSound3D()");
	// We use string ids in this scripting system
	if(pNode->GetDataType() != Script::STRING)
		return Error::Handle("No id found for sound3d identifier");

	// Just return true if the sound3d is already registered
	if(IsSound3DRegistered(pNode->GetString()))
		return true;

	Sound3DPool pool;
	ScriptNode* pChildNode = pNode->GetChild();
	while(pChildNode)
	{
		if(SNDMGR_STRCMP(pChildNode->GetName(), "FileName") == 0)
			pool.m_Init.m_sFileName = pChildNode->GetString();
		else if(SNDMGR_STRCMP(pChildNode->GetName(), "Looping") == 0)
			pool.m_Init.m_bLooping = pChildNode->GetBool();
		else if(SNDMGR_STRCMP(pChildNode->GetName(), "Streaming") == 0)
			pool.m_Init.m_bStreaming = pChildNode->GetBool();
		else if(SNDMGR_STRCMP(pChildNode->GetName(), "Music") == 0)
			pool.m_Init.m_bMusic = pChildNode->GetBool();
		else if(SNDMGR_STRCMP(pChildNode->GetName(), "Position") == 0)
			pool.m_Init.m_Prop.m_vPosition = pChildNode->GetVector();
		else if(SNDMGR_STRCMP(pChildNode->GetName(), "Velocity") == 0)
			pool.m_Init.m_Prop.m_vVelocity = pChildNode->GetVector();
		else if(SNDMGR_STRCMP(pChildNode->GetName(), "ConeOrientation") == 0)
			pool.m_Init.m_Prop.m_vConeOrientation = pChildNode->GetVector();
		else if(SNDMGR_STRCMP(pChildNode->GetName(), "InsideConeAngle") == 0)
			pool.m_Init.m_Prop.m_nInsideConeAngle = pChildNode->GetInteger();
		else if(SNDMGR_STRCMP(pChildNode->GetName(), "OutsideConeAngle") == 0)
			pool.m_Init.m_Prop.m_nOutsideConeAngle = pChildNode->GetInteger();
		else if(SNDMGR_STRCMP(pChildNode->GetName(), "ConeOutsideVolume") == 0)
			pool.m_Init.m_Prop.m_fConeOutsideVolume = pChildNode->GetReal();
		else if(SNDMGR_STRCMP(pChildNode->GetName(), "MinDistance") == 0)
			pool.m_Init.m_Prop.m_fMinDistance = pChildNode->GetReal();
		else if(SNDMGR_STRCMP(pChildNode->GetName(), "MaxDistance") == 0)
			pool.m_Init.m_Prop.m_fMaxDistance = pChildNode->GetReal();
		else if(SNDMGR_STRCMP(pChildNode->GetName(), "Mode") == 0)
		{
			if(pChildNode->GetDataType() == Script::INTEGER)
			{
				pool.m_Init.m_Prop.m_nMode = pChildNode->GetInteger();
			}
			else
			{
				if(SNDMGR_STRCMP(pChildNode->GetString(), "Normal") == 0)
					pool.m_Init.m_Prop.m_nMode = MODE_NORMAL;
				else if(SNDMGR_STRCMP(pChildNode->GetString(), "HeadRelative") == 0)
					pool.m_Init.m_Prop.m_nMode = MODE_HEADRELATIVE;
				else if(SNDMGR_STRCMP(pChildNode->GetString(), "Disable") == 0)
					pool.m_Init.m_Prop.m_nMode = MODE_DISABLE;
			}
		}
		else if(SNDMGR_STRCMP(pChildNode->GetName(), "Volume") == 0)
			pool.m_Init.m_Prop.m_fVolume = pChildNode->GetReal();
		else if(SNDMGR_STRCMP(pChildNode->GetName(), "Pitch") == 0)
			pool.m_Init.m_Prop.m_fPitch = pChildNode->GetReal();
		else if(SNDMGR_STRCMP(pChildNode->GetName(), "ReadCursor") == 0)
			pool.m_Init.m_Prop.m_nReadCursor = pChildNode->GetInteger();
		else
		{
			return Error::Handle("Syntax error in Sound3D definition");
		}
		pChildNode = pChildNode->GetSibling();
	}

	// Insert the sound3d definition into the map
	m_Snd3DMap.insert(make_pair(pNode->GetString(), pool));
	DebugOut(4, "Registering Sound3D \"%s\" in sound manager", pNode->GetString());
	return true;
}