Add option in GUI to use custom names

pull/5/head
Miepee 4 years ago
parent 0e629a87ee
commit a0818c7399

@ -29,8 +29,12 @@ public partial class MainForm : Form
mainLayout.AddRow(checkboxLinux, checkboxAndroid, checkboxMac); mainLayout.AddRow(checkboxLinux, checkboxAndroid, checkboxMac);
mainLayout.AddSpace(); mainLayout.AddSpace();
mainLayout.EndCentered(); mainLayout.EndCentered();
mainLayout.BeginCentered();
mainLayout.AddRow(labelModName, new Label { Width = 15 }, textboxModName);
mainLayout.AddSpace();
mainLayout.EndCentered();
mainLayout.BeginVertical(); mainLayout.BeginVertical();
mainLayout.AddRange(new Label { Height = 10}, buttonPort, null); mainLayout.AddRange(new Label { Height = 10 }, buttonPort, null);
mainLayout.EndVertical(); mainLayout.EndVertical();
var mainPage = new TabPage var mainPage = new TabPage
@ -62,6 +66,7 @@ public partial class MainForm : Form
checkboxAndroid.CheckedChanged += ShouldButtonPortBeEnabled; checkboxAndroid.CheckedChanged += ShouldButtonPortBeEnabled;
checkboxLinux.CheckedChanged += ShouldButtonPortBeEnabled; checkboxLinux.CheckedChanged += ShouldButtonPortBeEnabled;
checkboxMac.CheckedChanged += ShouldButtonPortBeEnabled; checkboxMac.CheckedChanged += ShouldButtonPortBeEnabled;
textboxModName.TextChanged += ShouldButtonPortBeEnabled;
filePicker.FilePathChanged += ShouldButtonPortBeEnabled; filePicker.FilePathChanged += ShouldButtonPortBeEnabled;
buttonPort.Click += ButtonPortOnClick; buttonPort.Click += ButtonPortOnClick;
} }
@ -88,11 +93,15 @@ public partial class MainForm : Form
if (checkboxLinux.Checked.Value) if (checkboxLinux.Checked.Value)
await Task.Run(() => PortHelper.PortWindowsToLinux(modZipPath,linuxPath, OutputHandlerDelegate)); await Task.Run(() => PortHelper.PortWindowsToLinux(modZipPath,linuxPath, OutputHandlerDelegate));
if (checkboxAndroid.Checked.Value) if (checkboxAndroid.Checked.Value)
await Task.Run(() =>PortHelper.PortWindowsToAndroid(modZipPath, androidPath, null, OutputHandlerDelegate)); {
string modName = null;
if (!String.IsNullOrWhiteSpace(textboxModName.Text)) modName = textboxModName.Text;
await Task.Run(() => PortHelper.PortWindowsToAndroid(modZipPath, androidPath, modName, OutputHandlerDelegate));
}
if (checkboxMac.Checked.Value) if (checkboxMac.Checked.Value)
{ {
MessageBox.Show(this, "Currently the mod name is set as \"foo\", you need to manually correct that later! (Search for the files yoyorunner.config and Info.plist"); string modName = textboxModName.Text;
string modName = "foo";
await Task.Run(() => PortHelper.PortWindowsToMac(modZipPath, macPath, modName, OutputHandlerDelegate)); await Task.Run(() => PortHelper.PortWindowsToMac(modZipPath, macPath, modName, OutputHandlerDelegate));
} }
@ -114,9 +123,12 @@ public partial class MainForm : Form
private void ShouldButtonPortBeEnabled(object sender, EventArgs e) private void ShouldButtonPortBeEnabled(object sender, EventArgs e)
{ {
// any checkbox + selected mod // there needs to be a selected mod + any checkbox (if mac, then there needs to be a name)
if ((checkboxAndroid.Checked.Value || checkboxLinux.Checked.Value || checkboxMac.Checked.Value) if ((!String.IsNullOrWhiteSpace(filePicker.FilePath)
&& !String.IsNullOrWhiteSpace(filePicker.FilePath)) && ((checkboxAndroid.Checked.Value && !checkboxMac.Checked.Value))
|| (checkboxLinux.Checked.Value && !checkboxMac.Checked.Value)
|| (checkboxMac.Checked.Value && !String.IsNullOrWhiteSpace(textboxModName.Text))))
buttonPort.Enabled = true; buttonPort.Enabled = true;
else else
buttonPort.Enabled = false; buttonPort.Enabled = false;
@ -129,6 +141,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;
} }
// Attributes // Attributes
@ -154,6 +167,12 @@ public partial class MainForm : Form
Text = "Mac" Text = "Mac"
}; };
private readonly Label labelModName = new Label
{
Text = "Enter mod name:\n(Required for Mac!)"
};
private readonly TextBox textboxModName = new TextBox();
private readonly Button buttonPort = new Button private readonly Button buttonPort = new Button
{ {
Text = "Port!", Text = "Port!",

@ -199,6 +199,7 @@ public static partial class PortHelper
Directory.Delete(assetsDir, true); Directory.Delete(assetsDir, true);
} }
// TODO: try to figure out if its possible to extract the name from the data.win file and then just offer a "use custom save directory" option that decides whether to use it or not.
public static void PortWindowsToAndroid(string inputRawZipPath, string outputRawApkPath, string modName = null, OutputHandlerDelegate outputDelegate = null) public static void PortWindowsToAndroid(string inputRawZipPath, string outputRawApkPath, string modName = null, OutputHandlerDelegate outputDelegate = null)
{ {
outputHandler = outputDelegate; outputHandler = outputDelegate;

Loading…
Cancel
Save