//------------------------------------------------------------------------// 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; }
//------------------------------------------------------------------------// bool SoundManager::LoadPeriodic(ScriptNode* pNode, PeriodicElement& pe) { FN("SoundManager::LoadPeriodic()"); // Check to see if the node has the "default" keyword, meaning it should // clear all values to their original defaults. if((pNode->GetDataType() == Script::VARIABLE) && (strcmp(pNode->GetVariable(), "Default") == 0)) pe.Clear(); ScriptNode* pChildNode = pNode->GetChild(); while(pChildNode) { if(SNDMGR_STRCMP(pChildNode->GetName(), "Sound3D") == 0) pe.m_sSound3DID = pChildNode->GetString(); else if(SNDMGR_STRCMP(pChildNode->GetName(), "MinPitch") == 0) pe.m_Init.m_fMinPitch = pChildNode->GetReal(); else if(SNDMGR_STRCMP(pChildNode->GetName(), "MaxPitch") == 0) pe.m_Init.m_fMaxPitch = pChildNode->GetReal(); else if(SNDMGR_STRCMP(pChildNode->GetName(), "MinDelay") == 0) pe.m_Init.m_fMinDelay = pChildNode->GetReal(); else if(SNDMGR_STRCMP(pChildNode->GetName(), "MaxDelay") == 0) pe.m_Init.m_fMaxDelay = pChildNode->GetReal(); else if(SNDMGR_STRCMP(pChildNode->GetName(), "XRange") == 0) pe.m_Init.m_fXRange = pChildNode->GetReal(); else if(SNDMGR_STRCMP(pChildNode->GetName(), "YRange") == 0) pe.m_Init.m_fYRange = pChildNode->GetReal(); else if(SNDMGR_STRCMP(pChildNode->GetName(), "ZRange") == 0) pe.m_Init.m_fZRange = pChildNode->GetReal(); else if(SNDMGR_STRCMP(pChildNode->GetName(), "MinDistance") == 0) pe.m_Init.m_fMinDistance = pChildNode->GetReal(); else return false; pChildNode = pChildNode->GetSibling(); } return true; }
//------------------------------------------------------------------------// bool SoundManager::LoadBackground(ScriptNode* pNode, BackgroundElement& bge) { FN("SoundManager::LoadBackground()"); // Check to see if the node has the "Default" keyword, meaning it should // clear all values to their original defaults. if((pNode->GetDataType() == Script::VARIABLE) && (strcmp(pNode->GetVariable(), "Default") == 0)) bge.Clear(); ScriptNode* pChildNode = pNode->GetChild(); while(pChildNode) { if(SNDMGR_STRCMP(pChildNode->GetName(), "Sound") == 0) bge.m_sSoundID = pChildNode->GetString(); else if(SNDMGR_STRCMP(pChildNode->GetName(), "MinVolume") == 0) bge.m_Init.m_fMinVolume = pChildNode->GetReal(); else if(SNDMGR_STRCMP(pChildNode->GetName(), "MaxVolume") == 0) bge.m_Init.m_fMaxVolume = pChildNode->GetReal(); else if(SNDMGR_STRCMP(pChildNode->GetName(), "MinVolumeTime") == 0) bge.m_Init.m_fMinVolumeTime = pChildNode->GetReal(); else if(SNDMGR_STRCMP(pChildNode->GetName(), "MaxVolumeTime") == 0) bge.m_Init.m_fMaxVolumeTime = pChildNode->GetReal(); else if(SNDMGR_STRCMP(pChildNode->GetName(), "MinPitch") == 0) bge.m_Init.m_fMinPitch = pChildNode->GetReal(); else if(SNDMGR_STRCMP(pChildNode->GetName(), "MaxPitch") == 0) bge.m_Init.m_fMaxPitch = pChildNode->GetReal(); else if(SNDMGR_STRCMP(pChildNode->GetName(), "MinPitchTime") == 0) bge.m_Init.m_fMinPitchTime = pChildNode->GetReal(); else if(SNDMGR_STRCMP(pChildNode->GetName(), "MaxPitchTime") == 0) bge.m_Init.m_fMaxPitchTime = pChildNode->GetReal(); else return false; pChildNode = pChildNode->GetSibling(); } return true; }
//------------------------------------------------------------------------// 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; }