Ejemplo n.º 1
0
        /// <summary>
        /// Parses the image from the wz filetod
        /// </summary>
        /// <param name="wzReader">The BinaryReader that is currently reading the wz file</param>
        public void ParseImage()
        {
            if (Parsed)
            {
                return;
            }
            else if (Changed)
            {
                Parsed = true;
                return;
            }

            this.parseEverything = false;
            long originalPos = reader.BaseStream.Position;

            reader.BaseStream.Position = offset;
            byte b = reader.ReadByte();

            if (b != WzImageHeaderByte || reader.ReadString() != "Property" || reader.ReadUInt16() != 0)
            {
                return;
            }
            properties.AddRange(WzImageProperty.ParsePropertyList(offset, reader, this, this));
            parsed = true;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Parses the image from the wz filetod
        /// </summary>
        /// <param name="wzReader">The BinaryReader that is currently reading the wz file</param>
        /// <returns>bool Parse status</returns>
        public bool ParseImage(bool parseEverything)
        {
            if (Parsed)
            {
                return(true);
            }
            else if (Changed)
            {
                Parsed = true;
                return(true);
            }
            this.parseEverything = parseEverything;
            long originalPos = reader.BaseStream.Position;

            reader.BaseStream.Position = offset;

            byte   b    = reader.ReadByte();
            string prop = reader.ReadString();
            ushort val  = reader.ReadUInt16();

            if (b != WzImageHeaderByte || prop != "Property" || val != 0)
            {
                return(false);
            }

            properties.AddRange(WzImageProperty.ParsePropertyList(offset, reader, this, this));
            parsed = true;
            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Parses the image from the wz filetod
        /// </summary>
        public void ParseImage()
        {
            if (Parsed)
            {
                return;
            }
            if (Changed)
            {
                Parsed = true; return;
            }
            parseEverything = false;
            var originalPos = reader.BaseStream.Position;

            reader.BaseStream.Position = Offset;
            var b = reader.ReadByte();

            if (b != 0x73 || reader.ReadString() != "Property" || reader.ReadUInt16() != 0)
            {
                return;
            }

            properties.AddRange(WzImageProperty.ParsePropertyList(Offset, reader, this, this));
            Parsed = true;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Parses the image from the wz filetod
        /// </summary>
        /// <param name="wzReader">The BinaryReader that is currently reading the wz file</param>
        /// <returns>bool Parse status</returns>
        public bool ParseImage(bool forceReadFromData = false)
        {
            if (!forceReadFromData)   // only check if parsed or changed if its not false read
            {
                if (Parsed)
                {
                    return(true);
                }
                else if (Changed)
                {
                    Parsed = true;
                    return(true);
                }
            }

            lock (reader) // for multi threaded XMLWZ export.
            {
                long originalPos = reader.BaseStream.Position;
                reader.BaseStream.Position = offset;

                byte b = reader.ReadByte();
                switch (b)
                {
                case 0x1:     // .lua
                {
                    if (IsLuaWzImage)
                    {
                        WzLuaProperty lua = WzImageProperty.ParseLuaProperty(offset, reader, this, this);

                        List <WzImageProperty> luaImage = new List <WzImageProperty>();
                        luaImage.Add(lua);

                        properties.AddRange(luaImage);
                        parsed = true;         // test
                        return(true);
                    }

                    return(false);        // unhandled for now, if it isnt an .lua image
                }

                case WzImageHeaderByte:
                {
                    string prop = reader.ReadString();
                    ushort val  = reader.ReadUInt16();
                    if (prop != "Property" || val != 0)
                    {
                        return(false);
                    }
                    break;
                }

                default:
                {
                    // todo: log this or warn.
                    Helpers.ErrorLogger.Log(Helpers.ErrorLevel.MissingFeature, "[WzImage] New Wz image header found. b = " + b);
                    return(false);
                }
                }
                List <WzImageProperty> images = WzImageProperty.ParsePropertyList(offset, reader, this, this);
                properties.AddRange(images);

                parsed = true;
            }
            return(true);
        }
Ejemplo n.º 5
0
        internal static WzExtended ExtractMore(WzBinaryReader reader, uint offset, int eob, string name, string iname, WzObject parent, WzImage imgParent)
        {
            if (iname == "")
            {
                iname = reader.ReadString();
            }
            switch (iname)
            {
            case "Property":
                WzSubProperty subProp = new WzSubProperty(name)
                {
                    Parent = parent
                };
                reader.BaseStream.Position += 2;     // Reserved?
                subProp.AddProperties(WzImageProperty.ParsePropertyList(offset, reader, subProp, imgParent));
                return(subProp);

            case "Canvas":
                WzCanvasProperty canvasProp = new WzCanvasProperty(name)
                {
                    Parent = parent
                };
                reader.BaseStream.Position++;
                if (reader.ReadByte() == 1)
                {
                    reader.BaseStream.Position += 2;
                    canvasProp.AddProperties(WzImageProperty.ParsePropertyList(offset, reader, canvasProp, imgParent));
                }
                canvasProp.PngProperty = new WzPngProperty(reader, imgParent.parseEverything)
                {
                    Parent = canvasProp
                };
                return(canvasProp);

            case "Shape2D#Vector2D":
                WzVectorProperty vecProp = new WzVectorProperty(name)
                {
                    Parent = parent
                };
                vecProp.X = new WzIntProperty("X", reader.ReadCompressedInt())
                {
                    Parent = vecProp
                };
                vecProp.Y = new WzIntProperty("Y", reader.ReadCompressedInt())
                {
                    Parent = vecProp
                };
                return(vecProp);

            case "Shape2D#Convex2D":
                WzConvexProperty convexProp = new WzConvexProperty(name)
                {
                    Parent = parent
                };
                int convexEntryCount = reader.ReadCompressedInt();
                convexProp.WzProperties.Capacity = convexEntryCount;
                for (int i = 0; i < convexEntryCount; i++)
                {
                    convexProp.AddProperty(ParseExtendedProp(reader, offset, 0, name, convexProp, imgParent));
                }
                return(convexProp);

            case "Sound_DX8":
                WzSoundProperty soundProp = new WzSoundProperty(name, reader, imgParent.parseEverything)
                {
                    Parent = parent
                };
                return(soundProp);

            case "UOL":
                reader.BaseStream.Position++;
                switch (reader.ReadByte())
                {
                case 0:
                    return(new WzUOLProperty(name, reader.ReadString())
                    {
                        Parent = parent
                    });

                case 1:
                    return(new WzUOLProperty(name, reader.ReadStringAtOffset(offset + reader.ReadInt32()))
                    {
                        Parent = parent
                    });
                }
                throw new Exception("Unsupported UOL type");

            default:
                throw new Exception("Unknown iname: " + iname);
            }
        }