private async Task PackVPP() { try { string[] Args = { gamePath.Text + "\\data\\misc.vpp_pc", gamePath.Text + "\\data\\_TEMP\\misc.vpp_pc.UNPACKED\\" }; int UnpackExitCode = new Gibbed.Volition.Pack.VPP.Packer <Gibbed.Volition.FileFormats.PackageFileV3, Gibbed.Volition.FileFormats.Package.Entry>().Main(Args); packingProgress.Invoke((MethodInvoker) delegate { packingProgress.Value = 30; }); if (installWeapons.Checked == true) { string[] Args2 = { gamePath.Text + "\\data\\items.vpp_pc", gamePath.Text + "\\data\\_TEMP\\items.vpp_pc.UNPACKED\\" }; int UnpackExitCode2 = new Gibbed.Volition.Pack.VPP.Packer <Gibbed.Volition.FileFormats.PackageFileV3, Gibbed.Volition.FileFormats.Package.Entry>().Main(Args2); } else { Console.WriteLine(""); } packingProgress.Invoke((MethodInvoker) delegate { packingProgress.Value = 55; }); if (installVehicles.Checked == true) { string[] Args3 = { gamePath.Text + "\\data\\vehicles_r.vpp_pc", gamePath.Text + "\\data\\_TEMP\\vehicles_r.vpp_pc.UNPACKED\\" }; int UnpackExitCode3 = new Gibbed.Volition.Pack.VPP.Packer <Gibbed.Volition.FileFormats.PackageFileV3, Gibbed.Volition.FileFormats.Package.Entry>().Main(Args3); } else { Console.WriteLine(""); } packingProgress.Invoke((MethodInvoker) delegate { packingProgress.Value = 100; }); packingGIF.Image = DLCTransferMod.Properties.Resources.icons8_checkmark_15; } catch (Exception e) { MessageBox.Show("Process failed to run: " + e); } }
private async void button1_ClickAsync(object sender, EventArgs e) { TreeNode tn = modList.SelectedNode; if (tn == null) { MessageBox.Show("You don't have a mod selected yet!", "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (modList.SelectedNode.Nodes.Count == 0) { this.Enabled = false; string text; text = modList.Nodes.IndexOf(modList.SelectedNode).ToString(); Console.WriteLine(text); string selecteditem = text; try { try { if (!File.Exists(game_DirectoryText.Text + "\\build\\pc\\cache\\misc.vpp_pc.BACKUP")) { File.Copy(game_DirectoryText.Text + "\\build\\pc\\cache\\misc.vpp_pc", game_DirectoryText.Text + "\\build\\pc\\cache\\misc.vpp_pc.BACKUP", true); } else if (File.Exists(game_DirectoryText.Text + "\\build\\pc\\cache\\misc.vpp_pc.BACKUP")) { Console.WriteLine("Backup file already exists"); } } catch (Exception a) { MessageBox.Show(a.ToString(), "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); } try { if (!File.Exists(game_DirectoryText.Text + "\\build\\pc\\cache\\table.vpp_pc")) { Console.WriteLine("Table file already renamed or removed"); } else if (File.Exists(game_DirectoryText.Text + "\\build\\pc\\cache\\table.vpp_pc")) { File.Move(game_DirectoryText.Text + "\\build\\pc\\cache\\table.vpp_pc", game_DirectoryText.Text + "\\build\\pc\\cache\\table.vpp_pc.RENAMED"); } } catch (Exception a) { MessageBox.Show(a.ToString(), "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); } UnpackVPP(); //string selecteditem = modList.(modList.SelectedItem); string path = game_DirectoryText.Text + "\\build\\pc\\cache\\_TEMP\\misc.vpp_pc\\"; string dirScanner = game_DirectoryText.Text + "\\mods"; // Scan for XML files located in the user specified game directory. string[] allFiles = Directory.GetFiles(dirScanner, "*.xml", SearchOption.AllDirectories); foreach (string file in allFiles) { // Read XML files found in the game directory. string[] lines = File.ReadAllLines(file); // Find and search XML files with the same name of the listbox item. string firstOccurrence = lines.FirstOrDefault(l => l.Contains(selecteditem)); if (firstOccurrence != null) { string parent_directory_path; parent_directory_path = Path.GetDirectoryName(file); string[] files = Directory.GetFiles(parent_directory_path + "\\misc.vpp_pc\\"); try { foreach (string file2 in files) { // Delete files with names from program folder string filenames = Path.GetFileName(file2); string filestocopy = Path.Combine(parent_directory_path + "\\misc.vpp_pc\\", filenames); DirectoryInfo d = new DirectoryInfo(parent_directory_path + "\\misc.vpp_pc\\"); File.Delete(Path.Combine(path, filenames)); } DirectoryInfo d2 = new DirectoryInfo(parent_directory_path + "\\misc.vpp_pc\\"); string d4 = parent_directory_path + "\\misc.vpp_pc\\"; string d3 = game_DirectoryText.Text + "\\build\\pc\\cache\\_TEMP\\misc.vpp_pc\\"; Console.WriteLine(d3); Console.WriteLine(d2); foreach (FileInfo files2 in d2.GetFiles("*.*", SearchOption.AllDirectories)) { files2.CopyTo(Path.Combine(d3, files2.Name)); } } catch (Exception a) { MessageBox.Show(a.ToString(), "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } //Delete VPP so that the VPP can be packed without an error. File.Delete(game_DirectoryText.Text + "\\build\\pc\\cache\\misc.vpp_pc"); while (!Directory.Exists(game_DirectoryText.Text + "\\build\\pc\\cache\\_TEMP\\")) { wait(1000); Console.WriteLine("_TEMP is not created yet."); } while (Directory.Exists(game_DirectoryText.Text + "\\build\\pc\\cache\\_TEMP\\")) { string[] Args2 = { game_DirectoryText.Text + "\\build\\pc\\cache\\misc.vpp_pc", game_DirectoryText.Text + "\\build\\pc\\cache\\_TEMP\\misc.vpp_pc\\" }; int UnpackExitCode2 = new Gibbed.Volition.Pack.VPP.Packer <Gibbed.Volition.FileFormats.PackageFileV6, Gibbed.Volition.FileFormats.Package.Entry>().Main(Args2); break; } Directory.Delete(game_DirectoryText.Text + "\\build\\pc\\cache\\_TEMP\\", true); this.Enabled = true; MessageBox.Show("Mod activated.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (FileNotFoundException a) { MessageBox.Show("The misc.vpp_pc file could not be found in your build\\pc\\cache directory!", "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Enabled = true; } catch (Exception b) { MessageBox.Show(b.ToString(), "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Enabled = true; } } else { MessageBox.Show("You don't have a mod selected yet!", "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } }
public void PackVPP() { string[] Args2 = { game_DirectoryText.Text + "\\build\\pc\\cache\\misc.vpp_pc", game_DirectoryText.Text + "\\build\\pc\\cache\\_TEMP\\misc.vpp" }; int UnpackExitCode2 = new Gibbed.Volition.Pack.VPP.Packer <Gibbed.Volition.FileFormats.PackageFileV3, Gibbed.Volition.FileFormats.Package.Entry>().Main(Args2); }
public void PackVPP() { string[] Args = { game_DirectoryText.Text + "\\data\\misc_PACKED.vpp_pc", game_DirectoryText.Text + "\\data\\misc.vpp\\" }; int UnpackExitCode = new Gibbed.Volition.Pack.VPP.Packer <Gibbed.Volition.FileFormats.PackageFileV3, Gibbed.Volition.FileFormats.Package.Entry>().Main(Args); }