|
@@ -0,0 +1,82 @@
|
|
1
|
+#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+from ips import perform_ips_patch
|
|
4
|
+from PyQt5 import QtCore, QtGui, QtWidgets
|
|
5
|
+
|
|
6
|
+import sys
|
|
7
|
+
|
|
8
|
+class ApplicationWindow(QtWidgets.QWidget):
|
|
9
|
+ def __init__(self):
|
|
10
|
+ super().__init__()
|
|
11
|
+ self.initUI()
|
|
12
|
+
|
|
13
|
+ def initUI(self):
|
|
14
|
+ self.setWindowTitle("OpenIPS Patcher")
|
|
15
|
+
|
|
16
|
+ self.base_rom_label = QtWidgets.QLineEdit(self)
|
|
17
|
+ self.base_rom_label.setReadOnly(True)
|
|
18
|
+
|
|
19
|
+ self.patch_file_label = QtWidgets.QLineEdit(self)
|
|
20
|
+ self.patch_file_label.setReadOnly(True)
|
|
21
|
+
|
|
22
|
+ self.output_file_label = QtWidgets.QLineEdit(self)
|
|
23
|
+ self.output_file_label.setReadOnly(True)
|
|
24
|
+
|
|
25
|
+ self.base_rom_select = QtWidgets.QPushButton(self)
|
|
26
|
+ self.base_rom_select.setText("Select base rom")
|
|
27
|
+ self.base_rom_select.clicked.connect(self.selRomFile)
|
|
28
|
+
|
|
29
|
+ self.patch_file_select = QtWidgets.QPushButton(self)
|
|
30
|
+ self.patch_file_select.setText("Select IPS Patch File")
|
|
31
|
+ self.patch_file_select.clicked.connect(self.selIPSFile)
|
|
32
|
+
|
|
33
|
+ self.output_file_select = QtWidgets.QPushButton(self)
|
|
34
|
+ self.output_file_select.setText("Select output location")
|
|
35
|
+ self.output_file_select.clicked.connect(self.selSaveFile)
|
|
36
|
+
|
|
37
|
+ self.ips32_mode = QtWidgets.QCheckBox(self)
|
|
38
|
+ self.ips32_mode.setText("IPS32")
|
|
39
|
+ self.run_patch = QtWidgets.QPushButton(self)
|
|
40
|
+ self.run_patch.setText("Apply patch")
|
|
41
|
+ self.run_patch.clicked.connect(self.runPatch)
|
|
42
|
+
|
|
43
|
+ grid = QtWidgets.QGridLayout()
|
|
44
|
+ grid.addWidget(self.base_rom_label, 0, 0)
|
|
45
|
+ grid.addWidget(self.base_rom_select, 0, 1)
|
|
46
|
+ grid.addWidget(self.patch_file_label, 1, 0)
|
|
47
|
+ grid.addWidget(self.patch_file_select, 1, 1)
|
|
48
|
+ grid.addWidget(self.output_file_label, 2, 0)
|
|
49
|
+ grid.addWidget(self.output_file_select, 2, 1)
|
|
50
|
+ grid.addWidget(self.ips32_mode, 3, 0)
|
|
51
|
+ grid.addWidget(self.run_patch, 3, 1)
|
|
52
|
+
|
|
53
|
+ self.setLayout(grid)
|
|
54
|
+ self.show()
|
|
55
|
+
|
|
56
|
+ def runPatch(self):
|
|
57
|
+ patch_file = open(self.patch_file_label.text(), "rb")
|
|
58
|
+ error = perform_ips_patch(patch_file, self.base_rom_label.text(), self.output_file_label.text(), False)
|
|
59
|
+ if error == 0:
|
|
60
|
+ QtWidgets.QErrorMessage.qtHandler().showMessage("File patched successfully!")
|
|
61
|
+ elif error == -1:
|
|
62
|
+ QtWidgets.QErrorMessage.qtHandler().showMessage("Error: Invalid IPS")
|
|
63
|
+
|
|
64
|
+ def selRomFile(self):
|
|
65
|
+ fileName, _ = QtWidgets.QFileDialog.getOpenFileName(self,"Select base ROM", "","All Files (*)")
|
|
66
|
+ if fileName:
|
|
67
|
+ self.base_rom_label.setText(fileName)
|
|
68
|
+
|
|
69
|
+ def selIPSFile(self):
|
|
70
|
+ fileName, _ = QtWidgets.QFileDialog.getOpenFileName(self,"Select IPS patch", "","IPS Files (*.ips);;All Files (*)")
|
|
71
|
+ if fileName:
|
|
72
|
+ self.patch_file_label.setText(fileName)
|
|
73
|
+
|
|
74
|
+ def selSaveFile(self):
|
|
75
|
+ fileName, _ = QtWidgets.QFileDialog.getSaveFileName(self,"Select Output File Location","","All Files (*)")
|
|
76
|
+ if fileName:
|
|
77
|
+ self.output_file_label.setText(fileName)
|
|
78
|
+
|
|
79
|
+if __name__ == "__main__":
|
|
80
|
+ app = QtWidgets.QApplication(sys.argv)
|
|
81
|
+ mw = ApplicationWindow()
|
|
82
|
+ sys.exit(app.exec_())
|