Do initial basic GUI

pull/5/head
Miepee 4 years ago
parent 18316d7fa4
commit 0aee51b6eb

@ -7,6 +7,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AM2RPortHelperCLI", "AM2RPo
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AM2RPortHelperLib", "AM2RPortHelperLib\AM2RPortHelperLib.csproj", "{FB200270-51C9-45FC-BF9C-E9006576D00A}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AM2RPortHelperLib", "AM2RPortHelperLib\AM2RPortHelperLib.csproj", "{FB200270-51C9-45FC-BF9C-E9006576D00A}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AM2RPortHelperGUI", "AM2RPortHelperGUI\AM2RPortHelperGUI\AM2RPortHelperGUI.csproj", "{A803417B-9A25-4166-820F-6089D7EE84A9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AM2RPortHelperGUI.Gtk", "AM2RPortHelperGUI\AM2RPortHelperGUI.Gtk\AM2RPortHelperGUI.Gtk.csproj", "{05041346-DD3B-40BB-AA1B-3D69B4DD2ADA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AM2RPortHelperGUI.Mac", "AM2RPortHelperGUI\AM2RPortHelperGUI.Mac\AM2RPortHelperGUI.Mac.csproj", "{21D15228-8BC7-41DB-8913-74AE82566712}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AM2RPortHelperGUI.Wpf", "AM2RPortHelperGUI\AM2RPortHelperGUI.Wpf\AM2RPortHelperGUI.Wpf.csproj", "{4C4043B0-38AB-479A-A4B3-D3F7F39092F0}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -21,6 +29,22 @@ Global
{FB200270-51C9-45FC-BF9C-E9006576D00A}.Debug|Any CPU.Build.0 = Debug|Any CPU {FB200270-51C9-45FC-BF9C-E9006576D00A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FB200270-51C9-45FC-BF9C-E9006576D00A}.Release|Any CPU.ActiveCfg = Release|Any CPU {FB200270-51C9-45FC-BF9C-E9006576D00A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FB200270-51C9-45FC-BF9C-E9006576D00A}.Release|Any CPU.Build.0 = Release|Any CPU {FB200270-51C9-45FC-BF9C-E9006576D00A}.Release|Any CPU.Build.0 = Release|Any CPU
{A803417B-9A25-4166-820F-6089D7EE84A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A803417B-9A25-4166-820F-6089D7EE84A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A803417B-9A25-4166-820F-6089D7EE84A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A803417B-9A25-4166-820F-6089D7EE84A9}.Release|Any CPU.Build.0 = Release|Any CPU
{05041346-DD3B-40BB-AA1B-3D69B4DD2ADA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{05041346-DD3B-40BB-AA1B-3D69B4DD2ADA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{05041346-DD3B-40BB-AA1B-3D69B4DD2ADA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{05041346-DD3B-40BB-AA1B-3D69B4DD2ADA}.Release|Any CPU.Build.0 = Release|Any CPU
{21D15228-8BC7-41DB-8913-74AE82566712}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{21D15228-8BC7-41DB-8913-74AE82566712}.Debug|Any CPU.Build.0 = Debug|Any CPU
{21D15228-8BC7-41DB-8913-74AE82566712}.Release|Any CPU.ActiveCfg = Release|Any CPU
{21D15228-8BC7-41DB-8913-74AE82566712}.Release|Any CPU.Build.0 = Release|Any CPU
{4C4043B0-38AB-479A-A4B3-D3F7F39092F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4C4043B0-38AB-479A-A4B3-D3F7F39092F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4C4043B0-38AB-479A-A4B3-D3F7F39092F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4C4043B0-38AB-479A-A4B3-D3F7F39092F0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

@ -16,9 +16,6 @@
<None Update="LICENSE"> <None Update="LICENSE">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Update="utils/**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\AM2RPortHelperGUI\AM2RPortHelperGUI.csproj"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Eto.Platform.Gtk" Version="2.7.0"/>
</ItemGroup>
</Project>

@ -0,0 +1,14 @@
using System;
using Eto.Forms;
namespace AM2RPortHelperGUI.Gtk
{
class Program
{
[STAThread]
public static void Main(string[] args)
{
new Application(Eto.Platforms.Gtk).Run(new MainForm());
}
}
}

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<RuntimeIdentifiers>osx-x64;osx-arm64</RuntimeIdentifiers>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\AM2RPortHelperGUI\AM2RPortHelperGUI.csproj"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Eto.Platform.Mac64" Version="2.7.0"/>
</ItemGroup>
</Project>

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>AM2RPortHelperGUI</string>
<key>CFBundleIdentifier</key>
<string>com.example.AM2RPortHelperGUI</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>LSMinimumSystemVersion</key>
<string>10.14</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>NSHumanReadableCopyright</key>
<string></string>
<key>CFBundleIconFile</key>
<string>Icon.icns</string>
</dict>
</plist>

@ -0,0 +1,14 @@
using System;
using Eto.Forms;
namespace AM2RPortHelperGUI.Mac
{
class Program
{
[STAThread]
public static void Main(string[] args)
{
new Application(Eto.Platforms.Mac64).Run(new MainForm());
}
}
}

@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\AM2RPortHelperGUI\AM2RPortHelperGUI.csproj"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Eto.Platform.Wpf" Version="2.7.0"/>
</ItemGroup>
</Project>

@ -0,0 +1,14 @@
using System;
using Eto.Forms;
namespace AM2RPortHelperGUI.Wpf
{
class Program
{
[STAThread]
public static void Main(string[] args)
{
new Application(Eto.Platforms.Wpf).Run(new MainForm());
}
}
}

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Eto.Forms" Version="2.7.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\AM2RPortHelperLib\AM2RPortHelperLib.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,133 @@
using System;
using System.IO;
using System.Threading.Tasks;
using AM2RPortHelperLib;
using Eto.Forms;
using Eto.Drawing;
namespace AM2RPortHelperGUI
{
public partial class MainForm : Form
{
public MainForm()
{
Title = "AM2RPortHelper";
MinimumSize = new Size(200, 200);
var mainLayout = new DynamicLayout();
mainLayout.BeginVertical();
mainLayout.AddRange(labelSelectMod,
new Label { Height = 5},
filePicker,
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 am2rModPage = new TabPage
{
Text = "AM2RLauncher Mods",
Content = am2rModLayout
};
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();
FileInfo modZipPath = new FileInfo(filePicker.FilePath);
if (checkboxLinux.Checked.Value)
await Task.Run(() => PortHelper.PortWindowsToLinux(modZipPath));
if (checkboxAndroid.Checked.Value)
await Task.Run(() =>PortHelper.PortWindowsToAndroid(modZipPath));
if (checkboxMac.Checked.Value)
await Task.Run(() =>PortHelper.PortWindowsToMac(modZipPath));
EnableAllElements();
}
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;
else
buttonPort.Enabled = false;
}
private void DisableAllElements()
{
checkboxAndroid.Enabled = false;
checkboxLinux.Enabled = false;
checkboxMac.Enabled = false;
filePicker.Enabled = false;
buttonPort.Enabled = false;
}
private void EnableAllElements()
{
checkboxAndroid.Enabled = true;
checkboxLinux.Enabled = true;
checkboxMac.Enabled = true;
filePicker.Enabled = true;
buttonPort.Enabled = true;
}
private Label labelSelectMod = new Label
{
Text = "Select Mod:"
};
private FilePicker filePicker = new FilePicker()
{
Filters = { new FileFilter("Zip file", "*.zip") }
};
private CheckBox checkboxLinux = new CheckBox()
{
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
};
}
}

@ -1,13 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <LangVersion>10</LangVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.4" /> <PackageReference Include="SixLabors.ImageSharp" Version="1.0.4" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Update="utils/**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project> </Project>

@ -23,7 +23,7 @@ public class PortHelper
if (Directory.Exists(extractDirectory)) if (Directory.Exists(extractDirectory))
Directory.Delete(extractDirectory, true); Directory.Delete(extractDirectory, true);
Console.WriteLine("Extracting..."); Console.WriteLine("Extracting...");
ZipFile.ExtractToDirectory(modZipPath.FullName, extractDirectory, true); ZipFile.ExtractToDirectory(modZipPath.FullName, extractDirectory);
// Move everything into assets folder // Move everything into assets folder
Console.WriteLine("Moving into assets folder..."); Console.WriteLine("Moving into assets folder...");
@ -56,6 +56,7 @@ public class PortHelper
{ {
Console.ForegroundColor = ConsoleColor.Red; Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(linuxModPath + " already exists! Please move it somewhere else."); Console.WriteLine(linuxModPath + " already exists! Please move it somewhere else.");
Console.ResetColor();
return; return;
} }
Console.WriteLine("Creating zip..."); Console.WriteLine("Creating zip...");
@ -160,6 +161,7 @@ public class PortHelper
{ {
Console.ForegroundColor = ConsoleColor.Red; Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(apkModPath + " already exists! Please move it somewhere else."); Console.WriteLine(apkModPath + " already exists! Please move it somewhere else.");
Console.ResetColor();
return; return;
} }
File.Move(finalApkBuild, apkModPath); File.Move(finalApkBuild, apkModPath);
@ -195,7 +197,7 @@ public class PortHelper
// Extract mod to temp location // Extract mod to temp location
Console.WriteLine("Extracting..."); Console.WriteLine("Extracting...");
ZipFile.ExtractToDirectory(modZipPath.FullName, extractDirectory, true); ZipFile.ExtractToDirectory(modZipPath.FullName, extractDirectory);
// Delete unnecessary files, rename data.win, move in the new runner // Delete unnecessary files, rename data.win, move in the new runner
Console.WriteLine("Delete unnecessary files and lowercase them..."); Console.WriteLine("Delete unnecessary files and lowercase them...");
@ -268,6 +270,7 @@ public class PortHelper
{ {
Console.ForegroundColor = ConsoleColor.Red; Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(macosModPath + " already exists! Please move it somewhere else."); Console.WriteLine(macosModPath + " already exists! Please move it somewhere else.");
Console.ResetColor();
return; return;
} }
Console.WriteLine("Creating zip..."); Console.WriteLine("Creating zip...");

Loading…
Cancel
Save