public object Clone() { SoundEntryCollection sCollection = new SoundEntryCollection(); foreach (BGMEntry sEntryBGM in _SoundEntriesBGMs) { BGMEntry newSEntryBGM = (BGMEntry)sEntryBGM.Clone(); sCollection._SoundEntriesBGMs.Add(newSEntryBGM); } sCollection.GenerateSoundEntriesBGMDictionary(); foreach (SoundEntry sEntry in _SoundEntries) { SoundEntry newSEntry = (SoundEntry)sEntry.Clone(); newSEntry.BGMFiles = new List <SoundEntryBGM>(); foreach (SoundEntryBGM sEntryBGM in sEntry.BGMFiles) { newSEntry.BGMFiles.Add(new SoundEntryBGM(sCollection, newSEntry, sEntryBGM.BGMID)); } newSEntry.SoundEntryCollection = sCollection; sCollection._SoundEntries.Add(newSEntry); } sCollection.GenerateSoundEntriesDictionary(); foreach (MyMusicStage myMusicStage in _MyMusicStages) { MyMusicStage nMyMusicStage = new MyMusicStage(myMusicStage.MyMusicStageID); foreach (MyMusicStageBGM sMusicStageBGM in myMusicStage.BGMs) { MyMusicStageBGM nMyMusicStageBGM = (MyMusicStageBGM)sMusicStageBGM.Clone(); nMyMusicStageBGM.SoundEntryCollection = sCollection; nMyMusicStage.BGMs.Add(nMyMusicStageBGM); } sCollection._MyMusicStages.Add(nMyMusicStage); } foreach (SoundDBStage soundDBStage in _SoundDBStages) { List <SoundDBStageSoundEntry> sEntries = new List <SoundDBStageSoundEntry>(); foreach (SoundDBStageSoundEntry sSoundDBStageSoundEntry in soundDBStage.SoundEntries) { sEntries.Add(new SoundDBStageSoundEntry(sCollection, sSoundDBStageSoundEntry.SoundID)); } SoundDBStage nSoundDBStage = new SoundDBStage(sCollection, soundDBStage.SoundDBStageID); nSoundDBStage.SoundEntries = sEntries; sCollection._SoundDBStages.Add(nSoundDBStage); } sCollection.GenerateStagesDictionaries(); return(sCollection); }
public UISoundDBFile(SmashProjectManager projectManager, SoundEntryCollection sEntryCollection, string path) { string uiSoundDBFile; uiSoundDBFile = PathHelper.FolderEditorMods + path; if (!File.Exists(uiSoundDBFile)) { uiSoundDBFile = projectManager.ExtractResource(path, PathHelper.FolderTemp); } SoundEntryCollection = sEntryCollection; _Path = path; _Project = projectManager; using (FileStream fileStream = File.Open(uiSoundDBFile, FileMode.Open)) { using (BinaryReader b = new BinaryReader(fileStream)) { byte[] header = b.ReadBytes(2); if (header[0] != 0xff || header[1] != 0xff) { throw new Exception(string.Format("Can't load '{0}', the file doesn't appear to be 'ui_sound_db.bin'.", uiSoundDBFile)); } //Keep header b.BaseStream.Position = 0; _Header = b.ReadBytes(HEADER_LEN); //Number of elements b.BaseStream.Position = HEADER_LEN; int nbrStages = ReadNbrEntries(b); //Offset to second table int offsetUnknownSecondTable = HEADER_LEN + 0x5 + (nbrStages * 0xd2); b.BaseStream.Position = offsetUnknownSecondTable; int nbrUnknownSecondTableBlocs = ReadNbrEntries(b); b.BaseStream.Position = offsetUnknownSecondTable; _SecondBloc = b.ReadBytes((int)(0x5 + (nbrUnknownSecondTableBlocs * 0xa))); //Offset to variable/songid table int offsetSongTable = offsetUnknownSecondTable + 0x5 + (nbrUnknownSecondTableBlocs * 0xa); b.BaseStream.Position = offsetSongTable; int nbrSoundEntries = ReadNbrEntries(b); //Retrieve all sounds for (int i = 0; i < nbrSoundEntries; i++) { int index = ReadInt32(b); SoundEntry sEntry = ParseSoundEntry(b, index); if (sEntry != null && (INCLUDE_EMPTY_SOUND || sEntry.BGMFiles.Count == 0 || sEntry.BGMFiles[0].BGMID != 0x450)) { SoundEntryCollection.SoundEntries.Add(sEntry); } } //Retrieve info per stage for (int i = 0; i < nbrStages; i++) { b.BaseStream.Position = HEADER_LEN + 0x5 + (i * 0xd2); int stageId = ReadInt32(b); int nbrSounds = ReadInt32(b); List <SoundDBStageSoundEntry> stageSoundEntries = new List <SoundDBStageSoundEntry>(); for (int j = 0; j < nbrSounds; j++) { int sEntryIndex = ReadInt32(b); stageSoundEntries.Add(new SoundDBStageSoundEntry(SoundEntryCollection, sEntryIndex)); } SoundDBStage soundDBStage = new SoundDBStage(SoundEntryCollection, stageId); soundDBStage.SoundEntries = stageSoundEntries; SoundEntryCollection.SoundDBStages.Add(soundDBStage); } } } }