public SoundEntry CreateSoundEntry()
        {
            SoundEntry sEntry = new SoundEntry(this);

            sEntry.SoundID = GetNewSoundID();
            sEntry.BGMFiles.Add(new SoundEntryBGM(this, sEntry, 0x450));
            sEntry.InSoundTest  = true;
            sEntry.Byte2        = true;
            sEntry.Byte3        = true;
            sEntry.Byte4        = false;
            sEntry.InRegionEUUS = true;
            sEntry.InRegionJPN  = true;
            sEntry.SoundSource  = SoundSource.CoreGameSound;
            sEntry.SoundMixType = SoundMixType.Original;
            sEntry.IconID       = 0x0; //smashbros
            sEntry.SoundTestBackImageBehavior = SoundTestBackImageBehavior.RosterRandom;
            sEntry.SoundTestOrder             = 999;
            sEntry.StageCreationOrder         = 999;
            sEntry.StageCreationGroupID       = 0x0; //smashbros
            sEntry.Int17 = 0x0;

            sEntry.Title          = Strings.DEFAULT_SENTRY_TITLE;
            sEntry.SoundTestTitle = Strings.DEFAULT_SENTRY_TITLE2;
            sEntry.Description    = string.Empty;
            sEntry.Description2   = string.Empty;
            sEntry.Source         = string.Empty;

            _SoundEntries.Add(sEntry);
            _SoundEntries.Sort((x, y) => x.SoundID.CompareTo(y.SoundID));
            _SoundEntriesPerID.Add(sEntry.SoundID, sEntry);

            return(sEntry);
        }
        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);
        }
Esempio n. 3
0
        private SoundEntry ParseSoundEntry(BinaryReader b, int id)
        {
            SoundEntry sEntry = new SoundEntry(SoundEntryCollection);

            //Sound Index
            sEntry.SoundID = id; //Important, has apparently something to do with unlock conditions.

            //Sound BGM (up to 5)
            for (int i = 0; i < 5; i++)
            {
                int bgmID = ReadInt32(b);
                if (bgmID != 0x0)
                {
                    sEntry.BGMFiles.Add(new SoundEntryBGM(SoundEntryCollection, sEntry, bgmID));
                }
            }

            //Flags?
            sEntry.InSoundTest  = ReadBool(b);
            sEntry.Byte2        = ReadBool(b);
            sEntry.Byte3        = ReadBool(b);
            sEntry.Byte4        = ReadBool(b);
            sEntry.InRegionJPN  = ReadBool(b);
            sEntry.InRegionEUUS = ReadBool(b);

            //Properties
            sEntry.SoundSource  = ReadSourceSound(b);
            sEntry.SoundMixType = ReadMixType(b);
            sEntry.IconID       = ReadInt32(b);
            sEntry.SoundTestBackImageBehavior = ReadSoundTestBackImageBehavior(b);

            int nbrAssociatedCharacters = ReadInt32(b);

            for (int i = 0; i < 8; i++)
            {
                int fighterID = ReadInt32(b);
                if (fighterID != -1)
                {
                    sEntry.AssociatedFightersIDs.Add(fighterID);
                }
            }

            sEntry.OriginalSoundLabel = ReadString(b);

            sEntry.SoundTestOrder       = ReadOrder(b);
            sEntry.StageCreationOrder   = ReadOrder(b);
            sEntry.StageCreationGroupID = ReadInt32(b);

            sEntry.Int17 = ReadInt16(b);

            return(sEntry);
        }
Esempio n. 4
0
        private void WriteSoundEntry(BinaryWriter w, SoundEntry sEntry)
        {
            WriteInt32BigEndian(w, sEntry.SoundID);

            for (int i = 0; i < 5; i++)
            {
                if (sEntry.BGMFiles.Count > i)
                {
                    WriteInt32BigEndian(w, sEntry.BGMFiles[i].BGMID);
                }
                else
                {
                    WriteInt32BigEndian(w, 0);
                }
            }

            WriteBool(w, sEntry.InSoundTest);
            WriteBool(w, sEntry.Byte2);
            WriteBool(w, sEntry.Byte3);
            WriteBool(w, sEntry.Byte4);
            WriteBool(w, sEntry.InRegionJPN);
            WriteBool(w, sEntry.InRegionEUUS);

            WriteInt32BigEndian(w, (int)sEntry.SoundSource);
            WriteInt32BigEndian(w, (int)sEntry.SoundMixType);
            WriteInt32BigEndian(w, sEntry.IconID);
            WriteInt32BigEndian(w, (int)sEntry.SoundTestBackImageBehavior);

            WriteInt32BigEndian(w, sEntry.AssociatedFightersIDs.Count);
            for (int i = 0; i < 8; i++)
            {
                if (sEntry.AssociatedFightersIDs.Count > i)
                {
                    WriteInt32BigEndian(w, sEntry.AssociatedFightersIDs[i]);
                }
                else
                {
                    WriteInt32BigEndian(w, -1);
                }
            }

            WriteString(w, sEntry.SoundLabel);

            WriteInt32BigEndian(w, sEntry.SoundTestOrder);
            WriteInt32BigEndian(w, sEntry.StageCreationOrder);
            WriteInt32BigEndian(w, sEntry.StageCreationGroupID);

            WriteInt16BigEndian(w, sEntry.Int17);
        }
Esempio n. 5
0
        private void WriteDummySoundEntry(BinaryWriter w, int id)
        {
            SoundEntry sEntry = new SoundEntry(SoundEntryCollection);

            sEntry.SoundID = id;
            sEntry.BGMFiles.Add(new SoundEntryBGM(SoundEntryCollection, sEntry, 0x450));
            sEntry.SoundSource                = SoundSource.CoreGameSound;
            sEntry.SoundMixType               = SoundMixType.Original;
            sEntry.IconID                     = -1;
            sEntry.StageCreationGroupID       = -1;
            sEntry.SoundTestOrder             = 999;
            sEntry.StageCreationOrder         = 999;
            sEntry.SoundTestBackImageBehavior = SoundTestBackImageBehavior.NULL;

            WriteSoundEntry(w, sEntry);
        }
        public void RemoveSoundEntry(int soundID)
        {
            if (_SoundEntriesPerID.ContainsKey(soundID))
            {
                SoundEntry sEntry = _SoundEntriesPerID[soundID];

                //Delete SoundEntry in stages
                foreach (SoundDBStage soundDBStage in _SoundDBStages)
                {
                    SoundDBStageSoundEntry sStageEntry = soundDBStage.SoundEntries.Find(p => p.SoundEntry.SoundID == sEntry.SoundID);
                    if (sStageEntry != null)
                    {
                        soundDBStage.SoundEntries.Remove(sStageEntry);
                    }
                }

                //Delete in SoundDB
                _SoundEntriesPerID.Remove(soundID);
                _SoundEntries.Remove(sEntry);
            }
        }
Esempio n. 7
0
 public SoundEntryBGM(SoundEntryCollection soundEntryCollection, SoundEntry sEntry, int bgmID)
 {
     SoundEntryCollection = soundEntryCollection;
     BGMID      = bgmID;
     SoundEntry = sEntry;
 }
Esempio n. 8
0
        public UISoundDBFile(Sm4shProject projectManager, SoundEntryCollection sEntryCollection, string path)
        {
            string 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);
                    }
                }
            }
        }
Esempio n. 9
0
        private void SetNewMSBTPerSoundEntry(SortedDictionary <string, MSBTVariable> newMSBTDB, SoundEntry sEntry)
        {
            MSBTVariable newTitle        = new MSBTVariable(VAR_TITLE + sEntry.SoundLabel, sEntry.Title.Replace(Environment.NewLine, "\n"));
            MSBTVariable newTitle2       = new MSBTVariable(VAR_TITLE2 + sEntry.SoundLabel, sEntry.SoundTestTitle.Replace(Environment.NewLine, "\n"));
            MSBTVariable newDescription  = new MSBTVariable(VAR_DESCRIPTION + sEntry.SoundLabel, sEntry.Description.Replace(Environment.NewLine, "\n"));
            MSBTVariable newDescription2 = new MSBTVariable(VAR_DESCRIPTION2 + sEntry.SoundLabel, sEntry.Description2.Replace(Environment.NewLine, "\n"));
            MSBTVariable newSource       = new MSBTVariable(VAR_SOURCE + sEntry.SoundLabel, sEntry.Source.Replace(Environment.NewLine, "\n"));

            newMSBTDB.Add(newTitle.Name, newTitle);
            newMSBTDB.Add(newTitle2.Name, newTitle2);
            newMSBTDB.Add(newDescription.Name, newDescription);
            newMSBTDB.Add(newDescription2.Name, newDescription2);
            newMSBTDB.Add(newSource.Name, newSource);
        }