private void button2_Click(object sender, EventArgs e) { //MessageBox.Show(System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)); string managed = gamePath + "\\Antigraviator_Data\\Managed"; List <string> sourcePaths = new List <string>(); List <string> destPaths = new List <string>(); string[] assembly = new string[6] { "ZeroG.pdb", "ZeroG.dll", "LiteNetLib.dll", "FrameworkZeroG.dll", "FrameworkZeroG.pdb", "0Harmony.dll" }; foreach (string file in assembly) { if (!FilesCopier.DeleteFile(managed + file)) { WriteToLog(managed + "\\" + file + " failed to delete"); MessageBox.Show("Some old mod files could not be deleted, this may cause problems with the installation. " + Environment.NewLine + "Please check the log for more details and manually replace the respective files"); } sourcePaths.Add(Application.StartupPath + "\\" + file); destPaths.Add(managed + "\\" + file); } if (!FilesCopier.CopyMultiple(sourcePaths, destPaths, true)) { WriteToLog("Some new mod files could not be copied to " + managed); MessageBox.Show("Some new mod files could not be copied to " + managed + Environment.NewLine + "Please copy them manually (refer to support for how)"); } if (isAlreadyPatched) { WriteToLog("No need to patch Assembly-CSharp.dll as it is already patched"); //MessageBox.Show("Successfully installed!"); } else { if (!FilesCopier.CreateBackup()) { WriteToLog("A backup could not be created. It is recommended to manually create a backup of " + managed + "\\Assembly-CSharp.dll"); MessageBox.Show("An automatic backup could not be created." + Environment.NewLine + "Please manually create a backup of " + managed + "\\Assembly-CSharp.dll , then press OK"); } else { WriteToLog("Created automatic backup at My Documents"); } if (!FilesCopier.AddToBackup(managed + "\\Assembly-CSharp.dll", "Backup-Assembly-CSharp.dll")) { WriteToLog("A backup of Assembly-CSharp.dll could not be created!"); MessageBox.Show("An automatic backup of Assembly-CSharp.dll could not be created. Please manually backup" + Environment.NewLine + managed + "\\Assembly-CSharp.dll , then press OK"); } else { WriteToLog("Created backup of Assembly-CSharp.dll"); } if (!FilesVerifierPatcher.PatchACShrp(managed + "\\Assembly-CSharp.dll", managed + "\\ZeroG.dll", "TempACShrp.dll", managed)) { WriteToLog("Assembly-CSharp.dll could not be patched!"); MessageBox.Show(managed + "\\Assembly-CSharp.dll could not be patched! Please do it manually"); if (FilesCopier.DeleteFile(managed + "\\Assembly-CSharp.dll")) { if (FilesCopier.CopyFile(Environment.SpecialFolder.MyDocuments + "\\ZeroG Mod Temp files\\Backup-Assembly-CSharp.dll", managed + "\\Assembly-CSharp.dll", true)) { WriteToLog("Assembly-CSharp.dll successfully restored."); } else { WriteToLog("Assembly-CSharp.dll could not be automatically restored. Please do it manually"); MessageBox.Show(@"Assembly-CSharp.dll could not be restored. Please restore it from My Documents\ZeroG Mod Temp Files\Backup-Assembly-CSharp.dll" + Environment.NewLine + " (or from wherever you backed it up manually) and paste it in " + Environment.NewLine + managed + " and rename it Assembly-CSharp"); } } else { WriteToLog("Assembly-CSharp.dll could not be deleted!"); MessageBox.Show(managed + @"\Assembly-CSharp.dll could not be restored. Please restore it from My Documents\ZeroG Mod Temp Files\Backup-Assembly-CSharp.dll" + Environment.NewLine + " (or from wherever you backed it up manually) and paste it in " + Environment.NewLine + managed + " and rename it Assembly-CSharp"); } } else { if (!FilesCopier.ClearBackup()) { WriteToLog("Failed to delete temporary backup"); MessageBox.Show("The automatic temporary backup that was created was not deleted. Please do it manually"); } WriteToLog("Assembly-CSharp.dll successfully patched!"); } } if (FilesCopier.CopyFolder(Application.StartupPath + "\\Server\\GUI", System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\Antigraviator LAN Multiplayer Server", true)) { WriteToLog("Successfully copied server files to desktop"); } else { WriteToLog("Failed to copy server files!"); MessageBox.Show("You have to copy the server from the zip manually"); } MessageBox.Show("Installation complete!"); }
private void button3_Click(object sender, EventArgs e) { string managed = gamePath + "\\Antigraviator_Data\\Managed"; if (isAlreadyPatched) { if (!FilesCopier.CreateBackup()) { WriteToLog("A backup could not be created. It is recommended to manually create a backup of " + managed + "\\Assembly-CSharp.dll"); MessageBox.Show("An automatic backup could not be created." + Environment.NewLine + "Please manually create a backup of " + managed + "\\Assembly-CSharp.dll , then press OK"); } else { WriteToLog("Created automatic backup at My Documents"); } if (!FilesCopier.AddToBackup(managed + "\\Assembly-CSharp.dll", "Backup-Assembly-CSharp.dll")) { WriteToLog("A backup of Assembly-CSharp.dll could not be created!"); MessageBox.Show("An automatic backup of Assembly-CSharp.dll could not be created. Please manually backup" + Environment.NewLine + managed + "\\Assembly-CSharp.dll , then press OK"); } else { WriteToLog("Created backup of Assembly-CSharp.dll"); } if (!FilesVerifierPatcher.RestoreACShrp(managed + "\\Assembly-CSharp.dll", "TmpACShrp.dll", managed)) { WriteToLog("Assembly-CSharp.dll could not be unpatched!"); MessageBox.Show(managed + "\\Assembly-CSharp.dll could not be unpatched! Please do it manually"); if (FilesCopier.DeleteFile(managed + "\\Assembly-CSharp.dll")) { if (FilesCopier.CopyFile(Environment.SpecialFolder.MyDocuments + "\\ZeroG Mod Temp files\\Backup-Assembly-CSharp.dll", managed + "\\Assembly-CSharp.dll", true)) { WriteToLog("Assembly-CSharp.dll successfully restored."); } else { WriteToLog("Assembly-CSharp.dll could not be automatically restored. Please do it manually"); MessageBox.Show(@"Assembly-CSharp.dll could not be restored. Please restore it from My Documents\ZeroG Mod Temp Files\Backup-Assembly-CSharp.dll" + Environment.NewLine + " (or from wherever you backed it up manually) and paste it in " + Environment.NewLine + managed + " and rename it Assembly-CSharp"); } } else { WriteToLog("Assembly-CSharp.dll could not be deleted!"); MessageBox.Show(managed + @"\Assembly-CSharp.dll could not be restored. Please restore it from My Documents\ZeroG Mod Temp Files\Backup-Assembly-CSharp.dll" + Environment.NewLine + " (or from wherever you backed it up manually) and paste it in " + Environment.NewLine + managed + " and rename it Assembly-CSharp"); } } else { if (!FilesCopier.ClearBackup()) { WriteToLog("Failed to delete temporary backup"); MessageBox.Show("The automatic temporary backup that was created was not deleted. Please do it manually"); } WriteToLog("Assembly-CSharp.dll successfully unpatched!"); } } string[] assembly = new string[6] { "ZeroG.pdb", "ZeroG.dll", "LiteNetLib.dll", "FrameworkZeroG.dll", "FrameworkZeroG.pdb", "0Harmony.dll" }; foreach (string file in assembly) { if (!FilesCopier.DeleteFile(managed + file)) { WriteToLog(managed + "\\" + file + " failed to delete"); MessageBox.Show("Some old mod files could not be deleted. " + Environment.NewLine + "Please check the log for more details and manually delete the respective files"); } } button3.Enabled = false; MessageBox.Show("Successfully uninstalled ZeroG"); }