internal static List<IWzImageProperty> ParsePropertyList(uint offset, WzBinaryReader reader, IWzObject parent, WzImage parentImg) { int entryCount = reader.ReadCompressedInt(); List<IWzImageProperty> properties = new List<IWzImageProperty>(entryCount); for (int i = 0; i < entryCount; i++) { string name = reader.ReadStringBlock(offset); switch (reader.ReadByte()) { case 0: properties.Add(new WzNullProperty(name) { Parent = parent/*, ParentImage = parentImg*/ }); break; case 0x0B: case 2: properties.Add(new WzUnsignedShortProperty(name, reader.ReadUInt16()) { Parent = parent/*, ParentImage = parentImg*/ }); break; case 3: properties.Add(new WzCompressedIntProperty(name, reader.ReadCompressedInt()) { Parent = parent/*, ParentImage = parentImg*/ }); break; case 4: byte type = reader.ReadByte(); if (type == 0x80) properties.Add(new WzByteFloatProperty(name, reader.ReadSingle()) { Parent = parent/*, ParentImage = parentImg*/ }); else if (type == 0) properties.Add(new WzByteFloatProperty(name, 0f) { Parent = parent/*, ParentImage = parentImg*/ }); break; case 5: properties.Add(new WzDoubleProperty(name, reader.ReadDouble()) { Parent = parent/*, ParentImage = parentImg*/ }); break; case 8: properties.Add(new WzStringProperty(name, reader.ReadStringBlock(offset)) { Parent = parent }); break; case 9: int eob = (int)(reader.ReadUInt32() + reader.BaseStream.Position); IWzImageProperty exProp = ParseExtendedProp(reader, offset, eob, name, parent, parentImg); properties.Add(exProp); if (reader.BaseStream.Position != eob) reader.BaseStream.Position = eob; break; default: throw new Exception("Unknown property type at ParsePropertyList"); } } return properties; }
internal static IWzImageProperty[] ParsePropertyList(uint offset, WzBinaryReader reader, IWzObject parent, WzImage parentImg) { List<IWzImageProperty> properties = new List<IWzImageProperty>(); int entryCount = reader.ReadCompressedInt(); for (int i = 0; i < entryCount; i++) { string name = reader.ReadStringBlock(offset); byte ptype = reader.ReadByte(); switch (ptype) { case 0: properties.Add(new WzNullProperty(name, i) { Parent = parent, ParentImage = parentImg }); break; case 0x0B: case 2: properties.Add(new WzUnsignedShortProperty(name, reader.ReadUInt16()) { Parent = parent, ParentImage = parentImg }); break; case 3: properties.Add(new WzCompressedIntProperty(name, reader.ReadCompressedInt()) { Parent = parent, ParentImage = parentImg }); break; case 4: byte type = reader.ReadByte(); if (type == 0x80) properties.Add(new WzByteFloatProperty(name, reader.ReadSingle()) { Parent = parent, ParentImage = parentImg }); else if (type == 0) properties.Add(new WzByteFloatProperty(name, 0f) { Parent = parent, ParentImage = parentImg }); break; case 5: properties.Add(new WzDoubleProperty(name, reader.ReadDouble()) { Parent = parent, ParentImage = parentImg }); break; case 8: properties.Add(new WzStringProperty(name, reader.ReadStringBlock(offset)) { Parent = parent }); break; case 9: int eob = (int)(reader.ReadUInt32() + reader.BaseStream.Position); WzExtendedProperty exProp = new WzExtendedProperty(offset, eob, name); exProp.Parent = parent; exProp.ParentImage = parentImg; exProp.ParseExtendedProperty(reader); properties.Add(exProp); if (reader.BaseStream.Position != eob) reader.BaseStream.Position = eob; break; default: { Console.WriteLine("Unknown type: {0} | {1}", ptype, name); break; } } } return properties.ToArray(); }