12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- #!/usr/bin/env python3
-
- from ips import perform_ips_patch
- from PyQt5 import QtCore, QtGui, QtWidgets
-
- import sys
-
- class ApplicationWindow(QtWidgets.QWidget):
- def __init__(self):
- super().__init__()
- self.initUI()
-
- def initUI(self):
- self.setWindowTitle("OpenIPS Patcher")
-
- self.base_rom_label = QtWidgets.QLineEdit(self)
- self.base_rom_label.setReadOnly(True)
-
- self.patch_file_label = QtWidgets.QLineEdit(self)
- self.patch_file_label.setReadOnly(True)
-
- self.output_file_label = QtWidgets.QLineEdit(self)
- self.output_file_label.setReadOnly(True)
-
- self.base_rom_select = QtWidgets.QPushButton(self)
- self.base_rom_select.setText("Select base rom")
- self.base_rom_select.clicked.connect(self.selRomFile)
-
- self.patch_file_select = QtWidgets.QPushButton(self)
- self.patch_file_select.setText("Select IPS Patch File")
- self.patch_file_select.clicked.connect(self.selIPSFile)
-
- self.output_file_select = QtWidgets.QPushButton(self)
- self.output_file_select.setText("Select output location")
- self.output_file_select.clicked.connect(self.selSaveFile)
-
- self.ips32_mode = QtWidgets.QCheckBox(self)
- self.ips32_mode.setText("IPS32")
- self.run_patch = QtWidgets.QPushButton(self)
- self.run_patch.setText("Apply patch")
- self.run_patch.clicked.connect(self.runPatch)
-
- grid = QtWidgets.QGridLayout()
- grid.addWidget(self.base_rom_label, 0, 0)
- grid.addWidget(self.base_rom_select, 0, 1)
- grid.addWidget(self.patch_file_label, 1, 0)
- grid.addWidget(self.patch_file_select, 1, 1)
- grid.addWidget(self.output_file_label, 2, 0)
- grid.addWidget(self.output_file_select, 2, 1)
- grid.addWidget(self.ips32_mode, 3, 0)
- grid.addWidget(self.run_patch, 3, 1)
-
- self.setLayout(grid)
- self.show()
-
- def runPatch(self):
- patch_file = open(self.patch_file_label.text(), "rb")
- error = perform_ips_patch(patch_file, self.base_rom_label.text(), self.output_file_label.text(), False)
- if error == 0:
- QtWidgets.QErrorMessage.qtHandler().showMessage("File patched successfully!")
- elif error == -1:
- QtWidgets.QErrorMessage.qtHandler().showMessage("Error: Invalid IPS")
-
- def selRomFile(self):
- fileName, _ = QtWidgets.QFileDialog.getOpenFileName(self,"Select base ROM", "","All Files (*)")
- if fileName:
- self.base_rom_label.setText(fileName)
-
- def selIPSFile(self):
- fileName, _ = QtWidgets.QFileDialog.getOpenFileName(self,"Select IPS patch", "","IPS Files (*.ips);;All Files (*)")
- if fileName:
- self.patch_file_label.setText(fileName)
-
- def selSaveFile(self):
- fileName, _ = QtWidgets.QFileDialog.getSaveFileName(self,"Select Output File Location","","All Files (*)")
- if fileName:
- self.output_file_label.setText(fileName)
-
- if __name__ == "__main__":
- app = QtWidgets.QApplication(sys.argv)
- mw = ApplicationWindow()
- sys.exit(app.exec_())
|