コード例 #1
0
        /// <summary>
        /// Load a layout file.
        /// </summary>
        /// <param name="in_szLayoutFileName">Layout file name</param>
        public void LoadLayout(string in_szLayoutFileName)
        {
            FilePackagerLayout layout = null;

            XmlReaderSettings readerSettings = new XmlReaderSettings();

            readerSettings.ValidationType = ValidationType.Schema;
            string szSchemaPath = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "/Package Layout/FilePackagerLayout.xsd";
            string fpl          = AkFilePackager.Properties.Resources.FilePackagerLayout;

            System.Xml.XmlTextReader stream = new System.Xml.XmlTextReader(new System.IO.StringReader(fpl));
            readerSettings.Schemas.Add(null, stream);

            using (XmlReader reader = XmlReader.Create(in_szLayoutFileName, readerSettings))
            {
                // Verify the schema version.
                reader.MoveToContent();
                if (reader.GetAttribute("SchemaVersion") != LAYOUT_SCHEMA_VERSION)
                {
                    throw new Exception("Wrong Layout file schema version.");
                }

                // Deserialize.
                System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(FilePackagerLayout));
                layout = (FilePackagerLayout)serializer.Deserialize(reader);
            }

            ClearLayout();
            System.Diagnostics.Debug.Assert(layout != null);
            m_layout = layout;

            // Update model.
            m_szCurrentPersistFile           = in_szLayoutFileName;
            m_settings.uDefaultBlockSize     = m_layout.DefaultBlockSize;
            m_settings.szFilePackageFilename = m_layout.OutputFileName;
            ReorderFiles();

            OnModelUpdate();
        }
コード例 #2
0
        /// <summary>
        /// Saves the current layout to disk.
        /// The name of the persistence file is stored in this class.
        /// </summary>
        public void SaveLayout()
        {
            System.Diagnostics.Debug.Assert(HasPersistFile);

            // Update layout.
            if (m_layout == null)
            {
                m_layout = new FilePackagerLayout();
            }
            m_layout.SchemaVersion    = uint.Parse(LAYOUT_SCHEMA_VERSION);
            m_layout.DefaultBlockSize = m_settings.uDefaultBlockSize;
            m_layout.OutputFileName   = m_settings.szFilePackageFilename;
            m_layout.FileList.Clear();
            foreach (OrderedFile file in m_arFileOrder)
            {
                AK.Wwise.FilePackager.PackageLayout.File laidOutFile = new AK.Wwise.FilePackager.PackageLayout.File();
                laidOutFile.Id       = file.Id;
                laidOutFile.Language = file.Language;
                laidOutFile.Type     = file.Type;
                // Mark model as laid out if not missing.
                if (file.Status == OrderedFile.StatusType.FileStatusNew)
                {
                    file.Status = OrderedFile.StatusType.FileStatusLaidOut;
                }
                m_layout.FileList.Add(laidOutFile);
            }


            // Serialize.
            System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(FilePackagerLayout));
            System.IO.FileStream fileStream = new System.IO.FileStream(m_szCurrentPersistFile, System.IO.FileMode.Create);
            serializer.Serialize(fileStream, m_layout);
            fileStream.Close();

            m_bIsLayoutDirty = false;
            OnModelUpdate();
        }