|
|
|
@ -7,165 +7,164 @@ using AM2RPortHelperLib;
|
|
|
|
using Eto.Forms;
|
|
|
|
using Eto.Forms;
|
|
|
|
using Eto.Drawing;
|
|
|
|
using Eto.Drawing;
|
|
|
|
|
|
|
|
|
|
|
|
namespace AM2RPortHelperGUI
|
|
|
|
namespace AM2RPortHelperGUI;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public partial class MainForm : Form
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public partial class MainForm : Form
|
|
|
|
public MainForm()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public MainForm()
|
|
|
|
Title = "AM2RPortHelper";
|
|
|
|
|
|
|
|
MinimumSize = new Size(200, 200);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var mainLayout = new DynamicLayout();
|
|
|
|
|
|
|
|
mainLayout.BeginVertical();
|
|
|
|
|
|
|
|
mainLayout.AddRange(labelSelectMod,
|
|
|
|
|
|
|
|
new Label { Height = 5 },
|
|
|
|
|
|
|
|
filePicker,
|
|
|
|
|
|
|
|
labelProgress,
|
|
|
|
|
|
|
|
new Label { Height = 10 });
|
|
|
|
|
|
|
|
mainLayout.EndVertical();
|
|
|
|
|
|
|
|
mainLayout.BeginCentered();
|
|
|
|
|
|
|
|
mainLayout.AddRow(checkboxLinux, checkboxAndroid, checkboxMac);
|
|
|
|
|
|
|
|
mainLayout.AddSpace();
|
|
|
|
|
|
|
|
mainLayout.EndCentered();
|
|
|
|
|
|
|
|
mainLayout.BeginVertical();
|
|
|
|
|
|
|
|
mainLayout.AddRange(new Label { Height = 10}, buttonPort, null);
|
|
|
|
|
|
|
|
mainLayout.EndVertical();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var mainPage = new TabPage
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Title = "AM2RPortHelper";
|
|
|
|
Text = "Raw Mods",
|
|
|
|
MinimumSize = new Size(200, 200);
|
|
|
|
Content = mainLayout
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var mainLayout = new DynamicLayout();
|
|
|
|
|
|
|
|
mainLayout.BeginVertical();
|
|
|
|
|
|
|
|
mainLayout.AddRange(labelSelectMod,
|
|
|
|
|
|
|
|
new Label { Height = 5 },
|
|
|
|
|
|
|
|
filePicker,
|
|
|
|
|
|
|
|
labelProgress,
|
|
|
|
|
|
|
|
new Label { Height = 10 });
|
|
|
|
|
|
|
|
mainLayout.EndVertical();
|
|
|
|
|
|
|
|
mainLayout.BeginCentered();
|
|
|
|
|
|
|
|
mainLayout.AddRow(checkboxLinux, checkboxAndroid, checkboxMac);
|
|
|
|
|
|
|
|
mainLayout.AddSpace();
|
|
|
|
|
|
|
|
mainLayout.EndCentered();
|
|
|
|
|
|
|
|
mainLayout.BeginVertical();
|
|
|
|
|
|
|
|
mainLayout.AddRange(new Label { Height = 10}, buttonPort, null);
|
|
|
|
|
|
|
|
mainLayout.EndVertical();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var mainPage = new TabPage
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Text = "Raw Mods",
|
|
|
|
|
|
|
|
Content = mainLayout
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var am2rModLayout = new DynamicLayout();
|
|
|
|
var am2rModLayout = new DynamicLayout();
|
|
|
|
var am2rModPage = new TabPage
|
|
|
|
var am2rModPage = new TabPage
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Text = "AM2RLauncher Mods",
|
|
|
|
Text = "AM2RLauncher Mods",
|
|
|
|
Content = am2rModLayout
|
|
|
|
Content = am2rModLayout
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Content = new TabControl
|
|
|
|
Content = new TabControl
|
|
|
|
{
|
|
|
|
|
|
|
|
Pages =
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mainPage,
|
|
|
|
|
|
|
|
am2rModPage
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// events
|
|
|
|
|
|
|
|
checkboxAndroid.CheckedChanged += ShouldButtonPortBeEnabled;
|
|
|
|
|
|
|
|
checkboxLinux.CheckedChanged += ShouldButtonPortBeEnabled;
|
|
|
|
|
|
|
|
checkboxMac.CheckedChanged += ShouldButtonPortBeEnabled;
|
|
|
|
|
|
|
|
filePicker.FilePathChanged += ShouldButtonPortBeEnabled;
|
|
|
|
|
|
|
|
buttonPort.Click += ButtonPortOnClick;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private async void ButtonPortOnClick(object sender, EventArgs e)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DisableAllElements();
|
|
|
|
Pages =
|
|
|
|
|
|
|
|
|
|
|
|
PortHelper.OutputHandlerDelegate handler = 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";
|
|
|
|
|
|
|
|
string androidPath = $"{currentDir}/{Path.GetFileNameWithoutExtension(modZipPath)}_ANDROID.apk";
|
|
|
|
|
|
|
|
string macPath = $"{currentDir}/{Path.GetFileNameWithoutExtension(modZipPath)}_MACOS.zip";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (File.Exists(linuxPath))
|
|
|
|
|
|
|
|
File.Delete(linuxPath);
|
|
|
|
|
|
|
|
if (File.Exists(androidPath))
|
|
|
|
|
|
|
|
File.Delete(androidPath);
|
|
|
|
|
|
|
|
if (File.Exists(macPath))
|
|
|
|
|
|
|
|
File.Delete(macPath);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (checkboxLinux.Checked.Value)
|
|
|
|
|
|
|
|
await Task.Run(() => PortHelper.PortWindowsToLinux(modZipPath,linuxPath, handler));
|
|
|
|
|
|
|
|
if (checkboxAndroid.Checked.Value)
|
|
|
|
|
|
|
|
await Task.Run(() =>PortHelper.PortWindowsToAndroid(modZipPath, androidPath, handler));
|
|
|
|
|
|
|
|
if (checkboxMac.Checked.Value)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string modName = "foo";//MessageBox.Show()
|
|
|
|
mainPage,
|
|
|
|
await Task.Run(() => PortHelper.PortWindowsToMac(modZipPath, macPath, modName, handler));
|
|
|
|
am2rModPage
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
labelProgress.Text = "Done!";
|
|
|
|
// events
|
|
|
|
OpenFolder(currentDir);
|
|
|
|
checkboxAndroid.CheckedChanged += ShouldButtonPortBeEnabled;
|
|
|
|
|
|
|
|
checkboxLinux.CheckedChanged += ShouldButtonPortBeEnabled;
|
|
|
|
EnableAllElements();
|
|
|
|
checkboxMac.CheckedChanged += ShouldButtonPortBeEnabled;
|
|
|
|
}
|
|
|
|
filePicker.FilePathChanged += ShouldButtonPortBeEnabled;
|
|
|
|
|
|
|
|
buttonPort.Click += ButtonPortOnClick;
|
|
|
|
public static void OpenFolder(string path)
|
|
|
|
}
|
|
|
|
|
|
|
|
private async void ButtonPortOnClick(object sender, EventArgs e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
DisableAllElements();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PortHelper.OutputHandlerDelegate handler = 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";
|
|
|
|
|
|
|
|
string androidPath = $"{currentDir}/{Path.GetFileNameWithoutExtension(modZipPath)}_ANDROID.apk";
|
|
|
|
|
|
|
|
string macPath = $"{currentDir}/{Path.GetFileNameWithoutExtension(modZipPath)}_MACOS.zip";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (File.Exists(linuxPath))
|
|
|
|
|
|
|
|
File.Delete(linuxPath);
|
|
|
|
|
|
|
|
if (File.Exists(androidPath))
|
|
|
|
|
|
|
|
File.Delete(androidPath);
|
|
|
|
|
|
|
|
if (File.Exists(macPath))
|
|
|
|
|
|
|
|
File.Delete(macPath);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (checkboxLinux.Checked.Value)
|
|
|
|
|
|
|
|
await Task.Run(() => PortHelper.PortWindowsToLinux(modZipPath,linuxPath, handler));
|
|
|
|
|
|
|
|
if (checkboxAndroid.Checked.Value)
|
|
|
|
|
|
|
|
await Task.Run(() =>PortHelper.PortWindowsToAndroid(modZipPath, androidPath, handler));
|
|
|
|
|
|
|
|
if (checkboxMac.Checked.Value)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
|
|
|
string modName = "foo";//MessageBox.Show()
|
|
|
|
Process.Start("explorer.exe", $"\"{path}\"");
|
|
|
|
await Task.Run(() => PortHelper.PortWindowsToMac(modZipPath, macPath, modName, handler));
|
|
|
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
|
|
|
|
|
|
|
Process.Start("xdg-open", $"\"{path}\"");
|
|
|
|
|
|
|
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
|
|
|
|
|
|
|
Process.Start("open", $"\"{path}\"");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ShouldButtonPortBeEnabled(object sender, EventArgs e)
|
|
|
|
labelProgress.Text = "Done!";
|
|
|
|
{
|
|
|
|
OpenFolder(currentDir);
|
|
|
|
// any checkbox + selected mod
|
|
|
|
|
|
|
|
if ((checkboxAndroid.Checked.Value || checkboxLinux.Checked.Value || checkboxMac.Checked.Value)
|
|
|
|
|
|
|
|
&& !String.IsNullOrWhiteSpace(filePicker.FilePath))
|
|
|
|
|
|
|
|
buttonPort.Enabled = true;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
buttonPort.Enabled = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void DisableAllElements()
|
|
|
|
EnableAllElements();
|
|
|
|
{
|
|
|
|
}
|
|
|
|
checkboxAndroid.Enabled = false;
|
|
|
|
|
|
|
|
checkboxLinux.Enabled = false;
|
|
|
|
|
|
|
|
checkboxMac.Enabled = false;
|
|
|
|
|
|
|
|
filePicker.Enabled = false;
|
|
|
|
|
|
|
|
buttonPort.Enabled = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void EnableAllElements()
|
|
|
|
public static void OpenFolder(string path)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
checkboxAndroid.Enabled = true;
|
|
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
|
|
|
checkboxLinux.Enabled = true;
|
|
|
|
Process.Start("explorer.exe", $"\"{path}\"");
|
|
|
|
checkboxMac.Enabled = true;
|
|
|
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
|
|
|
filePicker.Enabled = true;
|
|
|
|
Process.Start("xdg-open", $"\"{path}\"");
|
|
|
|
|
|
|
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
|
|
|
|
|
|
|
Process.Start("open", $"\"{path}\"");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void ShouldButtonPortBeEnabled(object sender, EventArgs e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// any checkbox + selected mod
|
|
|
|
|
|
|
|
if ((checkboxAndroid.Checked.Value || checkboxLinux.Checked.Value || checkboxMac.Checked.Value)
|
|
|
|
|
|
|
|
&& !String.IsNullOrWhiteSpace(filePicker.FilePath))
|
|
|
|
buttonPort.Enabled = true;
|
|
|
|
buttonPort.Enabled = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
|
|
|
|
buttonPort.Enabled = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Label labelSelectMod = new Label
|
|
|
|
private void DisableAllElements()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Text = "Select Mod:"
|
|
|
|
checkboxAndroid.Enabled = false;
|
|
|
|
};
|
|
|
|
checkboxLinux.Enabled = false;
|
|
|
|
private FilePicker filePicker = new FilePicker()
|
|
|
|
checkboxMac.Enabled = false;
|
|
|
|
{
|
|
|
|
filePicker.Enabled = false;
|
|
|
|
Filters = { new FileFilter("Zip file", "*.zip") }
|
|
|
|
buttonPort.Enabled = false;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private CheckBox checkboxLinux = new CheckBox()
|
|
|
|
private void EnableAllElements()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Text = "Linux"
|
|
|
|
checkboxAndroid.Enabled = true;
|
|
|
|
};
|
|
|
|
checkboxLinux.Enabled = true;
|
|
|
|
private CheckBox checkboxAndroid = new CheckBox()
|
|
|
|
checkboxMac.Enabled = true;
|
|
|
|
{
|
|
|
|
filePicker.Enabled = true;
|
|
|
|
Text = "Android"
|
|
|
|
buttonPort.Enabled = true;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
private CheckBox checkboxMac = new CheckBox()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Text = "Mac"
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Button buttonPort = new Button()
|
|
|
|
private Label labelSelectMod = new Label
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Text = "Port!",
|
|
|
|
Text = "Select Mod:"
|
|
|
|
Enabled = false
|
|
|
|
};
|
|
|
|
};
|
|
|
|
private FilePicker filePicker = new FilePicker()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Filters = { new FileFilter("Zip file", "*.zip") }
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
private Label labelProgress = new Label()
|
|
|
|
private CheckBox checkboxLinux = new CheckBox()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Text = "Info: "
|
|
|
|
Text = "Linux"
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
private CheckBox checkboxAndroid = new CheckBox()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Text = "Android"
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
private CheckBox checkboxMac = new CheckBox()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Text = "Mac"
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Button buttonPort = new Button()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Text = "Port!",
|
|
|
|
|
|
|
|
Enabled = false
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Label labelProgress = new Label()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Text = "Info: "
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|