Пример #1
0
        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (dlgSaveFile.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            PESTool.Tools pestools = new PESTool.Tools();
            MemoryStream  stream   = new MemoryStream();

            pestools.decompresstoMemory(openedFile, stream);
            MemoryStream[] subfiles = pestools.splitmultifile(stream, false);
            subfiles[openedSubFile] = new MemoryStream();

            dpow.SaveToFile(subfiles[openedSubFile]);

            stream = pestools.mergemultifile(subfiles, false);
            pestools.compressFile(stream, dlgSaveFile.FileName, false);
        }
Пример #2
0
        private void openfile(string filename)
        {
            openedFile = filename;
            PESTool.Tools pestools  = new PESTool.Tools();
            MemoryStream  memstream = new MemoryStream();

            pestools.decompresstoMemory(filename, memstream);
            MemoryStream[] subfiles = pestools.splitmultifile(memstream, false);

            List <string> availabledpows = new List <string>();

            for (int i = 0; i < subfiles.Length; i++)
            {
                byte[] buffer = new byte[4];
                subfiles[i].Read(buffer, 0, 4);
                if (System.Text.Encoding.ASCII.GetString(buffer) == "DPOW")
                {
                    availabledpows.Add(pestools.fnames[i]);
                }
                subfiles[i].Seek(0, SeekOrigin.Begin);
            }

            int    k           = 0;
            string openingfile = "";

            if (availabledpows.Count == 0)
            {
                MessageBox.Show("No DPOWs on this file");
                return;
            }
            else if (availabledpows.Count > 1)
            {
                frmSelectSubfile frmPickFile = new frmSelectSubfile();
                frmPickFile.subfiles = availabledpows.ToArray();
                frmPickFile.ShowDialog();
                openingfile = frmPickFile.cmbSubfile.Text;
            }
            else
            {
                openingfile = availabledpows[0];
            }

            for (int i = 0; i < subfiles.Length; i++)
            {
                if (pestools.fnames[i] == openingfile)
                {
                    k = i;
                }
            }
            dpow          = new DPOW.Reader.DPOWObject(subfiles[k]);
            openedSubFile = k;

            init3D();

            refreshLists();

            string dir = Path.GetDirectoryName(filename);

            for (int i = 0; i < dpow.Textures.Length; i++)
            {
                if (File.Exists(dir + "\\" + dpow.Textures[i] + ".png"))
                {
                    createMaterial(dpow.Textures[i], System.Drawing.Image.FromFile(dir + "\\" + dpow.Textures[i] + ".png"));

                    imlTextures.Images.Add(dpow.Textures[i], System.Drawing.Image.FromFile(dir + "\\" + dpow.Textures[i] + ".png"));
                    lstTextures.Items[i].ImageKey = dpow.Textures[i];
                }
            }

            lstTextures.Refresh();
        }