Exemplo n.º 1
0
        void loadDifferences()
        {
            // here we would query a website for latest patch rev.
            WzMapleVersion vrs     = WzMapleVersion.GMS; // is classic old GMS??
            string         imgPath = textBox1.Text;
            string         wzPath  = textBox2.Text;

            Console.WriteLine("imgPath: " + imgPath + ", wzPath: " + wzPath);
            WzFile affected = new WzFile(wzPath, vrs);

            affected.ParseWzFile();
            char[] split   = { '\\', '/' };
            string imgName = imgPath.Split(split)[imgPath.Split(split).Length - 1].Trim();

            Console.WriteLine("imgName: " + imgName);
            WzImage    toPatch = affected.WzDirectory.GetImageByName(imgName);
            FileStream stream  = File.OpenRead(imgPath);
            WzImage    img     = new WzImage("-" + imgName, stream, vrs);

            img.ParseImage();
            toPatch.ParseImage();
            toPatch.ClearProperties();
            toPatch.AddProperties(img.WzProperties);
            affected.WzDirectory.GetImageByName(imgName).changed = true;
            affected.SaveToDisk(wzPath + ".new");
            affected.Dispose();
            stream.Close();
            while (!tryDelete(wzPath))
            {
                Thread.Sleep(1000);             // ensure that we can rename the file
            }
            File.Move(wzPath + ".new", wzPath); // rewrite w/ patched file
            button1.Text = "Done!";
        }