From d17a41d7ca657e50724314ec89a5c781466e2265 Mon Sep 17 00:00:00 2001 From: Miepee <38186597+Miepee@users.noreply.github.com> Date: Mon, 15 Nov 2021 10:55:35 +0100 Subject: [PATCH] fix bug, bump version, optional feature - fix the bug where the zip has to be next to the executable - if the program detects icon.png's or splash.png's in the zip already, it won't overwrite them. --- AM2RPortHelper/AM2RPortHelper.csproj | 3 +++ AM2RPortHelper/LICENSE | 21 +++++++++++++++++++++ AM2RPortHelper/Program.cs | 23 ++++++++++++----------- 3 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 AM2RPortHelper/LICENSE diff --git a/AM2RPortHelper/AM2RPortHelper.csproj b/AM2RPortHelper/AM2RPortHelper.csproj index 081e9d2..a5766a4 100644 --- a/AM2RPortHelper/AM2RPortHelper.csproj +++ b/AM2RPortHelper/AM2RPortHelper.csproj @@ -6,6 +6,9 @@ + + PreserveNewest + PreserveNewest diff --git a/AM2RPortHelper/LICENSE b/AM2RPortHelper/LICENSE new file mode 100644 index 0000000..028a30c --- /dev/null +++ b/AM2RPortHelper/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Miepee + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/AM2RPortHelper/Program.cs b/AM2RPortHelper/Program.cs index ddeeb9a..96097c4 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.Reflection; using System.Runtime.InteropServices; using System.Threading; @@ -9,9 +10,9 @@ namespace AM2RPortHelper { class Program { - static string version = "1.0"; + static string version = "1.1"; static string tmp = Path.GetTempPath(); - static string currentDir = Directory.GetCurrentDirectory(); + static string currentDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); static string utilDir = currentDir + "/utils"; static void Main(string[] args) @@ -46,8 +47,6 @@ namespace AM2RPortHelper default: Console.WriteLine("Unacceptable input. Aborting..."); return; } - Console.WriteLine("Successfully finished!"); - 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); } @@ -79,8 +78,10 @@ namespace AM2RPortHelper File.Delete(assetsDir + "/D3DX9_43.dll"); File.Move(assetsDir + "/data.win", assetsDir + "/game.unx"); File.Copy(utilDir + "/runner", extractDirectory + "/runner"); - File.Copy(utilDir + "/icon.png", assetsDir + "/icon.png"); - File.Copy(utilDir + "/splash.png", assetsDir + "/splash.png"); + if (!File.Exists(assetsDir + "/icon.png")) + File.Copy(utilDir + "/icon.png", assetsDir + "/icon.png"); + if (!File.Exists(assetsDir + "/splash.png")) + File.Copy(utilDir + "/splash.png", assetsDir + "/splash.png"); //recursively lowercase everything in the assets folder LowercaseFolder(assetsDir); @@ -95,6 +96,8 @@ namespace AM2RPortHelper // Clean up Directory.Delete(assetsDir, true); + + 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"); } static void PortForAndroid(FileInfo modZipPath) @@ -103,7 +106,6 @@ namespace AM2RPortHelper string unzipDir = extractDirectory + "/zip"; 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"; @@ -118,8 +120,6 @@ namespace AM2RPortHelper Directory.CreateDirectory(extractDirectory); ZipFile.ExtractToDirectory(modZipPath.FullName, unzipDir); - //TODO: MAKE CROSS PLATFORM - // Run APKTOOL and decompress the file ProcessStartInfo pStartInfo = new ProcessStartInfo { @@ -153,7 +153,6 @@ namespace AM2RPortHelper File.WriteAllText(apkDir + "/apktool.yml", yamlFile); // Run APKTOOL and build the apk - //TODO: MAKE CROSS PLATFORM pStartInfo = new ProcessStartInfo { FileName = bin, @@ -164,7 +163,6 @@ namespace AM2RPortHelper p.Start(); p.WaitForExit(); - //TODO: MAKE CROSS PLATFORM // Sign the apk pStartInfo = new ProcessStartInfo { @@ -186,6 +184,9 @@ namespace AM2RPortHelper // Clean up Directory.Delete(extractDirectory, true); + + Console.WriteLine("Successfully finished!"); + Console.WriteLine("\n**This will currently use default splashes and icons, if you don't like them don't forget to replace them in the apk**\n"); } static void LowercaseFolder(string directory)