Ejemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            string bjpath = textBox1.Text;
            string cjpath = Application.StartupPath + @"\pjass\common.j";

            if (!File.Exists(bjpath))
            {
                MessageBox.Show("invalid blizzard.j path!"); return;
            }
            if (openMapDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            MpqLib.Mpq.CArchive map      = new MpqLib.Mpq.CArchive(openMapDialog.FileName);
            string[]            listfile = GenerateMapFilelist(map);
            if (saveMpqDialog.ShowDialog() == DialogResult.OK)
            {
                if (File.Exists(saveMpqDialog.FileName))
                {
                    File.Delete(saveMpqDialog.FileName);
                }
                //==================
                MpqLib.Mpq.CArchive mpq = new MpqLib.Mpq.CArchive(saveMpqDialog.FileName, true, MpqLib.Mpq.EArchiveFormat.Version1, 10000);
                //添加地图内文件
                for (int i = 0; i < listfile.Length; i++)
                {
                    MpqLib.Mpq.CFileStream file = new MpqLib.Mpq.CFileStream(map, listfile[i]);
                    byte[] fileb = new byte[file.Length];
                    fileb = file.Read((int)file.Length);
                    file.Close();
                    mpq.ImportFile(listfile[i], fileb);
                    fileb = null;

                    /*
                     * if (map.FileExists(listfile[i]))
                     * {
                     *  if (File.Exists("temp")) { File.Delete("temp"); }
                     *  map.ExportFile(listfile[i], "temp");
                     *  mpq.ImportFile(listfile[i], "temp");
                     * }
                     */
                }
                map.Close();
                //添加blizzard.j
                mpq.ImportFile(@"Scripts\Blizzard.j", bjpath);
                //添加blizzard.j
                mpq.ImportFile(@"Scripts\common.j", cjpath);
                //添加additional resources...
                PackAllFileToMpq(textBox2.Text.Trim(), textBox2.Text.Trim(), mpq);
                //关闭mpq
                mpq.Flush();
                mpq.Compact();
                mpq.Close();
                //测试地图
                MessageBox.Show("Mpq generated at:" + Environment.NewLine + saveMpqDialog.FileName, "Finish!");
            }
        }
Ejemplo n.º 2
0
 private void button9_Click(object sender, EventArgs e)
 {
     if (openMapDialog.ShowDialog() == DialogResult.OK)
     {
         if (File.Exists("war3map_edited.wts"))
         {
             File.Delete("war3map_edited.wts");
         }
         if (File.Exists("war3map.j"))
         {
             File.Delete("war3map.j");
         }
         if (File.Exists("war3mapMisc.txt"))
         {
             File.Delete("war3mapMisc.txt");
         }
         //导出文件
         MpqLib.Mpq.CArchive map = new MpqLib.Mpq.CArchive(openMapDialog.FileName);
         if (map.FileExists("war3map.j"))
         {
             map.ExportFile("war3map.j", "war3map.j");
         }
         if (map.FileExists("war3mapMisc.txt"))
         {
             map.ExportFile("war3mapMisc.txt", "war3mapMisc.txt");
         }
         if (map.FileExists("war3map.wts"))
         {
             map.ExportFile("war3map.wts", "war3map_edited.wts");
         }
         else
         {
             label1.Text = "war3map.wts doesn't exist in this map.";
             map.Close();
             return;
         }
         TransferStatus(true);
         label1.Text = "Transfering strings from war3map.wts...";
         wts_file wts = new wts_file("war3map_edited.wts");
         wts.SaveStripDataFile(true);
         wts.StringMapping();
         //打包进地图
         map.ImportFile("war3map.wts", "war3map_edited.wts");
         map.Flush();
         map.Compact();
         map.Close();
         if (File.Exists("war3map_edited.wts"))
         {
             File.Delete("war3map_edited.wts");
         }
         TransferStatus(false);
         refreshfrm();
         label1.Text = "Finish.";
         MessageBox.Show("Finish!");
     }
 }
Ejemplo n.º 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            string bjpath = textBox1.Text;
            string cjpath = Application.StartupPath + @"\pjass\common.j";
            if (!File.Exists(bjpath)) { MessageBox.Show("invalid blizzard.j path!"); return; }
            if (openMapDialog.ShowDialog() != DialogResult.OK) { return; }
            MpqLib.Mpq.CArchive map = new MpqLib.Mpq.CArchive(openMapDialog.FileName);
            string[] listfile = GenerateMapFilelist(map);
            if (saveMpqDialog.ShowDialog() == DialogResult.OK)
            {
                if (File.Exists(saveMpqDialog.FileName)) { File.Delete(saveMpqDialog.FileName); }
                //==================
                MpqLib.Mpq.CArchive mpq = new MpqLib.Mpq.CArchive(saveMpqDialog.FileName, true, MpqLib.Mpq.EArchiveFormat.Version1, 10000);
                //添加地图内文件
                for (int i = 0; i < listfile.Length; i++)
                {

                    MpqLib.Mpq.CFileStream file = new MpqLib.Mpq.CFileStream(map, listfile[i]);
                    byte[] fileb = new byte[file.Length];
                    fileb = file.Read((int)file.Length);
                    file.Close();
                    mpq.ImportFile(listfile[i], fileb);
                    fileb = null;

                    /*
                    if (map.FileExists(listfile[i]))
                    {
                        if (File.Exists("temp")) { File.Delete("temp"); }
                        map.ExportFile(listfile[i], "temp");
                        mpq.ImportFile(listfile[i], "temp");
                    }
                    */
                }
                map.Close();
                //添加blizzard.j
                mpq.ImportFile(@"Scripts\Blizzard.j", bjpath);
                //添加blizzard.j
                mpq.ImportFile(@"Scripts\common.j", cjpath);
                //添加additional resources...
                PackAllFileToMpq(textBox2.Text.Trim(), textBox2.Text.Trim(), mpq);
                //关闭mpq
                mpq.Flush();
                mpq.Compact();
                mpq.Close();
                //测试地图
                MessageBox.Show("Mpq generated at:"+Environment.NewLine+saveMpqDialog.FileName,"Finish!");
            }
        }
Ejemplo n.º 4
0
 private void button9_Click(object sender, EventArgs e)
 {
     if (openMapDialog.ShowDialog() == DialogResult.OK)
     {
         if (File.Exists("war3map_edited.wts")) { File.Delete("war3map_edited.wts"); }
         if (File.Exists("war3map.j")) { File.Delete("war3map.j"); }
         if (File.Exists("war3mapMisc.txt")) { File.Delete("war3mapMisc.txt"); }
         //导出文件
         MpqLib.Mpq.CArchive map = new MpqLib.Mpq.CArchive(openMapDialog.FileName);
         if (map.FileExists("war3map.j")) { map.ExportFile("war3map.j", "war3map.j"); }
         if (map.FileExists("war3mapMisc.txt")) { map.ExportFile("war3mapMisc.txt", "war3mapMisc.txt"); }
         if (map.FileExists("war3map.wts")) { map.ExportFile("war3map.wts", "war3map_edited.wts"); }
         else
         {
             label1.Text = "war3map.wts doesn't exist in this map.";
             map.Close();
             return;
         }
         TransferStatus(true);
         label1.Text = "Transfering strings from war3map.wts...";
         wts_file wts = new wts_file("war3map_edited.wts");
         wts.SaveStripDataFile(true);
         wts.StringMapping();
         //打包进地图
         map.ImportFile("war3map.wts", "war3map_edited.wts");
         map.Flush();
         map.Compact();
         map.Close();
         if (File.Exists("war3map_edited.wts")) { File.Delete("war3map_edited.wts"); }
         TransferStatus(false);
         refreshfrm();
         label1.Text = "Finish.";
         MessageBox.Show("Finish!");
     }
 }
Ejemplo n.º 5
0
        private void button7_Click(object sender, EventArgs e)
        {
            if (openMapDialog.ShowDialog() == DialogResult.OK)
            {
                TransferStatus(true);
                if (Directory.Exists("map")) { Directory.Delete("map", true); }
                Directory.CreateDirectory(@"map\Units");
                #region ---解压mpq---
                //开始解压文件
                label1.Text = "Extracting Files...";
                //用于设置进度条。
                progressBar1.Minimum = 0;
                progressBar1.Maximum = unitsfilelist.GetLength(0);
                progressBar1.Step = 1;
                progressBar1.Value = 0;
                MpqLib.Mpq.CArchive map = new MpqLib.Mpq.CArchive(openMapDialog.FileName);
                for (int i = 0; i < unitsfilelist.Length; i++)
                {
                    progressBar1.PerformStep();
                    string filename = @"Units\" + unitsfilelist[i];
                    if (map.FileExists(filename))
                    {
                        map.ExportFile(filename, @"map\Units\" + unitsfilelist[i]);
                    }
                }
                if (map.FileExists(@"war3map.w3i"))   //解w3i
                { map.ExportFile(@"war3map.w3i", @"map\" + @"war3map.w3i"); }

                if (map.FileExists(@"war3map.wts"))   //解wts
                { map.ExportFile(@"war3map.wts", @"map\" + @"war3map.wts"); }

                //map.Close();
                #endregion
                #region ---读取stringlist---
                label1.Text = "Load string list...";
                string inidata = @"inilist.txt";
                string wtsdata = @"wts_data.txt";
                if (!File.Exists(inidata)) { MessageBox.Show("inilist.txt missing"); return; }
                StreamReader sr = new StreamReader(inidata);
                string[] iniss = sr.ReadToEnd().Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                sr.Close();
                if (!File.Exists(wtsdata)) { MessageBox.Show("wts_data.txt missing"); return; }
                StreamReader sr2 = new StreamReader(wtsdata);
                string[] wtsss = sr2.ReadToEnd().Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                sr2.Close();
                #endregion
                #region ---还原w3i---
                if (File.Exists(@"map\war3map.w3i"))
                {
                    label1.Text = "Restoring war3map.w3i...";
                    RestoreFileStringFromW3i(@"map\war3map.w3i", wtsss, "GAME_STRING ", true);
                }
                #endregion
                #region ---还原wts---
                if (File.Exists(@"map\war3map.wts"))
                {
                    label1.Text = "Restoring war3map.wts...";
                    RestoreFileString(@"map\war3map.wts", wtsss, "GAME_STRING ", true);
                }
                #endregion
                #region ---还原slk---
                label1.Text = "Restoring slk...";
                //遍历文件夹
                DirectoryInfo TheFolder = new DirectoryInfo(@"map\Units");
                FileInfo[] TheFiles = TheFolder.GetFiles();
                //用于设置进度条。
                progressBar1.Minimum = 0;
                progressBar1.Maximum = TheFiles.GetLength(0);
                progressBar1.Step = 1;
                progressBar1.Value = 0;
                foreach (FileInfo NextFile in TheFolder.GetFiles())
                {
                    if (NextFile.Extension == ".txt" || NextFile.Extension == ".fdf")
                    {
                        RestoreFileString(NextFile.FullName, iniss, "INI_STRING "); //it also comes with the "GAME_STRING "
                        Application.DoEvents();
                        RestoreFileString(NextFile.FullName, wtsss, "GAME_STRING ");
                        Application.DoEvents();
                    }
                    progressBar1.PerformStep();
                    Application.DoEvents();
                }
                #endregion
                #region ---重新压入地图---
                //war3map.j导入
                if (File.Exists("war3map.j")) { File.Copy("war3map.j", @"map\war3map.j", true); }
                //war3mapMisc.txt导入
                if (File.Exists("war3mapMisc.txt")) { File.Copy("war3mapMisc.txt", @"map\war3mapMisc.txt", true); }
                label1.Text = "Import to map...";
                PackAllFileToMpq(Application.StartupPath + @"\map", Application.StartupPath + @"\map", map);
                map.Flush();
                map.Compact();
                map.Close();
                #endregion
                label1.Text = "Finish.";
                TransferStatus(false);
                refreshfrm();
                MessageBox.Show("Finish!");
            }
        }
Ejemplo n.º 6
0
        private void button7_Click(object sender, EventArgs e)
        {
            if (openMapDialog.ShowDialog() == DialogResult.OK)
            {
                TransferStatus(true);
                if (Directory.Exists("map"))
                {
                    Directory.Delete("map", true);
                }
                Directory.CreateDirectory(@"map\Units");
                #region ---解压mpq---
                //开始解压文件
                label1.Text = "Extracting Files...";
                //用于设置进度条。
                progressBar1.Minimum = 0;
                progressBar1.Maximum = unitsfilelist.GetLength(0);
                progressBar1.Step    = 1;
                progressBar1.Value   = 0;
                MpqLib.Mpq.CArchive map = new MpqLib.Mpq.CArchive(openMapDialog.FileName);
                for (int i = 0; i < unitsfilelist.Length; i++)
                {
                    progressBar1.PerformStep();
                    string filename = @"Units\" + unitsfilelist[i];
                    if (map.FileExists(filename))
                    {
                        map.ExportFile(filename, @"map\Units\" + unitsfilelist[i]);
                    }
                }
                if (map.FileExists(@"war3map.w3i"))   //解w3i
                {
                    map.ExportFile(@"war3map.w3i", @"map\" + @"war3map.w3i");
                }

                if (map.FileExists(@"war3map.wts"))   //解wts
                {
                    map.ExportFile(@"war3map.wts", @"map\" + @"war3map.wts");
                }

                //map.Close();
                #endregion
                #region ---读取stringlist---
                label1.Text = "Load string list...";
                string inidata = @"inilist.txt";
                string wtsdata = @"wts_data.txt";
                if (!File.Exists(inidata))
                {
                    MessageBox.Show("inilist.txt missing"); return;
                }
                StreamReader sr    = new StreamReader(inidata);
                string[]     iniss = sr.ReadToEnd().Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                sr.Close();
                if (!File.Exists(wtsdata))
                {
                    MessageBox.Show("wts_data.txt missing"); return;
                }
                StreamReader sr2   = new StreamReader(wtsdata);
                string[]     wtsss = sr2.ReadToEnd().Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                sr2.Close();
                #endregion
                #region ---还原w3i---
                if (File.Exists(@"map\war3map.w3i"))
                {
                    label1.Text = "Restoring war3map.w3i...";
                    RestoreFileStringFromW3i(@"map\war3map.w3i", wtsss, "GAME_STRING ", true);
                }
                #endregion
                #region ---还原wts---
                if (File.Exists(@"map\war3map.wts"))
                {
                    label1.Text = "Restoring war3map.wts...";
                    RestoreFileString(@"map\war3map.wts", wtsss, "GAME_STRING ", true);
                }
                #endregion
                #region ---还原slk---
                label1.Text = "Restoring slk...";
                //遍历文件夹
                DirectoryInfo TheFolder = new DirectoryInfo(@"map\Units");
                FileInfo[]    TheFiles  = TheFolder.GetFiles();
                //用于设置进度条。
                progressBar1.Minimum = 0;
                progressBar1.Maximum = TheFiles.GetLength(0);
                progressBar1.Step    = 1;
                progressBar1.Value   = 0;
                foreach (FileInfo NextFile in TheFolder.GetFiles())
                {
                    if (NextFile.Extension == ".txt" || NextFile.Extension == ".fdf")
                    {
                        RestoreFileString(NextFile.FullName, iniss, "INI_STRING "); //it also comes with the "GAME_STRING "
                        Application.DoEvents();
                        RestoreFileString(NextFile.FullName, wtsss, "GAME_STRING ");
                        Application.DoEvents();
                    }
                    progressBar1.PerformStep();
                    Application.DoEvents();
                }
                #endregion
                #region ---重新压入地图---
                //war3map.j导入
                if (File.Exists("war3map.j"))
                {
                    File.Copy("war3map.j", @"map\war3map.j", true);
                }
                //war3mapMisc.txt导入
                if (File.Exists("war3mapMisc.txt"))
                {
                    File.Copy("war3mapMisc.txt", @"map\war3mapMisc.txt", true);
                }
                label1.Text = "Import to map...";
                PackAllFileToMpq(Application.StartupPath + @"\map", Application.StartupPath + @"\map", map);
                map.Flush();
                map.Compact();
                map.Close();
                #endregion
                label1.Text = "Finish.";
                TransferStatus(false);
                refreshfrm();
                MessageBox.Show("Finish!");
            }
        }