Пример #1
0
 /// <summary>
 /// Copy sound info.
 /// </summary>
 /// <param name="s">Other sound info.</param>
 public void CopySoundInfo(SoundInfo s)
 {
     Name              = s.Name;
     File              = s.File;
     Sound3dInfo       = s.Sound3dInfo;
     Player            = s.Player;
     Volume            = s.Volume;
     RemoteFilter      = s.RemoteFilter;
     PanMode           = s.PanMode;
     PanCurve          = s.PanCurve;
     PlayerActorId     = s.PlayerActorId;
     PlayerPriority    = s.PlayerPriority;
     IsFrontBypass     = s.IsFrontBypass;
     UserParamsEnabled = s.UserParamsEnabled;
     UserParameter     = s.UserParameter;
 }
Пример #2
0
        /// <summary>
        /// Add a new sound file, and return it.
        /// </summary>
        /// <param name="type">New file entry type.</param>
        /// <param name="lastEntry">Last entry.</param>
        /// <param name="file">File to add.</param>
        /// <param name="keepReference">Whether or not to keep the reference to the ISoundFile provided.</param>
        /// <param name="externalPath">Use this if the file is a stream.</param>
        /// <returns>The new file.</returns>
        public SoundFile <ISoundFile> AddNewFile(NewFileEntryType type, int lastEntry, ISoundFile file, bool keepReference = false, string externalPath = null)
        {
            //Get proper file.
            ISoundFile f = file;

            if (f != null && !keepReference)
            {
                MemoryStream     o  = new MemoryStream();
                BinaryDataWriter bw = new BinaryDataWriter(o);
                file.Write(WriteMode, bw);
                f = SoundArchiveReader.ReadFile(o.ToArray());
                try { bw.Dispose(); } catch { }
                try { o.Dispose(); } catch { }
            }

            int index = 0;

            switch (type)
            {
            //Stream.
            case NewFileEntryType.Stream:
                while (lastEntry >= 0)
                {
                    if (Streams[lastEntry].File == null)
                    {
                        lastEntry--;
                    }
                    else
                    {
                        index = Streams[lastEntry].File.FileId + 1;
                        break;
                    }
                }
                break;

            //Wave sound data.
            case NewFileEntryType.WaveSoundData:
                while (lastEntry >= 0)
                {
                    if (WaveSoundDatas[lastEntry].File == null)
                    {
                        lastEntry--;
                    }
                    else
                    {
                        index = WaveSoundDatas[lastEntry].File.FileId + 1;
                        break;
                    }
                }
                break;

            //Sequence.
            case NewFileEntryType.Sequence:
                while (lastEntry >= 0)
                {
                    if (Sequences[lastEntry].File == null)
                    {
                        lastEntry--;
                    }
                    else
                    {
                        index = Sequences[lastEntry].File.FileId + 1;
                        break;
                    }
                }
                break;

            //Bank.
            case NewFileEntryType.Bank:
                while (lastEntry >= 0)
                {
                    if (Banks[lastEntry].File == null)
                    {
                        lastEntry--;
                    }
                    else
                    {
                        index = Banks[lastEntry].File.FileId + 1;
                        break;
                    }
                }
                break;

            //Wave archive.
            case NewFileEntryType.WaveArchive:
                while (lastEntry >= 0)
                {
                    if (WaveArchives[lastEntry].File == null)
                    {
                        lastEntry--;
                    }
                    else
                    {
                        index = WaveArchives[lastEntry].File.FileId + 1;
                        break;
                    }
                }
                break;

            //Group.
            case NewFileEntryType.Group:
                while (lastEntry >= 0)
                {
                    if (Groups[lastEntry].File == null)
                    {
                        lastEntry--;
                    }
                    else
                    {
                        index = Groups[lastEntry].File.FileId + 1;
                        break;
                    }
                }
                break;

            //Prefech.
            case NewFileEntryType.Prefetch:
                while (lastEntry >= 0)
                {
                    if (Streams[lastEntry].PrefetchFile == null)
                    {
                        lastEntry--;
                    }
                    else
                    {
                        index = Streams[lastEntry].PrefetchFile.FileId + 1;
                        break;
                    }
                }
                break;
            }

            //Insert file at the proper index.
            var filef = new SoundFile <ISoundFile>()
            {
                ExternalFileName = externalPath, File = f, FileType = (externalPath == null ? EFileType.Internal : EFileType.External)
            };

            if (externalPath != null)
            {
                filef.BackupExtension = "stm";
            }
            Files.Insert(index, filef);

            //Recreate file Ids.
            RecreateFileIds();

            //Programmed to fail if it messes up.
            return(Files[index]);
        }
Пример #3
0
 /// <summary>
 /// New bank entry.
 /// </summary>
 public BankEntry()
 {
     File = new SoundFile <ISoundFile>();
 }