示例#1
0
        /// <summary>
        /// Data model helper: Search the model for all languages, create an ID dynamically for each language.
        /// </summary>
        /// <param name="in_infoDOM">Data model.</param>
        /// <returns>A hash [LanguageNameString, GeneratedLanguageID]</returns>
        static internal Dictionary <string, uint> FindAllLanguages(SoundBanksInfo in_infoDOM)
        {
            Dictionary <string, uint> mapLanguages = new Dictionary <string, uint>();
            uint uID = AK_INVALID_LANGUAGE_ID;

            mapLanguages.Add("SFX", uID);

            // Search languages in streamed files.
            foreach (AK.Wwise.FilePackager.InfoFile.File streamedFile in in_infoDOM.StreamedFiles.FileCollection)
            {
                string szLanguage = streamedFile.Language;
                if (!mapLanguages.ContainsKey(szLanguage))
                {
                    ++uID;
                    mapLanguages.Add(szLanguage, uID);
                }
            }

            // Search languages in soundbanks.
            foreach (SoundBank soundBank in in_infoDOM.SoundBanks.SoundBankCollection)
            {
                string szLanguage = soundBank.Language;
                if (!mapLanguages.ContainsKey(szLanguage))
                {
                    ++uID;
                    mapLanguages.Add(szLanguage, uID);
                }
            }

            return(mapLanguages);
        }
示例#2
0
        /// <summary>
        /// Generate a file package.
        /// </summary>
        /// <param name="in_soundbanksInfo">Soundbanks data model.</param>
        /// <param name="in_settings">Generation settings.</param>
        /// <param name="in_szOutputFileName">Full path of the file package to be created.</param>
        /// <returns>Returns true when no files are missing.</returns>
        public bool Generate(SoundBanksInfo in_soundbanksInfo, PackageSettings in_settings, List <OrderedFile> in_listOrderedFiles)
        {
            // Open output file.
            FileStream file = new FileStream(in_settings.szFilePackageFilename, FileMode.Create);

            // Create the writer for data.
            FilePackageWriter.Endianness eEndianness;
            switch (in_soundbanksInfo.Platform)
            {
            case Platform.Windows:
                eEndianness = FilePackageWriter.Endianness.LittleEndian;
                break;

            default:
                eEndianness = FilePackageWriter.Endianness.BigEndian;
                break;
            }
            FilePackageWriter writer = new FilePackageWriter(file, eEndianness);

            // Generate the file package.
            bool bAllFilesExist = GeneratePackage(in_soundbanksInfo, in_settings, writer, in_listOrderedFiles);

            writer.Close();
            file.Close();

            return(bAllFilesExist);
        }
示例#3
0
        public int Generate(string in_szInfoFile, string in_szLayoutFile, CmdLinePackageSettings in_cmdLineSettings, bool in_bHideProgressUI, string in_szSpecifiedLanguage)
        {
            FilePackageGenerator generator = new FilePackageGenerator();

            // Display the progress bar (and log) only if the verbose switch was specified.
            if (!in_bHideProgressUI)
            {
                m_progressDlg = new Progress();

                generator.StepChange += m_progressDlg.ProgressStepHandler;
                generator.SubStep    += m_progressDlg.StepHandler;
                generator.LogMsg     += m_progressDlg.LogMsgHandler;

                m_progressDlg.StopRequested += generator.StopRequestedHandler;
                m_progressDlg.Closed        += new EventHandler(OnUIClosed);

                m_progressDlg.Show();
            }

            int iReturn = 0;

            try
            {
                // In order to successfully start packaging:
                // - an info file must have been specified;
                // - either the file package name OR a layout file must have been specified.
                if (in_szInfoFile.Length > 0 &&
                    (in_cmdLineSettings.FilePackagePathSpecified || in_szLayoutFile.Length > 0))
                {
                    SoundBanksInfo data = InfoFileHelpers.LoadInfoFile(in_szInfoFile, in_szSpecifiedLanguage);
                    if (data != null)
                    {
                        PackageSettings    settings;
                        List <OrderedFile> listOrderedFiles = null;
                        if (in_szLayoutFile.Length > 0)
                        {
                            PackagingEditorModel layoutModel = new PackagingEditorModel();
                            layoutModel.LoadLayout(in_szLayoutFile);

                            listOrderedFiles = layoutModel.OrderedFiles;
                            settings         = layoutModel.Settings;

                            // Override layout's settings with each command line setting that was specified.
                            in_cmdLineSettings.OverrideSettingsWithCmdLine(ref settings);
                        }
                        else
                        {
                            settings = in_cmdLineSettings.GetSettings();
                        }

                        bool bNoFileMissing = generator.Generate(data, settings, listOrderedFiles);

                        // Do not display warning if the user does not wish to see UI.
                        if (m_progressDlg != null)
                        {
                            if (!bNoFileMissing)
                            {
                                m_progressDlg.LogMsg("WARNING: some files referenced in " + in_szInfoFile + " could not be found.");
                            }
                            m_progressDlg.LogMsg("SUCCESSFUL file package generation: " + settings.szFilePackageFilename);
                        }
                    }
                }
                else
                {
                    string szInvalidParam = "";
                    if (in_szInfoFile.Length == 0)
                    {
                        szInvalidParam = "No info file specified (-info).\n";
                    }
                    if (!in_cmdLineSettings.FilePackagePathSpecified || in_szLayoutFile.Length == 0)
                    {
                        szInvalidParam += "Neither the output file path (-output) or a layout file (-layout) was specified.\n";
                    }
                    throw new Exception("Some of the required input parameters are not valid:\n" + szInvalidParam);
                }
            }
            catch (Exception ex)
            {
                if (m_progressDlg != null)
                {
                    m_progressDlg.LogMsg("File packaging FAILED! " + ex.Message);
                    MessageBox.Show("File packaging FAILED!\n\n" + ex.Message, Program.APP_NAME);
                }
                iReturn = 1;
            }

            if (m_progressDlg != null)
            {
                // Has UI. Let user know that it should run the message loop until the user closes the form.
                m_progressDlg.Finished();
                m_bRunApplicationLoop = true;
            }
            else
            {
                // No UI. Let user know that it does not need to start the message loop.
                m_bRunApplicationLoop = false;
            }

            return(iReturn);
        }
示例#4
0
        /// <summary>
        /// Generate the file package.
        /// Creates the package header:
        /// - Header
        /// - Map of language strings
        /// - Map of soundbank titles
        /// - Soundbank files LUT
        /// - Streamed audio files LUT
        /// Writes the header to file.
        /// Concatenates files referenced in the LUTs.
        /// </summary>
        /// <param name="in_soundbanksInfo">Soundbank data model.</param>
        /// <param name="in_settings">Generation settings.</param>
        /// <param name="in_writer">Binary writer.</param>
        /// <returns>Returns true when no files are missing.</returns>
        internal bool GeneratePackage(SoundBanksInfo in_soundbanksInfo, PackageSettings in_settings, FilePackageWriter in_writer, List <OrderedFile> in_listOrderedFiles)
        {
            bool bNoFilesMissing = true;

            const int    kNumSubStepsHeader = 6;
            const string kHeaderStepName    = "Generating header";

            OnStepChange(kNumSubStepsHeader, kHeaderStepName);

            // Header chunk.
            Header header = new Header();

            OnSubStep();

            // Language names map.
            Dictionary <string, uint> mapLanguageIDs = FindAllLanguages(in_soundbanksInfo);
            LanguagesMap langMap = new LanguagesMap(mapLanguageIDs);

            OnSubStep();

            // Banks LUT.
            FileLUT banksLUT = new FileLUT(in_settings.uDefaultBlockSize);

            foreach (FileDescriptorType soundbank in in_soundbanksInfo.SoundBanks.SoundBankCollection)
            {
                if (!banksLUT.Add(soundbank, mapLanguageIDs))
                {
                    bNoFilesMissing = false;
                }
            }
            banksLUT.Sort();
            OnSubStep();

            // Steamed files LUT.
            FileLUT streamsLUT = new FileLUT(in_settings.uDefaultBlockSize);

            foreach (FileDescriptorType stream in in_soundbanksInfo.StreamedFiles.FileCollection)
            {
                if (!streamsLUT.Add(stream, mapLanguageIDs))
                {
                    bNoFilesMissing = false;
                }
            }
            streamsLUT.Sort();
            OnSubStep();

            // Find the header size.
            uint uHeaderSize =
                header.SizeOnDisk +
                langMap.MapSizeSize +
                banksLUT.LUTSizeSize +
                streamsLUT.LUTSizeSize +
                langMap.TotalSize +
                banksLUT.TotalSize +
                streamsLUT.TotalSize;

            // Prepare files for ordered concatenation.
            FileOrganizer organizer = new FileOrganizer();

            organizer.AddLUT(AK.Wwise.FilePackager.PackageLayout.Type.SoundBank, banksLUT);
            organizer.AddLUT(AK.Wwise.FilePackager.PackageLayout.Type.StreamedAudio, streamsLUT);
            organizer.OrganizeFiles(uHeaderSize, in_listOrderedFiles, mapLanguageIDs, this);
            OnSubStep();


            // Set header size.
            header.HeaderSize = uHeaderSize;


            // Write to output file:

            // Header.
            header.Write(in_writer);
            in_writer.Write(langMap.TotalSize);
            in_writer.Write(banksLUT.TotalSize);
            in_writer.Write(streamsLUT.TotalSize);

            langMap.Write(in_writer);
            banksLUT.Write(in_writer);
            streamsLUT.Write(in_writer);
            OnSubStep();


            // Concatenated files.
            const string kConcatenateStepName = "Concatenating files";

            OnStepChange((int)(banksLUT.NumFiles + streamsLUT.NumFiles), kConcatenateStepName);
            organizer.ConcatenateFiles(in_writer, this);

            return(bNoFilesMissing);
        }