Beispiel #1
0
 public void WriteXml(XmlNode parentNode, string name = "position")
 {
     SRXmlNodeWriter writer = new SRXmlNodeWriter(parentNode, name);
     writer.Write("x", x);
     writer.Write("y", y);
     writer.Write("z", z);
 }
 public void WriteXml(XmlNode parentNode)
 {
     SRXmlNodeWriter writer = new SRXmlNodeWriter(parentNode, "orientation");
     writer.Write("x", x);
     writer.Write("y", y);
     writer.Write("z", z);
     writer.Write("w", w);
 }
Beispiel #3
0
 /// <summary>
 /// Writes the data block to an XML document.
 /// This may add one or more nodes to the given parentNode.
 /// </summary>
 /// <param name="parentNode">XML node to add this data block to.</param>
 /// <param name="index">Optional index attribute.</param>
 public override void WriteXml(XmlNode parentNode)
 {
     SRXmlNodeWriter writer = new SRXmlNodeWriter(parentNode, XmlTagName);
     writer.WriteHex("signature", signature);
     writer.Write("version", version);
     writer.Write("ref_data_start", refDataStart);
     writer.Write("unknown", unknown);
     SRXmlNodeWriter referenceDataWriter = new SRXmlNodeWriter(writer, "references");
     for (int i = 0; i < referenceData.Count; i++)
         referenceDataWriter.Write("reference", referenceData[i], i + 1);
 }
 // See description of this method in the abstract base class SRZoneProperty.
 protected override void WriteXmlData(XmlNode thisNode)
 {
     SRXmlNodeWriter writer = new SRXmlNodeWriter(thisNode);
     writer.Write("string", value);
 }
 /// <summary>
 /// Writes the data block to an XML document.
 /// </summary>
 /// <param name="parentNode">XML node to add this data block to.</param>
 /// <param name="index">Index within a sequence (starts at 0).</param>
 public override void WriteXml(XmlNode parentNode, int index)
 {
     try
     {
         SRXmlNodeWriter writer = new SRXmlNodeWriter(parentNode, XmlTagName, index + 1);
         writer.Write("file", name);
         writer.Write("pos_x", MeshPosToFloat(m_pos_x));
         writer.Write("pos_y", MeshPosToFloat(m_pos_y));
         writer.Write("pos_z", MeshPosToFloat(m_pos_z));
         writer.Write("pitch", MeshOrientToFloat(pitch));
         writer.Write("bank", MeshOrientToFloat(bank));
         writer.Write("heading", MeshOrientToFloat(heading));
     }
     catch (Exception e)
     {
         // Add context information for the error message
         if (index >= 0)
             e.Data[BlockName] = index + 1;
         throw;
     }
 }
Beispiel #6
0
        /// <summary>
        /// Writes the data block to an XML document.
        /// </summary>
        /// <param name="parentNode">XML node to add this data block to.</param>
        /// <param name="index">Index within a sequence (starts at 0).</param>
        public override void WriteXml(XmlNode parentNode, int index)
        {
            try
            {
                SRXmlNodeWriter writer = new SRXmlNodeWriter(parentNode, XmlTagName, index + 1);

                writer.Write("name", name != null ? name : "");
                writer.WriteHex("handle", handleOffset);
                writer.WriteHex("parent_handle", parentHandleOffset);
                writer.WriteHex("object_type_hash", objectTypeHash);
                writer.Write("padding", padding);

                XmlNode propertiesNode = writer.CreateNode("properties");
                int i = 0;
                foreach (SRZoneProperty property in propertyList)
                    property.WriteXml(propertiesNode, i++);
            }
            catch (Exception e)
            {
                // Add context information for the error message
                if (index >= 0)
                    e.Data[BlockName] = index + 1;
                throw;
            }
        }
Beispiel #7
0
        /// <summary>
        /// Writes the section block to an XML document.
        /// </summary>
        /// <param name="parentNode">XML node to add this section to.</param>
        /// <param name="index">Index within a sequence (starts at 0).</param>
        public override void WriteXml(XmlNode parentNode, int index)
        {
            try
            {
                SRXmlNodeWriter writer = new SRXmlNodeWriter(parentNode, XmlTagName, index + 1);

                writer.WriteHex("id", sectionID);
                if (HasDescription())
                    writer.Write("description", Description());
                if (HasGPUData())
                    writer.Write("gpu_size", gpuSize);
                if (cpuData != null)
                    cpuData.WriteXml(writer.CreateNode("cpu_data"));
            }
            catch (Exception e)
            {
                // Add context information for the error message
                if (index >= 0)
                    e.Data[BlockName] = index + 1;
                throw;
            }
        }
 /// <summary>
 /// Writes the data block to an XML document.
 /// This may add one or more nodes to the given parentNode.
 /// </summary>
 /// <param name="parentNode">XML node to add this data block to.</param>
 /// <param name="index">Optional index attribute.</param>
 public override void WriteXml(XmlNode parentNode)
 {
     SRXmlNodeWriter writer = new SRXmlNodeWriter(parentNode, XmlTagName);
     writer.Write("signature", signature);
     writer.Write("version", version);
     fileReferenceOffset.WriteXml(writer.Node, "file_reference_offset");
     writer.WriteHex("file_references_ptr", fileReferencesPtr);
     writer.Write("zone_type", zoneType);
     string zoneTypeName = (zoneType < WorldZoneTypeNames.Length) ? WorldZoneTypeNames[zoneType] : "unknown";
     writer.Write("zone_type_description", zoneTypeName);    // informational only
     SRXmlNodeWriter referenceDataWriter = new SRXmlNodeWriter(writer, "mesh_file_references");
     for (int i = 0; i < references.Count; i++)
         references[i].WriteXml(referenceDataWriter.Node, i);
 }
        /// <summary>
        /// Writes the data block to an XML document.
        /// This may add one or more nodes to the given parentNode.
        /// </summary>
        /// <param name="parentNode">XML node to add this data block to.</param>
        /// <param name="index">Optional index attribute.</param>
        public override void WriteXml(XmlNode parentNode)
        {
            int index;

            SRXmlNodeWriter writer = new SRXmlNodeWriter(parentNode, XmlTagName);

            writer.WriteHex("signature", signature);
            writer.Write("version", version);
            writer.WriteHex("flags", flags);
            writer.WriteHex("handle_list_pointer", handleListPointer);
            writer.WriteHex("object_data_pointer", objectDataPointer);
            writer.Write("object_data_size", objectDataSize);

            SRXmlNodeWriter handleWriter = new SRXmlNodeWriter(writer, "handles");
            index = 0;
            foreach (UInt64 handle in handleList)
                handleWriter.WriteHex("handle", handle, ++index);

            XmlNode objectsNode = writer.CreateNode("objects");
            index = 0;
            foreach (SRZoneObject srObject in objectList)
                srObject.WriteXml(objectsNode, index++);
        }
Beispiel #10
0
 /// <summary>
 /// Writes the data block to an XML document.
 /// </summary>
 /// <param name="parentNode">XML node to add this data block to.</param>
 /// <param name="index">Index within a sequence (starts at 0).</param>
 public override void WriteXml(XmlNode parentNode, int index)
 {
     try
     {
         SRXmlNodeWriter writer = new SRXmlNodeWriter(parentNode, XmlTagName, index + 1);
         writer.Write("type", Type);
         string typeName = (Type < PropertyTypeNames.Length) ? PropertyTypeNames[Type] : "unknown";
         writer.Write("type_description", typeName);
         writer.WriteHex("name_crc", nameCrc);
         WriteXmlData(writer.CreateNode("value"));
         if (paddingData != null)
             paddingData.WriteXml(writer.CreateNode("padding"));
     }
     catch (Exception e)
     {
         // Add context information for the error message
         if (index >= 0)
             e.Data[BlockName] = index + 1;
         throw;
     }
 }
        /// <summary>
        /// Writes the zone file to an XML file.
        /// </summary>
        /// <param name="xmlFile">File system path to the XML file to be created.</param>
        public void WriteXmlFile(string xmlFile)
        {
            try
            {
                XmlDocument xmlDocument = new XmlDocument();
                XmlElement xmlRoot = xmlDocument.CreateElement("root");
                xmlDocument.AppendChild(xmlRoot);

                // Write the tool version number (major.minor version determines XML format)
                SRXmlNodeWriter nodeWriter = new SRXmlNodeWriter(xmlRoot, "srzonetool");
                Assembly assem = Assembly.GetEntryAssembly();
                AssemblyName assemName = assem.GetName();
                Version ver = assemName.Version;
                nodeWriter.Write("version", ver.Major + "." + ver.Minor);

                // Write the zone header section, if there is one
                if (vFileHeader != null && worldZoneHeader != null)
                {
                    XmlElement czhFileNode = xmlDocument.CreateElement(XmlZoneHeaderTagName);
                    xmlRoot.AppendChild(czhFileNode);
                    vFileHeader.WriteXml(czhFileNode);
                    worldZoneHeader.WriteXml(czhFileNode);
                }

                // Write the zone data section, if there is one
                if (sectionList != null)
                {
                    XmlElement cznFileNode = xmlDocument.CreateElement(XmlZoneDataTagName);
                    xmlRoot.AppendChild(cznFileNode);
                    int index = 0;
                    foreach (SRZoneSection section in sectionList)
                        section.WriteXml(cznFileNode, index++);
                }

                xmlDocument.Save(xmlFile);
            }
            catch (Exception e)
            {
                // Add context information for the error message
                e.Data["Action"] = "writing XML file";
                throw;
            }
        }
Beispiel #12
0
 public SRXmlNodeWriter(SRXmlNodeWriter parentWriter, string name, int index = 0)
 {
     parentNode = parentWriter.CreateNode(name, index);
 }