//------------------------------------------------------------------------// bool MusicManager::LoadSegment(ScriptNode* pNode) { FN("MusicManager::LoadSegment()"); // We use string ids in this scripting system if(pNode->GetDataType() != Script::STRING) return Error::Handle("No id found for sound identifier"); // Make sure the segment ID doesn't already exist ISegmentMap::iterator itr = m_SegmentMap.find(pNode->GetString()); if(itr != m_SegmentMap.end()) return true; SegmentInit init; ScriptNode* pChildNode = pNode->GetChild(); init.m_pDLS = m_pCurrentDLS; while(pChildNode) { if(MUSMGR_STRCMP(pChildNode->GetName(), "FileName") == 0) init.m_sFileName = pChildNode->GetString(); else if(MUSMGR_STRCMP(pChildNode->GetName(), "Looping") == 0) init.m_bLooping = pChildNode->GetBool(); else if(MUSMGR_STRCMP(pChildNode->GetName(), "Music") == 0) init.m_bMusic = pChildNode->GetBool(); else if(MUSMGR_STRCMP(pChildNode->GetName(), "DLS") == 0) { IDLSMap::iterator itr = m_DLSMap.find(pChildNode->GetString()); if(itr != m_DLSMap.end()) init.m_pDLS = itr->second; } pChildNode = pChildNode->GetSibling(); } ISegment* pSegment; if(!AudioMgr()->CreateSegment(pSegment)) return false; if(!pSegment->Init(init)) return false; // Insert the segment into the map m_SegmentMap.insert(make_pair(pNode->GetString(), pSegment)); return true; }
//------------------------------------------------------------------------// 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 MusicManager::LoadTheme(ScriptNode* pNode) { FN("MusicManager::LoadTheme()"); // We use string ids in this scripting system if(pNode->GetDataType() != Script::STRING) return Error::Handle("No id found for theme identifier"); Theme* pTheme = 0; // Make sure the theme ID doesn't already exist ThemeMap::iterator itr = m_ThemeMap.find(pNode->GetString()); if(itr != m_ThemeMap.end()) pTheme = itr->second; else pTheme = new Theme; if(!pTheme) return false; ScriptNode* pChildNode = pNode->GetChild(); while(pChildNode) { if(MUSMGR_STRCMP(pChildNode->GetName(), "Src") == 0) { if(!LoadThemeNode(pChildNode, pTheme)) return false; } else if(MUSMGR_STRCMP(pChildNode->GetName(), "Interlude") == 0) { pTheme->SetInterlude(pChildNode->GetBool()); } else return false; pChildNode = pChildNode->GetSibling(); } // Insert the theme into the map m_ThemeMap.insert(make_pair(pNode->GetString(), pTheme)); 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; }