From dc45dabd342af51f25aef7d7e22b7e33999cbf29 Mon Sep 17 00:00:00 2001 From: Dmitry Isaenko Date: Sun, 25 Sep 2022 15:22:08 +0300 Subject: [PATCH] Fix few errors, make app to be in line with current libKonogonka implementation --- .../Controllers/NPDM/NPDMController.java | 8 +++--- .../Controllers/RFS/RomFsController.java | 6 ++--- .../XCI/Hfs0TableViewController.java | 25 +++++++------------ .../Controllers/XCI/XCIController.java | 4 +-- .../konogonka/Settings/SettingsWindow.java | 9 ++++--- src/main/java/konogonka/Workers/Analyzer.java | 10 ++++---- 6 files changed, 28 insertions(+), 34 deletions(-) diff --git a/src/main/java/konogonka/Controllers/NPDM/NPDMController.java b/src/main/java/konogonka/Controllers/NPDM/NPDMController.java index 8211fb2..ec45e77 100644 --- a/src/main/java/konogonka/Controllers/NPDM/NPDMController.java +++ b/src/main/java/konogonka/Controllers/NPDM/NPDMController.java @@ -115,9 +115,9 @@ public class NPDMController implements ITabController { public void analyze(File file) { analyze(file, 0); } @Override public void analyze(ISuperProvider parentProvider, int fileNo) throws Exception { - Task analyzer = Analyzer.analyzeNPDM(parentProvider, fileNo); + Task analyzer = Analyzer.analyzeNPDM(parentProvider, fileNo); analyzer.setOnSucceeded(e->{ - NPDMProvider npdm = (NPDMProvider) analyzer.getValue(); + NPDMProvider npdm = analyzer.getValue(); setData(npdm, null); }); Thread workThread = new Thread(analyzer); @@ -126,9 +126,9 @@ public class NPDMController implements ITabController { } @Override public void analyze(File file, long offset) { - Task analyzer = Analyzer.analyzeNPDM(file, offset); + Task analyzer = Analyzer.analyzeNPDM(file, offset); analyzer.setOnSucceeded(e->{ - NPDMProvider npdm = (NPDMProvider) analyzer.getValue(); + NPDMProvider npdm = analyzer.getValue(); if (offset == 0) setData(npdm, file); else diff --git a/src/main/java/konogonka/Controllers/RFS/RomFsController.java b/src/main/java/konogonka/Controllers/RFS/RomFsController.java index 1b67522..ca66ed7 100644 --- a/src/main/java/konogonka/Controllers/RFS/RomFsController.java +++ b/src/main/java/konogonka/Controllers/RFS/RomFsController.java @@ -29,9 +29,9 @@ import libKonogonka.Tools.ISuperProvider; import libKonogonka.Tools.RomFs.FileSystemEntry; import libKonogonka.Tools.RomFs.IRomFsProvider; import libKonogonka.Tools.RomFs.Level6Header; -import libKonogonka.Tools.RomFs.RomFsDecryptedProvider; import konogonka.Workers.Analyzer; import konogonka.Workers.DumbRomFsExtractor; +import libKonogonka.Tools.RomFs.RomFsProvider; import java.io.File; import java.net.URL; @@ -155,9 +155,9 @@ public class RomFsController implements ITabController { catch (Exception e){ e.printStackTrace(); } - Task analyzer = Analyzer.analyzeRomFS(file, lv6offset); + Task analyzer = Analyzer.analyzeRomFS(file, lv6offset); analyzer.setOnSucceeded(e->{ - RomFsDecryptedProvider provider = analyzer.getValue(); + RomFsProvider provider = analyzer.getValue(); this.setData(provider); }); Thread workThread = new Thread(analyzer); diff --git a/src/main/java/konogonka/Controllers/XCI/Hfs0TableViewController.java b/src/main/java/konogonka/Controllers/XCI/Hfs0TableViewController.java index 8e887bf..e72bdc8 100644 --- a/src/main/java/konogonka/Controllers/XCI/Hfs0TableViewController.java +++ b/src/main/java/konogonka/Controllers/XCI/Hfs0TableViewController.java @@ -157,13 +157,8 @@ public class Hfs0TableViewController implements Initializable { } }); - uploadColumn.setCellFactory(new Callback, TableCell>() { - @Override - public TableCell call(TableColumn paramFeatures) { - CheckBoxTableCell cell = new CheckBoxTableCell<>(); - return cell; - } - }); + uploadColumn.setCellFactory(paramFeatures -> new CheckBoxTableCell<>()); + table.setRowFactory( // this shit is made to implement context menu. It's such a pain.. new Callback, TableRow>() { @Override @@ -185,16 +180,14 @@ public class Hfs0TableViewController implements Initializable { row.contextMenuProperty().bind( Bindings.when(Bindings.isNotNull(row.itemProperty())).then(contextMenu).otherwise((ContextMenu)null) ); - row.setOnMouseClicked(new EventHandler() { // Just.. don't ask.. - @Override - public void handle(MouseEvent mouseEvent) { - if (!row.isEmpty() && mouseEvent.getButton() == MouseButton.PRIMARY){ - Hfs0RowModel thisItem = row.getItem(); - thisItem.setMarkSelected(!thisItem.isMarkSelected()); - table.refresh(); - } - mouseEvent.consume(); + // Just.. don't ask.. + row.setOnMouseClicked(mouseEvent -> { + if (!row.isEmpty() && mouseEvent.getButton() == MouseButton.PRIMARY){ + Hfs0RowModel thisItem = row.getItem(); + thisItem.setMarkSelected(!thisItem.isMarkSelected()); + table.refresh(); } + mouseEvent.consume(); }); return row; } diff --git a/src/main/java/konogonka/Controllers/XCI/XCIController.java b/src/main/java/konogonka/Controllers/XCI/XCIController.java index 93f06b8..5bbf695 100644 --- a/src/main/java/konogonka/Controllers/XCI/XCIController.java +++ b/src/main/java/konogonka/Controllers/XCI/XCIController.java @@ -117,9 +117,9 @@ public class XCIController implements ITabController { public void analyze(File selectedFile){ HFSBlockController.setSelectedFile(selectedFile); - Task analyzer = Analyzer.analyzeXCI(selectedFile, AppPreferences.getInstance().getXciHeaderKey()); + Task analyzer = Analyzer.analyzeXCI(selectedFile, AppPreferences.getInstance().getXciHeaderKey()); analyzer.setOnSucceeded(e->{ - populateFields((XCIProvider) analyzer.getValue()); + populateFields(analyzer.getValue()); }); Thread workThread = new Thread(analyzer); workThread.setDaemon(true); diff --git a/src/main/java/konogonka/Settings/SettingsWindow.java b/src/main/java/konogonka/Settings/SettingsWindow.java index 608ac99..dd1026c 100644 --- a/src/main/java/konogonka/Settings/SettingsWindow.java +++ b/src/main/java/konogonka/Settings/SettingsWindow.java @@ -27,6 +27,7 @@ import konogonka.MainFx; import java.io.IOException; import java.util.Locale; +import java.util.Objects; import java.util.ResourceBundle; public class SettingsWindow { @@ -50,10 +51,10 @@ public class SettingsWindow { stageSettings.setTitle(resourceBundle.getString("settings_SettingsName")); stageSettings.getIcons().addAll( - new Image(MainFx.class.getResourceAsStream("/res/settings_icon32x32.png")), - new Image(MainFx.class.getResourceAsStream("/res/settings_icon48x48.png")), - new Image(MainFx.class.getResourceAsStream("/res/settings_icon64x64.png")), - new Image(MainFx.class.getResourceAsStream("/res/settings_icon128x128.png")) + new Image(Objects.requireNonNull(MainFx.class.getResourceAsStream("/res/settings_icon32x32.png"))), + new Image(Objects.requireNonNull(MainFx.class.getResourceAsStream("/res/settings_icon48x48.png"))), + new Image(Objects.requireNonNull(MainFx.class.getResourceAsStream("/res/settings_icon64x64.png"))), + new Image(Objects.requireNonNull(MainFx.class.getResourceAsStream("/res/settings_icon128x128.png"))) ); Scene settingsScene = new Scene(parentAbout, 800, 800); diff --git a/src/main/java/konogonka/Workers/Analyzer.java b/src/main/java/konogonka/Workers/Analyzer.java index 605d0f6..2ed48d4 100644 --- a/src/main/java/konogonka/Workers/Analyzer.java +++ b/src/main/java/konogonka/Workers/Analyzer.java @@ -25,7 +25,7 @@ import libKonogonka.Tools.ISuperProvider; import libKonogonka.Tools.NCA.NCAProvider; import libKonogonka.Tools.NPDM.NPDMProvider; import libKonogonka.Tools.PFS0.PFS0Provider; -import libKonogonka.Tools.RomFs.RomFsDecryptedProvider; +import libKonogonka.Tools.RomFs.RomFsProvider; import libKonogonka.Tools.TIK.TIKProvider; import libKonogonka.Tools.XCI.XCIProvider; @@ -161,14 +161,14 @@ public class Analyzer { }; } - public static Task analyzeRomFS(File file, long lv6offset){ + public static Task analyzeRomFS(File file, long lv6offset){ LogPrinter logPrinter = new LogPrinter(); - return new Task() { + return new Task() { @Override - protected RomFsDecryptedProvider call() { + protected RomFsProvider call() { logPrinter.print("\tStart chain: RomFS", EMsgType.INFO); try { - return new RomFsDecryptedProvider(file, lv6offset); + return new RomFsProvider(file, lv6offset); } catch (Exception e) { logPrinter.print(e.getMessage(), EMsgType.FAIL); return null;