Example #1
0
 public void ReadXml(XmlNode parentNode, string name = "position")
 {
     SRXmlNodeReader reader = new SRXmlNodeReader(parentNode, name);
     x = reader.ReadSingle("x");
     y = reader.ReadSingle("y");
     z = reader.ReadSingle("z");
 }
 public void ReadXml(XmlNode parentNode)
 {
     SRXmlNodeReader reader = new SRXmlNodeReader(parentNode, "orientation");
     x = reader.ReadSingle("x");
     y = reader.ReadSingle("y");
     z = reader.ReadSingle("z");
     w = reader.ReadSingle("w");
 }
Example #3
0
 /// <summary>
 /// Reads the contents of a data block from an XML document.
 /// This may read one or more nodes from the given parentNode.
 /// This can return false if it doesn't find any data nodes in the parentNode.
 /// </summary>
 /// <param name="parentNode">XML node to read from.</param>
 /// <returns>true</returns>
 public override void ReadXml(XmlNode parentNode)
 {
     SRXmlNodeReader reader = new SRXmlNodeReader(parentNode, XmlTagName);
     signature = reader.ReadUInt16("signature");
     version = reader.ReadUInt16("version");
     refDataStart = reader.ReadUInt32("ref_data_start");
     unknown = reader.ReadUInt32("unknown");
     XmlNodeList referenceNodes = reader.Node.SelectNodes("./references/reference");
     var numReferences = referenceNodes.Count;
     referenceData = new List<string>(numReferences);
     for (int i = 0; i < numReferences; i++)
         referenceData.Add(referenceNodes[i].InnerText);
 }
 // See description of this method in the abstract base class SRZoneProperty.
 protected override void ReadXmlData(XmlNode thisNode)
 {
     SRXmlNodeReader reader = new SRXmlNodeReader(thisNode);
     value = reader.ReadString("string");
 }
 /// <summary>
 /// Reads the contents of a data block from an XML document.
 /// </summary>
 /// <param name="thisNode">XML node which represents an instance of this data block.</param>
 /// <param name="index">Index within a sequence (starts at 0).</param>
 public void ReadXml(XmlNode thisNode, int index)
 {
     try
     {
         SRXmlNodeReader reader = new SRXmlNodeReader(thisNode);
         name = reader.ReadString("file");
         m_pos_x = MeshPosToInt16(reader.ReadSingle("pos_x"));
         m_pos_y = MeshPosToInt16(reader.ReadSingle("pos_y"));
         m_pos_z = MeshPosToInt16(reader.ReadSingle("pos_z"));
         pitch = MeshOrientToInt16(reader.ReadSingle("pitch"));
         bank = MeshOrientToInt16(reader.ReadSingle("bank"));
         heading = MeshOrientToInt16(reader.ReadSingle("heading"));
     }
     catch (Exception e)
     {
         // Add context information for the error message
         if (index >= 0)
             e.Data[BlockName] = index + 1;
         throw;
     }
 }
Example #6
0
 /// <summary>
 /// Reads the contents of a data block from an XML document.
 /// </summary>
 /// <param name="thisNode">XML node which represents an instance of this data block.</param>
 /// <param name="index">Index within a sequence (starts at 0).</param>
 public void ReadXml(XmlNode thisNode, int index)
 {
     try
     {
         SRXmlNodeReader reader = new SRXmlNodeReader(thisNode);
         name = reader.ReadString("name");
         if (name == "") name = null;
         handleOffset = reader.ReadUInt64("handle");
         parentHandleOffset = reader.ReadUInt64("parent_handle");
         objectTypeHash = reader.ReadInt32("object_type_hash");
         padding = reader.ReadUInt16("padding");
         XmlNodeList propertyNodes = reader.Node.SelectNodes("./properties/" + SRZoneProperty.XmlTagName);
         propertyList = new List<SRZoneProperty>(propertyNodes.Count);
         for (int i = 0; i < propertyNodes.Count; i++)
             propertyList.Add(SRZoneProperty.Create(propertyNodes[i], i));
     }
     catch (Exception e)
     {
         // Add context information for the error message
         if (index >= 0)
             e.Data[BlockName] = index + 1;
         throw;
     }
 }
Example #7
0
 /// <summary>
 /// Reads the contents of a section block from an XML document.
 /// </summary>
 /// <param name="node">XML node which represents an instance of this data block.</param>
 /// <param name="index">Index within a sequence (starts at 0).</param>
 public void ReadXml(XmlNode thisNode, int index)
 {
     try
     {
         SRXmlNodeReader reader = new SRXmlNodeReader(thisNode);
         sectionID = reader.ReadUInt32("id");
         gpuSize = reader.ReadUInt32("gpu_size");
         XmlNode cpuDataNode = reader.GetNodeOptional("cpu_data");
         if (cpuDataNode == null)
             cpuData = null;
         else if (SRRawDataBlock.HasRawXmlData(cpuDataNode))
             cpuData = new SRRawDataBlock(cpuDataNode);
         else
             cpuData = new SRZoneObjectSectionCpuData(cpuDataNode);
     }
     catch (Exception e)
     {
         // Add context information for the error message
         if (index >= 0)
             e.Data[BlockName] = index + 1;
         throw;
     }
 }
Example #8
0
 /// <summary>
 /// Reads the contents of a data block from an XML document.
 /// This may read one or more nodes from the given parentNode.
 /// This can return false if it doesn't find any data nodes in the parentNode.
 /// </summary>
 /// <param name="parentNode">XML node to read from.</param>
 /// <returns>true</returns>
 public override void ReadXml(XmlNode parentNode)
 {
     SRXmlNodeReader reader = new SRXmlNodeReader(parentNode, XmlTagName);
     signature = reader.ReadString("signature");
     version = reader.ReadUInt32("version");
     fileReferenceOffset = new SRPosition(reader.Node, "file_reference_offset");
     fileReferencesPtr = reader.ReadUInt32("file_references_ptr");
     zoneType = (Byte)reader.ReadUInt16("zone_type");
     XmlNodeList referenceNodes = reader.Node.SelectNodes("./mesh_file_references/" + SRZoneMeshFileReference.XmlTagName);
     references = new List<SRZoneMeshFileReference>(referenceNodes.Count);
     for (int i = 0; i < referenceNodes.Count; i++)
         references.Add(new SRZoneMeshFileReference(referenceNodes[i], i, vFileHeader));
 }
        /// <summary>
        /// Reads the contents of a data block from an XML document.
        /// This may read one or more nodes from the given parentNode.
        /// This can return false if it doesn't find any data nodes in the parentNode.
        /// </summary>
        /// <param name="parentNode">XML node to read from.</param>
        /// <returns>true</returns>
        public override void ReadXml(XmlNode parentNode)
        {
            SRXmlNodeReader reader = new SRXmlNodeReader(parentNode, XmlTagName);
            signature = reader.ReadUInt32("signature");
            version = reader.ReadUInt32("version");
            flags = reader.ReadUInt32("flags");
            handleListPointer = reader.ReadUInt32("handle_list_pointer");
            objectDataPointer = reader.ReadUInt32("object_data_pointer");
            objectDataSize = reader.ReadUInt32("object_data_size");
            XmlNodeList handleNodes = reader.Node.SelectNodes("./handles/handle");
            var numHandles = handleNodes.Count;
            handleList = new List<UInt64>((int)numHandles);
            for (int i = 0; i < numHandles; i++)
                handleList.Add(SRXmlNodeReader.ReadUInt64(handleNodes[i]));

            XmlNodeList objectNodes = reader.Node.SelectNodes("./objects/" + SRZoneObject.XmlTagName);
            var numObjects = objectNodes.Count;
            objectList = new List<SRZoneObject>(numObjects);
            for (int i = 0; i < numObjects; i++)
                objectList.Add(new SRZoneObject(objectNodes[i], i));
        }
Example #10
0
        /// <summary>
        /// Reads a property from an XML document and creates a new property object containing the data.
        /// The returned property will be an instance of one of the concrete derived property classes.
        /// </summary>
        /// <param name="thisNode">XML node which represents an instance of this data block.</param>
        /// <param name="index">Index within a sequence (starts at 0).</param>
        /// <returns>The new zone property which was read from the input stream.</returns>
        public static SRZoneProperty Create(XmlNode parentNode, int index)
        {
            SRZoneProperty property;
            try
            {
                // Read the common header
                SRXmlNodeReader reader = new SRXmlNodeReader(parentNode);
                UInt16 type = reader.ReadUInt16("type");
                Int32 nameCrc = reader.ReadInt32("name_crc");

                // Create the appropriate derived class based on the header information
                if (SRRawDataBlock.HasRawXmlData(parentNode))
                    property = new SRZoneDataProperty(type, nameCrc);
                else
                    property = Create(type, nameCrc);

                // Read the class-specific data into the derived class
                property.ReadXmlData(SRXmlNodeReader.GetNode(parentNode, "value"));

                // Read the optional padding data
                XmlNode paddingNode = reader.GetNodeOptional("padding");
                if (paddingNode != null && SRRawDataBlock.HasRawXmlData(paddingNode))
                    property.paddingData = new SRRawDataBlock(paddingNode);
            }
            catch (Exception e)
            {
                // Add context information for the error message
                if (index >= 0)
                    e.Data[BlockName] = index + 1;
                throw;
            }
            return property;
        }