Skip to content

Commit 8d6b779

Browse files
committed
Add guide link and backup revert option, rename file duplication method
1 parent 2c8c1c4 commit 8d6b779

File tree

5 files changed

+44
-12
lines changed

5 files changed

+44
-12
lines changed

Refresher/Accessors/EmulatorPatchAccessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ private string GetPath(string path)
2525
public override Stream OpenWrite(string path) => File.OpenWrite(this.GetPath(path));
2626
public override void RemoveFile(string path) => File.Delete(this.GetPath(path));
2727

28-
public override void DuplicateFile(string inPath, string outPath)
28+
public override void CopyFile(string inPath, string outPath)
2929
=> File.Copy(this.GetPath(inPath), this.GetPath(outPath));
3030
}

Refresher/Accessors/PatchAccessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void UploadFile(string inPath, string outPath)
2929
inStream.CopyTo(outStream);
3030
}
3131

32-
public virtual void DuplicateFile(string inPath, string outPath)
32+
public virtual void CopyFile(string inPath, string outPath)
3333
{
3434
using Stream inStream = this.OpenRead(inPath);
3535
using Stream outStream = this.OpenWrite(outPath);

Refresher/UI/ConsolePatchForm.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ protected override TableRow AddRemoteField()
2525
{
2626
return AddField("PS3's IP", out this._remoteAddress, new Button(this.PathChanged) { Text = "Connect" });
2727
}
28+
29+
public override void Guide(object? sender, EventArgs e)
30+
{
31+
this.OpenUrl("https://littlebigrefresh.github.io/Docs/patching/ps3");
32+
}
2833

2934
protected override bool NeedsResign => true;
3035
protected override bool ShouldReplaceExecutable => true;

Refresher/UI/IntegratedPatchForm.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public override void CompletePatch(object? sender, EventArgs e) {
162162
{
163163
string backup = destination + ".ORIG";
164164
if (!this.Accessor.FileExists(backup))
165-
this.Accessor.DuplicateFile(destination, backup);
165+
this.Accessor.CopyFile(destination, backup);
166166

167167
this.Accessor.RemoveFile(destination);
168168
}
@@ -178,6 +178,28 @@ public override void CompletePatch(object? sender, EventArgs e) {
178178
// Probably slow but prevents crash
179179
this.GameChanged(this, EventArgs.Empty);
180180
}
181+
182+
public override IEnumerable<Button> AddExtraButtons()
183+
{
184+
if (this.ShouldReplaceExecutable)
185+
{
186+
yield return new Button(this.RevertToOriginalExecutable) { Text = "Revert EBOOT" };
187+
}
188+
}
189+
190+
private void RevertToOriginalExecutable(object? sender, EventArgs e)
191+
{
192+
if (this.Accessor == null) return;
193+
194+
if (!this.Accessor.FileExists(this._usrDir + "EBOOT.BIN.ORIG"))
195+
{
196+
MessageBox.Show("Cannot revert EBOOT since the original EBOOT does not exist", MessageBoxType.Error);
197+
return;
198+
}
199+
200+
this.Accessor.CopyFile(this._usrDir + "EBOOT.BIN.ORIG", this._usrDir + "EBOOT.BIN");
201+
MessageBox.Show("The EBOOT has successfully been reverted to it's original backup");
202+
}
181203

182204
protected abstract TableRow AddRemoteField();
183205
protected abstract bool NeedsResign { get; }

Refresher/UI/PatchForm.cs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,16 @@ protected void InitializePatcher()
4040
TableLayout formPanel = this.FormPanel;
4141
formPanel.Spacing = new Size(5, 5);
4242
formPanel.Padding = new Padding(0, 0, 0, 10);
43+
44+
StackLayout layout;
4345

4446
this.Content = new Splitter
4547
{
4648
Orientation = Orientation.Vertical,
4749
Panel1 = formPanel,
4850

4951
// ReSharper disable once RedundantExplicitParamsArrayCreation
50-
Panel2 = new StackLayout(new StackLayoutItem[]
52+
Panel2 = layout = new StackLayout(new StackLayoutItem[]
5153
{
5254
this._messages,
5355
new Button(this.Guide) { Text = "View guide" },
@@ -62,6 +64,9 @@ protected void InitializePatcher()
6264
},
6365
};
6466

67+
foreach (Button button in this.AddExtraButtons())
68+
layout.Items.Add(button);
69+
6570
this.UrlField.TextChanged += this.Reverify;
6671
this.UrlField.PlaceholderText = "http://localhost:10061/lbp";
6772
}
@@ -75,10 +80,7 @@ protected void InitializePatcher()
7580
};
7681

7782
control = new TControl();
78-
if (forceHeight != -1)
79-
{
80-
control.Height = forceHeight;
81-
}
83+
if (forceHeight != -1) control.Height = forceHeight;
8284

8385
if (button != null)
8486
{
@@ -97,6 +99,11 @@ public virtual void CompletePatch(object? sender, EventArgs e)
9799
// Not necessary for some patchers maybe
98100
}
99101

102+
public virtual IEnumerable<Button> AddExtraButtons()
103+
{
104+
return Array.Empty<Button>();
105+
}
106+
100107
public virtual void Guide(object? sender, EventArgs e)
101108
{
102109
MessageBox.Show("No guide exists for this patch method yet, so stay tuned!", MessageBoxType.Warning);
@@ -120,10 +127,8 @@ private void Autodiscover(object? sender, EventArgs arg)
120127
{
121128
try
122129
{
123-
using HttpClient client = new()
124-
{
125-
BaseAddress = new Uri(this.UrlField.Text),
126-
};
130+
using HttpClient client = new();
131+
client.BaseAddress = new Uri(this.UrlField.Text);
127132

128133
HttpResponseMessage response = client.GetAsync("/autodiscover").Result;
129134
response.EnsureSuccessStatusCode();

0 commit comments

Comments
 (0)