|
|
|
@ -1,4 +1,7 @@
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
using System.CommandLine;
|
|
|
|
|
|
|
|
using System.CommandLine.Builder;
|
|
|
|
|
|
|
|
using System.CommandLine.Parsing;
|
|
|
|
using System.IO;
|
|
|
|
using System.IO;
|
|
|
|
using System.Threading;
|
|
|
|
using System.Threading;
|
|
|
|
using AM2RPortHelperLib;
|
|
|
|
using AM2RPortHelperLib;
|
|
|
|
@ -11,41 +14,106 @@ internal static class Program
|
|
|
|
|
|
|
|
|
|
|
|
//TODO: add "-l" flag. transfer launcher mods to each other.
|
|
|
|
//TODO: add "-l" flag. transfer launcher mods to each other.
|
|
|
|
|
|
|
|
|
|
|
|
private static void Main(string[] args)
|
|
|
|
private static int Main(string[] args)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Console.WriteLine("AM2RPortHelperCLI v" + version);
|
|
|
|
Console.WriteLine("AM2RPortHelperCLI v" + version);
|
|
|
|
|
|
|
|
|
|
|
|
if (args == null || args.Length == 0)
|
|
|
|
//TODO!
|
|
|
|
{
|
|
|
|
var interactiveOption = new Option<bool>(new[] {"-i", "--interactive"}, "Use an interactive mode");
|
|
|
|
Console.WriteLine("Please drag-n-drop a Zip of your mod or provide it as an argument.");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileInfo modZipPath = new FileInfo(args[0]);
|
|
|
|
RootCommand rootCommand = new RootCommand();
|
|
|
|
if (!modZipPath.Exists && modZipPath.Extension.ToLower() != "zip")
|
|
|
|
rootCommand.AddOption(interactiveOption);
|
|
|
|
{
|
|
|
|
rootCommand.SetHandler(RootMethod, interactiveOption);
|
|
|
|
Console.WriteLine("Path does not point to a mod zip");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return rootCommand.Invoke(args);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
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("\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("THIS ONLY WORKS FOR MODS BASED ON THE COMMUNITY UPDATES! MODS BASED ON 1.1 WILL NOT WORK!");
|
|
|
|
Console.WriteLine("THIS ONLY WORKS FOR MODS BASED ON THE COMMUNITY UPDATES! MODS BASED ON 1.1 WILL NOT WORK!");
|
|
|
|
Console.WriteLine("To which platform do you want to port to?\n1 - Linux\n2 - Android\n3 - MacOS");
|
|
|
|
Console.WriteLine("To which platform do you want to port to?\n1 - Linux\n2 - Android\n3 - MacOS");
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
var input = Console.ReadKey().Key.ToString();
|
|
|
|
}
|
|
|
|
Console.WriteLine();
|
|
|
|
private static void RootMethod(bool interactive)
|
|
|
|
switch (input)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (interactive)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case "D1": PortHelper.PortWindowsToLinux(modZipPath); break;
|
|
|
|
RunInteractive();
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var x = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void RunInteractive()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// Path to zip
|
|
|
|
|
|
|
|
bool invalidZip = true;
|
|
|
|
|
|
|
|
string modZipPath;
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Console.WriteLine("Please provide the full path to the raw mod zip!");
|
|
|
|
|
|
|
|
modZipPath = Console.ReadLine();
|
|
|
|
|
|
|
|
|
|
|
|
case "D2": PortHelper.PortWindowsToAndroid(modZipPath); break;
|
|
|
|
if (modZipPath == null || (!File.Exists(modZipPath) && Path.GetExtension(modZipPath).ToLower() != ".zip"))
|
|
|
|
|
|
|
|
Console.WriteLine("Path does not exist, or does not point to a zip file!");
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
invalidZip = false;
|
|
|
|
|
|
|
|
} while (invalidZip);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// OS choice
|
|
|
|
|
|
|
|
bool linuxSelected = false;
|
|
|
|
|
|
|
|
bool androidSelected = false;
|
|
|
|
|
|
|
|
bool macSelected = false;
|
|
|
|
|
|
|
|
bool invalidOS = true;
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Console.WriteLine("Select the platforms you want to port to:");
|
|
|
|
|
|
|
|
Console.WriteLine($"1 - Linux (currently {(linuxSelected ? "on" : "off")})");
|
|
|
|
|
|
|
|
Console.WriteLine($"2 - Android (currently {(androidSelected ? "on" : "off")})");
|
|
|
|
|
|
|
|
Console.WriteLine($"3 - Mac (currently {(macSelected ? "on" : "off")})");
|
|
|
|
|
|
|
|
Console.WriteLine("4 - Port!");
|
|
|
|
|
|
|
|
var input = Console.ReadKey().Key.ToString();
|
|
|
|
|
|
|
|
Console.WriteLine();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (input)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case "D1": linuxSelected = !linuxSelected; break;
|
|
|
|
|
|
|
|
|
|
|
|
case "D3": PortHelper.PortWindowsToMac(modZipPath); break;
|
|
|
|
case "D2": androidSelected = !androidSelected; break;
|
|
|
|
|
|
|
|
|
|
|
|
default: Console.WriteLine("Unacceptable input. Aborting..."); return;
|
|
|
|
case "D3": macSelected = !macSelected; break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case "D4":
|
|
|
|
|
|
|
|
if (linuxSelected || androidSelected || macSelected)
|
|
|
|
|
|
|
|
invalidOS = false;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
Console.WriteLine("You have to at least select one OS!");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} while (invalidOS);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string currentDir = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
|
|
|
|
|
|
|
|
string linuxPath = $"{currentDir}/{Path.GetFileNameWithoutExtension(modZipPath)}_LINUX.zip";
|
|
|
|
|
|
|
|
string androidPath = $"{currentDir}/{Path.GetFileNameWithoutExtension(modZipPath)}_ANDROID.apk";
|
|
|
|
|
|
|
|
string macPath = $"{currentDir}/{Path.GetFileNameWithoutExtension(modZipPath)}_MACOS.zip";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (File.Exists(linuxPath))
|
|
|
|
|
|
|
|
File.Delete(linuxPath);
|
|
|
|
|
|
|
|
if (File.Exists(androidPath))
|
|
|
|
|
|
|
|
File.Delete(androidPath);
|
|
|
|
|
|
|
|
if (File.Exists(macPath))
|
|
|
|
|
|
|
|
File.Delete(macPath);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (linuxSelected)
|
|
|
|
|
|
|
|
PortHelper.PortWindowsToLinux(modZipPath,linuxPath);
|
|
|
|
|
|
|
|
if (androidSelected)
|
|
|
|
|
|
|
|
PortHelper.PortWindowsToAndroid(modZipPath, androidPath);
|
|
|
|
|
|
|
|
if (macSelected)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Console.WriteLine("Mac requires a name! Please enter one (no special characters!):");
|
|
|
|
|
|
|
|
string modName = Console.ReadLine();
|
|
|
|
|
|
|
|
PortHelper.PortWindowsToMac(modZipPath, macPath, modName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("Successfully finished!");
|
|
|
|
Console.WriteLine("Successfully finished!");
|
|
|
|
Console.WriteLine("Exiting in 3 seconds...");
|
|
|
|
|
|
|
|
Thread.Sleep(3000);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|