Small misc cleaning

pull/5/head
Miepee 4 years ago
parent 4b4fba58d8
commit 9738752b82

@ -1,6 +1,5 @@
using System;
using System.CommandLine;
using System.CommandLine.Builder;
using System.IO;
using AM2RPortHelperLib;
@ -14,8 +13,7 @@ internal static class Program
private static int Main(string[] args)
{
Console.WriteLine("AM2RPortHelperCLI v" + PortHelper.Version);
//TODO!
var interactiveOption = new Option<bool>(new[] { "-i", "--interactive" }, "Use an interactive mode. This will ignore all other options.");
var fileOption = new Option<FileInfo>(new[] { "-f", "--file" }, "The file path to the raw mod that should be ported. *REQUIRED*");
var linuxOption = new Option<FileInfo>(new[] { "-l", "--linux" }, "The output file path for the Linux mod. None given equals to no Linux port.");
@ -23,7 +21,7 @@ internal static class Program
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 mod. Required for the Mac option, has no effect on anything else.");
RootCommand rootCommand = new RootCommand()
RootCommand rootCommand = new RootCommand
{
interactiveOption,
fileOption,

@ -3,7 +3,7 @@ using Eto.Forms;
namespace AM2RPortHelperGUI.Gtk;
class Program
static class Program
{
[STAThread]
public static void Main(string[] args)

@ -3,7 +3,7 @@ using Eto.Forms;
namespace AM2RPortHelperGUI.Mac;
class Program
static class Program
{
[STAThread]
public static void Main(string[] args)

@ -3,7 +3,7 @@ using Eto.Forms;
namespace AM2RPortHelperGUI.Wpf;
class Program
static class Program
{
[STAThread]
public static void Main(string[] args)

@ -63,11 +63,13 @@ public partial class MainForm : Form
filePicker.FilePathChanged += ShouldButtonPortBeEnabled;
buttonPort.Click += ButtonPortOnClick;
}
// Helper functions
private async void ButtonPortOnClick(object sender, EventArgs e)
{
DisableAllElements();
PortHelper.OutputHandlerDelegate handler = output => Application.Instance.Invoke(() => labelProgress.Text = $"Info: {output}");
void OutputHandlerDelegate(string output) => Application.Instance.Invoke(() => labelProgress.Text = $"Info: {output}");
string modZipPath = filePicker.FilePath;
string currentDir = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
string linuxPath = $"{currentDir}/{Path.GetFileNameWithoutExtension(modZipPath)}_LINUX.zip";
@ -82,13 +84,13 @@ public partial class MainForm : Form
File.Delete(macPath);
if (checkboxLinux.Checked.Value)
await Task.Run(() => PortHelper.PortWindowsToLinux(modZipPath,linuxPath, handler));
await Task.Run(() => PortHelper.PortWindowsToLinux(modZipPath,linuxPath, OutputHandlerDelegate));
if (checkboxAndroid.Checked.Value)
await Task.Run(() =>PortHelper.PortWindowsToAndroid(modZipPath, androidPath, handler));
await Task.Run(() =>PortHelper.PortWindowsToAndroid(modZipPath, androidPath, OutputHandlerDelegate));
if (checkboxMac.Checked.Value)
{
string modName = "foo";//MessageBox.Show()
await Task.Run(() => PortHelper.PortWindowsToMac(modZipPath, macPath, modName, handler));
await Task.Run(() => PortHelper.PortWindowsToMac(modZipPath, macPath, modName, OutputHandlerDelegate));
}
labelProgress.Text = "Done!";
@ -97,7 +99,7 @@ public partial class MainForm : Form
EnableAllElements();
}
public static void OpenFolder(string path)
private static void OpenFolder(string path)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
Process.Start("explorer.exe", $"\"{path}\"");
@ -135,35 +137,36 @@ public partial class MainForm : Form
buttonPort.Enabled = true;
}
private Label labelSelectMod = new Label
// Attributes
private readonly Label labelSelectMod = new Label
{
Text = "Select Mod:"
};
private FilePicker filePicker = new FilePicker()
private readonly FilePicker filePicker = new FilePicker
{
Filters = { new FileFilter("Zip file", "*.zip") }
};
private CheckBox checkboxLinux = new CheckBox()
private readonly CheckBox checkboxLinux = new CheckBox
{
Text = "Linux"
};
private CheckBox checkboxAndroid = new CheckBox()
private readonly CheckBox checkboxAndroid = new CheckBox
{
Text = "Android"
};
private CheckBox checkboxMac = new CheckBox()
private readonly CheckBox checkboxMac = new CheckBox
{
Text = "Mac"
};
private Button buttonPort = new Button()
private readonly Button buttonPort = new Button
{
Text = "Port!",
Enabled = false
};
private Label labelProgress = new Label()
private readonly Label labelProgress = new Label
{
Text = "Info: "
};

Loading…
Cancel
Save