This commit is contained in:
Amazed 2022-01-09 20:13:13 +01:00
parent b2358d323e
commit 33da827626

24
main.py
View File

@ -1,17 +1,13 @@
import os import os
import struct import struct
import subprocess
import sys import sys
import traceback import traceback
from pathlib import Path from pathlib import Path
import shutil import shutil
import zlib import zlib
import requests import requests
import threading
from PySide6.QtCore import QProcess from PySide6.QtCore import QProcess
from PySide6.QtWidgets import QApplication, QMainWindow, QFileDialog, QMessageBox, QTreeWidgetItem, QLayout, QLabel, \ from PySide6.QtWidgets import QApplication, QMainWindow, QFileDialog, QMessageBox, QPushButton
QLineEdit, QPushButton
from mainwindow import Ui_MainWindow from mainwindow import Ui_MainWindow
@ -21,11 +17,10 @@ class MainWindow(QMainWindow):
self.ui = Ui_MainWindow() self.ui = Ui_MainWindow()
self.ui.setupUi(self) self.ui.setupUi(self)
self.giants_path = locate_giants_folder() self.giants_path = locate_giants_folder()
if not self.giants_path:
raise Exception()
self.wdefs_path = self.giants_path / "Bin" / "wdefs.bin" self.wdefs_path = self.giants_path / "Bin" / "wdefs.bin"
self.giantsmain_path = self.giants_path / "GiantsMain.exe" self.giantsmain_path = self.giants_path / "GiantsMain.exe"
if not self.giants_path:
self.close()
self.ui.lineEdit.textEdited.connect(self.on_textedit_changed) self.ui.lineEdit.textEdited.connect(self.on_textedit_changed)
self.ui.pushButton.clicked.connect(self.on_button_clicked) self.ui.pushButton.clicked.connect(self.on_button_clicked)
@ -142,7 +137,9 @@ def ask_giants_directory() -> Path:
QMessageBox.information(None, "Wdefs", QMessageBox.information(None, "Wdefs",
"Could not locate your Giants installation automatically.\nPlease browse to your Giants folder and select GiantsMain.exe") "Could not locate your Giants installation automatically.\nPlease browse to your Giants folder and select GiantsMain.exe")
giantsmain_path, _filename = QFileDialog.getOpenFileName(None, caption="Wdefs", filter="GiantsMain.exe") giantsmain_path, _filename = QFileDialog.getOpenFileName(None, caption="Wdefs", filter="GiantsMain.exe")
return Path(giantsmain_path).parent if giantsmain_path:
return Path(giantsmain_path).parent
return None
def crc(inp_bytes: bytes) -> int: def crc(inp_bytes: bytes) -> int:
@ -169,6 +166,9 @@ def new_exe_bytes(wdefs_bytes: bytes, giantsmain_path: Path) -> bytes:
if __name__ == "__main__": if __name__ == "__main__":
app = QApplication(sys.argv) app = QApplication(sys.argv)
app.setQuitOnLastWindowClosed(True) app.setQuitOnLastWindowClosed(True)
window = MainWindow() try:
window.show() window = MainWindow()
sys.exit(app.exec()) window.show()
sys.exit(app.exec())
except:
sys.exit(1)