Ejemplo n.º 1
0
        internal override bool Read(WzFileStream stream)
        {
            this.Unknow1_Byte = stream.Read1u();
            bool hasProperty = stream.ReadBool();

            if (hasProperty)
            {
                this.CanvasProperty.Read(stream);
            }
            this.Width         = stream.Read4(true);
            this.Height        = stream.Read4(true);
            this.Format        = (WzCanvasFormat)stream.Read4(true);
            this.Scale         = stream.Read1u();
            this.Unknow2_Int   = stream.Read4();
            this.DataSize      = stream.Read4();
            this.mCanvasOffset = (uint)stream.Tell();

            if (stream.DynamicRead)
            {
                stream.Skip(this.DataSize);
                this.mStream = stream;
            }
            else
            {
                this.CanvasData = this.ResolveData(stream);
            }

            return(true);
        }
Ejemplo n.º 2
0
        internal bool Read(WzFileStream zs)
        {
            this.Items.Clear();
            zs.Seek(this.Offset);

            int count = zs.Read4(true);

            for (int i = 0; i < count; i++)
            {
                WzArchiveItem     item = null;
                WzArchiveItemType itemtype;
                string            itemname = zs.StringPool.DirectoryRead(out itemtype, WzArchiveItemType.Reference);

                if (itemtype == WzArchiveItemType.Directory)
                {
                    item = new WzDirectory(itemname);
                }
                else if (itemtype == WzArchiveItemType.File)
                {
                    item = new WzFile(itemname, zs.KeyType)
                    {
                        Stream = zs.BaseStream
                    };
                }
                else
                {
                    throw new InvalidDataException("Undefined item type : " + (int)itemtype);
                }

                item.Size     = zs.Read4(true);
                item.Checksum = zs.Read4(true);
                uint offKey = HashTools.GenerateOffsetKey((uint)zs.Tell(), this.Archive.DataOffset, this.Archive.Hash);
                item.Offset = HashTools.DecryptOffsetHash(zs.Read4u(), offKey, this.Archive.DataOffset);

                if ((item.Offset + item.Size) > zs.Length)
                {
                    return(false);
                }

                this.Add(item);
            }
            for (int i = 0; i < this.Items.Count; i++)
            {
                if (this.Items[i].Type == WzArchiveItemType.Directory)
                {
                    (this.Items[i] as WzDirectory).Read(zs);
                }
            }

            return(true);
        }
Ejemplo n.º 3
0
        private byte[] ResolveData(WzFileStream zs)
        {
            byte unk = zs.Read1u();
            byte cmf = zs.Read1u();
            byte flg = zs.Read1u();

            zs.Skip(-3);

            if (CanvasZlibTool.CheckDeflate(unk, cmf, flg))
            {
                return(zs.Read(this.DataSize));
            }
            else
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    ms.WriteByte(zs.Read1u());
                    for (int i = 1; i < this.DataSize;)
                    {
                        int blocksize = zs.Read4();
                        ms.Write(zs.Read(blocksize, true), 0, blocksize);
                        i += blocksize + 4;
                    }
                    return(ms.ToArray());
                }
            }
        }
Ejemplo n.º 4
0
        internal override bool Read(WzFileStream stream)
        {
            int nSize = stream.Read4(true);

            for (int i = 0; i < nSize; ++i)
            {
                WzVector2D vec = WzSerialize.FromClassName(stream.StringPool.Read()) as WzVector2D;
                vec.Read(stream);
                this.Vertices.Add(vec);
            }
            return(true);
        }
Ejemplo n.º 5
0
        internal void Read(WzFileStream stream)
        {
            this.majortype    = new Guid(stream.Read(16));       //MEDIATYPE_Stream
            this.subtype      = new Guid(stream.Read(16));       //MEDIASUBTYPE_WAVE
            this.Unknow1_Byte = stream.Read1u();
            this.Unknow2_Byte = stream.Read1u();
            this.formattype   = new Guid(stream.Read(16));       //WMFORMAT_WaveFormatEx

            if (this.formattype == SoundDX8Constants.WMFORMAT_WaveFormatEx)
            {
                this.cbFormat = (uint)stream.Read4(true);
                this.pbFormat = stream.Read((int)this.cbFormat);
            }
        }
Ejemplo n.º 6
0
        internal override bool Read(WzFileStream stream)
        {
            this.Unknow1_Byte = stream.Read1u();
            this.DataSize     = stream.Read4(true);
            this.Duration     = stream.Read4(true);
            this.Unknow3_Byte = stream.Read1u();

            WzMediaType wzmt = new WzMediaType();

            wzmt.Read(stream);
            this.MediaType    = wzmt;
            this.mSoundOffset = (uint)stream.Tell();
            if (stream.DynamicRead)
            {
                this.mStream = stream;
                stream.Skip(this.DataSize);
            }
            else
            {
                this.SoundData = stream.Read(this.DataSize);
            }
            return(true);
        }
Ejemplo n.º 7
0
        internal override bool Read(WzFileStream stream)
        {
            this.mList.Clear();

            this.Unknow1_UShort = stream.Read2u(); //0
            int count = stream.Read4(true);

            for (int i = 0; i < count; ++i)
            {
                this.Add(this.ReadVariant(stream));
            }

            return(true);
        }
Ejemplo n.º 8
0
        /// <summary> 從指定資料流讀取腳本資料 </summary>
        public bool Read(WzFileStream stream)
        {
            stream.Seek(0, true);
            byte flag = stream.Read1u();

            switch (flag)
            {
            case 1:
                int len = stream.Read4(true);
                this.Script = stream.ReadString(len, Encoding.UTF8, true);
                break;

            default:
                throw new NotSupportedException("Not supported flag : " + flag);
            }
            return(true);
        }
Ejemplo n.º 9
0
        /// <summary> 從指定的<see cref="WzFileStream"/>中讀取文字 </summary>
        public static string Read(WzFileStream stream)
        {
            int  len  = stream.Read1();
            bool uni  = len > 0;
            int  flag = (uni ? len : ~len);

            if (len == 0)
            {
                return("");
            }

            len = flag == 0x7F ? stream.Read4() : Math.Abs(len);

            byte[] str = stream.Read(len * (uni ? 2 : 1), true);

            Process(str, len, uni);

            return((uni ? Encoding.Unicode : Encoding.ASCII).GetString(str));
        }
Ejemplo n.º 10
0
        /// <summary> </summary>
        internal override void Read(WzFileStream fs)
        {
            int  blockSize = fs.Read4();
            long off       = fs.Tell();

            string      classname = fs.StringPool.Read();
            WzSerialize obj       = WzSerialize.FromClassName(classname, this.Name);

            obj.ImageFile = this.Parent.ImageFile;
            obj.Read(fs);

            if (fs.Tell() != (off + blockSize))
            {
                fs.Seek(off + blockSize);
#if DEBUG
                System.Console.WriteLine("沒有解析完全 : {0}", this.GetImagePath());
#endif
            }

            this.Value = obj;
        }
Ejemplo n.º 11
0
 internal override bool Read(WzFileStream stream)
 {
     this.X = stream.Read4(true);
     this.Y = stream.Read4(true);
     return(true);
 }
Ejemplo n.º 12
0
 internal override void Read(WzFileStream fs)
 {
     this.Value = (uint)fs.Read4(true);
 }