Skip to content

Commit

Permalink
Make cross platform + fill readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Miepee committed Nov 14, 2021
1 parent d90ada3 commit 71de0a0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
20 changes: 13 additions & 7 deletions AM2RPortHelper/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Runtime.InteropServices;
using System.Threading;

namespace AM2RPortHelper
Expand Down Expand Up @@ -46,7 +47,7 @@ static void Main(string[] args)
}

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);
}
Expand Down Expand Up @@ -103,9 +104,14 @@ static void PortForAndroid(FileInfo modZipPath)
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);
Expand All @@ -117,8 +123,8 @@ static void PortForAndroid(FileInfo modZipPath)
// 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 };
Expand Down Expand Up @@ -150,8 +156,8 @@ static void PortForAndroid(FileInfo modZipPath)
//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 };
Expand All @@ -162,8 +168,8 @@ static void PortForAndroid(FileInfo modZipPath)
// 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 };
Expand Down
3 changes: 1 addition & 2 deletions AM2RPortHelper/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 71de0a0

Please sign in to comment.