Example #1
0
        public void ConcatenateFiles(FilePackageWriter in_writer, IProgressNotificationsDispatcher in_notifDispatcher)
        {
            foreach (FileLUT.IncludedFile file in m_arOrganizedFileEntries)
            {
                // Add padding so that next file falls on a block boundary.
                PadToBlock(in_writer, file.uBlockSize, in_writer.Position);

                // At this point we know the file exists.
                System.Diagnostics.Debug.Assert(file.szPath.Length > 0 && System.IO.File.Exists(file.szPath));

                in_notifDispatcher.NotifyLogMsg("Copying file " + file.szPath);

                // Copy file.
                in_writer.Write(System.IO.File.ReadAllBytes(file.szPath));

                in_notifDispatcher.NotifySubstep();
            }
        }
Example #2
0
        public void OrganizeFiles(
            ulong in_uDataOffset,
            IEnumerable <FilePackageGenerator.Context.PackageItem> in_ordered,
            Dictionary <string, uint> in_mapLanguages,
            IProgressNotificationsDispatcher in_notifDispatcher)
        {
            // Build list of files based on specified file order.
            if (in_ordered != null)
            {
                foreach (FilePackageGenerator.Context.PackageItem item in in_ordered)
                {
                    string   language = "SFX";
                    string   name     = string.Empty;
                    UInt64   itemId   = 0;
                    FileType fileType = FileType.SoundBank;
                    if (item.ExternalSourceInfo != null)
                    {
                        fileType = FileType.ExternalSource;
                        itemId   = item.ExternalSourceInfo.Id;
                        name     = item.ExternalSourceInfo.Name;
                    }
                    else if (item.Descriptor != null)
                    {
                        language = item.Descriptor.Language;
                        itemId   = item.Descriptor.Id;
                        name     = item.Descriptor.ShortName;
                        if (item.Descriptor.GetType() == typeof(AK.Wwise.InfoFile.SoundBanksInfoStreamedFiles))
                        {
                            fileType = FileType.StreamedAudio;
                        }
                        else if (item.Descriptor.GetType() == typeof(AK.Wwise.InfoFile.SoundBanksInfoMediaFilesNotInAnyBank))
                        {
                            fileType = FileType.LooseMedia;
                        }
                    }

                    // Select proper LUT.
                    FileLUT lut = m_arFileLUTs[CategoryForType(fileType)];

                    // Find file (binary search: files in LUTs are sorted in ID/LanguageID.
                    uint uLanguageID;
                    if (in_mapLanguages.TryGetValue(language, out uLanguageID))
                    {
                        int iFileIndex = lut.FindEntry(itemId, uLanguageID);
                        if (iFileIndex >= 0)
                        {
                            FileLUT.IncludedFile file = lut.GetAt(iFileIndex);

                            // File was laid out.
                            // Set starting block, mark as ready.
                            AddOrganizedFile(file, ref in_uDataOffset);
                        }
                    }
                    else
                    {
                        // Invalid language.
                        in_notifDispatcher.NotifyLogMsg("WARNING: File " + name + " specified in the layout has invalid language + " + language + ".", Severity.Warning);
                    }
                }
            }

            // Default logic: add files of all LUTs in order.

            // Set each file's starting block.
            foreach (FileLUT lut in m_arFileLUTs.Values)
            {
                foreach (FileLUT.IncludedFile file in lut)
                {
                    if (!file.Included)
                    {
                        AddOrganizedFile(file, ref in_uDataOffset);
                    }
                }
            }
        }
Example #3
0
        public IEnumerable <NamedAction> ConcatenateFiles(FilePackageWriter in_writer, IProgressNotificationsDispatcher in_notifDispatcher)
        {
            List <NamedAction> actions = new List <NamedAction>();

            foreach (OrganizedFile file in m_arOrganizedFileEntries)
            {
                string path      = file.szPath;
                uint   blockSize = file.uBlockSize;

                actions.Add(new NamedAction("Writing " + path, delegate()
                {
                    // Add padding so that next file falls on a block boundary.
                    PadToBlock(in_writer, blockSize, in_writer.Position);

                    // At this point we know the file exists.
                    System.Diagnostics.Debug.Assert(path.Length > 0 && System.IO.File.Exists(path));

                    in_notifDispatcher.NotifyLogMsg("Packing: " + path, Severity.Message);

                    // Copy file.
                    in_writer.Write(System.IO.File.ReadAllBytes(path));
                }));
            }

            return(actions);
        }
Example #4
0
        public void OrganizeFiles(ulong in_uDataOffset, List <OrderedFile> in_listOrderedFiles, Dictionary <string, uint> in_mapLanguages, IProgressNotificationsDispatcher in_notifDispatcher)
        {
            // Build list of files based on specified file order.
            if (in_listOrderedFiles != null)
            {
                foreach (OrderedFile orderedFile in in_listOrderedFiles)
                {
                    // Select proper LUT.
                    FileLUT lut = m_arFileLUTs[orderedFile.Type];

                    // Find file (binary search: files in LUTs are sorted in ID/LanguageID.
                    uint uLanguageID;
                    if (in_mapLanguages.TryGetValue(orderedFile.Language, out uLanguageID))
                    {
                        int iFileIndex = lut.FindEntry(orderedFile.Id, uLanguageID);
                        if (iFileIndex >= 0)
                        {
                            FileLUT.IncludedFile file = lut.GetAt(iFileIndex);

                            // File was laid out.
                            // Set starting block, mark as ready.
                            AddOrganizedFile(file, ref in_uDataOffset);
                        }
                        else
                        {
                            // File specified in layout is not in the LUT.
                            in_notifDispatcher.NotifyLogMsg("WARNING: File " + orderedFile.ShortName + " specified in the layout is missing.");
                        }
                    }
                    else
                    {
                        // Invalid language.
                        in_notifDispatcher.NotifyLogMsg("WARNING: File " + orderedFile.ShortName + " specified in the layout has invalid language + " + orderedFile.Language + ".");
                    }
                }
            }

            // Default logic: add files of all LUTs in order.

            // Set each file's starting block.
            foreach (FileLUT lut in m_arFileLUTs.Values)
            {
                foreach (FileLUT.IncludedFile file in lut)
                {
                    if (!file.Included)
                    {
                        AddOrganizedFile(file, ref in_uDataOffset);
                    }
                }
            }
        }