1 #ifndef __REPLACEMENTSOUNDS_H 2 #define __REPLACEMENTSOUNDS_H 3 4 /* 5 6 Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc. 7 and the "Aleph One" developers. 8 9 This program is free software; you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation; either version 3 of the License, or 12 (at your option) any later version. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 This license is contained in the file "COPYING", 20 which is included with this source code; it is available online at 21 http://www.gnu.org/licenses/gpl.html 22 23 Handles MML-specified external replacement sounds 24 25 */ 26 27 #include <string> 28 #include "SoundFile.h" 29 30 #include <boost/unordered_map.hpp> 31 32 class ExternalSoundHeader : public SoundInfo 33 { 34 public: ExternalSoundHeader()35 ExternalSoundHeader() : SoundInfo() { } ~ExternalSoundHeader()36 ~ExternalSoundHeader() { } 37 boost::shared_ptr<SoundData> LoadExternal(FileSpecifier& File); 38 }; 39 40 struct SoundOptions 41 { 42 FileSpecifier File; 43 ExternalSoundHeader Sound; 44 }; 45 46 class SoundReplacements 47 { 48 public: instance()49 static inline SoundReplacements* instance() { 50 static SoundReplacements *m_instance = nullptr; 51 if (!m_instance) m_instance = new SoundReplacements; 52 return m_instance; 53 } 54 55 SoundOptions *GetSoundOptions(short Index, short Slot); Reset()56 void Reset() { m_hash.clear(); } 57 void Add(const SoundOptions& Data, short Index, short Slot); 58 59 private: SoundReplacements()60 SoundReplacements() { } 61 62 typedef std::pair<short, short> key; 63 64 boost::unordered_map<key, SoundOptions> m_hash; 65 }; 66 67 #endif 68