Skip to content

Commit

Permalink
Automatically determine game version
Browse files Browse the repository at this point in the history
  • Loading branch information
jvyden committed Apr 28, 2024
1 parent 3c9e9f0 commit 2729793
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Refresher/UI/EmulatorPatchForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public class EmulatorPatchForm : IntegratedPatchForm
{
private FilePicker _folderField = null!;
private TextBox _ppuHash = null!;
private TextBox _gameVersion = null!;
private Button _filePatchButton = null!;

public EmulatorPatchForm() : base("RPCS3 Patch")
Expand All @@ -36,26 +35,30 @@ public EmulatorPatchForm() : base("RPCS3 Patch")
}

this._ppuHash.TextChanged += this.UpdateTextFields;
this._gameVersion.TextChanged += this.UpdateTextFields;
}

private void UpdateTextFields(object? sender, EventArgs args)
{
if (this.Patcher != null)
{
this.Patcher.PpuHash = this._ppuHash.Text;
this.Patcher.GameVersion = this._gameVersion.Text;
this.Reverify(null, EventArgs.Empty);
}
}

protected override void BeforePatch(object? sender, EventArgs e)
{
if (this.GameDropdown.SelectedValue is not GameItem game)
{
Program.Log("Game was null before patch, bailing", nameof(EmulatorPatchForm));
return;
}

if (this.Patcher != null)
{
this.Patcher.GenerateRpcs3Patch = true;
this.Patcher.PpuHash = this._ppuHash.Text;
this.Patcher.GameVersion = this._gameVersion.Text;
this.Patcher.GameVersion = game.Version;
this.Patcher.Rpcs3PatchFolder = Path.Combine(this._folderField.FilePath, "../patches");
this.Patcher.GameName = ((GameItem)this.GameDropdown.SelectedValue).Text;
this.Patcher.TitleId = ((GameItem)this.GameDropdown.SelectedValue).TitleId;
Expand Down Expand Up @@ -93,7 +96,6 @@ protected override IEnumerable<TableRow> AddFields()
return new[]
{
AddField("Game PPU hash", out this._ppuHash),
AddField("Game Version", out this._gameVersion),
AddField("RPCS3 dev_hdd0 folder", out this._folderField),
AddField("", out this._filePatchButton),
};
Expand Down
1 change: 1 addition & 0 deletions Refresher/UI/IntegratedPatchForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ protected virtual void PathChanged(object? sender, EventArgs ev)
}

ParamSfo sfo = new(sfoStream);
item.Version = sfo.Table["APP_VER"].ToString() ?? "unknown";
item.Text = $"{sfo.Table["TITLE"]} [{game}]";
}
catch
Expand Down
1 change: 1 addition & 0 deletions Refresher/UI/Items/GameItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ namespace Refresher.UI.Items;
public class GameItem : ImageListItem
{
public string TitleId = string.Empty;
public string Version = string.Empty;
}

0 comments on commit 2729793

Please sign in to comment.