示例#1
0
        public AWzObject GetObjectFromPath(string path)
        {
            string[] seperatedPath = path.Split('/');
            if (seperatedPath[0].ToLower() != mName.ToLower())
            {
                return(null);
            }
            if (seperatedPath.Length == 1)
            {
                return(this);
            }
            AWzObject curObj = this;

            for (int i = 1; i < seperatedPath.Length; i++)
            {
                if (curObj == null)
                {
                    return(null);
                }
                switch (curObj.ObjectType)
                {
                case WzObjectType.Directory:
                    curObj = ((WzDirectory)curObj)[seperatedPath[i]];
                    continue;

                case WzObjectType.Image:
                    curObj = ((WzImage)curObj)[seperatedPath[i]];
                    continue;

                case WzObjectType.Property:
                    switch (((AWzImageProperty)curObj).PropertyType)
                    {
                    case WzPropertyType.Canvas:
                        curObj = ((WzCanvasProperty)curObj)[seperatedPath[i]];
                        continue;

                    case WzPropertyType.Convex:
                        curObj = ((WzConvexProperty)curObj)[seperatedPath[i]];
                        continue;

                    case WzPropertyType.SubProperty:
                        curObj = ((WzSubProperty)curObj)[seperatedPath[i]];
                        continue;

                    case WzPropertyType.Vector:
                        if (seperatedPath[i] == "X")
                        {
                            return(((WzVectorProperty)curObj).X);
                        }
                        return(seperatedPath[i] == "Y" ? ((WzVectorProperty)curObj).Y : null);

                    default:         // Wut?
                        return(null);
                    }
                }
            }
            return(curObj);
        }
示例#2
0
        internal static AWzImageProperty ParseExtendedProp(WzBinaryReader pReader, uint pOffset, int pEndOfBlock, string pName, AWzObject pParent, WzImage pImgParent)
        {
            byte b = pReader.ReadByte();

            switch (b)
            {
            case 0x1B:
                return(ExtractMore(pReader, pOffset, pEndOfBlock, pName, pReader.ReadStringAtOffset(pOffset + pReader.ReadInt32()), pParent, pImgParent));

            case 0x73:
                return(ExtractMore(pReader, pOffset, pEndOfBlock, pName, pReader.ReadString(), pParent, pImgParent));

            default:
                return(null);
                //throw new Exception("Invlid type at ParseExtendedProp: " + b);
            }
        }
示例#3
0
        internal static AWzImageProperty ExtractMore(WzBinaryReader pReader, uint pOffset, int pEndOfBlock, string pName, string pImageName, AWzObject pParent, WzImage pImgParent)
        {
            switch (pImageName)
            {
            case "Property":
                WzSubProperty subProp = new WzSubProperty(pName)
                {
                    Parent = pParent, ParentImage = pImgParent
                };
                pReader.BaseStream.Position += 2;
                subProp.AddProperties(ParsePropertyList(pOffset, pReader, subProp, pImgParent));
                return(subProp);

            case "Canvas":
                WzCanvasProperty canvasProp = new WzCanvasProperty(pName)
                {
                    Parent = pParent, ParentImage = pImgParent
                };
                pReader.BaseStream.Position++;
                if (pReader.ReadByte() == 1)
                {
                    pReader.BaseStream.Position += 2;
                    canvasProp.AddProperties(ParsePropertyList(pOffset, pReader, canvasProp, pImgParent));
                }
                canvasProp.PngProperty = new WzPngProperty(pReader)
                {
                    Parent = canvasProp, ParentImage = pImgParent
                };
                return(canvasProp);

            case "Shape2D#Vector2D":
                WzVectorProperty vecProp = new WzVectorProperty(pName)
                {
                    Parent = pParent, ParentImage = pImgParent
                };
                vecProp.X = new WzCompressedIntProperty("X", pReader.ReadCompressedInt())
                {
                    Parent = vecProp, ParentImage = pImgParent
                };
                vecProp.Y = new WzCompressedIntProperty("Y", pReader.ReadCompressedInt())
                {
                    Parent = vecProp, ParentImage = pImgParent
                };
                return(vecProp);

            case "Shape2D#Convex2D":
                WzConvexProperty convexProp = new WzConvexProperty(pName)
                {
                    Parent = pParent, ParentImage = pImgParent
                };
                int convexEntryCount = pReader.ReadCompressedInt();
                for (int i = 0; i < convexEntryCount; i++)
                {
                    AWzImageProperty imgProp = ParseExtendedProp(pReader, pOffset, 0, pName, convexProp, pImgParent);
                    if (imgProp != null)
                    {
                        convexProp.AddProperty(imgProp);
                    }
                }
                return(convexProp);

            case "Sound_DX8":
                WzSoundProperty soundProp = new WzSoundProperty(pName)
                {
                    Parent = pParent, ParentImage = pImgParent
                };
                soundProp.ParseSound(pReader);
                return(soundProp);

            case "UOL":
                pReader.BaseStream.Position++;
                byte b = pReader.ReadByte();
                switch (b)
                {
                case 0:
                    return(new WzUOLProperty(pName, pReader.ReadString())
                    {
                        Parent = pParent, ParentImage = pImgParent
                    });

                case 1:
                    return(new WzUOLProperty(pName, pReader.ReadStringAtOffset(pOffset + pReader.ReadInt32()))
                    {
                        Parent = pParent, ParentImage = pImgParent
                    });

                default:
                    throw new Exception("Unsupported UOL type: " + b);
                }

            default:
                throw new Exception("Unknown image name: " + pImageName);
            }
        }
示例#4
0
        internal static List <AWzImageProperty> ParsePropertyList(uint pOffset, WzBinaryReader pReader, AWzObject pParent, WzImage pParentImg)
        {
            List <AWzImageProperty> properties = new List <AWzImageProperty>();
            int entryCount = pReader.ReadCompressedInt();

            for (int i = 0; i < entryCount; i++)
            {
                string name = pReader.ReadStringBlock(pOffset).Trim();
                byte   b    = pReader.ReadByte();
                switch (b)
                {
                case 0:
                    properties.Add(new WzNullProperty(name)
                    {
                        Parent = pParent, ParentImage = pParentImg
                    });
                    break;

                case 2:
                case 11:     //UShort
                    properties.Add(new WzShortProperty(name, pReader.ReadInt16())
                    {
                        Parent = pParent, ParentImage = pParentImg
                    });
                    break;

                case 3:
                case 19:     //UInt
                    properties.Add(new WzCompressedIntProperty(name, pReader.ReadCompressedInt())
                    {
                        Parent = pParent, ParentImage = pParentImg
                    });
                    break;

                case 4:
                    byte type = pReader.ReadByte();
                    if (type == 0x80)
                    {
                        properties.Add(new WzByteFloatProperty(name, pReader.ReadSingle())
                        {
                            Parent = pParent, ParentImage = pParentImg
                        });
                    }
                    else if (type == 0)
                    {
                        properties.Add(new WzByteFloatProperty(name, 0f)
                        {
                            Parent = pParent, ParentImage = pParentImg
                        });
                    }
                    break;

                case 5:
                    properties.Add(new WzDoubleProperty(name, pReader.ReadDouble())
                    {
                        Parent = pParent, ParentImage = pParentImg
                    });
                    break;

                case 8:
                    properties.Add(new WzStringProperty(name, pReader.ReadStringBlock(pOffset))
                    {
                        Parent = pParent, ParentImage = pParentImg
                    });
                    break;

                case 9:
                    int eob = (int)(pReader.ReadUInt32() + pReader.BaseStream.Position);
                    AWzImageProperty exProp = ParseExtendedProp(pReader, pOffset, eob, name, pParent, pParentImg);
                    if (exProp != null)
                    {
                        properties.Add(exProp);
                    }
                    pReader.BaseStream.Position = eob;
                    break;

                case 20:
                    properties.Add(new WzCompressedLongProperty(name, pReader.ReadCompressedLong())
                    {
                        Parent = pParent, ParentImage = pParentImg
                    });
                    break;

                default:
                    throw new Exception("Unknown property type at ParsePropertyList: " + b + " name: " + name + " offset: " + pReader.getCurrentOffset());
                }
            }
            return(properties);
        }