From ef2efbe90235596567a1544df2f086d5e1e82acd Mon Sep 17 00:00:00 2001 From: NinjaCheetah <58050615+NinjaCheetah@users.noreply.github.com> Date: Wed, 10 Apr 2024 21:17:11 -0400 Subject: [PATCH] Renamed files to make more sense, updated CI to match, also uses TARs to preserve executability --- .github/workflows/python-build.yml | 16 ++- .gitignore | 3 + main.py => NUSD-Py.py | 28 +++- qt/py/ui_MainMenu.py | 51 +++++--- qt/ui/MainMenu.ui | 201 ++++++++++++++++------------- 5 files changed, 176 insertions(+), 123 deletions(-) rename main.py => NUSD-Py.py (89%) diff --git a/.github/workflows/python-build.yml b/.github/workflows/python-build.yml index 39ecb7a..2b528f8 100644 --- a/.github/workflows/python-build.yml +++ b/.github/workflows/python-build.yml @@ -31,14 +31,15 @@ jobs: pip install -r requirements.txt - name: Build Package run: | - nuitka3 --onefile --plugin-enable=pyside6 main.py + nuitka3 --assume-yes-for-downloads --onefile --plugin-enable=pyside6 main.py - name: Prepare Package for Upload run: | - mv main.bin ~/NUSD-Py + mv NUSD-Py.bin ~/NUSD-Py + tar cvf NUSD-Py.tar NUSD-Py.bin - name: Upload Package uses: actions/upload-artifact@v4.3.0 with: - path: ~/NUSD-Py + path: ~/NUSD-Py.tar name: NUSD-Py-linux-bin build-macos: @@ -60,11 +61,12 @@ jobs: nuitka3 --assume-yes-for-downloads --onefile --plugin-enable=pyside6 main.py --macos-create-app-bundle --disable-console - name: Prepare Package for Upload run: | - mv main.app ~/NUSD-Py.app + mv NUSD-Py.app ~/NUSD-Py.app + tar cvf NUSD-Py.tar NUSD-Py.app - name: Upload Package uses: actions/upload-artifact@v4.3.0 with: - path: ~/NUSD-Py.app + path: ~/NUSD-Py.tar name: NUSD-Py-macos-bin build-windows: @@ -85,10 +87,10 @@ jobs: pip install -r requirements.txt - name: Build Package run: | - nuitka --assume-yes-for-downloads --standalone --plugin-enable=pyside6 main.py --disable-console + nuitka --assume-yes-for-downloads --onefile --plugin-enable=pyside6 main.py --disable-console - name: Upload Package uses: actions/upload-artifact@v4.3.0 with: - path: D:\a\NUSD-Py\NUSD-Py\main.dist\ + path: D:\a\NUSD-Py\NUSD-Py\NUSD-Py.exe name: NUSD-Py-windows-bin diff --git a/.gitignore b/.gitignore index 14d098e..a6ea93e 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,9 @@ share/python-wheels/ *.egg-info/ main.build/ main.dist/ +NUSD-Py.build/ +NUSD-Py.dist/ +NUSD-Py.onefile-build/ .installed.cfg *.egg MANIFEST diff --git a/main.py b/NUSD-Py.py similarity index 89% rename from main.py rename to NUSD-Py.py index 8786840..14fcc81 100644 --- a/main.py +++ b/NUSD-Py.py @@ -1,10 +1,11 @@ import sys import os +import json import pathlib import libWiiPy -from PySide6.QtWidgets import QApplication, QMainWindow, QFileDialog, QMessageBox +from PySide6.QtWidgets import QApplication, QMainWindow, QFileDialog, QMessageBox, QTreeWidgetItem, QTreeWidget from PySide6.QtCore import QRunnable, Slot, QThreadPool, Signal, QObject, Qt from qt.py.ui_MainMenu import Ui_MainWindow @@ -28,7 +29,7 @@ class Worker(QRunnable): def run(self): try: self.fn(**self.kwargs) - except ValueError: + except ValueError as e: self.signals.result.emit(1) else: self.signals.result.emit(0) @@ -44,6 +45,12 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.ui.download_btn.clicked.connect(self.download_btn_pressed) self.ui.pack_wad_chkbox.clicked.connect(self.pack_wad_chkbox_toggled) + tree = self.ui.title_tree + + for title in sys_titles: + new_title = QTreeWidgetItem(tree) + new_title.setText(0, title["Name"]) + def update_log_text(self, new_text): self.log_text += new_text + "\n" self.ui.log_text_browser.setText(self.log_text) @@ -65,12 +72,11 @@ class MainWindow(QMainWindow, Ui_MainWindow): def check_download_result(self, result): if result == 1: msgBox = QMessageBox() - msgBox.setWindowTitle("Invalid Title ID/Version") + msgBox.setWindowTitle("Invalid Title ID") msgBox.setIcon(QMessageBox.Icon.Critical) - msgBox.setTextFormat(Qt.MarkdownText) - msgBox.setText("### No title with the requested Title ID or version could be found!") - msgBox.setInformativeText("Please make sure the Title ID is entered correctly, and if a specific version is" - " set, that it exists for the chosen title.") + msgBox.setText("No title with the provided Title ID could be found!") + msgBox.setInformativeText("Please make sure that you have entered a valid Title ID or selected one from the" + " title database.") msgBox.setStandardButtons(QMessageBox.StandardButton.Ok) msgBox.setDefaultButton(QMessageBox.StandardButton.Ok) msgBox.exec() @@ -78,6 +84,8 @@ class MainWindow(QMainWindow, Ui_MainWindow): def run_nus_download(self, progress_callback): tid = self.ui.tid_entry.text() + if tid == "": + raise ValueError try: version = int(self.ui.version_entry.text()) except ValueError: @@ -173,6 +181,12 @@ class MainWindow(QMainWindow, Ui_MainWindow): if __name__ == "__main__": app = QApplication(sys.argv) + wii_database = json.load(open("wii-database.json", "r")) + sys_titles = [] + for key in wii_database["SYS"]: + sys_titles.append(key) + print(sys_titles[0]["Name"]) + out_folder = pathlib.Path("titles") if not out_folder.is_dir(): out_folder.mkdir() diff --git a/qt/py/ui_MainMenu.py b/qt/py/ui_MainMenu.py index 0d9ad63..7b83f56 100644 --- a/qt/py/ui_MainMenu.py +++ b/qt/py/ui_MainMenu.py @@ -15,22 +15,34 @@ from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor, QFont, QFontDatabase, QGradient, QIcon, QImage, QKeySequence, QLinearGradient, QPainter, QPalette, QPixmap, QRadialGradient, QTransform) -from PySide6.QtWidgets import (QApplication, QCheckBox, QHBoxLayout, QLabel, - QLineEdit, QMainWindow, QMenuBar, QPushButton, - QSizePolicy, QStatusBar, QTextBrowser, QVBoxLayout, - QWidget) +from PySide6.QtWidgets import (QApplication, QCheckBox, QHBoxLayout, QHeaderView, + QLabel, QLineEdit, QMainWindow, QMenuBar, + QPushButton, QSizePolicy, QStatusBar, QTextBrowser, + QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget) class Ui_MainWindow(object): def setupUi(self, MainWindow): if not MainWindow.objectName(): MainWindow.setObjectName(u"MainWindow") - MainWindow.resize(305, 605) - MainWindow.setMinimumSize(QSize(305, 605)) - MainWindow.setMaximumSize(QSize(305, 605)) + MainWindow.resize(610, 605) + MainWindow.setMinimumSize(QSize(610, 605)) + MainWindow.setMaximumSize(QSize(800, 605)) self.centralwidget = QWidget(MainWindow) self.centralwidget.setObjectName(u"centralwidget") - self.verticalLayout_2 = QVBoxLayout(self.centralwidget) - self.verticalLayout_2.setObjectName(u"verticalLayout_2") + self.horizontalLayout_3 = QHBoxLayout(self.centralwidget) + self.horizontalLayout_3.setObjectName(u"horizontalLayout_3") + self.title_tree = QTreeWidget(self.centralwidget) + __qtreewidgetitem = QTreeWidgetItem() + __qtreewidgetitem.setText(0, u"1"); + self.title_tree.setHeaderItem(__qtreewidgetitem) + self.title_tree.setObjectName(u"title_tree") + self.title_tree.setColumnCount(1) + self.title_tree.header().setVisible(False) + + self.horizontalLayout_3.addWidget(self.title_tree) + + self.verticalLayout_3 = QVBoxLayout() + self.verticalLayout_3.setObjectName(u"verticalLayout_3") self.horizontalLayout = QHBoxLayout() self.horizontalLayout.setObjectName(u"horizontalLayout") self.show_titles_btn = QPushButton(self.centralwidget) @@ -44,7 +56,7 @@ class Ui_MainWindow(object): self.horizontalLayout.addWidget(self.show_more_btn) - self.verticalLayout_2.addLayout(self.horizontalLayout) + self.verticalLayout_3.addLayout(self.horizontalLayout) self.horizontalLayout_2 = QHBoxLayout() self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") @@ -65,17 +77,17 @@ class Ui_MainWindow(object): self.horizontalLayout_2.addWidget(self.version_entry) - self.verticalLayout_2.addLayout(self.horizontalLayout_2) + self.verticalLayout_3.addLayout(self.horizontalLayout_2) self.download_btn = QPushButton(self.centralwidget) self.download_btn.setObjectName(u"download_btn") - self.verticalLayout_2.addWidget(self.download_btn) + self.verticalLayout_3.addWidget(self.download_btn) self.log_text_browser = QTextBrowser(self.centralwidget) self.log_text_browser.setObjectName(u"log_text_browser") - self.verticalLayout_2.addWidget(self.log_text_browser) + self.verticalLayout_3.addWidget(self.log_text_browser) self.horizontalLayout_4 = QHBoxLayout() self.horizontalLayout_4.setObjectName(u"horizontalLayout_4") @@ -91,29 +103,32 @@ class Ui_MainWindow(object): self.horizontalLayout_4.addWidget(self.wad_file_entry) - self.verticalLayout_2.addLayout(self.horizontalLayout_4) + self.verticalLayout_3.addLayout(self.horizontalLayout_4) self.keep_enc_chkbox = QCheckBox(self.centralwidget) self.keep_enc_chkbox.setObjectName(u"keep_enc_chkbox") self.keep_enc_chkbox.setChecked(True) - self.verticalLayout_2.addWidget(self.keep_enc_chkbox) + self.verticalLayout_3.addWidget(self.keep_enc_chkbox) self.create_dec_chkbox = QCheckBox(self.centralwidget) self.create_dec_chkbox.setObjectName(u"create_dec_chkbox") - self.verticalLayout_2.addWidget(self.create_dec_chkbox) + self.verticalLayout_3.addWidget(self.create_dec_chkbox) self.use_local_chkbox = QCheckBox(self.centralwidget) self.use_local_chkbox.setObjectName(u"use_local_chkbox") self.use_local_chkbox.setEnabled(False) - self.verticalLayout_2.addWidget(self.use_local_chkbox) + self.verticalLayout_3.addWidget(self.use_local_chkbox) + + + self.horizontalLayout_3.addLayout(self.verticalLayout_3) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QMenuBar(MainWindow) self.menubar.setObjectName(u"menubar") - self.menubar.setGeometry(QRect(0, 0, 305, 30)) + self.menubar.setGeometry(QRect(0, 0, 610, 30)) MainWindow.setMenuBar(self.menubar) self.statusbar = QStatusBar(MainWindow) self.statusbar.setObjectName(u"statusbar") diff --git a/qt/ui/MainMenu.ui b/qt/ui/MainMenu.ui index 3ffda20..4904e8d 100644 --- a/qt/ui/MainMenu.ui +++ b/qt/ui/MainMenu.ui @@ -6,19 +6,19 @@ 0 0 - 305 + 610 605 - 305 + 610 605 - 305 + 800 605 @@ -26,121 +26,140 @@ MainWindow - + - - - - - Titles - - - - - - - More - - - - + + + 1 + + + false + + + + 1 + + + - + - + + + + + Titles + + + + + + + More + + + + + + + + + + + + + + Title ID + + + + + + + v + + + + + + + + 75 + 16777215 + + + + Version + + + + + + + + Start NUS Download! + + + + + + - - Title ID - - + + + + + Pack WAD + + + + + + + false + + + File Name + + + + + + + - v + Keep Enc. Contents + + + true - - - - 75 - 16777215 - - - - Version - - - - - - - - - Start NUS Download! - - - - - - - - - - - - - - + - Pack WAD + Create Decrypted Contents (*.app) - + false - - File Name + + Use Local Files If They Exist - - - - Keep Enc. Contents - - - true - - - - - - - Create Decrypted Contents (*.app) - - - - - - - false - - - Use Local Files If They Exist - - - @@ -148,7 +167,7 @@ 0 0 - 305 + 610 30