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.
actions 1.1
Miepee 5 years ago
parent 75f2d4db23
commit d17a41d7ca

@ -6,6 +6,9 @@
</PropertyGroup>
<ItemGroup>
<None Update="LICENSE">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="utils\AM2RWrapper.apk">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>

@ -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.

@ -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)

Loading…
Cancel
Save