Skip to content

Commit e4abba2

Browse files
authored
Merge pull request #87 from LittleBigRefresh/patchwork-config
Add pipeline for reconfiguring Patchwork
2 parents 01e4668 + f7184c4 commit e4abba2

File tree

4 files changed

+62
-13
lines changed

4 files changed

+62
-13
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Refresher.Core.Pipelines.Steps;
2+
3+
namespace Refresher.Core.Pipelines.Lbp;
4+
5+
public class PatchworkPs3ConfigPipeline : Pipeline
6+
{
7+
public override string Id => "patchwork-config-ps3";
8+
public override string Name => "Patchwork PS3 Config";
9+
10+
protected override Type SetupAccessorStepType => typeof(SetupPS3AccessorStep);
11+
12+
protected override List<Type> StepTypes =>
13+
[
14+
typeof(UploadPatchworkConfigurationStep),
15+
];
16+
}

Refresher.Core/Pipelines/Pipeline.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,27 @@ public async Task<List<GameInformation>> DownloadGameListAsync(CancellationToken
202202
return this.GameList;
203203
}
204204

205+
public async Task ConnectAsync(CancellationToken cancellationToken = default)
206+
{
207+
if (this.State != PipelineState.NotStarted)
208+
{
209+
this.State = PipelineState.Error;
210+
throw new InvalidOperationException("Pipeline must be in a clean state before downloading games.");
211+
}
212+
213+
if(this.SetupAccessorStepType == null)
214+
throw new InvalidOperationException("This pipeline doesn't have accessors configured.");
215+
216+
List<Step> stepTypes = [
217+
(Step)Activator.CreateInstance(this.SetupAccessorStepType, this)!,
218+
];
219+
220+
this.State = PipelineState.Running;
221+
222+
await this.RunListOfSteps(stepTypes, cancellationToken);
223+
this.Reset();
224+
}
225+
205226
public async Task RevertGameEbootAsync(CancellationToken cancellationToken = default)
206227
{
207228
if (this.State != PipelineState.NotStarted)

Refresher/UI/MainForm.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class MainForm : RefresherForm
2020
new Label { Text = "LittleBigPlanet:" },
2121
this.PipelineButton<LbpPS3PatchPipeline>("Patch LBP1/2/3 for PS3"),
2222

23+
this.PipelineButton<PatchworkPs3ConfigPipeline>("Reconfigure Patch for PS3"),
2324
new Label { Text = "General (for non-LBP games):" },
2425
new Button((_, _) => this.ShowChild<FilePatchForm>()) { Text = "File Patch (using a .ELF)" },
2526
this.PipelineButton<RPCS3PatchPipeline>("Patch any RPCS3 game"),

Refresher/UI/PipelineForm.cs

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ private void InitializePipeline()
140140
case StepInputType.Directory:
141141
row = AddField<FilePicker>(input, value);
142142
if (input.ShouldCauseGameDownloadWhenChanged)
143-
(row.Cells[1].Control as FilePicker)!.FilePathChanged += this.OnDownloadGameList;
143+
(row.Cells[1].Control as FilePicker)!.FilePathChanged += this.OnConnect;
144144
break;
145145
case StepInputType.ConsoleIp:
146-
row = AddField<TextBox>(input, value, this._connectButton = new Button(this.OnDownloadGameList) { Text = "Connect" });
146+
row = AddField<TextBox>(input, value, this._connectButton = new Button(this.OnConnect) { Text = "Connect" });
147147
break;
148148
default:
149149
throw new ArgumentOutOfRangeException();
@@ -232,7 +232,7 @@ private void OnButtonClick(object? sender, EventArgs e)
232232
this.UpdateFormState();
233233
}
234234

235-
private void OnDownloadGameList(object? sender, EventArgs e)
235+
private void OnConnect(object? sender, EventArgs e)
236236
{
237237
if (this._pipeline == null)
238238
return;
@@ -246,11 +246,20 @@ private void OnDownloadGameList(object? sender, EventArgs e)
246246
{
247247
try
248248
{
249-
List<GameInformation> games = await this._pipeline!.DownloadGameListAsync();
250-
await Application.Instance.InvokeAsync(() =>
249+
if (this._gamesDropDown != null)
251250
{
252-
this.HandleGameList(games);
253-
});
251+
List<GameInformation> games = await this._pipeline!.DownloadGameListAsync();
252+
await Application.Instance.InvokeAsync(() =>
253+
{
254+
this.HandleConnection();
255+
this.HandleGameList(games);
256+
});
257+
}
258+
else
259+
{
260+
await this._pipeline.ConnectAsync();
261+
await Application.Instance.InvokeAsync(this.HandleConnection);
262+
}
254263
}
255264
catch (DirectoryNotFoundException)
256265
{
@@ -264,15 +273,17 @@ await Application.Instance.InvokeAsync(() =>
264273
});
265274
}
266275

276+
private void HandleConnection()
277+
{
278+
if (this._connectButton == null) return;
279+
280+
this._connectButton.Enabled = false;
281+
this._connectButton.Text = "Connected!";
282+
}
283+
267284
private void HandleGameList(List<GameInformation> games)
268285
{
269286
Debug.Assert(this._gamesDropDown != null);
270-
271-
if (this._connectButton != null)
272-
{
273-
this._connectButton.Enabled = false;
274-
this._connectButton.Text = "Connected!";
275-
}
276287

277288
this._gamesDropDown.Items.Clear();
278289

0 commit comments

Comments
 (0)