Add windows port option to cli, improve interactive slightly, clean zip checks

mac
Miepee 3 years ago
parent 6620cdd16b
commit 49c43e89fe

@ -123,10 +123,8 @@ internal static class Program
} }
private static void RunInteractive() private static void RunInteractive()
{ {
Console.WriteLine("**Before you proceed, make sure to replace the icon.png and splash.png with custom ones if you don't want to have placeholders**");
Console.WriteLine("THIS TOOL ONLY WORKS FOR MODS BASED ON THE COMMUNITY UPDATES! MODS BASED ON 1.1 WILL NOT WORK!"); Console.WriteLine("THIS TOOL ONLY WORKS FOR MODS BASED ON THE COMMUNITY UPDATES! MODS BASED ON 1.1 WILL NOT WORK!");
// Path to zip // Path to zip
bool invalidZip = true; bool invalidZip = true;
string modZipPath; string modZipPath;
@ -142,6 +140,7 @@ internal static class Program
} while (invalidZip); } while (invalidZip);
// OS choice // OS choice
bool windowsSelected = false;
bool linuxSelected = false; bool linuxSelected = false;
bool androidSelected = false; bool androidSelected = false;
bool macSelected = false; bool macSelected = false;
@ -149,23 +148,26 @@ internal static class Program
do do
{ {
Console.WriteLine("Select the platforms you want to port to:"); Console.WriteLine("Select the platforms you want to port to:");
Console.WriteLine($"1 - Linux (currently {(linuxSelected ? "on" : "off")})"); Console.WriteLine($"1 - Windows (currently {(windowsSelected ? "on" : "off")})");
Console.WriteLine($"2 - Android (currently {(androidSelected ? "on" : "off")})"); Console.WriteLine($"2 - Linux (currently {(linuxSelected ? "on" : "off")})");
Console.WriteLine($"3 - Mac (currently {(macSelected ? "on" : "off")})"); Console.WriteLine($"3 - Android (currently {(androidSelected ? "on" : "off")})");
Console.WriteLine("4 - Port!"); Console.WriteLine($"4 - Mac (currently {(macSelected ? "on" : "off")})");
Console.WriteLine("5 - Port!");
var input = Console.ReadKey().Key.ToString(); var input = Console.ReadKey().Key.ToString();
Console.WriteLine(); Console.WriteLine();
switch (input) switch (input)
{ {
case "D1": linuxSelected = !linuxSelected; break; case "D1": windowsSelected = !windowsSelected; break;
case "D2": linuxSelected = !linuxSelected; break;
case "D2": androidSelected = !androidSelected; break; case "D3": androidSelected = !androidSelected; break;
case "D3": macSelected = !macSelected; break; case "D4": macSelected = !macSelected; break;
case "D4": case "D5":
if (linuxSelected || androidSelected || macSelected) if (windowsSelected || linuxSelected || androidSelected || macSelected)
invalidOS = false; invalidOS = false;
else else
Console.WriteLine("You have to select at least one OS!"); Console.WriteLine("You have to select at least one OS!");
@ -183,6 +185,10 @@ internal static class Program
string splashPath = Console.ReadLine(); string splashPath = Console.ReadLine();
if (String.IsNullOrWhiteSpace(splashPath) || !File.Exists(splashPath)) splashPath = null; if (String.IsNullOrWhiteSpace(splashPath) || !File.Exists(splashPath)) splashPath = null;
// If any of the paths were null, we fix them here to use defaults
iconPath = RawMods.GetProperPathToBuiltinIcons(nameof(Resources.icon), iconPath);
splashPath = RawMods.GetProperPathToBuiltinIcons(nameof(Resources.splash), splashPath);
// Port everything // Port everything
string currentDir = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory); string currentDir = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
string linuxPath = $"{currentDir}/{Path.GetFileNameWithoutExtension(modZipPath)}_LINUX.zip"; string linuxPath = $"{currentDir}/{Path.GetFileNameWithoutExtension(modZipPath)}_LINUX.zip";
@ -232,7 +238,8 @@ internal static class Program
} }
while (customSaveSelected == null); while (customSaveSelected == null);
RawMods.PortToAndroid(modZipPath, androidPath, iconPath, splashPath, customSaveSelected.Value, customSaveSelected.Value, OutputHandlerDelegate); RawMods.PortToAndroid(modZipPath, androidPath, iconPath, splashPath, customSaveSelected.Value,
customSaveSelected.Value, OutputHandlerDelegate);
} }
if (macSelected) if (macSelected)
{ {
@ -248,11 +255,9 @@ internal static class Program
// We want people to also provide zips that don't end in .zip. If it turns out to not be a zip, it'll still throw later. // We want people to also provide zips that don't end in .zip. If it turns out to not be a zip, it'll still throw later.
private static bool IsValidInputZip(string path) private static bool IsValidInputZip(string path)
{ {
return path != null && File.Exists(path); return File.Exists(path);
} }
private static bool IsValidInputZip(FileSystemInfo path) private static bool IsValidInputZip(FileSystemInfo path) => IsValidInputZip(path?.FullName);
{
return IsValidInputZip(path?.FullName);
}
} }
Loading…
Cancel
Save