Make CLI and GUI work again

mac
Miepee 3 years ago
parent 7e1392c94e
commit ff34c23a88

@ -22,7 +22,7 @@ internal static class Program
var linuxOption = new Option<FileInfo>(new[] { "-l", "--linux" }, "The output file path for the Linux mod. None given equals to no Linux port."); var linuxOption = new Option<FileInfo>(new[] { "-l", "--linux" }, "The output file path for the Linux mod. None given equals to no Linux port.");
var androidOption = new Option<FileInfo>(new[] { "-a", "--android" }, "The output file path for the Android mod. None given equals to no Android port."); var androidOption = new Option<FileInfo>(new[] { "-a", "--android" }, "The output file path for the Android mod. None given equals to no Android port.");
var macOption = new Option<FileInfo>(new[] { "-m", "--mac" }, "The output file path for the Mac mod. None given equals to no Mac port."); var macOption = new Option<FileInfo>(new[] { "-m", "--mac" }, "The output file path for the Mac mod. None given equals to no Mac port.");
var nameOption = new Option<string>(new[] { "-n", "--name" }, "The name used for the Mac or Android mod. Required for the Mac option, and optional for the Android version. Has no effect on anything else."); var nameOption = new Option<bool>(new[] { "-s", "--customsave" }, "Whether the Android Port should use a custom save location. Has no effect on anything else.");
var internetOption = new Option<bool>(new[] { "-w", "--internet" }, "Add internet usage permissions to the Android mod. Has no effect to other OS."); var internetOption = new Option<bool>(new[] { "-w", "--internet" }, "Add internet usage permissions to the Android mod. Has no effect to other OS.");
var verboseOption = new Option<bool>(new[] { "-v", "--verbose" }, "Whether to show verbose output."); var verboseOption = new Option<bool>(new[] { "-v", "--verbose" }, "Whether to show verbose output.");
@ -44,7 +44,7 @@ internal static class Program
} }
#pragma warning disable CS1998 #pragma warning disable CS1998
private static async Task<int> RootMethod(bool interactive, FileInfo inputModPath, FileInfo linuxPath, FileInfo androidPath, FileInfo macPath, private static async Task<int> RootMethod(bool interactive, FileInfo inputModPath, FileInfo linuxPath, FileInfo androidPath, FileInfo macPath,
string modName, bool usesInternet, bool beVerbose) bool useCustomSave, bool usesInternet, bool beVerbose)
#pragma warning restore CS1998 #pragma warning restore CS1998
{ {
if (interactive || beVerbose) if (interactive || beVerbose)
@ -69,16 +69,11 @@ internal static class Program
if (androidPath is not null) if (androidPath is not null)
{ {
RawMods.PortToAndroid(inputModPath.FullName, androidPath.FullName, RawMods.PortToAndroid(inputModPath.FullName, androidPath.FullName,
String.IsNullOrWhiteSpace(modName) ? null : modName, usesInternet, beVerbose ? OutputHandlerDelegate : null); useCustomSave, usesInternet, beVerbose ? OutputHandlerDelegate : null);
} }
if (macPath is not null) if (macPath is not null)
{ {
if (modName is null) RawMods.PortToMac(inputModPath.FullName, macPath.FullName, beVerbose ? OutputHandlerDelegate : null);
{
Console.Error.WriteLine("Mac option was chosen but mod name was not given!");
return 1;
}
RawMods.PortToMac(inputModPath.FullName, macPath.FullName, modName, beVerbose ? OutputHandlerDelegate : null);
} }
if (beVerbose) if (beVerbose)
Console.WriteLine("Done."); Console.WriteLine("Done.");
@ -170,8 +165,23 @@ internal static class Program
Console.WriteLine(); Console.WriteLine();
} }
while (internetSelected == null); while (internetSelected == null);
bool? customSaveSelected = null;
do
{
Console.WriteLine("Do you want to use a custom save location for Android (y/n)?");
var input = Console.ReadKey().Key;
switch (input)
{
case ConsoleKey.Y: customSaveSelected = true; break;
case ConsoleKey.N: customSaveSelected = false; break;
default: Console.WriteLine("Invalid input!"); break;
}
Console.WriteLine();
}
while (customSaveSelected == null);
RawMods.PortToAndroid(modZipPath, androidPath, null, internetSelected.Value, OutputHandlerDelegate); RawMods.PortToAndroid(modZipPath, androidPath, customSaveSelected.Value, customSaveSelected.Value, OutputHandlerDelegate);
} }
if (macSelected) if (macSelected)
{ {
@ -180,7 +190,7 @@ internal static class Program
Console.WriteLine("Mac requires a name! Please enter one (no special characters!):"); Console.WriteLine("Mac requires a name! Please enter one (no special characters!):");
string modName = Console.ReadLine(); string modName = Console.ReadLine();
RawMods.PortToMac(modZipPath, macPath, modName, OutputHandlerDelegate); RawMods.PortToMac(modZipPath, macPath, OutputHandlerDelegate);
} }
Console.WriteLine("Successfully finished!"); Console.WriteLine("Successfully finished!");

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>.net6.0</TargetFramework>
<LangVersion>10</LangVersion> <LangVersion>10</LangVersion>
</PropertyGroup> </PropertyGroup>

@ -42,7 +42,7 @@ public partial class MainForm : Form
mainLayout.EndCentered(); mainLayout.EndCentered();
mainLayout.AddRow(new Label() { Height = 5 }); mainLayout.AddRow(new Label() { Height = 5 });
mainLayout.BeginCentered(); mainLayout.BeginCentered();
mainLayout.AddRow(labelModName, new Label { Width = 15 }, textboxModName); mainLayout.AddRow(checkboxUseCustomSave);
mainLayout.EndCentered(); mainLayout.EndCentered();
mainLayout.AddSpace(); mainLayout.AddSpace();
mainLayout.BeginVertical(); mainLayout.BeginVertical();
@ -79,7 +79,7 @@ public partial class MainForm : Form
checkboxAndroidRequiresInternet.CheckedChanged += ShouldButtonPortBeEnabled; checkboxAndroidRequiresInternet.CheckedChanged += ShouldButtonPortBeEnabled;
checkboxLinux.CheckedChanged += ShouldButtonPortBeEnabled; checkboxLinux.CheckedChanged += ShouldButtonPortBeEnabled;
checkboxMac.CheckedChanged += ShouldButtonPortBeEnabled; checkboxMac.CheckedChanged += ShouldButtonPortBeEnabled;
textboxModName.TextChanged += ShouldButtonPortBeEnabled; checkboxUseCustomSave.TextChanged += ShouldButtonPortBeEnabled;
filePicker.FilePathChanged += ShouldButtonPortBeEnabled; filePicker.FilePathChanged += ShouldButtonPortBeEnabled;
buttonPort.Click += ButtonPortOnClick; buttonPort.Click += ButtonPortOnClick;
} }
@ -107,19 +107,18 @@ public partial class MainForm : Form
{ {
if (File.Exists(androidPath)) if (File.Exists(androidPath))
File.Delete(androidPath); File.Delete(androidPath);
string modName = null; bool useCustomSave = checkboxUseCustomSave.Checked.Value;
if (!String.IsNullOrWhiteSpace(textboxModName.Text)) modName = textboxModName.Text;
bool useInternet = checkboxAndroidRequiresInternet.Checked.Value; bool useInternet = checkboxAndroidRequiresInternet.Checked.Value;
await Task.Run(() => RawMods.PortToAndroid(modZipPath, androidPath, modName, useInternet, OutputHandlerDelegate)); await Task.Run(() => RawMods.PortToAndroid(modZipPath, androidPath, useCustomSave, useInternet, OutputHandlerDelegate));
} }
if (checkboxMac.Checked.Value) if (checkboxMac.Checked.Value)
{ {
if (File.Exists(macPath)) if (File.Exists(macPath))
File.Delete(macPath); File.Delete(macPath);
string modName = textboxModName.Text; string modName = checkboxUseCustomSave.Text;
await Task.Run(() => RawMods.PortToMac(modZipPath, macPath, modName, OutputHandlerDelegate)); await Task.Run(() => RawMods.PortToMac(modZipPath, macPath, OutputHandlerDelegate));
} }
labelProgress.Text = "Done!"; labelProgress.Text = "Done!";
@ -144,7 +143,7 @@ public partial class MainForm : Form
if ((!String.IsNullOrWhiteSpace(filePicker.FilePath) if ((!String.IsNullOrWhiteSpace(filePicker.FilePath)
&& ((checkboxAndroid.Checked.Value && !checkboxMac.Checked.Value)) && ((checkboxAndroid.Checked.Value && !checkboxMac.Checked.Value))
|| (checkboxLinux.Checked.Value && !checkboxMac.Checked.Value) || (checkboxLinux.Checked.Value && !checkboxMac.Checked.Value)
|| (checkboxMac.Checked.Value && !String.IsNullOrWhiteSpace(textboxModName.Text)))) || (checkboxMac.Checked.Value && !String.IsNullOrWhiteSpace(checkboxUseCustomSave.Text))))
buttonPort.Enabled = true; buttonPort.Enabled = true;
else else
@ -159,7 +158,7 @@ public partial class MainForm : Form
checkboxMac.Enabled = !disabled; checkboxMac.Enabled = !disabled;
filePicker.Enabled = !disabled; filePicker.Enabled = !disabled;
buttonPort.Enabled = !disabled; buttonPort.Enabled = !disabled;
textboxModName.Enabled = !disabled; checkboxUseCustomSave.Enabled = !disabled;
} }
// Attributes // Attributes
@ -203,16 +202,15 @@ public partial class MainForm : Form
private readonly CheckBox checkboxAndroidRequiresInternet = new CheckBox private readonly CheckBox checkboxAndroidRequiresInternet = new CheckBox
{ {
Text = "Requires internet (See tooltip for info)", Text = "Requires internet (See tooltip for info)",
ToolTip = "Only affects Android. If your mod interacts with the internet in any way (such as multiplayer), you should check this," + ToolTip = "Only affects Android. If your mod interacts with the internet in any way (such as multiplayer), you should check this, " +
"as otherwise internet functions won't work." "as otherwise internet functions won't work."
}; };
private readonly Label labelModName = new Label private readonly CheckBox checkboxUseCustomSave = new CheckBox
{ {
Text = "Enter mod name:\n(See tooltip for info)", Text = "Use custom save location (See tooltip for info)",
ToolTip = "The mod name is required for Mac, and optional for Android. It does not have any affect on other OS.\n" + ToolTip = "Only affects Android. Determines whether Android will use a custom save location based on its display name. If you don't " +
"For Mac, it is used as the display name when the application is started. For Android, the name is used for the save location." "want your mod overwriting normal AM2R on Android, you should check this."
}; };
private readonly TextBox textboxModName = new TextBox();
private readonly Button buttonPort = new Button private readonly Button buttonPort = new Button
{ {

@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework> <!--TODO: UndertaleModLib needs to properly support .net standard! -->
<TargetFramework>.net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<LangVersion>10</LangVersion> <LangVersion>10</LangVersion>
<PackageVersion>1.8.0</PackageVersion> <PackageVersion>1.8.0</PackageVersion>

@ -1 +1 @@
Subproject commit 79704260e15ab8c7ffdbc7effb3cbe366f480a00 Subproject commit ad5a84bdfbf3a58079c3e2a60ce487b3438a0bce
Loading…
Cancel
Save