diff --git a/AM2RPortHelper/Program.cs b/AM2RPortHelper/Program.cs index 0c64e5c..ddeeb9a 100644 --- a/AM2RPortHelper/Program.cs +++ b/AM2RPortHelper/Program.cs @@ -2,6 +2,7 @@ using System.Diagnostics; using System.IO; using System.IO.Compression; +using System.Runtime.InteropServices; using System.Threading; namespace AM2RPortHelper @@ -46,7 +47,7 @@ namespace AM2RPortHelper } Console.WriteLine("Successfully finished!"); - Console.WriteLine("**Make sure to replace the icon.png and splash.png with custom ones if you don't want to have placeholders**"); + Console.WriteLine("\n**Make sure to replace the icon.png and splash.png with custom ones if you don't want to have placeholders**\n"); Console.WriteLine("Exiting in 5 seconds..."); Thread.Sleep(5000); } @@ -103,9 +104,14 @@ namespace AM2RPortHelper string apkDir = extractDirectory + "/apk"; string apkAssetsDir = apkDir + "/assets"; string currentDir = Directory.GetCurrentDirectory(); + string bin = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "cmd.exe" : "java"; + string args = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "/C java -jar " : "-jar "; + string apktool = currentDir + "/utils/apktool.jar"; + string signer = currentDir + "/utils/uber-apk-signer.jar"; string finalApkBuild = extractDirectory + "/build-aligned-debugSigned.apk"; string apkModPath = currentDir + "/" + Path.GetFileNameWithoutExtension(modZipPath.FullName) + "_ANDROID.apk"; + // Check if temp folder exists, delete if yes, extract zip to there if (Directory.Exists(extractDirectory)) Directory.Delete(extractDirectory, true); @@ -117,8 +123,8 @@ namespace AM2RPortHelper // Run APKTOOL and decompress the file ProcessStartInfo pStartInfo = new ProcessStartInfo { - FileName = "cmd.exe", - Arguments = "/C java -jar \"" + currentDir + "/utils/apktool.jar\" d -f -o \"" + apkDir + "\" \"" + currentDir + "/utils/AM2RWrapper.apk" + "\"", + FileName = bin, + Arguments = args + "\"" + apktool + "\" d -f -o \"" + apkDir + "\" \"" + currentDir + "/utils/AM2RWrapper.apk" + "\"", CreateNoWindow = true }; Process p = new Process() { StartInfo = pStartInfo }; @@ -150,8 +156,8 @@ namespace AM2RPortHelper //TODO: MAKE CROSS PLATFORM pStartInfo = new ProcessStartInfo { - FileName = "cmd.exe", - Arguments = "/C java -jar \"" + currentDir + "/utils/apktool.jar\" b \"" + apkDir + "\" -o \"" + extractDirectory + "/build.apk" + "\"", + FileName = bin, + Arguments = args + "\"" + apktool + "\" b \"" + apkDir + "\" -o \"" + extractDirectory + "/build.apk" + "\"", CreateNoWindow = true }; p = new Process() { StartInfo = pStartInfo }; @@ -162,8 +168,8 @@ namespace AM2RPortHelper // Sign the apk pStartInfo = new ProcessStartInfo { - FileName = "cmd.exe", - Arguments = "/C java -jar \"" + currentDir + "/utils/uber-apk-signer.jar\" -a \"" + extractDirectory + "/build.apk" + "\"", + FileName = bin, + Arguments = args + "\"" + signer + "\" -a \"" + extractDirectory + "/build.apk" + "\"", CreateNoWindow = true }; p = new Process() { StartInfo = pStartInfo }; diff --git a/AM2RPortHelper/Properties/launchSettings.json b/AM2RPortHelper/Properties/launchSettings.json index 28633d7..084c28e 100644 --- a/AM2RPortHelper/Properties/launchSettings.json +++ b/AM2RPortHelper/Properties/launchSettings.json @@ -1,8 +1,7 @@ { "profiles": { "AM2RPortHelper": { - "commandName": "Project", - "commandLineArgs": "\"C:\\Users\\Narr\\Desktop\\AM2R History Archive\\Official Releases\\(16-08-15) AM2R v1.1.zip\"" + "commandName": "Project" } } } \ No newline at end of file diff --git a/README.md b/README.md index 65a6d40..0cfa0fc 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,6 @@ # AM2RPortHelper - A simple tool to make porting AM2R Windows builds to other platforms easier. +A simple tool to make porting Windows builds of AM2R-Mods to other platforms easier. This will *only* work with VM-mods of the Community Updates, not of the original 1.1. +You need to have at least .NET Core 5 installed. + +## How do I use this? +Simply compress your mod as a zip, and then drag-n-drop it into this tool. After that, select if you want to have a port made for Linux or Android. A zip/apk that can be used for the [AM2RModPacker]() will then be created into the directory next to the program.