Esempio n. 1
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);
        }
Esempio n. 2
0
 /// <summary>
 /// Overrides the package settings with values stored herein, only
 /// when these values have been set explicitly by the user.
 /// </summary>
 /// <param name="io_settings">Package settings. Settings that were set explicitly are replaced.</param>
 public void OverrideSettingsWithCmdLine(ref PackageSettings io_settings)
 {
     if (m_bDefaultBlockSizeSpecified)
     {
         io_settings.uDefaultBlockSize = m_uDefaultBlockSize;
     }
     if (m_bFilePackagePathSpecified)
     {
         io_settings.szFilePackageFilename = m_szFilePackagePath;
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Update all view controls with the model.
        /// </summary>
        /// <param name="in_iFirstSelectedIndex">List item index to select/display</param>
        /// <param name="in_iNumSelectedIndices">Number of selected items (always contiguous)</param>
        /// <param name="in_bListChanged">True when list has changed (avoid refreshing it for nothing)</param>
        private void UpdateView(int in_iFirstSelectedIndex, int in_iNumSelectedIndices, bool in_bListChanged)
        {
            textBoxInfoFile.Text = (m_model.InfoFileName.Length > 0) ? m_model.InfoFileName : "<none>";

            PackageSettings settings = m_model.Settings;

            textBoxDefaultBlockSize.Text = settings.uDefaultBlockSize.ToString();
            textBoxOutputFilePath.Text   = settings.szFilePackageFilename;

            if (in_bListChanged)
            {
                listViewFiles.BeginUpdate();
                listViewFiles.Items.Clear();
                foreach (OrderedFile file in m_model.OrderedFiles)
                {
                    ListHelpers.AddOrderedFile(listViewFiles, file);
                }
                if (in_iNumSelectedIndices > 0)
                {
                    listViewFiles.Items[in_iFirstSelectedIndex + in_iNumSelectedIndices - 1].EnsureVisible();
                    for (int i = 0; i < in_iNumSelectedIndices; i++)
                    {
                        listViewFiles.Items[in_iFirstSelectedIndex + i].Selected = true;
                    }
                    listViewFiles.Items[in_iFirstSelectedIndex].EnsureVisible();
                }
                listViewFiles.EndUpdate();
            }

            // Window title.
            if (m_model.HasPersistFile)
            {
                this.Text = Program.APP_NAME + " - " + System.IO.Path.GetFileName(m_model.CurrentPersistFile);
                if (m_model.LayoutDirty)
                {
                    this.Text += " *";
                }
            }

            closeLayoutToolStripMenuItem.Enabled         = m_model.HasLayoutEdited;
            generateFilePackageToolStripMenuItem.Enabled = m_model.CanPerformPackaging;
        }
Esempio n. 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);
        }