Small misc cleaning

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

@ -1,6 +1,5 @@
using System; using System;
using System.CommandLine; using System.CommandLine;
using System.CommandLine.Builder;
using System.IO; using System.IO;
using AM2RPortHelperLib; using AM2RPortHelperLib;
@ -15,7 +14,6 @@ internal static class Program
{ {
Console.WriteLine("AM2RPortHelperCLI v" + PortHelper.Version); 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 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 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."); 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 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."); 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, interactiveOption,
fileOption, fileOption,

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

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

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

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

Loading…
Cancel
Save