public bool ReadXml(XmlReader reader) { reader.Read(); reader.ReadToFollowing("vfx"); reader.MoveToAttribute("version"); var version = reader.Value; if (version == "GZ") { this.version = Version.Gz; } else if (version == "TPP") { this.version = Version.Tpp; } else { Console.WriteLine("No valid version specified. Add a version attribute to the <vfx> node with a value of GZ or TPP."); return(false); } reader.ReadStartElement("vfx"); reader.ReadStartElement("nodes"); while (reader.NodeType == XmlNodeType.Element) { if (reader.LocalName == "edges") { break; } var type = reader.GetAttribute("class"); var typeHash = Program.HashString(type); if (!this.Definitions.ContainsKey(typeHash)) { throw new FormatException($"Unrecognized node type {type}"); } var definition = this.Definitions[typeHash]; var node = FxVfxNode.FromTemplate(definition); node.ReadXml(reader); this.nodes.Add(node); } reader.ReadEndElement(); reader.ReadStartElement("edges"); while (reader.NodeType == XmlNodeType.Element) { var edge = new FxModuleEdge(); edge.ReadXml(reader); this.edges.Add(edge); } return(true); }
public static FxModuleEdge Read(BinaryReader reader, NodeIndexSize size) { var edge = new FxModuleEdge(); if (size == NodeIndexSize.UInt8) { edge.sourceNodeIndex = reader.ReadByte(); edge.targetNodeIndex = reader.ReadByte(); } else { edge.sourceNodeIndex = reader.ReadUInt16(); edge.targetNodeIndex = reader.ReadUInt16(); } edge.sourcePortType = reader.ReadByte(); edge.sourcePortIndex = reader.ReadByte(); edge.targetPortType = reader.ReadByte(); edge.targetPortIndex = reader.ReadByte(); return(edge); }
private void ReadEdge(BinaryReader reader, FxModuleEdge.NodeIndexSize edgeIndexSize) { var edge = FxModuleEdge.Read(reader, edgeIndexSize); edges.Add(edge); }