mirror of
https://github.com/LBPUnion/UnionPatcher.git
synced 2025-08-02 14:18:44 +00:00
Use stock eto message boxes instead of custom.
This commit is contained in:
parent
4b6165ab8d
commit
c1e755276d
3 changed files with 61 additions and 47 deletions
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using Eto;
|
using Eto;
|
||||||
using Eto.Drawing;
|
using Eto.Drawing;
|
||||||
using Eto.Forms;
|
using Eto.Forms;
|
||||||
|
@ -73,46 +74,54 @@ public class FilePatchForm : Form {
|
||||||
|
|
||||||
private void Patch() {
|
private void Patch() {
|
||||||
if(string.IsNullOrWhiteSpace(this.filePicker.FilePath)) {
|
if(string.IsNullOrWhiteSpace(this.filePicker.FilePath)) {
|
||||||
Gui.CreateOkDialog("Form Error", "No file specified!").ShowModal();
|
Gui.CreateOkDialog("Form Error", "No file specified!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(string.IsNullOrWhiteSpace(this.serverUrl.Text)) {
|
if(string.IsNullOrWhiteSpace(this.serverUrl.Text)) {
|
||||||
Gui.CreateOkDialog("Form Error", "No server URL specified!").ShowModal();
|
Gui.CreateOkDialog("Form Error", "No server URL specified!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(string.IsNullOrWhiteSpace(this.outputFileName.FilePath)) {
|
if(string.IsNullOrWhiteSpace(this.outputFileName.FilePath)) {
|
||||||
Gui.CreateOkDialog("Form Error", "No output file specified!").ShowModal();
|
Gui.CreateOkDialog("Form Error", "No output file specified!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.filePicker.FilePath == this.outputFileName.FilePath) {
|
if(this.filePicker.FilePath == this.outputFileName.FilePath) {
|
||||||
Gui.CreateOkDialog("Form Error", "Input and output filename are the same! Please save the patched file with a different name so you have a backup of your the original EBOOT.ELF.").ShowModal();
|
Gui.CreateOkDialog("Form Error", "Input and output filename are the same! Please save the patched file with a different name so you have a backup of your the original EBOOT.ELF.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Uri.TryCreate(this.serverUrl.Text, UriKind.Absolute, out _)) {
|
if(!Uri.TryCreate(this.serverUrl.Text, UriKind.Absolute, out _)) {
|
||||||
Gui.CreateOkDialog("Form Error", "Server URL is invalid! Please enter a valid URL.").ShowModal();
|
Gui.CreateOkDialog("Form Error", "Server URL is invalid! Please enter a valid URL.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!Regex.IsMatch(this.serverUrl.Text, "LITTLEBIGPLANETPS3_XML")) {
|
||||||
|
bool userCertain = Gui.CreateConfirmationDialog("URL Mistype", $"Server URL {this.serverUrl.Text} does not match LITTLEBIGPLANETPS3_XML, are you sure you want to use this?");
|
||||||
|
if (!userCertain) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// else, godspeed, captain
|
||||||
|
}
|
||||||
|
|
||||||
// Validate EBOOT after validating form; more expensive
|
// Validate EBOOT after validating form; more expensive
|
||||||
|
|
||||||
ElfFile eboot = new(this.filePicker.FilePath);
|
ElfFile eboot = new(this.filePicker.FilePath);
|
||||||
|
|
||||||
if(eboot.IsValid == false) {
|
if(eboot.IsValid == false) {
|
||||||
Gui.CreateOkDialog("EBOOT Error", $"{eboot.Name} is not a valid ELF file (magic number mismatch)\n" + "The EBOOT must be decrypted before using this tool").ShowModal();
|
Gui.CreateOkDialog("EBOOT Error", $"{eboot.Name} is not a valid ELF file (magic number mismatch)\n" + "The EBOOT must be decrypted before using this tool");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(eboot.Is64Bit == null) {
|
if(eboot.Is64Bit == null) {
|
||||||
Gui.CreateOkDialog("EBOOT Error", $"{eboot.Name} does not target a valid system").ShowModal();
|
Gui.CreateOkDialog("EBOOT Error", $"{eboot.Name} does not target a valid system");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(string.IsNullOrWhiteSpace(eboot.Architecture)) {
|
if(string.IsNullOrWhiteSpace(eboot.Architecture)) {
|
||||||
Gui.CreateOkDialog("EBOOT Error", $"{eboot.Name} does not target a valid architecture (PowerPC or ARM)").ShowModal();
|
Gui.CreateOkDialog("EBOOT Error", $"{eboot.Name} does not target a valid architecture (PowerPC or ARM)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,10 +129,10 @@ public class FilePatchForm : Form {
|
||||||
Patcher.PatchFile(this.filePicker.FilePath, this.serverUrl.Text, this.outputFileName.FilePath);
|
Patcher.PatchFile(this.filePicker.FilePath, this.serverUrl.Text, this.outputFileName.FilePath);
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
catch(Exception e) {
|
||||||
Gui.CreateOkDialog("Error occurred while patching", "An error occured while patching:\n" + e).ShowModal();
|
Gui.CreateOkDialog("Error occurred while patching", "An error occured while patching:\n" + e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Gui.CreateOkDialog("Success!", "The Server URL has been patched to " + this.serverUrl.Text).ShowModal();
|
Gui.CreateOkDialog("Success!", "The Server URL has been patched to " + this.serverUrl.Text);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -34,25 +34,25 @@ public class RemotePatchForm : Form
|
||||||
control.Click += delegate {
|
control.Click += delegate {
|
||||||
if (string.IsNullOrEmpty(this.ps3LocalIP.Text))
|
if (string.IsNullOrEmpty(this.ps3LocalIP.Text))
|
||||||
{
|
{
|
||||||
Gui.CreateOkDialog("Error", "No PS3 IP address specified!").ShowModal();
|
Gui.CreateOkDialog("Error", "No PS3 IP address specified!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(this.lbpGameID.Text))
|
if (string.IsNullOrEmpty(this.lbpGameID.Text))
|
||||||
{
|
{
|
||||||
Gui.CreateOkDialog("Error", "No title ID specified!").ShowModal();
|
Gui.CreateOkDialog("Error", "No title ID specified!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(this.serverUrl.Text))
|
if (string.IsNullOrEmpty(this.serverUrl.Text))
|
||||||
{
|
{
|
||||||
Gui.CreateOkDialog("Error", "No server URL specified!").ShowModal();
|
Gui.CreateOkDialog("Error", "No server URL specified!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Uri.TryCreate(this.serverUrl.Text, UriKind.Absolute, out _))
|
if (!Uri.TryCreate(this.serverUrl.Text, UriKind.Absolute, out _))
|
||||||
{
|
{
|
||||||
Gui.CreateOkDialog("Error", "Server URL is invalid! Please enter a valid URL.").ShowModal();
|
Gui.CreateOkDialog("Error", "Server URL is invalid! Please enter a valid URL.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,11 +69,11 @@ public class RemotePatchForm : Form
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Gui.CreateOkDialog("Error occurred while patching", "An error occured while patching:\n" + e).ShowModal();
|
Gui.CreateOkDialog("Error occurred while patching", "An error occured while patching:\n" + e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Gui.CreateOkDialog("Success!", $"The Server URL for {this.lbpGameID.Text} on the PS3 at {this.ps3LocalIP.Text} has been patched to {this.serverUrl.Text}").ShowModal();
|
Gui.CreateOkDialog("Success!", $"The Server URL for {this.lbpGameID.Text} on the PS3 at {this.ps3LocalIP.Text} has been patched to {this.serverUrl.Text}");
|
||||||
};
|
};
|
||||||
|
|
||||||
return control;
|
return control;
|
||||||
|
@ -91,13 +91,13 @@ public class RemotePatchForm : Form
|
||||||
control.Click += delegate {
|
control.Click += delegate {
|
||||||
if (string.IsNullOrEmpty(this.ps3LocalIP.Text))
|
if (string.IsNullOrEmpty(this.ps3LocalIP.Text))
|
||||||
{
|
{
|
||||||
Gui.CreateOkDialog("Form Error", "No PS3 IP address specified!").ShowModal();
|
Gui.CreateOkDialog("Form Error", "No PS3 IP address specified!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(this.lbpGameID.Text))
|
if (string.IsNullOrEmpty(this.lbpGameID.Text))
|
||||||
{
|
{
|
||||||
Gui.CreateOkDialog("Form Error", "No game ID specified!").ShowModal();
|
Gui.CreateOkDialog("Form Error", "No game ID specified!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,11 +107,11 @@ public class RemotePatchForm : Form
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Gui.CreateOkDialog("Error occurred while reverting EBOOT", "An error occured while patching:\n" + e).ShowModal();
|
Gui.CreateOkDialog("Error occurred while reverting EBOOT", "An error occured while patching:\n" + e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Gui.CreateOkDialog("Success!", $"UnionRemotePatcher reverted your the EBOOT for {this.lbpGameID.Text} to stock. You're ready to patch your EBOOT again.").ShowModal();
|
Gui.CreateOkDialog("Success!", $"UnionRemotePatcher reverted your the EBOOT for {this.lbpGameID.Text} to stock. You're ready to patch your EBOOT again.");
|
||||||
};
|
};
|
||||||
|
|
||||||
return control;
|
return control;
|
||||||
|
|
|
@ -9,39 +9,44 @@ public static class Gui {
|
||||||
new Application().Run(new ModeSelectionForm());
|
new Application().Run(new ModeSelectionForm());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Dialog CreateOkDialog(string title, string errorMessage) {
|
public static void CreateOkDialog(string title, string errorMessage) {
|
||||||
DynamicLayout layout = new();
|
MessageBox.Show(errorMessage, title, MessageBoxButtons.OK, MessageBoxType.Question);
|
||||||
Button button;
|
// DynamicLayout layout = new();
|
||||||
|
// Button button;
|
||||||
|
|
||||||
layout.Spacing = new Size(5, 5);
|
// layout.Spacing = new Size(5, 5);
|
||||||
layout.MinimumSize = new Size(350, 100);
|
// layout.MinimumSize = new Size(350, 100);
|
||||||
|
|
||||||
layout.BeginHorizontal();
|
// layout.BeginHorizontal();
|
||||||
layout.Add(new Label {
|
// layout.Add(new Label {
|
||||||
Text = errorMessage,
|
// Text = errorMessage,
|
||||||
});
|
// });
|
||||||
|
|
||||||
layout.BeginHorizontal();
|
// layout.BeginHorizontal();
|
||||||
layout.BeginVertical();
|
// layout.BeginVertical();
|
||||||
layout.Add(null);
|
// layout.Add(null);
|
||||||
layout.Add(button = new Button {
|
// layout.Add(button = new Button {
|
||||||
Text = "OK",
|
// Text = "OK",
|
||||||
});
|
// });
|
||||||
|
|
||||||
layout.EndVertical();
|
// layout.EndVertical();
|
||||||
layout.EndHorizontal();
|
// layout.EndHorizontal();
|
||||||
layout.EndHorizontal();
|
// layout.EndHorizontal();
|
||||||
|
|
||||||
Dialog dialog = new() {
|
// Dialog dialog = new() {
|
||||||
Content = layout,
|
// Content = layout,
|
||||||
Padding = new Padding(10, 10, 10, 10),
|
// Padding = new Padding(10, 10, 10, 10),
|
||||||
Title = title,
|
// Title = title,
|
||||||
};
|
// };
|
||||||
|
|
||||||
button.Click += delegate {
|
// button.Click += delegate {
|
||||||
dialog.Close();
|
// dialog.Close();
|
||||||
};
|
// };
|
||||||
|
|
||||||
return dialog;
|
// return dialog;
|
||||||
|
}
|
||||||
|
public static bool CreateConfirmationDialog(string title, string errorMessage) {
|
||||||
|
DialogResult result = MessageBox.Show(errorMessage, title, MessageBoxButtons.YesNo, MessageBoxType.Question);
|
||||||
|
return result == DialogResult.Yes;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue