clean gui functions

mac
Miepee 3 years ago
parent 27c8a26b92
commit 6620cdd16b

@ -116,29 +116,17 @@ public partial class MainForm : Form
buttonEditIcon.Click += ButtonEditIconClick; buttonEditIcon.Click += ButtonEditIconClick;
buttonEditSplash.Click += ButtonEditSplashClick; buttonEditSplash.Click += ButtonEditSplashClick;
} }
// TODO: condense these
private void ButtonEditSplashClick(object sender, EventArgs e) private void ButtonEditSplashClick(object sender, EventArgs e)
{ {
var dialog = new OpenFileDialog(); ButtonEditResourceClick(imageViewSplash, nameof(Resources.splash));
if (dialog.ShowDialog(this) != DialogResult.Ok)
return;
File.Copy(dialog.FileName, userSplashPath, true);
imageViewSplash.Image = new Bitmap(GetByteArrayFromResource(nameof(Resources.splash)));
} }
private void ButtonEditIconClick(object sender, EventArgs e) private void ButtonEditIconClick(object sender, EventArgs e)
{ {
var dialog = new OpenFileDialog(); ButtonEditResourceClick(imageViewIcon, nameof(Resources.icon));
if (dialog.ShowDialog(this) != DialogResult.Ok)
return;
File.Copy(dialog.FileName, userIconPath, true);
imageViewIcon.Image = new Bitmap(GetByteArrayFromResource(nameof(Resources.icon)));
} }
// Helper functions
private async void ButtonPortOnClick(object sender, EventArgs e) private async void ButtonPortOnClick(object sender, EventArgs e)
{ {
SetDisableStatusOfAllElements(true); SetDisableStatusOfAllElements(true);
@ -146,6 +134,7 @@ public partial class MainForm : Form
void OutputHandlerDelegate(string 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);
// TODO: ask where to save them!
string windowsPath = $"{currentDir}/{Path.GetFileNameWithoutExtension(modZipPath)}_WINDOWS.zip"; string windowsPath = $"{currentDir}/{Path.GetFileNameWithoutExtension(modZipPath)}_WINDOWS.zip";
string linuxPath = $"{currentDir}/{Path.GetFileNameWithoutExtension(modZipPath)}_LINUX.zip"; string linuxPath = $"{currentDir}/{Path.GetFileNameWithoutExtension(modZipPath)}_LINUX.zip";
string androidPath = $"{currentDir}/{Path.GetFileNameWithoutExtension(modZipPath)}_ANDROID.apk"; string androidPath = $"{currentDir}/{Path.GetFileNameWithoutExtension(modZipPath)}_ANDROID.apk";
@ -199,6 +188,7 @@ public partial class MainForm : Form
SetDisableStatusOfAllElements(false); SetDisableStatusOfAllElements(false);
} }
// Helper functions
private static void OpenFolder(string path) private static void OpenFolder(string path)
{ {
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
@ -230,7 +220,25 @@ public partial class MainForm : Form
checkboxUseCustomSave.Enabled = !disabled; checkboxUseCustomSave.Enabled = !disabled;
} }
private void ButtonEditResourceClick(ImageView control, string nameOfResource)
{
var dialog = new OpenFileDialog() {Title = "Select new " + nameOfResource};
if (dialog.ShowDialog(this) != DialogResult.Ok)
return;
string destName = nameOfResource switch
{
nameof(Resources.icon) => userIconPath,
nameof(Resources.splash) => userSplashPath,
_ => throw new Exception("You dun goofed!")
};
File.Copy(dialog.FileName, destName, true);
control.Image = new Bitmap(GetByteArrayFromResource(nameOfResource));
}
// Attributes // Attributes
#region Attributes
private readonly Label labelSelectMod = new Label private readonly Label labelSelectMod = new Label
{ {
Text = "Select Mod:" Text = "Select Mod:"
@ -310,4 +318,5 @@ public partial class MainForm : Form
Text = "Port!", Text = "Port!",
Enabled = false Enabled = false
}; };
#endregion
} }

@ -547,7 +547,7 @@ public abstract class RawMods : ModsBase
/// </summary> /// </summary>
/// <param name="Data">The GameMaker data file.</param> /// <param name="Data">The GameMaker data file.</param>
/// <param name="output">Delegate on where to send output messages to.</param> /// <param name="output">Delegate on where to send output messages to.</param>
/// <exception cref="NotSupportedException"><paramref name="Data"/> has a not supported Bytecode version.</exception> /// <exception cref="NotSupportedException"><paramref name="Data"/> has a not supported Bytecode version (13, 14, GM2.3+).</exception>
private static void ChangeToByteCode16(UndertaleData Data, OutputHandlerDelegate output) private static void ChangeToByteCode16(UndertaleData Data, OutputHandlerDelegate output)
{ {
if (Data is null) return; if (Data is null) return;

Loading…
Cancel
Save