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 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 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 verboseOption = new Option<bool>(new[] { "-v", "--verbose" }, "Whether to show verbose output.");
@ -44,7 +44,7 @@ internal static class Program
}
#pragma warning disable CS1998
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
{
if (interactive || beVerbose)
@ -69,16 +69,11 @@ internal static class Program
if (androidPath is not null)
{
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 (modName is 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);
RawMods.PortToMac(inputModPath.FullName, macPath.FullName, beVerbose ? OutputHandlerDelegate : null);
}
if (beVerbose)
Console.WriteLine("Done.");
@ -171,7 +166,22 @@ internal static class Program
}
while (internetSelected == null);
RawMods.PortToAndroid(modZipPath, androidPath, null, internetSelected.Value, OutputHandlerDelegate);
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, customSaveSelected.Value, customSaveSelected.Value, OutputHandlerDelegate);
}
if (macSelected)
{
@ -180,7 +190,7 @@ internal static class Program
Console.WriteLine("Mac requires a name! Please enter one (no special characters!):");
string modName = Console.ReadLine();
RawMods.PortToMac(modZipPath, macPath, modName, OutputHandlerDelegate);
RawMods.PortToMac(modZipPath, macPath, OutputHandlerDelegate);
}
Console.WriteLine("Successfully finished!");

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

@ -42,7 +42,7 @@ public partial class MainForm : Form
mainLayout.EndCentered();
mainLayout.AddRow(new Label() { Height = 5 });
mainLayout.BeginCentered();
mainLayout.AddRow(labelModName, new Label { Width = 15 }, textboxModName);
mainLayout.AddRow(checkboxUseCustomSave);
mainLayout.EndCentered();
mainLayout.AddSpace();
mainLayout.BeginVertical();
@ -79,7 +79,7 @@ public partial class MainForm : Form
checkboxAndroidRequiresInternet.CheckedChanged += ShouldButtonPortBeEnabled;
checkboxLinux.CheckedChanged += ShouldButtonPortBeEnabled;
checkboxMac.CheckedChanged += ShouldButtonPortBeEnabled;
textboxModName.TextChanged += ShouldButtonPortBeEnabled;
checkboxUseCustomSave.TextChanged += ShouldButtonPortBeEnabled;
filePicker.FilePathChanged += ShouldButtonPortBeEnabled;
buttonPort.Click += ButtonPortOnClick;
}
@ -108,18 +108,17 @@ public partial class MainForm : Form
if (File.Exists(androidPath))
File.Delete(androidPath);
string modName = null;
if (!String.IsNullOrWhiteSpace(textboxModName.Text)) modName = textboxModName.Text;
bool useCustomSave = checkboxUseCustomSave.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 (File.Exists(macPath))
File.Delete(macPath);
string modName = textboxModName.Text;
await Task.Run(() => RawMods.PortToMac(modZipPath, macPath, modName, OutputHandlerDelegate));
string modName = checkboxUseCustomSave.Text;
await Task.Run(() => RawMods.PortToMac(modZipPath, macPath, OutputHandlerDelegate));
}
labelProgress.Text = "Done!";
@ -144,7 +143,7 @@ public partial class MainForm : Form
if ((!String.IsNullOrWhiteSpace(filePicker.FilePath)
&& ((checkboxAndroid.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;
else
@ -159,7 +158,7 @@ public partial class MainForm : Form
checkboxMac.Enabled = !disabled;
filePicker.Enabled = !disabled;
buttonPort.Enabled = !disabled;
textboxModName.Enabled = !disabled;
checkboxUseCustomSave.Enabled = !disabled;
}
// Attributes
@ -206,13 +205,12 @@ public partial class MainForm : Form
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."
};
private readonly Label labelModName = new Label
private readonly CheckBox checkboxUseCustomSave = new CheckBox
{
Text = "Enter mod name:\n(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" +
"For Mac, it is used as the display name when the application is started. For Android, the name is used for the save location."
Text = "Use custom save location (See tooltip for info)",
ToolTip = "Only affects Android. Determines whether Android will use a custom save location based on its display name. If you don't " +
"want your mod overwriting normal AM2R on Android, you should check this."
};
private readonly TextBox textboxModName = new TextBox();
private readonly Button buttonPort = new Button
{

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

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