mirror of
https://github.com/LBPUnion/UnionPatcher.git
synced 2025-08-02 06:08:39 +00:00
Don't lock up the UI thread.
Remove useless help button Shorten the UI a bit
This commit is contained in:
parent
d9c1ff7b40
commit
edfe30154e
4 changed files with 51 additions and 81 deletions
|
@ -24,25 +24,8 @@ public class FilePatchForm : Form {
|
||||||
return control;
|
return control;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Control CreateHelpButton(int tabIndex = 0) {
|
|
||||||
Button control = new() {
|
|
||||||
Text = "Help",
|
|
||||||
TabIndex = tabIndex,
|
|
||||||
};
|
|
||||||
|
|
||||||
control.Click += delegate {
|
|
||||||
Process process = new();
|
|
||||||
|
|
||||||
process.StartInfo.UseShellExecute = true;
|
|
||||||
process.StartInfo.FileName = "https://www.lbpunion.com";
|
|
||||||
process.Start();
|
|
||||||
};
|
|
||||||
|
|
||||||
return control;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FilePatchForm() {
|
public FilePatchForm() {
|
||||||
this.Title = "UnionPatcher - File Patch";
|
this.Title = "File Patch";
|
||||||
this.ClientSize = new Size(500, -1);
|
this.ClientSize = new Size(500, -1);
|
||||||
this.Content = new TableLayout {
|
this.Content = new TableLayout {
|
||||||
Spacing = new Size(5,5),
|
Spacing = new Size(5,5),
|
||||||
|
@ -61,7 +44,7 @@ public class FilePatchForm : Form {
|
||||||
new TableCell(this.outputFileName = new FilePicker { TabIndex = 2, FileAction = FileAction.SaveFile, Filters = { new FileFilter("ELF files", "*.elf", "*.ELF"), new FileFilter("All Files", "*.*") }})
|
new TableCell(this.outputFileName = new FilePicker { TabIndex = 2, FileAction = FileAction.SaveFile, Filters = { new FileFilter("ELF files", "*.elf", "*.ELF"), new FileFilter("All Files", "*.*") }})
|
||||||
),
|
),
|
||||||
new TableRow(
|
new TableRow(
|
||||||
new TableCell(this.CreateHelpButton(4)),
|
new TableCell(),
|
||||||
new TableCell(this.CreatePatchButton(3))
|
new TableCell(this.CreatePatchButton(3))
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
|
@ -8,8 +8,8 @@ namespace LBPUnion.UnionPatcher.Gui.Forms;
|
||||||
public class ModeSelectionForm : Form {
|
public class ModeSelectionForm : Form {
|
||||||
#region UI
|
#region UI
|
||||||
public ModeSelectionForm() {
|
public ModeSelectionForm() {
|
||||||
this.Title = "Welcome to UnionPatcher";
|
this.Title = "UnionPatcher";
|
||||||
this.ClientSize = new Size(500, -1);
|
this.ClientSize = new Size(200, -1);
|
||||||
this.Content = new TableLayout {
|
this.Content = new TableLayout {
|
||||||
Spacing = new Size(5, 5),
|
Spacing = new Size(5, 5),
|
||||||
Padding = new Padding(10, 10, 10, 10),
|
Padding = new Padding(10, 10, 10, 10),
|
||||||
|
@ -17,9 +17,6 @@ public class ModeSelectionForm : Form {
|
||||||
new TableRow(
|
new TableRow(
|
||||||
new TableCell(new Button(openRemotePatcher) { Text = "Remote Patcher (PS3)" })
|
new TableCell(new Button(openRemotePatcher) { Text = "Remote Patcher (PS3)" })
|
||||||
),
|
),
|
||||||
new TableRow(
|
|
||||||
new TableCell(new Button(openLocalPatcher) { Text = "Local Patch (RPCS3)", Enabled = false })
|
|
||||||
),
|
|
||||||
new TableRow(
|
new TableRow(
|
||||||
new TableCell(new Button(openFilePatcher) { Text = "File Patch (PS3/RPCS3)" })
|
new TableCell(new Button(openFilePatcher) { Text = "File Patch (PS3/RPCS3)" })
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Eto.Drawing;
|
using Eto.Drawing;
|
||||||
using Eto.Forms;
|
using Eto.Forms;
|
||||||
|
|
||||||
|
@ -31,7 +32,7 @@ public class RemotePatchForm : Form
|
||||||
Width = 200,
|
Width = 200,
|
||||||
};
|
};
|
||||||
|
|
||||||
control.Click += delegate {
|
control.Click += async delegate {
|
||||||
if (string.IsNullOrEmpty(this.ps3LocalIP.Text))
|
if (string.IsNullOrEmpty(this.ps3LocalIP.Text))
|
||||||
{
|
{
|
||||||
Gui.CreateOkDialog("Error", "No PS3 IP address specified!");
|
Gui.CreateOkDialog("Error", "No PS3 IP address specified!");
|
||||||
|
@ -56,24 +57,33 @@ public class RemotePatchForm : Form
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Task patchTask = null;
|
||||||
|
|
||||||
|
if (this.lbpGameID.Text.ToUpper().StartsWith('B'))
|
||||||
|
{
|
||||||
|
patchTask = this.RemotePatcher.DiscEBOOTRemotePatch(this.ps3LocalIP.Text, this.lbpGameID.Text, this.serverUrl.Text, this.ftpUser.Text, this.ftpPass.Text);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
patchTask = this.RemotePatcher.PSNEBOOTRemotePatch(this.ps3LocalIP.Text, this.lbpGameID.Text, this.serverUrl.Text, this.ftpUser.Text, this.ftpPass.Text);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Something went horribly wrong, this should be impossible to encounter.
|
||||||
|
if (patchTask == null) return;
|
||||||
|
|
||||||
|
Control revertButton = this.FindChild("revert");
|
||||||
|
foreach (Control control in this.Controls) control.Enabled = false;
|
||||||
|
Gui.CreateOkDialog("Sit Tight!", $"We're patching your title for {this.ps3LocalIP.Text}! Maybe grab some tea?");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (this.lbpGameID.Text.ToUpper().StartsWith('B'))
|
await patchTask;
|
||||||
{
|
Gui.CreateOkDialog("Have fun!", $"The Server URL for {this.lbpGameID.Text} on the PS3 at {this.ps3LocalIP.Text} has been patched to {this.serverUrl.Text}");
|
||||||
this.RemotePatcher.DiscEBOOTRemotePatch(this.ps3LocalIP.Text, this.lbpGameID.Text, this.serverUrl.Text, this.ftpUser.Text, this.ftpPass.Text);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.RemotePatcher.PSNEBOOTRemotePatch(this.ps3LocalIP.Text, this.lbpGameID.Text, this.serverUrl.Text, this.ftpUser.Text, this.ftpPass.Text);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Gui.CreateOkDialog("Error occurred while patching", "An error occured while patching:\n" + e);
|
Gui.CreateOkDialog("Error occurred while patching", "An error occured while patching:\n" + e.Message);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
foreach (Control control in this.Controls) control.Enabled = true;
|
||||||
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;
|
||||||
|
@ -85,10 +95,10 @@ public class RemotePatchForm : Form
|
||||||
{
|
{
|
||||||
Text = "Revert EBOOT",
|
Text = "Revert EBOOT",
|
||||||
TabIndex = tabIndex,
|
TabIndex = tabIndex,
|
||||||
Width = 200,
|
Width = 50,
|
||||||
};
|
};
|
||||||
|
|
||||||
control.Click += delegate {
|
control.Click += async delegate {
|
||||||
if (string.IsNullOrEmpty(this.ps3LocalIP.Text))
|
if (string.IsNullOrEmpty(this.ps3LocalIP.Text))
|
||||||
{
|
{
|
||||||
Gui.CreateOkDialog("Form Error", "No PS3 IP address specified!");
|
Gui.CreateOkDialog("Form Error", "No PS3 IP address specified!");
|
||||||
|
@ -101,36 +111,19 @@ public class RemotePatchForm : Form
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (Control control in this.Controls) control.Enabled = false;
|
||||||
|
Task revertTask = this.RemotePatcher.RevertEBOOT(this.ps3LocalIP.Text, this.lbpGameID.Text, this.serverUrl.Text, this.ftpUser.Text, this.ftpPass.Text);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.RemotePatcher.RevertEBOOT(this.ps3LocalIP.Text, this.lbpGameID.Text, this.serverUrl.Text, this.ftpUser.Text, this.ftpPass.Text);
|
await revertTask;
|
||||||
|
Gui.CreateOkDialog("Success!", $"UnionPatcher reverted your the EBOOT for {this.lbpGameID.Text} to stock. You're ready to patch your EBOOT again.");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Gui.CreateOkDialog("Error occurred while reverting EBOOT", "An error occured while patching:\n" + e);
|
Gui.CreateOkDialog("Error occurred while reverting EBOOT", "An error occured while patching:\n" + e.Message);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
foreach (Control control in this.Controls) control.Enabled = true;
|
||||||
Gui.CreateOkDialog("Success!", $"UnionRemotePatcher reverted your the EBOOT for {this.lbpGameID.Text} to stock. You're ready to patch your EBOOT again.");
|
|
||||||
};
|
|
||||||
|
|
||||||
return control;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Control CreateHelpButton(int tabIndex = 0)
|
|
||||||
{
|
|
||||||
Button control = new()
|
|
||||||
{
|
|
||||||
Text = "Help",
|
|
||||||
TabIndex = tabIndex,
|
|
||||||
};
|
|
||||||
|
|
||||||
control.Click += delegate {
|
|
||||||
Process process = new();
|
|
||||||
|
|
||||||
process.StartInfo.UseShellExecute = true;
|
|
||||||
process.StartInfo.FileName = "https://www.lbpunion.com";
|
|
||||||
process.Start();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return control;
|
return control;
|
||||||
|
@ -138,7 +131,7 @@ public class RemotePatchForm : Form
|
||||||
|
|
||||||
void InitializeComponent()
|
void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.Title = "UnionPatcher - Remote Patch";
|
this.Title = "Remote Patcher";
|
||||||
this.MinimumSize = new Size(450, 200);
|
this.MinimumSize = new Size(450, 200);
|
||||||
this.Resizable = false;
|
this.Resizable = false;
|
||||||
this.Padding = 10;
|
this.Padding = 10;
|
||||||
|
@ -169,11 +162,8 @@ public class RemotePatchForm : Form
|
||||||
new TableCell(this.ftpPass = new TextBox { TabIndex = 4 })
|
new TableCell(this.ftpPass = new TextBox { TabIndex = 4 })
|
||||||
),
|
),
|
||||||
new TableRow(
|
new TableRow(
|
||||||
new TableCell(this.CreateHelpButton(7)),
|
new TableCell(this.CreateRevertEBOOTButton(6)),
|
||||||
new TableRow(
|
new TableCell(this.CreatePatchButton(5))
|
||||||
new TableCell(this.CreatePatchButton(5)),
|
|
||||||
new TableCell(this.CreateRevertEBOOTButton(6))
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,7 +14,7 @@ public class RemotePatch
|
||||||
{
|
{
|
||||||
private readonly PS3MAPI _ps3Mapi = new();
|
private readonly PS3MAPI _ps3Mapi = new();
|
||||||
|
|
||||||
private static Dictionary<string, string> GetUsersAsync(string ps3Ip, string user, string pass)
|
private static Dictionary<string, string> GetUsers(string ps3Ip, string user, string pass)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Getting users...");
|
Console.WriteLine("Getting users...");
|
||||||
|
|
||||||
|
@ -95,11 +95,11 @@ public class RemotePatch
|
||||||
Console.WriteLine("\n===== END SCETOOL =====\n\n");
|
Console.WriteLine("\n===== END SCETOOL =====\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RevertEBOOT(string ps3ip, string gameID, string serverURL, string user, string pass)
|
public Task RevertEBOOT(string ps3ip, string gameID, string serverURL, string user, string pass)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Restoring original EBOOT.BIN from EBOOT.BIN.BAK");
|
Console.WriteLine("Restoring original EBOOT.BIN from EBOOT.BIN.BAK");
|
||||||
|
|
||||||
Task.Run(() =>
|
return Task.Run(() =>
|
||||||
{
|
{
|
||||||
// Create a simple directory structure
|
// Create a simple directory structure
|
||||||
Directory.CreateDirectory(@"eboot");
|
Directory.CreateDirectory(@"eboot");
|
||||||
|
@ -118,15 +118,15 @@ public class RemotePatch
|
||||||
{
|
{
|
||||||
throw new WebException("Could not find EBOOT.BIN.BAK on server.");
|
throw new WebException("Could not find EBOOT.BIN.BAK on server.");
|
||||||
}
|
}
|
||||||
}).Wait();
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PSNEBOOTRemotePatch(string ps3ip, string gameID, string serverURL, string user, string pass)
|
public Task PSNEBOOTRemotePatch(string ps3ip, string gameID, string serverURL, string user, string pass)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Detected Digital Copy - Running in Full Mode");
|
Console.WriteLine("Detected Digital Copy - Running in Full Mode");
|
||||||
|
|
||||||
// Create a new thread so we don't occupy the UI thread.
|
// Create a new thread so we don't occupy the UI thread.
|
||||||
Task.Run(() =>
|
return Task.Run(() =>
|
||||||
{
|
{
|
||||||
string idps = "";
|
string idps = "";
|
||||||
string contentID = "";
|
string contentID = "";
|
||||||
|
@ -158,7 +158,7 @@ public class RemotePatch
|
||||||
File.WriteAllBytes(@"data/idps", IDPSHelper.StringToByteArray(idps));
|
File.WriteAllBytes(@"data/idps", IDPSHelper.StringToByteArray(idps));
|
||||||
|
|
||||||
// Scan the users on the system
|
// Scan the users on the system
|
||||||
users = GetUsersAsync(ps3ip, user, pass);
|
users = GetUsers(ps3ip, user, pass);
|
||||||
|
|
||||||
// Scan the system for a license for the game
|
// Scan the system for a license for the game
|
||||||
foreach (string currentUser in users.Keys.ToArray())
|
foreach (string currentUser in users.Keys.ToArray())
|
||||||
|
@ -216,12 +216,12 @@ public class RemotePatch
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cut-down version that only patches disc copies
|
// Cut-down version that only patches disc copies
|
||||||
public void DiscEBOOTRemotePatch(string ps3ip, string gameID, string serverURL, string user, string pass)
|
public Task DiscEBOOTRemotePatch(string ps3ip, string gameID, string serverURL, string user, string pass)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Detected Disc Copy - Running in Simplified Mode");
|
Console.WriteLine("Detected Disc Copy - Running in Simplified Mode");
|
||||||
|
|
||||||
// Create a new thread so we don't occupy the UI thread.
|
// Create a new thread so we don't occupy the UI thread.
|
||||||
Task.Run(() =>
|
return Task.Run(() =>
|
||||||
{
|
{
|
||||||
// Create a simple directory structure
|
// Create a simple directory structure
|
||||||
Directory.CreateDirectory(@"eboot");
|
Directory.CreateDirectory(@"eboot");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue