From f078e062874a33cf2640311e1987dad7dcc0defc Mon Sep 17 00:00:00 2001 From: R-YaTian <47445484+R-YaTian@users.noreply.github.com> Date: Sun, 26 May 2024 20:11:26 +0800 Subject: [PATCH 1/6] Create maven.yml --- .github/workflows/maven.yml | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/maven.yml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 0000000..83e8819 --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,38 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Java CI with Maven + +on: + push: + branches: [ "workflow" ] + pull_request: + branches: [ "workflow" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + cache: maven + - name: Build with Maven + run: mvn -B -DskipTests clean package --file pom.xml + + - name: Upload a Build Artifact + uses: actions/upload-artifact@v4.3.3 + with: + name: package + path: ns-usbloader.jar + From 2480c0fbc19ef09f4d69dffa6cb26dd924b57710 Mon Sep 17 00:00:00 2001 From: R-YaTian <47445484+R-YaTian@users.noreply.github.com> Date: Sun, 26 May 2024 20:17:33 +0800 Subject: [PATCH 2/6] Update maven.yml --- .github/workflows/maven.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 83e8819..5b01586 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -31,8 +31,7 @@ jobs: run: mvn -B -DskipTests clean package --file pom.xml - name: Upload a Build Artifact - uses: actions/upload-artifact@v4.3.3 + uses: actions/upload-artifact@master with: name: package - path: ns-usbloader.jar - + path: targets/*.jar From e3b0e1283be5a2191a375a188d7199262f499da7 Mon Sep 17 00:00:00 2001 From: R-YaTian <47445484+R-YaTian@users.noreply.github.com> Date: Sun, 26 May 2024 20:25:33 +0800 Subject: [PATCH 3/6] Update maven.yml --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 5b01586..102c178 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -34,4 +34,4 @@ jobs: uses: actions/upload-artifact@master with: name: package - path: targets/*.jar + path: target/*.jar From aedaa22c5e47be240787761b4fa44e9a99fb2858 Mon Sep 17 00:00:00 2001 From: R-YaTian Date: Sun, 26 May 2024 21:00:12 +0800 Subject: [PATCH 4/6] feat: Add (de)selectAll options for contextMenu --- .github/workflows/maven.yml | 4 ++-- .gitignore | 3 ++- .../nsusbloader/Controllers/NSLRowModel.java | 17 ++++++++++------- .../Controllers/NSTableViewController.java | 14 +++++++++++++- src/main/resources/locale.properties | 6 ++++++ src/main/resources/locale_zh_CN.properties | 6 ++++++ 6 files changed, 39 insertions(+), 11 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 102c178..a06f84e 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -20,9 +20,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@master - name: Set up JDK 17 - uses: actions/setup-java@v3 + uses: actions/setup-java@master with: java-version: '17' distribution: 'temurin' diff --git a/.gitignore b/.gitignore index 92b14c1..7287d82 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ offsets.txt -environment.txt \ No newline at end of file +environment.txt +/target diff --git a/src/main/java/nsusbloader/Controllers/NSLRowModel.java b/src/main/java/nsusbloader/Controllers/NSLRowModel.java index e96fe6f..0e18e26 100644 --- a/src/main/java/nsusbloader/Controllers/NSLRowModel.java +++ b/src/main/java/nsusbloader/Controllers/NSLRowModel.java @@ -18,13 +18,16 @@ */ package nsusbloader.Controllers; +import nsusbloader.AppPreferences; import nsusbloader.NSLDataTypes.EFileStatus; import java.io.File; -import java.io.FilenameFilter; +import java.util.Locale; +import java.util.ResourceBundle; public class NSLRowModel { - + private Locale userLocale = AppPreferences.getInstance().getLocale(); + private ResourceBundle rb = ResourceBundle.getBundle("locale", userLocale); private String status; private File nspFile; private String nspFileName; @@ -65,23 +68,23 @@ public class NSLRowModel { markForUpload = value; } public File getNspFile(){ return nspFile; } - public void setStatus(EFileStatus status){ // TODO: Localization + public void setStatus(EFileStatus status){ switch (status){ case UPLOADED: - this.status = "Success"; + this.status = rb.getString("tab1_table_Lbl_Success"); markForUpload = false; break; case FAILED: - this.status = "Failed"; + this.status = rb.getString("tab1_table_Lbl_Failed"); break; case INDETERMINATE: this.status = "..."; break; case UNKNOWN: - this.status = "Unknown"; + this.status = rb.getString("tab1_table_Lbl_Unknown"); break; case INCORRECT_FILE_FAILED: - this.status = "Failed: Bad file"; + this.status = rb.getString("tab1_table_Lbl_BadFile"); markForUpload = false; break; } diff --git a/src/main/java/nsusbloader/Controllers/NSTableViewController.java b/src/main/java/nsusbloader/Controllers/NSTableViewController.java index 267da43..ff3c246 100644 --- a/src/main/java/nsusbloader/Controllers/NSTableViewController.java +++ b/src/main/java/nsusbloader/Controllers/NSTableViewController.java @@ -182,7 +182,19 @@ public class NSTableViewController implements Initializable { MediatorControl.getInstance().getGamesController().disableUploadStopBtn(true); // TODO: change to something better table.refresh(); }); - contextMenu.getItems().addAll(deleteMenuItem, deleteAllMenuItem); + MenuItem selectAllMenuItem = new MenuItem(resourceBundle.getString("tab1_table_contextMenu_Btn_SelectAll")); + selectAllMenuItem.setOnAction(actionEvent -> { + for (NSLRowModel model : rowsObsLst) + model.setMarkForUpload(true); + table.refresh(); + }); + MenuItem deselectAllMenuItem = new MenuItem(resourceBundle.getString("tab1_table_contextMenu_Btn_DeselectAll")); + deselectAllMenuItem.setOnAction(actionEvent -> { + for (NSLRowModel model : rowsObsLst) + model.setMarkForUpload(false); + table.refresh(); + }); + contextMenu.getItems().addAll(deleteMenuItem, deleteAllMenuItem, selectAllMenuItem, deselectAllMenuItem); row.setContextMenu(contextMenu); row.contextMenuProperty().bind( diff --git a/src/main/resources/locale.properties b/src/main/resources/locale.properties index 9622dfe..440401e 100644 --- a/src/main/resources/locale.properties +++ b/src/main/resources/locale.properties @@ -19,8 +19,14 @@ tab1_table_Lbl_Status=Status tab1_table_Lbl_FileName=File name tab1_table_Lbl_Size=Size tab1_table_Lbl_Upload=Upload? +tab1_table_Lbl_Success=Success +tab1_table_Lbl_Failed=Failed +tab1_table_Lbl_Unknown=Unknown +tab1_table_Lbl_BadFile=Failed: Bad file tab1_table_contextMenu_Btn_BtnDelete=Remove tab1_table_contextMenu_Btn_DeleteAll=Remove all +tab1_table_contextMenu_Btn_SelectAll=Select all +tab1_table_contextMenu_Btn_DeselectAll=Deselect all tab2_Lbl_HostIP=Host IP tab1_Lbl_NSIP=NS IP: tab2_Cb_ValidateNSHostName=Always validate NS IP input. diff --git a/src/main/resources/locale_zh_CN.properties b/src/main/resources/locale_zh_CN.properties index d428871..59f8b3b 100644 --- a/src/main/resources/locale_zh_CN.properties +++ b/src/main/resources/locale_zh_CN.properties @@ -19,8 +19,14 @@ tab1_table_Lbl_Status=\u72B6\u6001 tab1_table_Lbl_FileName=\u6587\u4EF6\u540D tab1_table_Lbl_Size=\u5927\u5C0F tab1_table_Lbl_Upload=\u4E0A\u4F20? +tab1_table_Lbl_Success=\u6210\u529F +tab1_table_Lbl_Failed=\u5931\u8D25 +tab1_table_Lbl_Unknown=\u672A\u77E5 +tab1_table_Lbl_BadFile=\u5931\u8D25: \u6587\u4EF6\u5F02\u5E38 tab1_table_contextMenu_Btn_BtnDelete=\u79FB\u9664 tab1_table_contextMenu_Btn_DeleteAll=\u79FB\u9664\u6240\u6709 +tab1_table_contextMenu_Btn_SelectAll=\u9009\u62E9\u5168\u90E8 +tab1_table_contextMenu_Btn_DeselectAll=\u53CD\u9009\u5168\u90E8 tab2_Lbl_HostIP=Host IP tab1_Lbl_NSIP=NS IP: tab2_Cb_ValidateNSHostName=\u603B\u662F\u9A8C\u8BC1 NS IP \u8F93\u5165\u3002 From fd449181f968d2fae313c9f4755a555166b4681b Mon Sep 17 00:00:00 2001 From: R-YaTian <47445484+R-YaTian@users.noreply.github.com> Date: Mon, 23 Dec 2024 09:36:24 +0800 Subject: [PATCH 5/6] Merge with master (#1) --- .woodpecker/woodpecker.yml | 82 +++++++++ README.md | 14 +- misc/windows/NSIS/installer.nsi | 4 +- pom.xml | 2 +- .../Controllers/FilesDropHandle.java | 11 +- .../Controllers/FilesDropHandleTask.java | 8 +- .../Controllers/FontSettingsController.java | 6 +- .../Controllers/GamesController.java | 173 +++++++++--------- .../nsusbloader/Controllers/ISubscriber.java | 25 +++ .../Controllers/NSLMainController.java | 58 ++---- .../Controllers/NSTableViewController.java | 23 ++- .../Controllers/NxdtController.java | 29 ++- .../Controllers/PatchesController.java | 26 +-- .../java/nsusbloader/Controllers/Payload.java | 48 +++++ .../Controllers/RcmController.java | 45 ++--- .../SettingsBlockGenericController.java | 11 +- .../Controllers/SplitMergeController.java | 164 ++++++++--------- .../java/nsusbloader/MediatorControl.java | 77 ++++---- .../ModelControllers/LogPrinterGui.java | 10 +- .../ModelControllers/MessagesConsumer.java | 52 ++---- src/main/java/nsusbloader/NSLMain.java | 7 +- .../java/nsusbloader/TransfersPublisher.java | 47 +++++ .../nsusbloader/com/usb/GoldLeaf_010.java | 4 +- .../java/nsusbloader/com/usb/GoldLeaf_07.java | 4 +- .../java/nsusbloader/com/usb/GoldLeaf_08.java | 4 +- .../java/nsusbloader/com/usb/UsbConnect.java | 2 +- src/main/resources/locale_ko_KR.properties | 4 + src/main/resources/locale_zh_CN.properties | 16 ++ .../java/integration/EsIntegrationTest.java | 2 +- .../java/integration/FsIntegrationTest.java | 2 +- 30 files changed, 570 insertions(+), 390 deletions(-) create mode 100644 .woodpecker/woodpecker.yml create mode 100644 src/main/java/nsusbloader/Controllers/ISubscriber.java create mode 100644 src/main/java/nsusbloader/Controllers/Payload.java create mode 100644 src/main/java/nsusbloader/TransfersPublisher.java diff --git a/.woodpecker/woodpecker.yml b/.woodpecker/woodpecker.yml new file mode 100644 index 0000000..11eea07 --- /dev/null +++ b/.woodpecker/woodpecker.yml @@ -0,0 +1,82 @@ +steps: + - name: test-standard + when: + event: [tag, push] + image: maven:3-openjdk-17 + commands: + - mvn -B -DskipTests clean package + - mvn test -B + - echo target/ns-usbloader-*jar + - mkdir artifacts + - cp target/ns-usbloader-*jar artifacts + volumes: + - /home/docker/woodpecker/files/m2:/root/.m2 + + - name: make-windows-installer + when: + event: [tag, push] + image: wheatstalk/makensis:3 + commands: + - cp target/NS-USBloader.exe misc/windows/NSIS/ + - misc/windows/update_version.sh + - cd misc/windows/NSIS + - makensis -V4 ./installer.nsi + - echo Installer-*.exe + - cp Installer-*.exe "../../../artifacts" + - rm ./NS-USBloader.exe + - rm ./Installer-*.exe + - cd ../../../ + volumes: + - /home/docker/woodpecker/files/assembly/openjdk-19.0.2:/assembly/jdk + - /home/docker/woodpecker/files/assembly/Drivers_set.exe:/assembly/Drivers_set.exe + + - name: emerge-legacy-artifact + when: + event: [tag, push] + image: maven:3-openjdk-17 + commands: + - . ./.make_legacy + - mvn -B -DskipTests clean package + - echo target/ns-usbloader-*jar + - cp target/ns-usbloader-*jar artifacts + volumes: + - /home/docker/woodpecker/files/m2:/root/.m2 + + - name: make-legacy-windows-installer + when: + event: [tag, push] + image: wheatstalk/makensis:3 + commands: + - cp target/NS-USBloader.exe misc/windows/NSIS/ + - misc/windows/update_version.sh legacy + - cd misc/windows/NSIS + - makensis -V4 ./installer.nsi + - echo Installer-*.exe + - cp Installer-*.exe "../../../artifacts" + - cd ../../../ + volumes: + - /home/docker/woodpecker/files/assembly/openjdk-19.0.2:/assembly/jdk + - /home/docker/woodpecker/files/assembly/Drivers_set.exe:/assembly/Drivers_set.exe + + - name: emerge-mac-m1-artifact + when: + event: [tag, push] + image: maven:3-openjdk-17 + commands: + - . ./.make_m1 + - mvn -B -DskipTests clean package + - echo target/ns-usbloader-*jar + - cp target/ns-usbloader-*jar artifacts + volumes: + - /home/docker/woodpecker/files/m2:/root/.m2 + + - name: save-artifacts + when: + event: [tag, push] + image: alpine:latest + commands: + - export ARTIFACTS_DIR="$(date -d @$CI_PIPELINE_CREATED +'%Y-%m-%d %H:%m %Z')" + - mkdir -p /builds/ns-usbloader/ + - mv artifacts "/builds/ns-usbloader/$ARTIFACTS_DIR" + volumes: + - /home/www/builds:/builds \ No newline at end of file diff --git a/README.md b/README.md index d01cd88..91f8aa2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

NS-USBloader

-![License](https://img.shields.io/badge/License-GPLv3-blue.svg) ![Releases](https://img.shields.io/github/downloads/developersu/ns-usbloader/total.svg) ![LatestVer](https://img.shields.io/github/release/developersu/ns-usbloader.svg) [![Build Status](https://ci.redrise.ru/api/badges/desu/ns-usbloader/status.svg)](https://ci.redrise.ru/desu/ns-usbloader) +![License](https://img.shields.io/badge/License-GPLv3-blue.svg) ![Releases](https://img.shields.io/github/downloads/developersu/ns-usbloader/total.svg) ![LatestVer](https://img.shields.io/github/release/developersu/ns-usbloader.svg) [![status-badge](https://ci.redrise.ru/api/badges/12/status.svg)](https://ci.redrise.ru/repos/12) NS-USBloader is: * A PC-side installer for **[Huntereb/Awoo-Installer](https://github.com/Huntereb/Awoo-Installer)** / other compatible installers (USB and Network supported) and **[XorTroll/Goldleaf](https://github.com/XorTroll/Goldleaf)** (USB) NSP installer. @@ -59,6 +59,7 @@ Sometimes I add new posts about this project [on my blog page](https://developer * Swedish by [Daniel Nylander](https://github.com/yeager) * Japanese by [kuragehime](https://github.com/kuragehimekurara1) * Ryukyuan languages by [kuragehime](https://github.com/kuragehimekurara1) +* Turkish language by [Erimsaholut](https://github.com/Erimsaholut) * Angelo Elias Dalzotto makes packages in AUR * Phoenix[Msc] provides his shiny Mac M1 for debug @@ -256,17 +257,6 @@ If you like this app, just give a star (@ GitHub). This is non-commercial project. -Nevertheless, I'll be more than happy if you find a chance to make a donation for charity to people I trust: - -* BTC → 1BnErE3n6LEdEjvvFrt4FMdXd1UGa5L7Ge -* ETH → 0x9c29418129553bE171181bb6245151aa0576A3b7 -* DOT → 15BWSwmA4xEHZdq3gGftWg7dctMQk9vXwqA92Pg22gsxDweF -* LTC → ltc1qfjvzxm04tax077ra9rvmxdnsum8alws2n20fag -* ETC → 0xe9064De288C8454942533a005AB72515e689226E -* USDT (TRC20) → TKgp5SvJGiqYNFtvJfEDGLFbezFEHq1tBy -* USDT (ERC20) → 0x9c29418129553bE171181bb6245151aa0576A3b7 -* XRP → rGmGaLsKmSUbxWfyi4mujtVamTzj3Nqxbw. - Thanks! Appreciate assistance and support of both [Vitaliy](https://github.com/SebastianUA) and [Konstantin](https://github.com/konstantin-kelemen). Without you all this magic would not have happened. diff --git a/misc/windows/NSIS/installer.nsi b/misc/windows/NSIS/installer.nsi index 4351b11..67c1073 100644 --- a/misc/windows/NSIS/installer.nsi +++ b/misc/windows/NSIS/installer.nsi @@ -91,8 +91,8 @@ Section "NS-USBloader" Install SetOutPath "$INSTDIR" - file /r jdk - file Drivers_set.exe + file /r \assembly\jdk + file \assembly\Drivers_set.exe file NS-USBloader.exe file logo.ico diff --git a/pom.xml b/pom.xml index 163c17c..82ee300 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ NS-USBloader ns-usbloader - 7.1 + 7.2 https://redrise.ru NS multi-tool diff --git a/src/main/java/nsusbloader/Controllers/FilesDropHandle.java b/src/main/java/nsusbloader/Controllers/FilesDropHandle.java index 29f4482..d2042cc 100644 --- a/src/main/java/nsusbloader/Controllers/FilesDropHandle.java +++ b/src/main/java/nsusbloader/Controllers/FilesDropHandle.java @@ -1,5 +1,5 @@ /* - Copyright 2019-2020 Dmitry Isaenko + Copyright 2019-2024 Dmitry Isaenko This file is part of NS-USBloader. @@ -39,10 +39,13 @@ import java.util.ResourceBundle; public class FilesDropHandle { - public FilesDropHandle(List files, String filesRegex, String foldersRegex){ + public FilesDropHandle(List files, + String filesRegex, + String foldersRegex, + NSTableViewController tableController){ FilesDropHandleTask filesDropHandleTask = new FilesDropHandleTask(files, filesRegex, foldersRegex); - ResourceBundle resourceBundle = MediatorControl.getInstance().getResourceBundle(); + ResourceBundle resourceBundle = MediatorControl.INSTANCE.getResourceBundle(); Button cancelButton = new Button(resourceBundle.getString("btn_Cancel")); ProgressIndicator progressIndicator = new ProgressIndicator(); @@ -101,7 +104,7 @@ public class FilesDropHandle { List allFiles = filesDropHandleTask.getValue(); if (! allFiles.isEmpty()) { - MediatorControl.getInstance().getGamesController().tableFilesListController.setFiles(allFiles); + tableController.setFiles(allFiles); } stage.close(); }); diff --git a/src/main/java/nsusbloader/Controllers/FilesDropHandleTask.java b/src/main/java/nsusbloader/Controllers/FilesDropHandleTask.java index 93bc8ad..598bc41 100644 --- a/src/main/java/nsusbloader/Controllers/FilesDropHandleTask.java +++ b/src/main/java/nsusbloader/Controllers/FilesDropHandleTask.java @@ -1,5 +1,5 @@ /* - Copyright 2019-2020 Dmitry Isaenko + Copyright 2019-2024 Dmitry Isaenko This file is part of NS-USBloader. @@ -32,7 +32,7 @@ public class FilesDropHandleTask extends Task> { private final List filesDropped; private final List allFiles; - private String messageTemplate; + private final String messageTemplate; private long filesScanned = 0; private long filesAdded = 0; @@ -43,12 +43,12 @@ public class FilesDropHandleTask extends Task> { this.filesRegex = filesRegex; this.foldersRegex = foldersRegex; this.allFiles = new ArrayList<>(); - this.messageTemplate = MediatorControl.getInstance().getResourceBundle().getString("windowBodyFilesScanned"); + this.messageTemplate = MediatorControl.INSTANCE.getResourceBundle().getString("windowBodyFilesScanned"); } @Override protected List call() { - if (filesDropped == null || filesDropped.size() == 0) + if (filesDropped == null || filesDropped.isEmpty()) return allFiles; for (File file : filesDropped){ diff --git a/src/main/java/nsusbloader/Controllers/FontSettingsController.java b/src/main/java/nsusbloader/Controllers/FontSettingsController.java index 0f7f14c..98c20a6 100644 --- a/src/main/java/nsusbloader/Controllers/FontSettingsController.java +++ b/src/main/java/nsusbloader/Controllers/FontSettingsController.java @@ -1,5 +1,5 @@ /* - Copyright 2019-2023 Dmitry Isaenko + Copyright 2019-2024 Dmitry Isaenko This file is part of NS-USBloader. @@ -142,7 +142,9 @@ public class FontSettingsController implements Initializable { final double fontSize = fontSizeSpinner.getValue().intValue(); preferences.setFontStyle(fontFamily, fontSize); - MediatorControl.getInstance().updateApplicationFont(fontFamily, fontSize); + + MediatorControl.INSTANCE.getLogArea().getScene().getRoot().setStyle( + String.format("-fx-font-family: \"%s\"; -fx-font-size: %.0f;", fontFamily, fontSize)); closeWindow(); } diff --git a/src/main/java/nsusbloader/Controllers/GamesController.java b/src/main/java/nsusbloader/Controllers/GamesController.java index 3c78b99..364cb08 100644 --- a/src/main/java/nsusbloader/Controllers/GamesController.java +++ b/src/main/java/nsusbloader/Controllers/GamesController.java @@ -1,5 +1,5 @@ /* - Copyright 2019-2020 Dmitry Isaenko, wolfposd + Copyright 2019-2024 Dmitry Isaenko, wolfposd This file is part of NS-USBloader. @@ -31,6 +31,7 @@ import javafx.scene.layout.Region; import javafx.stage.DirectoryChooser; import javafx.stage.FileChooser; import nsusbloader.AppPreferences; +import nsusbloader.NSLDataTypes.EFileStatus; import nsusbloader.com.net.NETCommunications; import nsusbloader.com.usb.UsbCommunications; import nsusbloader.FilesHelper; @@ -45,12 +46,14 @@ import java.util.*; import java.util.function.Consumer; import java.util.function.Supplier; -public class GamesController implements Initializable { +public class GamesController implements Initializable, ISubscriber { private static final String REGEX_ONLY_NSP = ".*\\.nsp$"; private static final String REGEX_ALLFILES_TINFOIL = ".*\\.(nsp$|xci$|nsz$|xcz$)"; private static final String REGEX_ALLFILES = ".*"; + private static final MediatorControl mediator = MediatorControl.INSTANCE; + @FXML private AnchorPane usbNetPane; @@ -63,7 +66,7 @@ public class GamesController implements Initializable { @FXML private Button switchThemeBtn; @FXML - public NSTableViewController tableFilesListController; // Accessible from Mediator (for drag-n-drop support) + private NSTableViewController tableFilesListController; @FXML private Button selectNspBtn, selectSplitBtn, uploadStopBtn; @@ -101,6 +104,7 @@ public class GamesController implements Initializable { disableUploadStopBtn(tableFilesListController.isFilesForUploadListEmpty()); }); // Add listener to notify tableView controller tableFilesListController.setNewProtocol(getSelectedProtocolByName()); // Notify tableView controller + tableFilesListController.setGamesController(this); ObservableList choiceNetUsbList = FXCollections.observableArrayList("USB", "NET"); choiceNetUsb.setItems(choiceNetUsbList); @@ -204,11 +208,11 @@ public class GamesController implements Initializable { } private boolean isAllFiletypesAllowedForGL() { - return ! MediatorControl.getInstance().getSettingsController().getGoldleafSettings().getNSPFileFilterForGL(); + return ! mediator.getSettingsController().getGoldleafSettings().getNSPFileFilterForGL(); } private boolean isXciNszXczSupport() { - return MediatorControl.getInstance().getSettingsController().getTinfoilSettings().isXciNszXczSupport(); + return mediator.getSettingsController().getTinfoilSettings().isXciNszXczSupport(); } /** @@ -216,7 +220,7 @@ public class GamesController implements Initializable { * tinfoil + xcinszxcz
* tinfoil + nsponly
* goldleaf
- * etc.. + * etc... */ private String getRegexForFiles() { if (isTinfoil() && isXciNszXczSupport()) @@ -368,56 +372,58 @@ public class GamesController implements Initializable { if (workThread != null && workThread.isAlive()) return; - // Collect files - List nspToUpload; - - TextArea logArea = MediatorControl.getInstance().getContoller().logArea; - if (isTinfoil() && tableFilesListController.getFilesForUpload() == null) { - logArea.setText(resourceBundle.getString("tab3_Txt_NoFolderOrFileSelected")); + ServiceWindow.getInfoNotification("(o_o\")", resourceBundle.getString("tab3_Txt_NoFolderOrFileSelected")); return; } - if ((nspToUpload = tableFilesListController.getFilesForUpload()) != null){ + // Collect files + List nspToUpload = tableFilesListController.getFilesForUpload(); + + if (nspToUpload == null) + nspToUpload = new ArrayList<>(); + //todo: add to make it visible + /* + else { + TextArea logArea = mediator.getLogArea(); logArea.setText(resourceBundle.getString("tab3_Txt_FilesToUploadTitle")+"\n"); nspToUpload.forEach(item -> logArea.appendText(" "+item.getAbsolutePath()+"\n")); } - else { - logArea.clear(); - nspToUpload = new LinkedList<>(); - } + */ - SettingsController settings = MediatorControl.getInstance().getSettingsController(); + SettingsController settings = mediator.getSettingsController(); // If USB selected if (isGoldLeaf()){ final SettingsBlockGoldleafController goldleafSettings = settings.getGoldleafSettings(); usbNetCommunications = new UsbCommunications(nspToUpload, "GoldLeaf" + goldleafSettings.getGlVer(), goldleafSettings.getNSPFileFilterForGL()); } - else if (( isTinfoil() && getSelectedNetUsb().equals("USB") )){ - usbNetCommunications = new UsbCommunications(nspToUpload, "TinFoil", false); - } - else { // NET INSTALL OVER TINFOIL - final String ipValidationPattern = "^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])$"; - final SettingsBlockTinfoilController tinfoilSettings = settings.getTinfoilSettings(); - - if (tinfoilSettings.isValidateNSHostName() && ! getNsIp().matches(ipValidationPattern)) { - if (!ServiceWindow.getConfirmationWindow(resourceBundle.getString("windowTitleBadIp"), resourceBundle.getString("windowBodyBadIp"))) - return; + else { + if (getSelectedNetUsb().equals("USB")){ + usbNetCommunications = new UsbCommunications(nspToUpload, "TinFoil", false); } + else { // NET INSTALL OVER TINFOIL + final String ipValidationPattern = "^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])$"; + final SettingsBlockTinfoilController tinfoilSettings = settings.getTinfoilSettings(); - String nsIP = getNsIp(); + if (tinfoilSettings.isValidateNSHostName() && ! getNsIp().matches(ipValidationPattern)) { + if (!ServiceWindow.getConfirmationWindow(resourceBundle.getString("windowTitleBadIp"), resourceBundle.getString("windowBodyBadIp"))) + return; + } - if (! tinfoilSettings.isExpertModeSelected()) - usbNetCommunications = new NETCommunications(nspToUpload, nsIP, false, "", "", ""); - else { - usbNetCommunications = new NETCommunications( - nspToUpload, - nsIP, - tinfoilSettings.isNoRequestsServe(), - tinfoilSettings.isAutoDetectIp()?"":tinfoilSettings.getHostIp(), - tinfoilSettings.isRandomlySelectPort()?"":tinfoilSettings.getHostPort(), - tinfoilSettings.isNoRequestsServe()?tinfoilSettings.getHostExtra():"" - ); + String nsIP = getNsIp(); + + if (! tinfoilSettings.isExpertModeSelected()) + usbNetCommunications = new NETCommunications(nspToUpload, nsIP, false, "", "", ""); + else { + usbNetCommunications = new NETCommunications( + nspToUpload, + nsIP, + tinfoilSettings.isNoRequestsServe(), + tinfoilSettings.isAutoDetectIp()?"":tinfoilSettings.getHostIp(), + tinfoilSettings.isRandomlySelectPort()?"":tinfoilSettings.getHostPort(), + tinfoilSettings.isNoRequestsServe()?tinfoilSettings.getHostExtra():"" + ); + } } } workThread = new Thread(usbNetCommunications); @@ -446,7 +452,7 @@ public class GamesController implements Initializable { * */ @FXML private void handleDragOver(DragEvent event){ - if (event.getDragboard().hasFiles() && ! MediatorControl.getInstance().getTransferActive()) + if (event.getDragboard().hasFiles() && ! mediator.getTransferActive()) event.acceptTransferModes(TransferMode.ANY); event.consume(); } @@ -456,47 +462,15 @@ public class GamesController implements Initializable { @FXML private void handleDrop(DragEvent event) { List files = event.getDragboard().getFiles(); - new FilesDropHandle(files, getRegexForFiles(), getRegexForFolders()); + new FilesDropHandle(files, getRegexForFiles(), getRegexForFolders(), tableFilesListController); event.setDropCompleted(true); event.consume(); } - + /** - * This thing modify UI for reusing 'Upload to NS' button and make functionality set for "Stop transmission" - * Called from mediator - * TODO: remove shitcoding practices + * This function called from NSTableViewController * */ - public void notifyThreadStarted(boolean isActive, EModule type){ - if (! type.equals(EModule.USB_NET_TRANSFERS)){ - usbNetPane.setDisable(isActive); - return; - } - - selectNspBtn.setDisable(isActive); - selectSplitBtn.setDisable(isActive); - btnUpStopImage.getStyleClass().clear(); - - if (isActive) { - btnUpStopImage.getStyleClass().add("regionStop"); - - uploadStopBtn.setOnAction(e-> stopBtnAction()); - uploadStopBtn.setText(resourceBundle.getString("btn_Stop")); - uploadStopBtn.getStyleClass().remove("buttonUp"); - uploadStopBtn.getStyleClass().add("buttonStop"); - } - else { - btnUpStopImage.getStyleClass().add("regionUpload"); - - uploadStopBtn.setOnAction(e-> uploadBtnAction()); - uploadStopBtn.setText(resourceBundle.getString("btn_Upload")); - uploadStopBtn.getStyleClass().remove("buttonStop"); - uploadStopBtn.getStyleClass().add("buttonUp"); - } - } - /** - * Crunch. This function called from NSTableViewController - * */ - public void disableUploadStopBtn(boolean disable){ + void disableUploadStopBtn(boolean disable){ if (isTinfoil()) uploadStopBtn.setDisable(disable); else @@ -515,11 +489,8 @@ public class GamesController implements Initializable { }).start(); } - public void updateFilesSelectorButtonBehaviour(boolean isDirectoryChooser){ + void setFilesSelectorButtonBehaviour(boolean isDirectoryChooser){ btnSelectImage.getStyleClass().clear(); - setFilesSelectorButtonBehaviour(isDirectoryChooser); - } - private void setFilesSelectorButtonBehaviour(boolean isDirectoryChooser){ if (isDirectoryChooser){ selectNspBtn.setOnAction(e -> selectFoldersBtnAction()); btnSelectImage.getStyleClass().add("regionScanFolders"); @@ -535,7 +506,7 @@ public class GamesController implements Initializable { /** * Get 'Recent' path */ - public String getRecentPath(){ + private String getRecentPath(){ return previouslyOpenedPath; } @@ -547,4 +518,42 @@ public class GamesController implements Initializable { preferences.setNetUsb(getSelectedNetUsb()); preferences.setNsIp(getNsIp()); } + + /** + * This thing modifies UI for reusing 'Upload to NS' button and make functionality set for "Stop transmission" + * */ + @Override + public void notify(EModule type, boolean isActive, Payload payload) { + if (! type.equals(EModule.USB_NET_TRANSFERS)){ + usbNetPane.setDisable(isActive); + return; + } + + selectNspBtn.setDisable(isActive); + selectSplitBtn.setDisable(isActive); + btnUpStopImage.getStyleClass().clear(); + + if (isActive) { + btnUpStopImage.getStyleClass().add("regionStop"); + + uploadStopBtn.setOnAction(e-> stopBtnAction()); + uploadStopBtn.setText(resourceBundle.getString("btn_Stop")); + uploadStopBtn.getStyleClass().remove("buttonUp"); + uploadStopBtn.getStyleClass().add("buttonStop"); + return; + } + btnUpStopImage.getStyleClass().add("regionUpload"); + + uploadStopBtn.setOnAction(e-> uploadBtnAction()); + uploadStopBtn.setText(resourceBundle.getString("btn_Upload")); + uploadStopBtn.getStyleClass().remove("buttonStop"); + uploadStopBtn.getStyleClass().add("buttonUp"); + + Map statusMap = payload.getStatusMap(); + + if (! statusMap.isEmpty()) { + for (String key : statusMap.keySet()) + tableFilesListController.setFileStatus(key, statusMap.get(key)); + } + } } \ No newline at end of file diff --git a/src/main/java/nsusbloader/Controllers/ISubscriber.java b/src/main/java/nsusbloader/Controllers/ISubscriber.java new file mode 100644 index 0000000..1e1ba59 --- /dev/null +++ b/src/main/java/nsusbloader/Controllers/ISubscriber.java @@ -0,0 +1,25 @@ +/* + Copyright 2019-2024 Dmitry Isaenko + + This file is part of NS-USBloader. + + NS-USBloader is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + NS-USBloader is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with NS-USBloader. If not, see . + */ +package nsusbloader.Controllers; + +import nsusbloader.NSLDataTypes.EModule; + +public interface ISubscriber { + void notify(EModule type, boolean status, Payload payload); +} diff --git a/src/main/java/nsusbloader/Controllers/NSLMainController.java b/src/main/java/nsusbloader/Controllers/NSLMainController.java index 533c450..a159c9e 100644 --- a/src/main/java/nsusbloader/Controllers/NSLMainController.java +++ b/src/main/java/nsusbloader/Controllers/NSLMainController.java @@ -1,5 +1,5 @@ /* - Copyright 2019-2020 Dmitry Isaenko + Copyright 2019-2024 Dmitry Isaenko This file is part of NS-USBloader. @@ -18,7 +18,6 @@ */ package nsusbloader.Controllers; -import javafx.application.HostServices; import javafx.concurrent.Task; import javafx.fxml.FXML; import javafx.fxml.Initializable; @@ -35,10 +34,10 @@ public class NSLMainController implements Initializable { private ResourceBundle resourceBundle; @FXML - public TextArea logArea; // Accessible from Mediator + private TextArea logArea; @FXML - public ProgressBar progressBar; // Accessible from Mediator + private ProgressBar progressBar; @FXML private TabPane mainTabPane; @@ -68,8 +67,6 @@ public class NSLMainController implements Initializable { logArea.appendText(rb.getString("tab3_Txt_GreetingsMessage2")+"\n"); - MediatorControl.getInstance().setController(this); - AppPreferences preferences = AppPreferences.getInstance(); if (preferences.getAutoCheckUpdates()) @@ -79,6 +76,22 @@ public class NSLMainController implements Initializable { mainTabPane.getTabs().remove(3); openLastOpenedTab(); + + TransfersPublisher transfersPublisher = new TransfersPublisher( + GamesTabController, + SplitMergeTabController, + RcmTabController, + NXDTabController, + PatchesTabController); + + MediatorControl.INSTANCE.configure( + resourceBundle, + SettingsTabController, + logArea, + progressBar, + GamesTabController, + transfersPublisher); + } private void checkForUpdates(){ Task> updTask = new UpdatesChecker(); @@ -101,40 +114,7 @@ public class NSLMainController implements Initializable { updates.setDaemon(true); updates.start(); } - /** - * Get resources - * TODO: Find better solution; used in UsbCommunications() -> GL -> SelectFile command - * @return ResourceBundle - */ - public ResourceBundle getResourceBundle() { - return resourceBundle; - } - /** - * Provide hostServices to Settings tab - * */ - public void setHostServices(HostServices hs ){ SettingsTabController.getGenericSettings().registerHostServices(hs);} - /** - * Get 'Settings' controller - * Used by FrontController - * */ - public SettingsController getSettingsCtrlr(){ - return SettingsTabController; - } - - public GamesController getGamesCtrlr(){ - return GamesTabController; - } - - public SplitMergeController getSmCtrlr(){ - return SplitMergeTabController; - } - - public RcmController getRcmCtrlr(){ return RcmTabController; } - - public NxdtController getNXDTabController(){ return NXDTabController; } - - public PatchesController getPatchesTabController(){ return PatchesTabController; } /** * Save preferences before exit * */ diff --git a/src/main/java/nsusbloader/Controllers/NSTableViewController.java b/src/main/java/nsusbloader/Controllers/NSTableViewController.java index ff3c246..fd65560 100644 --- a/src/main/java/nsusbloader/Controllers/NSTableViewController.java +++ b/src/main/java/nsusbloader/Controllers/NSTableViewController.java @@ -1,5 +1,5 @@ /* - Copyright 2019-2020 Dmitry Isaenko, wolfposd + Copyright 2019-2024 Dmitry Isaenko, wolfposd This file is part of NS-USBloader. @@ -42,6 +42,8 @@ public class NSTableViewController implements Initializable { private TableView table; private ObservableList rowsObsLst; + private GamesController gamesController; + @Override public void initialize(URL url, ResourceBundle resourceBundle) { rowsObsLst = FXCollections.observableArrayList(); @@ -52,10 +54,10 @@ public class NSTableViewController implements Initializable { table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); table.setOnKeyPressed(keyEvent -> { if (!rowsObsLst.isEmpty()) { - if (keyEvent.getCode() == KeyCode.DELETE && !MediatorControl.getInstance().getTransferActive()) { + if (keyEvent.getCode() == KeyCode.DELETE && !MediatorControl.INSTANCE.getTransferActive()) { rowsObsLst.removeAll(table.getSelectionModel().getSelectedItems()); if (rowsObsLst.isEmpty()) - MediatorControl.getInstance().getGamesController().disableUploadStopBtn(true); // TODO: change to something better + gamesController.disableUploadStopBtn(true); table.refresh(); } else if (keyEvent.getCode() == KeyCode.SPACE) { for (NSLRowModel item : table.getSelectionModel().getSelectedItems()) { @@ -173,13 +175,13 @@ public class NSTableViewController implements Initializable { deleteMenuItem.setOnAction(actionEvent -> { rowsObsLst.remove(row.getItem()); if (rowsObsLst.isEmpty()) - MediatorControl.getInstance().getGamesController().disableUploadStopBtn(true); // TODO: change to something better + gamesController.disableUploadStopBtn(true); table.refresh(); }); MenuItem deleteAllMenuItem = new MenuItem(resourceBundle.getString("tab1_table_contextMenu_Btn_DeleteAll")); deleteAllMenuItem.setOnAction(actionEvent -> { rowsObsLst.clear(); - MediatorControl.getInstance().getGamesController().disableUploadStopBtn(true); // TODO: change to something better + gamesController.disableUploadStopBtn(true); table.refresh(); }); MenuItem selectAllMenuItem = new MenuItem(resourceBundle.getString("tab1_table_contextMenu_Btn_SelectAll")); @@ -201,7 +203,7 @@ public class NSTableViewController implements Initializable { Bindings.when( Bindings.isNotNull( row.itemProperty())) - .then(MediatorControl.getInstance().getTransferActive()?null:contextMenu) + .then(MediatorControl.INSTANCE.getTransferActive()?null:contextMenu) .otherwise((ContextMenu) null) ); // Just.. don't ask.. @@ -222,6 +224,11 @@ public class NSTableViewController implements Initializable { table.getColumns().add(fileSizeColumn); table.getColumns().add(uploadColumn); } + + public void setGamesController(GamesController gamesController) { + this.gamesController = gamesController; + } + /** * Add single file when user selected it (Split file usually) * */ @@ -236,7 +243,7 @@ public class NSTableViewController implements Initializable { } else { rowsObsLst.add(new NSLRowModel(file, true)); - MediatorControl.getInstance().getGamesController().disableUploadStopBtn(false); // TODO: change to something better + gamesController.disableUploadStopBtn(false); } table.refresh(); } @@ -256,7 +263,7 @@ public class NSTableViewController implements Initializable { else { for (File file: newFiles) rowsObsLst.add(new NSLRowModel(file, true)); - MediatorControl.getInstance().getGamesController().disableUploadStopBtn(false); // TODO: change to something better + gamesController.disableUploadStopBtn(false); } //rowsObsLst.get(0).setMarkForUpload(true); table.refresh(); diff --git a/src/main/java/nsusbloader/Controllers/NxdtController.java b/src/main/java/nsusbloader/Controllers/NxdtController.java index c824cc9..a6439c6 100644 --- a/src/main/java/nsusbloader/Controllers/NxdtController.java +++ b/src/main/java/nsusbloader/Controllers/NxdtController.java @@ -25,8 +25,6 @@ import javafx.scene.control.Label; import javafx.scene.layout.Region; import javafx.stage.DirectoryChooser; import nsusbloader.AppPreferences; -import nsusbloader.FilesHelper; -import nsusbloader.MediatorControl; import nsusbloader.ModelControllers.CancellableRunnable; import nsusbloader.NSLDataTypes.EModule; import nsusbloader.Utilities.nxdumptool.NxdtTask; @@ -35,7 +33,7 @@ import java.io.File; import java.net.URL; import java.util.ResourceBundle; -public class NxdtController implements Initializable { +public class NxdtController implements Initializable, ISubscriber { @FXML private Label saveToLocationLbl, statusLbl; @@ -79,7 +77,6 @@ public class NxdtController implements Initializable { * */ private void startDumpProcess(){ if ((workThread == null || ! workThread.isAlive())){ - MediatorControl.getInstance().getContoller().logArea.clear(); nxdtTask = new NxdtTask(saveToLocationLbl.getText()); workThread = new Thread(nxdtTask); @@ -97,12 +94,22 @@ public class NxdtController implements Initializable { } } - public void notifyThreadStarted(boolean isActive, EModule type){ + /** + * Save application settings on exit + * */ + public void updatePreferencesOnExit(){ + AppPreferences.getInstance().setNXDTSaveToLocation(saveToLocationLbl.getText()); + } + + @Override + public void notify(EModule type, boolean isActive, Payload payload) { if (! type.equals(EModule.NXDT)){ injectPldBtn.setDisable(isActive); return; } + statusLbl.setText(payload.getMessage()); + if (isActive) { btnDumpStopImage.getStyleClass().clear(); btnDumpStopImage.getStyleClass().add("regionStop"); @@ -121,16 +128,4 @@ public class NxdtController implements Initializable { injectPldBtn.getStyleClass().remove("buttonStop"); injectPldBtn.getStyleClass().add("buttonUp"); } - public void setOneLineStatus(boolean status){ - if (status) - statusLbl.setText(rb.getString("done_txt")); - else - statusLbl.setText(rb.getString("failure_txt")); - } - /** - * Save application settings on exit - * */ - public void updatePreferencesOnExit(){ - AppPreferences.getInstance().setNXDTSaveToLocation(saveToLocationLbl.getText()); - } } diff --git a/src/main/java/nsusbloader/Controllers/PatchesController.java b/src/main/java/nsusbloader/Controllers/PatchesController.java index 6afd267..a2f0b8c 100644 --- a/src/main/java/nsusbloader/Controllers/PatchesController.java +++ b/src/main/java/nsusbloader/Controllers/PatchesController.java @@ -1,5 +1,5 @@ /* - Copyright 2018-2022 Dmitry Isaenko + Copyright 2018-2024 Dmitry Isaenko This file is part of NS-USBloader. @@ -46,7 +46,7 @@ import nsusbloader.Utilities.patches.fs.FsPatchMaker; import nsusbloader.Utilities.patches.loader.LoaderPatchMaker; // TODO: CLI SUPPORT -public class PatchesController implements Initializable { +public class PatchesController implements Initializable, ISubscriber { @FXML private VBox patchesToolPane; @FXML @@ -237,9 +237,8 @@ public class PatchesController implements Initializable { if (workThread != null && workThread.isAlive()) return; - statusLbl.setText(""); - if (MediatorControl.getInstance().getTransferActive()) { + if (MediatorControl.INSTANCE.getTransferActive()) { ServiceWindow.getErrorNotification(resourceBundle.getString("windowTitleError"), resourceBundle.getString("windowBodyPleaseStopOtherProcessFirst")); return; @@ -261,9 +260,8 @@ public class PatchesController implements Initializable { if (workThread != null && workThread.isAlive()) return; - statusLbl.setText(""); - if (MediatorControl.getInstance().getTransferActive()) { + if (MediatorControl.INSTANCE.getTransferActive()) { ServiceWindow.getErrorNotification(resourceBundle.getString("windowTitleError"), resourceBundle.getString("windowBodyPleaseStopOtherProcessFirst")); return; @@ -285,9 +283,8 @@ public class PatchesController implements Initializable { if (workThread != null && workThread.isAlive()) return; - statusLbl.setText(""); - if (MediatorControl.getInstance().getTransferActive()) { + if (MediatorControl.INSTANCE.getTransferActive()) { ServiceWindow.getErrorNotification(resourceBundle.getString("windowTitleError"), resourceBundle.getString("windowBodyPleaseStopOtherProcessFirst")); return; @@ -306,18 +303,20 @@ public class PatchesController implements Initializable { workThread.interrupt(); } - public void notifyThreadStarted(boolean isActive, EModule type) { + @Override + public void notify(EModule type, boolean isActive, Payload payload) { if (! type.equals(EModule.PATCHES)) { patchesToolPane.setDisable(isActive); return; } + statusLbl.setText(payload.getMessage()); + convertRegionEs.getStyleClass().clear(); makeFsBtn.setVisible(! isActive); makeLoaderBtn.setVisible(! isActive); if (isActive) { - MediatorControl.getInstance().getContoller().logArea.clear(); convertRegionEs.getStyleClass().add("regionStop"); makeEsBtn.setOnAction(e-> interruptProcessOfPatchMaking()); @@ -334,13 +333,6 @@ public class PatchesController implements Initializable { makeEsBtn.getStyleClass().add("buttonUp"); } - public void setOneLineStatus(boolean statusSuccess){ - if (statusSuccess) - statusLbl.setText(resourceBundle.getString("done_txt")); - else - statusLbl.setText(resourceBundle.getString("failure_txt")); - } - void updatePreferencesOnExit(){ AppPreferences.getInstance().setPatchesSaveToLocation(saveToLbl.getText()); if (locationKeysLbl.getText().isEmpty()) diff --git a/src/main/java/nsusbloader/Controllers/Payload.java b/src/main/java/nsusbloader/Controllers/Payload.java new file mode 100644 index 0000000..3b37fc1 --- /dev/null +++ b/src/main/java/nsusbloader/Controllers/Payload.java @@ -0,0 +1,48 @@ +/* + Copyright 2019-2024 Dmitry Isaenko + + This file is part of NS-USBloader. + + NS-USBloader is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + NS-USBloader is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with NS-USBloader. If not, see . + */ +package nsusbloader.Controllers; + +import nsusbloader.NSLDataTypes.EFileStatus; + +import java.util.Collections; +import java.util.Map; + +public class Payload { + private final String message; + private final Map statusMap; + + public Payload(){ + this(""); + } + public Payload(String message){ + this(message, Collections.emptyMap()); + } + public Payload(String message, Map statusMap){ + this.message = message; + this.statusMap = statusMap; + } + + public String getMessage() { + return message; + } + + public Map getStatusMap() { + return statusMap; + } +} diff --git a/src/main/java/nsusbloader/Controllers/RcmController.java b/src/main/java/nsusbloader/Controllers/RcmController.java index 3fc6b5e..de29650 100644 --- a/src/main/java/nsusbloader/Controllers/RcmController.java +++ b/src/main/java/nsusbloader/Controllers/RcmController.java @@ -1,5 +1,5 @@ /* - Copyright 2019-2020 Dmitry Isaenko + Copyright 2019-2024 Dmitry Isaenko This file is part of NS-USBloader. @@ -41,7 +41,7 @@ import java.io.File; import java.net.URL; import java.util.ResourceBundle; -public class RcmController implements Initializable { +public class RcmController implements Initializable, ISubscriber { @FXML private ToggleGroup rcmToggleGrp; @@ -68,12 +68,14 @@ public class RcmController implements Initializable { @FXML private Label statusLbl; + private AppPreferences preferences; private ResourceBundle rb; private String myRegexp; + @Override public void initialize(URL url, ResourceBundle resourceBundle) { this.rb = resourceBundle; - final AppPreferences preferences = AppPreferences.getInstance(); + this.preferences = AppPreferences.getInstance(); rcmToggleGrp.selectToggle(pldrRadio1); pldrRadio1.setOnAction(e -> statusLbl.setText("")); @@ -193,8 +195,7 @@ public class RcmController implements Initializable { } private void smash(){ - statusLbl.setText(""); - if (MediatorControl.getInstance().getTransferActive()) { + if (MediatorControl.INSTANCE.getTransferActive()) { ServiceWindow.getErrorNotification(rb.getString("windowTitleError"), rb.getString("windowBodyPleaseStopOtherProcessFirst")); return; @@ -273,31 +274,28 @@ public class RcmController implements Initializable { private void bntResetPayloader(ActionEvent event){ final Node btn = (Node)event.getSource(); + statusLbl.setText(""); + switch (btn.getId()){ case "resPldBtn1": payloadFNameLbl1.setText(""); payloadFPathLbl1.setText(""); - statusLbl.setText(""); break; case "resPldBtn2": payloadFNameLbl2.setText(""); payloadFPathLbl2.setText(""); - statusLbl.setText(""); break; case "resPldBtn3": payloadFNameLbl3.setText(""); payloadFPathLbl3.setText(""); - statusLbl.setText(""); break; case "resPldBtn4": payloadFNameLbl4.setText(""); payloadFPathLbl4.setText(""); - statusLbl.setText(""); break; case "resPldBtn5": payloadFNameLbl5.setText(""); payloadFPathLbl5.setText(""); - statusLbl.setText(""); } } @@ -324,27 +322,20 @@ public class RcmController implements Initializable { } } - public void setOneLineStatus(boolean statusSuccess){ - if (statusSuccess) - statusLbl.setText(rb.getString("done_txt")); - else - statusLbl.setText(rb.getString("failure_txt")); - } - - public void notifyThreadStarted(boolean isStart, EModule type){ - rcmToolPane.setDisable(isStart); - if (type.equals(EModule.RCM) && isStart){ - MediatorControl.getInstance().getContoller().logArea.clear(); - } + @Override + public void notify(EModule type, boolean isActive, Payload payload) { + rcmToolPane.setDisable(isActive); + if (type.equals(EModule.RCM)) + statusLbl.setText(payload.getMessage()); } /** * Save application settings on exit * */ public void updatePreferencesOnExit(){ - AppPreferences.getInstance().setRecentRcm(1, payloadFPathLbl1.getText()); - AppPreferences.getInstance().setRecentRcm(2, payloadFPathLbl2.getText()); - AppPreferences.getInstance().setRecentRcm(3, payloadFPathLbl3.getText()); - AppPreferences.getInstance().setRecentRcm(4, payloadFPathLbl4.getText()); - AppPreferences.getInstance().setRecentRcm(5, payloadFPathLbl5.getText()); + preferences.setRecentRcm(1, payloadFPathLbl1.getText()); + preferences.setRecentRcm(2, payloadFPathLbl2.getText()); + preferences.setRecentRcm(3, payloadFPathLbl3.getText()); + preferences.setRecentRcm(4, payloadFPathLbl4.getText()); + preferences.setRecentRcm(5, payloadFPathLbl5.getText()); } } diff --git a/src/main/java/nsusbloader/Controllers/SettingsBlockGenericController.java b/src/main/java/nsusbloader/Controllers/SettingsBlockGenericController.java index c90f049..fc4b584 100644 --- a/src/main/java/nsusbloader/Controllers/SettingsBlockGenericController.java +++ b/src/main/java/nsusbloader/Controllers/SettingsBlockGenericController.java @@ -1,5 +1,5 @@ /* - Copyright 2019-2020 Dmitry Isaenko + Copyright 2019-2024 Dmitry Isaenko This file is part of NS-USBloader. @@ -55,9 +55,7 @@ public class SettingsBlockGenericController implements Initializable { direcroriesChooserForRomsCB; @FXML private Hyperlink newVersionHyperlink; - private ResourceBundle resourceBundle; - private HostServices hostServices; @Override @@ -68,8 +66,8 @@ public class SettingsBlockGenericController implements Initializable { autoCheckForUpdatesCB.setSelected(preferences.getAutoCheckUpdates()); direcroriesChooserForRomsCB.setSelected(preferences.getDirectoriesChooserForRoms()); direcroriesChooserForRomsCB.setOnAction(actionEvent -> - MediatorControl.getInstance().getGamesController().updateFilesSelectorButtonBehaviour(direcroriesChooserForRomsCB.isSelected()) - ); + MediatorControl.INSTANCE.getGamesController().setFilesSelectorButtonBehaviour(direcroriesChooserForRomsCB.isSelected()) + ); Region btnSwitchImage = new Region(); btnSwitchImage.getStyleClass().add("regionUpdatesCheck"); @@ -81,6 +79,7 @@ public class SettingsBlockGenericController implements Initializable { languagesChB.setItems(settingsLanguagesSetup.getLanguages()); languagesChB.getSelectionModel().select(settingsLanguagesSetup.getRecentLanguage()); + hostServices = MediatorControl.INSTANCE.getHostServices(); newVersionHyperlink.setOnAction(e-> hostServices.showDocument(newVersionHyperlink.getText())); checkForUpdBtn.setOnAction(e->checkForUpdatesAction()); submitLanguageBtn.setOnAction(e->languageButtonAction()); @@ -149,8 +148,6 @@ public class SettingsBlockGenericController implements Initializable { return direcroriesChooserForRomsCB.isSelected(); } - protected void registerHostServices(HostServices hostServices){ this.hostServices = hostServices;} - void setNewVersionLink(String newVer){ newVersionHyperlink.setVisible(true); newVersionHyperlink.setText("https://github.com/developersu/ns-usbloader/releases/tag/"+newVer); diff --git a/src/main/java/nsusbloader/Controllers/SplitMergeController.java b/src/main/java/nsusbloader/Controllers/SplitMergeController.java index 57de95d..10e1de3 100644 --- a/src/main/java/nsusbloader/Controllers/SplitMergeController.java +++ b/src/main/java/nsusbloader/Controllers/SplitMergeController.java @@ -1,5 +1,5 @@ /* - Copyright 2019-2020 Dmitry Isaenko + Copyright 2019-2024 Dmitry Isaenko This file is part of NS-USBloader. @@ -31,7 +31,6 @@ import javafx.stage.FileChooser; import nsusbloader.AppPreferences; import nsusbloader.FilesHelper; import nsusbloader.MediatorControl; -import nsusbloader.ModelControllers.CancellableRunnable; import nsusbloader.NSLDataTypes.EModule; import nsusbloader.ServiceWindow; import nsusbloader.Utilities.splitmerge.SplitMergeTaskExecutor; @@ -41,7 +40,7 @@ import java.net.URL; import java.util.List; import java.util.ResourceBundle; -public class SplitMergeController implements Initializable { +public class SplitMergeController implements Initializable, ISubscriber { @FXML private ToggleGroup splitMergeTogGrp; @FXML @@ -147,13 +146,87 @@ public class SplitMergeController implements Initializable { convertBtn.setOnAction(actionEvent -> setConvertBtnAction()); } - public void notifyThreadStarted(boolean isStart, EModule type){ // todo: refactor: remove everything, place to separate container and just disable. - if (! type.equals(EModule.SPLIT_MERGE_TOOL)){ - smToolPane.setDisable(isStart); + /** + * It's button listener when convert-process in progress + * */ + private void stopBtnAction(){ + if (smThread != null && smThread.isAlive()) { + smThread.interrupt(); + } + } + /** + * It's button listener when convert-process NOT in progress + * */ + private void setConvertBtnAction(){ + if (MediatorControl.INSTANCE.getTransferActive()) { + ServiceWindow.getErrorNotification( + resourceBundle.getString("windowTitleError"), + resourceBundle.getString("windowBodyPleaseFinishTransfersFirst") + ); return; } - if (isStart){ - MediatorControl.getInstance().getContoller().logArea.clear(); + + if (splitRad.isSelected()) + smTask = new SplitMergeTaskExecutor(true, BlockListViewController.getItems(), saveToPathLbl.getText()); + else + smTask = new SplitMergeTaskExecutor(false, BlockListViewController.getItems(), saveToPathLbl.getText()); + smThread = new Thread(smTask); + smThread.setDaemon(true); + smThread.start(); + } + /** + * Drag-n-drop support (dragOver consumer) + * */ + @FXML + private void handleDragOver(DragEvent event){ + if (event.getDragboard().hasFiles() && ! MediatorControl.INSTANCE.getTransferActive()) + event.acceptTransferModes(TransferMode.ANY); + event.consume(); + } + /** + * Drag-n-drop support (drop consumer) + * */ + @FXML + private void handleDrop(DragEvent event) { + List files = event.getDragboard().getFiles(); + File firstFile = files.get(0); + + if (firstFile.isDirectory()) + mergeRad.fire(); + else + splitRad.fire(); + + this.BlockListViewController.addAll(files); + + event.setDropCompleted(true); + event.consume(); + } + + + /** + * Save application settings on exit + * */ + public void updatePreferencesOnExit(){ + if (splitRad.isSelected()) + AppPreferences.getInstance().setSplitMergeType(0); + else + AppPreferences.getInstance().setSplitMergeType(1); + + AppPreferences.getInstance().setSplitMergeRecent(saveToPathLbl.getText()); + } + + @Override + public void notify(EModule type, boolean isActive, Payload payload) { + // todo: refactor: remove everything, place to separate container and just disable. + + if (! type.equals(EModule.SPLIT_MERGE_TOOL)){ + smToolPane.setDisable(isActive); + return; + } + + statusLbl.setText(payload.getMessage()); + + if (isActive){ splitRad.setDisable(true); mergeRad.setDisable(true); selectFileFolderBtn.setDisable(true); @@ -182,79 +255,4 @@ public class SplitMergeController implements Initializable { else convertRegion.getStyleClass().add("regionOneToSplit"); } - - /** - * It's button listener when convert-process in progress - * */ - private void stopBtnAction(){ - if (smThread != null && smThread.isAlive()) { - smThread.interrupt(); - } - } - /** - * It's button listener when convert-process NOT in progress - * */ - private void setConvertBtnAction(){ - statusLbl.setText(""); - if (MediatorControl.getInstance().getTransferActive()) { - ServiceWindow.getErrorNotification( - resourceBundle.getString("windowTitleError"), - resourceBundle.getString("windowBodyPleaseFinishTransfersFirst") - ); - return; - } - - if (splitRad.isSelected()) - smTask = new SplitMergeTaskExecutor(true, BlockListViewController.getItems(), saveToPathLbl.getText()); - else - smTask = new SplitMergeTaskExecutor(false, BlockListViewController.getItems(), saveToPathLbl.getText()); - smThread = new Thread(smTask); - smThread.setDaemon(true); - smThread.start(); - } - /** - * Drag-n-drop support (dragOver consumer) - * */ - @FXML - private void handleDragOver(DragEvent event){ - if (event.getDragboard().hasFiles() && ! MediatorControl.getInstance().getTransferActive()) - event.acceptTransferModes(TransferMode.ANY); - event.consume(); - } - /** - * Drag-n-drop support (drop consumer) - * */ - @FXML - private void handleDrop(DragEvent event) { - List files = event.getDragboard().getFiles(); - File firstFile = files.get(0); - - if (firstFile.isDirectory()) - mergeRad.fire(); - else - splitRad.fire(); - - this.BlockListViewController.addAll(files); - - event.setDropCompleted(true); - event.consume(); - } - - public void setOneLineStatus(boolean status){ - if (status) - statusLbl.setText(resourceBundle.getString("done_txt")); - else - statusLbl.setText(resourceBundle.getString("failure_txt")); - } - /** - * Save application settings on exit - * */ - public void updatePreferencesOnExit(){ - if (splitRad.isSelected()) - AppPreferences.getInstance().setSplitMergeType(0); - else - AppPreferences.getInstance().setSplitMergeType(1); - - AppPreferences.getInstance().setSplitMergeRecent(saveToPathLbl.getText()); - } } \ No newline at end of file diff --git a/src/main/java/nsusbloader/MediatorControl.java b/src/main/java/nsusbloader/MediatorControl.java index a73b239..af2cb27 100644 --- a/src/main/java/nsusbloader/MediatorControl.java +++ b/src/main/java/nsusbloader/MediatorControl.java @@ -1,5 +1,5 @@ /* - Copyright 2019-2020 Dmitry Isaenko + Copyright 2019-2024 Dmitry Isaenko This file is part of NS-USBloader. @@ -18,50 +18,57 @@ */ package nsusbloader; +import javafx.application.HostServices; +import javafx.scene.control.ProgressBar; +import javafx.scene.control.TextArea; import nsusbloader.Controllers.*; import nsusbloader.NSLDataTypes.EModule; import java.util.ResourceBundle; -import java.util.concurrent.atomic.AtomicBoolean; public class MediatorControl { - private final AtomicBoolean isTransferActive = new AtomicBoolean(false); // Overcoded just for sure - private NSLMainController mainController; + public static final MediatorControl INSTANCE = new MediatorControl(); - public static MediatorControl getInstance(){ - return MediatorControlHold.INSTANCE; + private ResourceBundle resourceBundle; + private TransfersPublisher transfersPublisher; + private HostServices hostServices; + private GamesController gamesController; + private SettingsController settingsController; + + private TextArea logArea; + private ProgressBar progressBar; + + private MediatorControl(){} + + public void configure(ResourceBundle resourceBundle, + SettingsController settingsController, + TextArea logArea, + ProgressBar progressBar, + GamesController gamesController, + TransfersPublisher transfersPublisher) { + this.resourceBundle = resourceBundle; + this.settingsController = settingsController; + this.gamesController = gamesController; + this.logArea = logArea; + this.progressBar = progressBar; + this.transfersPublisher = transfersPublisher; + } + public void setHostServices(HostServices hostServices) { + this.hostServices = hostServices; } - private static class MediatorControlHold { - private static final MediatorControl INSTANCE = new MediatorControl(); - } - public void setController(NSLMainController controller){ - this.mainController = controller; + public HostServices getHostServices() { return hostServices; } + public ResourceBundle getResourceBundle(){ return resourceBundle; } + public SettingsController getSettingsController() { return settingsController; } + public GamesController getGamesController() { return gamesController; } + public TextArea getLogArea() { return logArea; } + public ProgressBar getProgressBar() { return progressBar; } + + public synchronized void setTransferActive(EModule appModuleType, boolean isActive, Payload payload) { + transfersPublisher.setTransferActive(appModuleType, isActive, payload); } - public NSLMainController getContoller(){ return mainController; } - public GamesController getGamesController(){ return mainController.getGamesCtrlr(); } - public SettingsController getSettingsController(){ return mainController.getSettingsCtrlr(); } - public SplitMergeController getSplitMergeController(){ return mainController.getSmCtrlr(); } - public RcmController getRcmController(){ return mainController.getRcmCtrlr(); } - public NxdtController getNxdtController(){ return mainController.getNXDTabController(); } - public PatchesController getPatchesController(){ return mainController.getPatchesTabController(); } - - public ResourceBundle getResourceBundle(){ - return mainController.getResourceBundle(); - } - - public synchronized void setBgThreadActive(boolean isActive, EModule appModuleType) { - isTransferActive.set(isActive); - getGamesController().notifyThreadStarted(isActive, appModuleType); - getSplitMergeController().notifyThreadStarted(isActive, appModuleType); - getRcmController().notifyThreadStarted(isActive, appModuleType); - getNxdtController().notifyThreadStarted(isActive, appModuleType); - getPatchesController().notifyThreadStarted(isActive, appModuleType); - } - public synchronized boolean getTransferActive() { return this.isTransferActive.get(); } - public void updateApplicationFont(String fontFamily, double fontSize){ - mainController.logArea.getScene().getRoot().setStyle( - String.format("-fx-font-family: \"%s\"; -fx-font-size: %.0f;", fontFamily, fontSize)); + public synchronized boolean getTransferActive() { + return transfersPublisher.getTransferActive(); } } diff --git a/src/main/java/nsusbloader/ModelControllers/LogPrinterGui.java b/src/main/java/nsusbloader/ModelControllers/LogPrinterGui.java index d557964..606771d 100644 --- a/src/main/java/nsusbloader/ModelControllers/LogPrinterGui.java +++ b/src/main/java/nsusbloader/ModelControllers/LogPrinterGui.java @@ -1,5 +1,5 @@ /* - Copyright 2019-2020 Dmitry Isaenko + Copyright 2019-2024 Dmitry Isaenko This file is part of NS-USBloader. @@ -40,9 +40,13 @@ public class LogPrinterGui implements ILogPrinter { LogPrinterGui(EModule whoIsAsking){ this.msgQueue = new LinkedBlockingQueue<>(); this.progressQueue = new LinkedBlockingQueue<>(); - this.statusMap = new HashMap<>(); + this.statusMap = new HashMap<>(); this.oneLinerStatus = new AtomicBoolean(); - this.msgConsumer = new MessagesConsumer(whoIsAsking, this.msgQueue, this.progressQueue, this.statusMap, this.oneLinerStatus); + this.msgConsumer = new MessagesConsumer(whoIsAsking, + this.msgQueue, + this.progressQueue, + this.statusMap, + this.oneLinerStatus); this.msgConsumer.start(); } /** diff --git a/src/main/java/nsusbloader/ModelControllers/MessagesConsumer.java b/src/main/java/nsusbloader/ModelControllers/MessagesConsumer.java index 08add56..491d5ad 100644 --- a/src/main/java/nsusbloader/ModelControllers/MessagesConsumer.java +++ b/src/main/java/nsusbloader/ModelControllers/MessagesConsumer.java @@ -1,5 +1,5 @@ /* - Copyright 2019-2020 Dmitry Isaenko + Copyright 2019-2024 Dmitry Isaenko This file is part of NS-USBloader. @@ -22,24 +22,26 @@ import javafx.animation.AnimationTimer; import javafx.scene.control.ProgressBar; import javafx.scene.control.ProgressIndicator; import javafx.scene.control.TextArea; -import nsusbloader.Controllers.NSTableViewController; +import nsusbloader.Controllers.Payload; import nsusbloader.MediatorControl; import nsusbloader.NSLDataTypes.EFileStatus; import nsusbloader.NSLDataTypes.EModule; import java.util.ArrayList; import java.util.HashMap; +import java.util.ResourceBundle; import java.util.concurrent.BlockingQueue; import java.util.concurrent.atomic.AtomicBoolean; public class MessagesConsumer extends AnimationTimer { - private final BlockingQueue msgQueue; - private final TextArea logsArea; + private static final MediatorControl mediator = MediatorControl.INSTANCE; + private static final TextArea logsArea = mediator.getLogArea(); + private static final ProgressBar progressBar = mediator.getProgressBar();; + private static final ResourceBundle resourceBundle = mediator.getResourceBundle(); + private final BlockingQueue msgQueue; private final BlockingQueue progressQueue; - private final ProgressBar progressBar; private final HashMap statusMap; - private final NSTableViewController tableViewController; private final EModule appModuleType; private final AtomicBoolean oneLinerStatus; @@ -53,22 +55,16 @@ public class MessagesConsumer extends AnimationTimer { AtomicBoolean oneLinerStatus){ this.appModuleType = appModuleType; this.isInterrupted = false; - this.msgQueue = msgQueue; - this.logsArea = MediatorControl.getInstance().getContoller().logArea; - this.progressQueue = progressQueue; - this.progressBar = MediatorControl.getInstance().getContoller().progressBar; - this.statusMap = statusMap; - this.tableViewController = MediatorControl.getInstance().getGamesController().tableFilesListController; - this.oneLinerStatus = oneLinerStatus; progressBar.setProgress(0.0); - progressBar.setProgress(ProgressIndicator.INDETERMINATE_PROGRESS); - MediatorControl.getInstance().setBgThreadActive(true, appModuleType); + + logsArea.clear(); + mediator.setTransferActive(appModuleType, true, new Payload()); } @Override @@ -89,32 +85,18 @@ public class MessagesConsumer extends AnimationTimer { }); } - if (isInterrupted) // It's safe 'cuz it's could't be interrupted while HashMap populating + if (isInterrupted) // safe, could not be interrupted while HashMap populating updateElementsAndStop(); } private void updateElementsAndStop(){ - MediatorControl.getInstance().setBgThreadActive(false, appModuleType); + Payload payload = new Payload( + resourceBundle.getString(oneLinerStatus.get() ? "done_txt" : "failure_txt"), + statusMap); + + mediator.setTransferActive(appModuleType, false, payload); progressBar.setProgress(0.0); - if (statusMap.size() > 0){ - for (String key : statusMap.keySet()) - tableViewController.setFileStatus(key, statusMap.get(key)); - } - - switch (appModuleType){ - case RCM: - MediatorControl.getInstance().getRcmController().setOneLineStatus(oneLinerStatus.get()); - break; - case NXDT: - MediatorControl.getInstance().getNxdtController().setOneLineStatus(oneLinerStatus.get()); - break; - case SPLIT_MERGE_TOOL: - MediatorControl.getInstance().getSplitMergeController().setOneLineStatus(oneLinerStatus.get()); - break; - case PATCHES: - MediatorControl.getInstance().getPatchesController().setOneLineStatus(oneLinerStatus.get()); - } this.stop(); } diff --git a/src/main/java/nsusbloader/NSLMain.java b/src/main/java/nsusbloader/NSLMain.java index fa40c9a..ce98308 100644 --- a/src/main/java/nsusbloader/NSLMain.java +++ b/src/main/java/nsusbloader/NSLMain.java @@ -1,5 +1,5 @@ /* - Copyright 2019-2020 Dmitry Isaenko + Copyright 2019-2024 Dmitry Isaenko This file is part of NS-USBloader. @@ -68,14 +68,15 @@ public class NSLMain extends Application { primaryStage.show(); primaryStage.setOnCloseRequest(e->{ - if (MediatorControl.getInstance().getTransferActive()) + if (MediatorControl.INSTANCE.getTransferActive()) if(! ServiceWindow.getConfirmationWindow(rb.getString("windowTitleConfirmExit"), rb.getString("windowBodyConfirmExit"))) e.consume(); }); NSLMainController controller = loader.getController(); - controller.setHostServices(getHostServices()); + MediatorControl.INSTANCE.setHostServices(getHostServices()); + primaryStage.setOnHidden(e-> { AppPreferences.getInstance().setSceneHeight(mainScene.getHeight()); AppPreferences.getInstance().setSceneWidth(mainScene.getWidth()); diff --git a/src/main/java/nsusbloader/TransfersPublisher.java b/src/main/java/nsusbloader/TransfersPublisher.java new file mode 100644 index 0000000..246cbb8 --- /dev/null +++ b/src/main/java/nsusbloader/TransfersPublisher.java @@ -0,0 +1,47 @@ +/* + Copyright 2019-2024 Dmitry Isaenko + + This file is part of NS-USBloader. + + NS-USBloader is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + NS-USBloader is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with NS-USBloader. If not, see . + */ +package nsusbloader; + +import nsusbloader.Controllers.ISubscriber; +import nsusbloader.Controllers.Payload; +import nsusbloader.NSLDataTypes.EModule; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; + +public class TransfersPublisher { + private final AtomicBoolean isTransferActive = new AtomicBoolean(false); + + private final List subscribers = new ArrayList<>(); + + public TransfersPublisher(ISubscriber... subscriber){ + subscribers.addAll(Arrays.asList(subscriber)); + } + + public void setTransferActive(EModule appModuleType, boolean isActive, Payload payload) { + isTransferActive.set(isActive); + subscribers.forEach(s->s.notify(appModuleType, isActive, payload)); + } + + public boolean getTransferActive() { + return isTransferActive.get(); + } +} diff --git a/src/main/java/nsusbloader/com/usb/GoldLeaf_010.java b/src/main/java/nsusbloader/com/usb/GoldLeaf_010.java index a5669d2..3f420a0 100644 --- a/src/main/java/nsusbloader/com/usb/GoldLeaf_010.java +++ b/src/main/java/nsusbloader/com/usb/GoldLeaf_010.java @@ -1,5 +1,5 @@ /* - Copyright 2019-2022 Dmitry Isaenko + Copyright 2019-2024 Dmitry Isaenko This file is part of NS-USBloader. @@ -933,7 +933,7 @@ class GoldLeaf_010 extends TransferModule { private boolean selectFile(){ File selectedFile = CompletableFuture.supplyAsync(() -> { FileChooser fChooser = new FileChooser(); - fChooser.setTitle(MediatorControl.getInstance().getResourceBundle().getString("btn_OpenFile")); // TODO: FIX BAD IMPLEMENTATION + fChooser.setTitle(MediatorControl.INSTANCE.getResourceBundle().getString("btn_OpenFile")); // TODO: FIX BAD IMPLEMENTATION fChooser.setInitialDirectory(new File(System.getProperty("user.home")));// TODO: Consider fixing; not a priority. fChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("*", "*")); return fChooser.showOpenDialog(null); // Leave as is for now. diff --git a/src/main/java/nsusbloader/com/usb/GoldLeaf_07.java b/src/main/java/nsusbloader/com/usb/GoldLeaf_07.java index 38adb7e..640032b 100644 --- a/src/main/java/nsusbloader/com/usb/GoldLeaf_07.java +++ b/src/main/java/nsusbloader/com/usb/GoldLeaf_07.java @@ -1,5 +1,5 @@ /* - Copyright 2019-2020 Dmitry Isaenko + Copyright 2019-2024 Dmitry Isaenko This file is part of NS-USBloader. @@ -918,7 +918,7 @@ class GoldLeaf_07 extends TransferModule { private boolean selectFile(){ File selectedFile = CompletableFuture.supplyAsync(() -> { FileChooser fChooser = new FileChooser(); - fChooser.setTitle(MediatorControl.getInstance().getResourceBundle().getString("btn_OpenFile")); // TODO: FIX BAD IMPLEMENTATION + fChooser.setTitle(MediatorControl.INSTANCE.getResourceBundle().getString("btn_OpenFile")); // TODO: FIX BAD IMPLEMENTATION fChooser.setInitialDirectory(new File(System.getProperty("user.home"))); // TODO: Consider fixing; not a prio. fChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("*", "*")); return fChooser.showOpenDialog(null); // Leave as is for now. diff --git a/src/main/java/nsusbloader/com/usb/GoldLeaf_08.java b/src/main/java/nsusbloader/com/usb/GoldLeaf_08.java index f8bf657..c367fd8 100644 --- a/src/main/java/nsusbloader/com/usb/GoldLeaf_08.java +++ b/src/main/java/nsusbloader/com/usb/GoldLeaf_08.java @@ -1,5 +1,5 @@ /* - Copyright 2019-2020 Dmitry Isaenko + Copyright 2019-2024 Dmitry Isaenko This file is part of NS-USBloader. @@ -941,7 +941,7 @@ class GoldLeaf_08 extends TransferModule { private boolean selectFile(){ File selectedFile = CompletableFuture.supplyAsync(() -> { FileChooser fChooser = new FileChooser(); - fChooser.setTitle(MediatorControl.getInstance().getResourceBundle().getString("btn_OpenFile")); // TODO: FIX BAD IMPLEMENTATION + fChooser.setTitle(MediatorControl.INSTANCE.getResourceBundle().getString("btn_OpenFile")); // TODO: FIX BAD IMPLEMENTATION fChooser.setInitialDirectory(new File(System.getProperty("user.home")));// TODO: Consider fixing; not a prio. fChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("*", "*")); return fChooser.showOpenDialog(null); // Leave as is for now. diff --git a/src/main/java/nsusbloader/com/usb/UsbConnect.java b/src/main/java/nsusbloader/com/usb/UsbConnect.java index f4e5ad3..99e0c75 100644 --- a/src/main/java/nsusbloader/com/usb/UsbConnect.java +++ b/src/main/java/nsusbloader/com/usb/UsbConnect.java @@ -169,7 +169,7 @@ public class UsbConnect { "Double check that you have administrator privileges (you're 'root') or check 'udev' rules set for this user (linux only)!\n\n" + "Steps to set 'udev' rules:\n" + "root # vim /etc/udev/rules.d/99-NS" + ((RCM_VID == VENDOR_ID) ? "RCM" : "") + ".rules\n" + - "SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"%04x\", ATTRS{idProduct}==\"%04x\", GROUP=\"plugdev\"\n" + + "SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"%04x\", ATTRS{idProduct}==\"%04x\", MODE=\"0666\"\n" + "root # udevadm control --reload-rules && udevadm trigger\n", UsbErrorCodes.getErrCode(returningValue), VENDOR_ID, PRODUCT_ID)); } else diff --git a/src/main/resources/locale_ko_KR.properties b/src/main/resources/locale_ko_KR.properties index 2a66669..71e5ba4 100644 --- a/src/main/resources/locale_ko_KR.properties +++ b/src/main/resources/locale_ko_KR.properties @@ -91,3 +91,7 @@ tabPatches_Btn_MakeAtmo=\uB85C\uB354 \uB9CC\uB4E4\uAE30 (Atmosphere) tabPatches_Btn_MakeAll=\uBAA8\uB450 \uB9CC\uB4E4\uAE30 tabPatches_ServiceWindowMessageEsFs=\uD38C\uC6E8\uC5B4\uC640 \uD0A4 \uBAA8\uB450 \uD328\uCE58\uB97C \uC0DD\uC131\uD558\uB3C4\uB85D \uC124\uC815\uD574\uC57C \uD569\uB2C8\uB2E4. \uADF8\uB807\uC9C0 \uC54A\uC73C\uBA74 \uBB34\uC5C7\uC744 \uD328\uCE58\uD560\uC9C0 \uBA85\uD655\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. tabPatches_ServiceWindowMessageLoader='\uB85C\uB354' \uD328\uCE58\uB97C \uC0DD\uC131\uD558\uB824\uBA74 Atmosphere \uD3F4\uB354\uB97C \uC815\uC758\uD574\uC57C \uD569\uB2C8\uB2E4. +tab2_Btn_ApplicationFont=\uC751\uC6A9 \uD504\uB85C\uADF8\uB7A8 \uAE00\uAF34 \uBCC0\uACBD +btn_ResetToDefaults=\uC7AC\uC124\uC815 +fontPreviewText=\uD14D\uC2A4\uD2B8 \uBBF8\uB9AC\uBCF4\uAE30 +fontSize=\uAE00\uAF34 \uC0AC\uC774\uC988: diff --git a/src/main/resources/locale_zh_CN.properties b/src/main/resources/locale_zh_CN.properties index 59f8b3b..9c15cee 100644 --- a/src/main/resources/locale_zh_CN.properties +++ b/src/main/resources/locale_zh_CN.properties @@ -85,4 +85,20 @@ windowBodyFilesScanned=\u626B\u63CF\u6587\u4EF6: %25d\n\u88AB\u6DFB\u52A0: %25d tab2_Lbl_AwooBlockTitle=awoo installer \u5B8C\u6210 tabRcm_Lbl_Payload=Payload: tabRcm_Lbl_FuseeGelee=Fus\u00E9e Gel\u00E9e RCM +tabPatches_Lbl_Firmware=Firmware: +tabPatches_Lbl_Atmo=Atmosphere: +tabPatches_Btn_fromFolder=From folder +tabPatches_Btn_asZipFile=as ZIP file +tabPatches_Lbl_Title=Patches +tabPatches_Lbl_Keys=Keys: +tabPatches_Btn_MakeEs=Make ES +tabPatches_Btn_MakeFs=Make FS +tabPatches_Btn_MakeAtmo=Make Loader (Atmosphere) +tabPatches_Btn_MakeAll=Make all +tabPatches_ServiceWindowMessageEsFs=Both firmware and keys should be set to generate patches. Otherwise, it's not clear what to patch. +tabPatches_ServiceWindowMessageLoader=Atmosphere folder should be defined to generate 'Loader' patch. +tab2_Btn_ApplicationFont=\u4fee\u6539\u7a0b\u5e8f\u5b57\u4f53 +btn_ResetToDefaults=\u91cd\u7f6e +fontPreviewText=\u6587\u5b57\u9884\u89c8 +fontSize=\u5b57\u53f7: diff --git a/src/test/java/integration/EsIntegrationTest.java b/src/test/java/integration/EsIntegrationTest.java index c8ec24e..8fb868c 100644 --- a/src/test/java/integration/EsIntegrationTest.java +++ b/src/test/java/integration/EsIntegrationTest.java @@ -22,7 +22,7 @@ public class EsIntegrationTest { pathToKeysFile = environment.getProdkeysLocation(); saveTo = environment.getSaveToLocation() + File.separator + "ES_LPR"; pathToFirmwares = environment.getFirmwaresLocation(); - pathToFirmware = pathToFirmware + File.separator + "Firmware 14.1.0"; + pathToFirmware = environment.getFirmwaresLocation() + File.separator + "Firmware 17.0.0"; } @DisplayName("ES Integration validation - everything") diff --git a/src/test/java/integration/FsIntegrationTest.java b/src/test/java/integration/FsIntegrationTest.java index 5a85acc..f56544c 100644 --- a/src/test/java/integration/FsIntegrationTest.java +++ b/src/test/java/integration/FsIntegrationTest.java @@ -25,7 +25,7 @@ public class FsIntegrationTest { pathToKeysFile = environment.getProdkeysLocation(); saveTo = environment.getSaveToLocation() + File.separator + "FS_LPR"; pathToFirmwares = environment.getFirmwaresLocation(); - pathToFirmware = pathToFirmware + File.separator + "Firmware 13.0.0"; + pathToFirmware = environment.getFirmwaresLocation() + File.separator + "Firmware 17.0.0"; } @DisplayName("FS Integration validation - everything") From 57be7de05d0bf3c288d44f3668ecca6781975dc6 Mon Sep 17 00:00:00 2001 From: TY <47445484+R-YaTian@users.noreply.github.com> Date: Wed, 15 Oct 2025 23:47:08 +0800 Subject: [PATCH 6/6] Delete .github/workflows/maven.yml --- .github/workflows/maven.yml | 38 ------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 .github/workflows/maven.yml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml deleted file mode 100644 index f48f330..0000000 --- a/.github/workflows/maven.yml +++ /dev/null @@ -1,38 +0,0 @@ -# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven - -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -name: Java CI with Maven - -on: - push: - branches: [ "workflow" ] - pull_request: - branches: [ "workflow" ] - workflow_dispatch: - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@master - - name: Set up JDK 17 - uses: actions/setup-java@master - with: - java-version: '17' - distribution: 'temurin' - cache: maven - - name: Build with Maven - run: mvn -B -DskipTests clean package --file pom.xml - - - name: Upload a Build Artifact - uses: actions/upload-artifact@master - with: - name: package - path: target/*.jar