From 08bf9f9876e6f5af86ee227b8cb50a15aa5474e2 Mon Sep 17 00:00:00 2001 From: Miepee Date: Thu, 8 Dec 2022 22:13:12 +0100 Subject: [PATCH] Actually make windows optional --- AM2RModPacker/ModPacker.cs | 39 +++++----- AM2RModPackerLib/Core.cs | 102 +++++++++++++------------- AM2RModPackerLib/XML/ModProfileXML.cs | 3 +- AM2RModPackerLib/XML/Serializer.cs | 4 +- 4 files changed, 76 insertions(+), 72 deletions(-) diff --git a/AM2RModPacker/ModPacker.cs b/AM2RModPacker/ModPacker.cs index 6e28850..3fac629 100644 --- a/AM2RModPacker/ModPacker.cs +++ b/AM2RModPacker/ModPacker.cs @@ -39,6 +39,7 @@ public partial class ModPacker : Form var dialog = new SelectFolderDialog(); // TODO: .config on linux + dialog.Directory = Environment.GetEnvironmentVariable("LocalAppData"); while (!wasSuccessful) { @@ -94,7 +95,6 @@ public partial class ModPacker : Form windowsLabel.Visible = false; windowsPath = ""; } - UpdateCreateButton(); } @@ -203,25 +203,28 @@ public partial class ModPacker : Form createLabel.Text = "Packaging mod(s)... This could take a while!"; string output; + bool successful; + string errorCode; - // TODO: make windows optional - using (var saveFile = new SaveFileDialog { Title = "Save Windows mod profile", Filters = { zipFileFilter } }) + if (windowsCheckBox.Checked.Value) { - if (saveFile.ShowDialog(this) == DialogResult.Ok) - output = saveFile.FileName; - else + using (var saveFile = new SaveFileDialog { Title = "Save Windows mod profile", Filters = { zipFileFilter } }) { - createLabel.Text = "Mod packaging aborted!"; - return; + if (saveFile.ShowDialog(this) == DialogResult.Ok) + output = saveFile.FileName; + else + { + createLabel.Text = "Mod packaging aborted!"; + return; + } + } + LoadProfileParameters(ProfileOperatingSystems.Windows); + (successful, errorCode) = Core.CreateModPack(profile, windowsPath, originalPath, apkPath, output); + if (!successful) + { + MessageBox.Show(errorCode, "Error", MessageBoxButtons.OK, MessageBoxType.Error); + AbortPatch(); } - } - LoadProfileParameters(ProfileOperatingSystems.Windows); - - (bool successful, string errorcode) = Core.CreateModPack(profile, windowsPath,originalPath, apkPath, output); - if (!successful) - { - MessageBox.Show(errorcode, "Error", MessageBoxButtons.OK, MessageBoxType.Error); - AbortPatch(); } if (linuxCheckBox.Checked.Value) @@ -237,10 +240,10 @@ public partial class ModPacker : Form } } LoadProfileParameters(ProfileOperatingSystems.Linux); - (successful, errorcode) = Core.CreateModPack(profile, linuxPath, originalPath, apkPath, output); + (successful, errorCode) = Core.CreateModPack(profile, linuxPath, originalPath, apkPath, output); if (!successful) { - MessageBox.Show(errorcode, "Error", MessageBoxButtons.OK, MessageBoxType.Error); + MessageBox.Show(errorCode, "Error", MessageBoxButtons.OK, MessageBoxType.Error); AbortPatch(); } } diff --git a/AM2RModPackerLib/Core.cs b/AM2RModPackerLib/Core.cs index a528cbd..e6482e0 100644 --- a/AM2RModPackerLib/Core.cs +++ b/AM2RModPackerLib/Core.cs @@ -61,100 +61,104 @@ public static class Core string newMD5 = CalculateMD5(tempOriginalPath + "/data.win"); if (newMD5 != originalMD5) - { return (false, "1.1 data.win does not meet MD5 checksum! Mod packaging aborted.\n1.1 MD5: " + originalMD5 + "\nYour MD5: " + newMD5); - } } catch (FileNotFoundException) { return (false, "data.win not found! Are you sure you selected AM2R 1.1? Mod packaging aborted."); } - // Create AM2R.exe and data.win patches - if (profile.OperatingSystem == "Windows") + switch (profile.OperatingSystem) { - if (!File.Exists(tempModPath + "/AM2R.exe")) - { //TODO: put this onto the outer method - /* + // Create AM2R.exe and data.win patches + case "Windows": + { + if (!File.Exists(tempModPath + "/AM2R.exe")) + { //TODO: put this onto the outer method + /* var result = MessageBox.Show("Modded game not found, make sure it's not placed in any subfolders.\nCreated profile will likely not be installable, are you sure you want to continue?", "WARNING", MessageBoxButtons.YesNo, MessageBoxType.Warning); if (result != DialogResult.Yes) { AbortPatch(); return (false, ""); }*/ - } + } - if (File.Exists(tempModPath + "profile.xml")) - { - //TODO: put this onto the outer method - /*var result = MessageBox.Show("profile.xml found. This file is used by the AM2RLauncher to determine profile stats and its inclusion may make the profile uninstallable. Are you sure you want to continue?", "WARNING", MessageBoxButtons.YesNo, MessageBoxType.Warning); + if (File.Exists(tempModPath + "profile.xml")) + { + //TODO: put this onto the outer method + /*var result = MessageBox.Show("profile.xml found. This file is used by the AM2RLauncher to determine profile stats and its inclusion may make the profile uninstallable. Are you sure you want to continue?", "WARNING", MessageBoxButtons.YesNo, MessageBoxType.Warning); if (result != DialogResult.Yes) { AbortPatch(); return (false, ""); }*/ - } + } - if (profile.UsesYYC) - { - CreatePatch(tempOriginalPath + "/data.win", tempModPath + "/AM2R.exe", tempProfilePath + "/AM2R.xdelta"); + if (profile.UsesYYC) + { + CreatePatch(tempOriginalPath + "/data.win", tempModPath + "/AM2R.exe", tempProfilePath + "/AM2R.xdelta"); + } + else + { + CreatePatch(tempOriginalPath + "/data.win", tempModPath + "/data.win", tempProfilePath + "/data.xdelta"); + CreatePatch(tempOriginalPath + "/AM2R.exe", tempModPath + "/AM2R.exe", tempProfilePath + "/AM2R.xdelta"); + } + break; } - else + case "Linux": { - CreatePatch(tempOriginalPath + "/data.win", tempModPath + "/data.win", tempProfilePath + "/data.xdelta"); - CreatePatch(tempOriginalPath + "/AM2R.exe", tempModPath + "/AM2R.exe", tempProfilePath + "/AM2R.xdelta"); - } - } - else if (profile.OperatingSystem == "Linux") - { - string runnerName = File.Exists(tempModPath + "/" + "AM2R") ? "AM2R" : "runner"; + string runnerName = File.Exists(tempModPath + "/" + "AM2R") ? "AM2R" : "runner"; - if (!File.Exists(tempModPath + "/" + runnerName)) - {//TODO: put this onto the outer method - /* + if (!File.Exists(tempModPath + "/" + runnerName)) + { //TODO: put this onto the outer method + /* var result = MessageBox.Show("Modded Linux game not found, make sure it's not placed in any subfolders.\nCreated profile will likely not be installable, are you sure you want to continue?", "WARNING", MessageBoxButtons.YesNo, MessageBoxType.Warning); if (result != DialogResult.Yes) { AbortPatch(); return (false, ""); }*/ - } + } - if (File.Exists(tempModPath + "profile.xml")) - { - //TODO: put this onto the outer method - /* var result = MessageBox.Show("profile.xml found. This file is used by the AM2RLauncher to determine profile stats and its inclusion may make the profile uninstallable. Are you sure you want to continue?", "WARNING", MessageBoxButtons.YesNo, MessageBoxType.Warning); + if (File.Exists(tempModPath + "profile.xml")) + { + //TODO: put this onto the outer method + /* var result = MessageBox.Show("profile.xml found. This file is used by the AM2RLauncher to determine profile stats and its inclusion may make the profile uninstallable. Are you sure you want to continue?", "WARNING", MessageBoxButtons.YesNo, MessageBoxType.Warning); if (result != DialogResult.Yes) { AbortPatch(); return (false, ""); }*/ - } + } - CreatePatch(tempOriginalPath + "/data.win", tempModPath + "/assets/game.unx", tempProfilePath + "/game.xdelta"); - CreatePatch(tempOriginalPath + "/AM2R.exe", tempModPath + "/" + runnerName, tempProfilePath + "/AM2R.xdelta"); - } - else if (profile.OperatingSystem == "Mac") - { - if (!File.Exists(tempModPath + "/AM2R.app/Contents/MacOS/Mac_Runner")) + CreatePatch(tempOriginalPath + "/data.win", tempModPath + "/assets/game.unx", tempProfilePath + "/game.xdelta"); + CreatePatch(tempOriginalPath + "/AM2R.exe", tempModPath + "/" + runnerName, tempProfilePath + "/AM2R.xdelta"); + break; + } + case "Mac": { - /*var result = MessageBox.Show("Modded Mac game not found, make sure it's not placed in any subfolders.\nCreated profile will likely not be installable, are you sure you want to continue?", "WARNING", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); + if (!File.Exists(tempModPath + "/AM2R.app/Contents/MacOS/Mac_Runner")) + { + /*var result = MessageBox.Show("Modded Mac game not found, make sure it's not placed in any subfolders.\nCreated profile will likely not be installable, are you sure you want to continue?", "WARNING", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result != DialogResult.Yes) AbortPatch();*/ - } + } - if (File.Exists(tempModPath + "profile.xml")) - { - /*var result = MessageBox.Show("profile.xml found. This file is used by the AM2RLauncher to determine profile stats and its inclusion may make the profile uninstallable. Are you sure you want to continue?", "WARNING", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); + if (File.Exists(tempModPath + "profile.xml")) + { + /*var result = MessageBox.Show("profile.xml found. This file is used by the AM2RLauncher to determine profile stats and its inclusion may make the profile uninstallable. Are you sure you want to continue?", "WARNING", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result != DialogResult.Yes) AbortPatch();*/ - } + } - CreatePatch(tempOriginalPath + "/data.win", tempModPath + "/AM2R.app/Contents/Resources/game.ios", tempProfilePath + "/game.xdelta"); - CreatePatch(tempOriginalPath + "/AM2R.exe", tempModPath + "/AM2R.app/Contents/MacOS/Mac_Runner", tempProfilePath + "/AM2R.xdelta"); + CreatePatch(tempOriginalPath + "/data.win", tempModPath + "/AM2R.app/Contents/Resources/game.ios", tempProfilePath + "/game.xdelta"); + CreatePatch(tempOriginalPath + "/AM2R.exe", tempModPath + "/AM2R.app/Contents/MacOS/Mac_Runner", tempProfilePath + "/AM2R.xdelta"); - // Copy plist over for custom title name - File.Copy(tempModPath + "/AM2R.app/Contents/Info.plist", tempProfilePath + "/Info.plist"); + // Copy plist over for custom title name + File.Copy(tempModPath + "/AM2R.app/Contents/Info.plist", tempProfilePath + "/Info.plist"); + break; + } } // Create game.droid patch and wrapper if Android is supported diff --git a/AM2RModPackerLib/XML/ModProfileXML.cs b/AM2RModPackerLib/XML/ModProfileXML.cs index 4c51942..1b180d8 100644 --- a/AM2RModPackerLib/XML/ModProfileXML.cs +++ b/AM2RModPackerLib/XML/ModProfileXML.cs @@ -1,5 +1,4 @@ -using System; -using System.Xml.Serialization; +using System.Xml.Serialization; namespace AM2RModPackerLib.XML; diff --git a/AM2RModPackerLib/XML/Serializer.cs b/AM2RModPackerLib/XML/Serializer.cs index bb6948c..ec820b0 100644 --- a/AM2RModPackerLib/XML/Serializer.cs +++ b/AM2RModPackerLib/XML/Serializer.cs @@ -1,6 +1,4 @@ -using System; -using System.IO; -using System.Text; +using System.Text; namespace AM2RModPackerLib.XML;