1- using System . Diagnostics ;
21using Eto ;
3- using Eto . Drawing ;
42using Eto . Forms ;
5- using Refresher . Patching ;
6- using Refresher . UI . Items ;
7- using Refresher . Verification ;
8- using SCEToolSharp ;
3+ using Refresher . Accessors ;
94
105namespace Refresher . UI ;
116
12- public class EmulatorPatchForm : PatchForm < Patcher >
7+ public class EmulatorPatchForm : IntegratedPatchForm
138{
14- private readonly FilePicker _folderField ;
15- private readonly DropDown _gameDropdown ;
16- private readonly TextBox _outputField ;
9+ private FilePicker _folderField = null ! ;
1710
18- private string _tempFile ;
19- private string _usrDir ;
20-
21- protected override TableLayout FormPanel { get ; }
22-
2311 public EmulatorPatchForm ( ) : base ( "RPCS3 Patch" )
2412 {
25- this . FormPanel = new TableLayout ( new List < TableRow >
26- {
27- AddField ( "RPCS3 dev_hdd0 folder" , out this . _folderField ) ,
28- AddField ( "Game to patch" , out this . _gameDropdown ) ,
29- AddField ( "Server URL" , out this . UrlField ) ,
30- AddField ( "Identifier (EBOOT.<value>.elf)" , out this . _outputField ) ,
31- } ) ;
32-
3313 this . _folderField . FileAction = FileAction . SelectFolder ;
3414 this . _folderField . FilePathChanged += this . PathChanged ;
35-
36- this . _outputField . PlaceholderText = "refresh" ;
37-
38- this . _gameDropdown . SelectedValueChanged += this . GameChanged ;
3915
4016 // RPCS3 builds for Windows are portable
4117 // TODO: Cache the last used location for easier entry
@@ -50,95 +26,24 @@ public EmulatorPatchForm() : base("RPCS3 Patch")
5026 this . LogMessage ( "RPCS3's path has been detected automatically! You do not need to change the path." ) ;
5127 }
5228 }
53-
54- this . InitializePatcher ( ) ;
5529 }
5630
57- private void PathChanged ( object ? sender , EventArgs ev )
31+ public override void Guide ( object ? sender , EventArgs e )
5832 {
59- string path = this . _folderField . FilePath ;
60- this . _gameDropdown . Items . Clear ( ) ;
61-
62- string gamesPath = Path . Join ( path , "game" ) ;
63- if ( ! Directory . Exists ( gamesPath ) ) return ;
64-
65- string [ ] games = Directory . GetDirectories ( Path . Join ( path , "game" ) ) ;
66-
67- foreach ( string gamePath in games )
68- {
69- string game = Path . GetFileName ( gamePath ) ;
70-
71- // Example TitleID: BCUS98208, must be 9 chars
72- if ( game . Length != 9 ) continue ; // Skip over profiles/save data/other garbage
73-
74- GameItem item = new ( ) ;
75-
76- string iconPath = Path . Combine ( gamePath , "ICON0.PNG" ) ;
77- if ( File . Exists ( iconPath ) )
78- {
79- item . Image = new Bitmap ( iconPath ) . WithSize ( new Size ( 64 , 64 ) ) ;
80- }
81-
82- string sfoPath = Path . Combine ( gamePath , "PARAM.SFO" ) ;
83- try
84- {
85- ParamSfo sfo = new ( File . OpenRead ( sfoPath ) ) ;
86- item . Text = $ "{ sfo . Table [ "TITLE" ] } [{ game } ]";
87- }
88- catch
89- {
90- item . Text = game ;
91- }
92-
93- item . TitleId = game ;
94-
95- this . _gameDropdown . Items . Add ( item ) ;
96- }
33+ this . OpenUrl ( "https://littlebigrefresh.github.io/Docs/patching/rpcs3" ) ;
9734 }
9835
99- private void GameChanged ( object ? sender , EventArgs ev )
36+ protected override void PathChanged ( object ? sender , EventArgs ev )
10037 {
101- GameItem ? game = this . _gameDropdown . SelectedValue as GameItem ;
102- Debug . Assert ( game != null ) ;
103-
104- this . _usrDir = Path . Combine ( this . _folderField . FilePath , "game" , game . TitleId , "USRDIR" ) ;
105- string ebootPath = Path . Combine ( this . _usrDir , "EBOOT.BIN" ) ;
106- string rapDir = Path . Combine ( this . _folderField . FilePath , "home" , "00000001" , "exdata" ) ;
107-
108- this . LogMessage ( "EBOOT Path: " + ebootPath ) ;
109- if ( ! File . Exists ( ebootPath ) )
110- {
111- this . FailVerify ( "Could not find the EBOOT. Patching cannot continue." , clear : false ) ;
112- return ;
113- }
114-
115- this . _tempFile = Path . GetTempFileName ( ) ;
116-
117- LibSceToolSharp . SetRapDirectory ( rapDir ) ;
118- LibSceToolSharp . Decrypt ( ebootPath , this . _tempFile ) ;
119-
120- this . LogMessage ( $ "The EBOOT has been successfully decrypted. It's stored at { this . _tempFile } .") ;
121-
122- this . Patcher = new Patcher ( File . Open ( this . _tempFile , FileMode . Open , FileAccess . ReadWrite ) ) ;
123-
124- this . Reverify ( sender , ev ) ;
125- }
126-
127- public override void CompletePatch ( object ? sender , EventArgs e ) {
128- string identifier = string . IsNullOrWhiteSpace ( this . _outputField . Text ) ? this . _outputField . PlaceholderText : this . _outputField . Text ;
129-
130- string destination = Path . Combine ( this . _usrDir , $ "EBOOT.{ identifier } .elf") ;
131-
132- File . Move ( this . _tempFile , destination , true ) ;
133- MessageBox . Show ( $ "Successfully patched EBOOT! It was saved to '{ destination } '.") ;
134-
135- // Re-initialize patcher so we can patch with the same parameters again
136- // Probably slow but prevents crash
137- this . GameChanged ( this , EventArgs . Empty ) ;
38+ this . Accessor = new EmulatorPatchAccessor ( this . _folderField . FilePath ) ;
39+ base . PathChanged ( sender , ev ) ;
13840 }
13941
140- public override void Guide ( object ? sender , EventArgs e )
42+ protected override TableRow AddRemoteField ( )
14143 {
142- this . OpenUrl ( "https://littlebigrefresh.github.io/Docs/patching/rpcs3" ) ;
44+ return AddField ( "RPCS3 dev_hdd0 folder" , out this . _folderField ) ;
14345 }
46+
47+ protected override bool NeedsResign => false ;
48+ protected override bool ShouldReplaceExecutable => false ;
14449}
0 commit comments