Improved error handling and reworded some danger strings

This commit is contained in:
Campbell 2024-04-14 13:21:40 -04:00
parent 6ad422943b
commit 1c2370b6cb
Signed by: NinjaCheetah
GPG Key ID: B547958AF96ED344
2 changed files with 30 additions and 21 deletions

View File

@ -6,7 +6,7 @@ import pathlib
import libWiiPy import libWiiPy
from PySide6.QtWidgets import QApplication, QMainWindow, QMessageBox, QTreeWidgetItem from PySide6.QtWidgets import QApplication, QMainWindow, QMessageBox, QTreeWidgetItem
from PySide6.QtCore import QRunnable, Slot, QThreadPool, Signal, QObject, Qt from PySide6.QtCore import QRunnable, Slot, QThreadPool, Signal, QObject
from qt.py.ui_MainMenu import Ui_MainWindow from qt.py.ui_MainMenu import Ui_MainWindow
@ -30,12 +30,11 @@ class Worker(QRunnable):
@Slot() @Slot()
def run(self): def run(self):
try: try:
self.fn(**self.kwargs) result = self.fn(**self.kwargs)
# TODO: Handle errors better than this
except ValueError: except ValueError:
self.signals.result.emit(1) self.signals.result.emit(1)
else: else:
self.signals.result.emit(0) self.signals.result.emit(result)
class MainWindow(QMainWindow, Ui_MainWindow): class MainWindow(QMainWindow, Ui_MainWindow):
@ -138,22 +137,29 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.threadpool.start(worker) self.threadpool.start(worker)
def check_download_result(self, result): def check_download_result(self, result):
if result == 1: msgBox = QMessageBox()
msgBox = QMessageBox() msgBox.setIcon(QMessageBox.Icon.Critical)
msgBox.setStandardButtons(QMessageBox.StandardButton.Ok)
msgBox.setDefaultButton(QMessageBox.StandardButton.Ok)
if result == -1:
msgBox.setWindowTitle("Invalid Title ID") msgBox.setWindowTitle("Invalid Title ID")
msgBox.setIcon(QMessageBox.Icon.Critical) msgBox.setText("The Title ID you have entered is not in a valid format!")
msgBox.setText("No title with the provided Title ID could be found!") msgBox.setInformativeText("Title IDs must be 16 digit strings of numbers and letters. Please enter a "
"correctly formatted Title ID, or select one from the menu on the left.")
msgBox.exec()
elif result == -2:
msgBox.setWindowTitle("Title ID/Version Not Found")
msgBox.setText("No title with the provided Title ID or version could be found!")
msgBox.setInformativeText("Please make sure that you have entered a valid Title ID or selected one from the" msgBox.setInformativeText("Please make sure that you have entered a valid Title ID or selected one from the"
" title database.") " title database, and that the provided version exists for the title you are"
msgBox.setStandardButtons(QMessageBox.StandardButton.Ok) " attempting to download.")
msgBox.setDefaultButton(QMessageBox.StandardButton.Ok)
msgBox.exec() msgBox.exec()
self.ui.download_btn.setEnabled(True) self.ui.download_btn.setEnabled(True)
def run_nus_download(self, progress_callback): def run_nus_download(self, progress_callback):
tid = self.ui.tid_entry.text() tid = self.ui.tid_entry.text()
if tid == "": if tid == "":
raise ValueError return -1
try: try:
version = int(self.ui.version_entry.text()) version = int(self.ui.version_entry.text())
except ValueError: except ValueError:
@ -171,11 +177,14 @@ class MainWindow(QMainWindow, Ui_MainWindow):
progress_callback.emit("Downloading title " + tid + " vLatest, please wait...") progress_callback.emit("Downloading title " + tid + " vLatest, please wait...")
progress_callback.emit(" - Downloading and parsing TMD...") progress_callback.emit(" - Downloading and parsing TMD...")
if version is not None: try:
title.load_tmd(libWiiPy.download_tmd(tid, version)) if version is not None:
else: title.load_tmd(libWiiPy.download_tmd(tid, version))
title.load_tmd(libWiiPy.download_tmd(tid)) else:
version = title.tmd.title_version title.load_tmd(libWiiPy.download_tmd(tid))
version = title.tmd.title_version
except ValueError:
return -2
version_dir = pathlib.Path(os.path.join(title_dir, str(version))) version_dir = pathlib.Path(os.path.join(title_dir, str(version)))
if not version_dir.is_dir(): if not version_dir.is_dir():

View File

@ -31,7 +31,7 @@
}, },
"Ticket": true, "Ticket": true,
"WAD Name": "BC-NUS", "WAD Name": "BC-NUS",
"Danger": "BC is required for the Wii's backwards compatibility with the GameCube. GameCube games will not run properly if BC is damaged or not present, and BC will need to be reinstalled." "Danger": "BC is required for the Wii's backwards compatibility with the GameCube. GameCube games will not run properly if BC is damaged or not present."
}, },
{ {
"Name": "MIOS", "Name": "MIOS",
@ -41,7 +41,7 @@
}, },
"Ticket": true, "Ticket": true,
"WAD Name": "MIOS-NUS", "WAD Name": "MIOS-NUS",
"Danger": "MIOS is required for the Wii's backwards compatibility with the GameCube. GameCube games will not run properly if MIOS is damaged or not present, and MIOS will need to be reinstalled." "Danger": "MIOS is required for the Wii's backwards compatibility with the GameCube. GameCube games will not run properly if MIOS is damaged or not present."
}, },
{ {
"Name": "EULA", "Name": "EULA",
@ -54,7 +54,7 @@
}, },
"Ticket": true, "Ticket": true,
"WAD Name": "EULA-NUS", "WAD Name": "EULA-NUS",
"Danger": "EULA is required to accept the End User License Agreement required to connect to WiiConnect24. Online services may not work correctly if EULA is damaged or not present, and EULA will need to be reinstalled." "Danger": "\"EULA\" is a hidden channel used to display the End User License Agreement that must be accepted to connect to WiiConnect24. Online services may not work correctly if this channel is damaged or not present."
}, },
{ {
"Name": "Region Select", "Name": "Region Select",
@ -67,7 +67,7 @@
}, },
"Ticket": true, "Ticket": true,
"WAD Name": "Region-Select-NUS", "WAD Name": "Region-Select-NUS",
"Danger": "Region Select during the Wii's initial setup. It is unlikely to cause functional problems after initial setup, but you will not be able to set up your console again if you factory reset it if Region Select is damaged or not present, and Region Select will need to be reinstalled." "Danger": "\"Region Select\" is a hidden channel used during the Wii's initial setup. It is unlikely to cause functional problems after setup is complete, but you will not be able to set up your console again if it is factory reset if this channel is damaged or not present, and it will need to be reinstalled."
} }
], ],
"IOS": [ "IOS": [