コード例 #1
0
ファイル: WzImageProperty.cs プロジェクト: Kagamia/MapleLib
 internal static List<WzImageProperty> ParsePropertyList(uint offset, WzBinaryReader reader, WzObject parent, WzImage parentImg)
 {
     int entryCount = reader.ReadCompressedInt();
     List<WzImageProperty> properties = new List<WzImageProperty>(entryCount);
     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) { Parent = parent });
                 break;
             case 11:
             case 2:
                 properties.Add(new WzShortProperty(name, reader.ReadInt16()) { Parent = parent });
                 break;
             case 3:
             case 19:
                 properties.Add(new WzIntProperty(name, reader.ReadCompressedInt()) { Parent = parent });
                 break;
             case 20:
                 properties.Add(new WzLongProperty(name, reader.ReadLong()) { Parent = parent });
                 break;
             case 4:
                 byte type = reader.ReadByte();
                 if (type == 0x80)
                     properties.Add(new WzFloatProperty(name, reader.ReadSingle()) { Parent = parent });
                 else if (type == 0)
                     properties.Add(new WzFloatProperty(name, 0f) { Parent = parent });
                 break;
             case 5:
                 properties.Add(new WzDoubleProperty(name, reader.ReadDouble()) { Parent = parent });
                 break;
             case 8:
                 properties.Add(new WzStringProperty(name, reader.ReadStringBlock(offset)) { Parent = parent });
                 break;
             case 9:
                 int eob = (int)(reader.ReadUInt32() + reader.BaseStream.Position);
                 WzImageProperty 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;
 }