diff --git a/pom.xml b/pom.xml
index 21352e0..b90c7c4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
NS-USBloader
ns-usbloader
- 7.0
+ 7.1-SNAPSHOT
https://redrise.ru
NS multi-tool
diff --git a/src/main/java/nsusbloader/AppPreferences.java b/src/main/java/nsusbloader/AppPreferences.java
index dfe8e49..9d59e44 100644
--- a/src/main/java/nsusbloader/AppPreferences.java
+++ b/src/main/java/nsusbloader/AppPreferences.java
@@ -18,6 +18,8 @@
*/
package nsusbloader;
+import javafx.scene.text.Font;
+
import java.util.Locale;
import java.util.prefs.Preferences;
@@ -28,6 +30,7 @@ public class AppPreferences {
private final Preferences preferences;
private final Locale locale;
public static final String[] goldleafSupportedVersions = {"v0.5", "v0.7.x", "v0.8-0.9", "v0.10"};
+ private static final Font DEFAULT_FONT = Font.getDefault();
private AppPreferences(){
this.preferences = Preferences.userRoot().node("NS-USBloader");
@@ -152,4 +155,17 @@ public class AppPreferences {
public void setPatchesTabInvisible(boolean value){preferences.putBoolean("patches_tab_visible", value);}
public String getPatchPattern(String type, int moduleNumber, int offsetId){ return preferences.get(String.format("%s_%02x_%02x", type, moduleNumber, offsetId), ""); }
public void setPatchPattern(String fullTypeSpecifier, String offset){ preferences.put(fullTypeSpecifier, offset); }
+
+ public String getFontFamily(){ return preferences.get("font_family", DEFAULT_FONT.getFamily()); }
+ public double getFontSize(){ return preferences.getDouble("font_size", DEFAULT_FONT.getSize()); }
+ public String getFontStyle(){
+ final String fontFamily = preferences.get("font_family", DEFAULT_FONT.getFamily());
+ final double fontSize = preferences.getDouble("font_size", DEFAULT_FONT.getSize());
+
+ return String.format("-fx-font-family: \"%s\"; -fx-font-size: %.0f;", fontFamily, fontSize);
+ }
+ public void setFontStyle(String fontFamily, double size){
+ preferences.put("font_family", fontFamily);
+ preferences.putDouble("font_size", size);
+ }
}
diff --git a/src/main/java/nsusbloader/Controllers/FilesDropHandle.java b/src/main/java/nsusbloader/Controllers/FilesDropHandle.java
index f66be03..29f4482 100644
--- a/src/main/java/nsusbloader/Controllers/FilesDropHandle.java
+++ b/src/main/java/nsusbloader/Controllers/FilesDropHandle.java
@@ -87,6 +87,7 @@ public class FilesDropHandle {
Scene mainScene = new Scene(parentVBox, 310, 185);
mainScene.getStylesheets().add(AppPreferences.getInstance().getTheme());
+ parentVBox.setStyle(AppPreferences.getInstance().getFontStyle());
stage.setOnHidden(windowEvent -> filesDropHandleTask.cancel(true ) );
diff --git a/src/main/java/nsusbloader/Controllers/FontSelector.java b/src/main/java/nsusbloader/Controllers/FontSelector.java
new file mode 100644
index 0000000..5f4a0dc
--- /dev/null
+++ b/src/main/java/nsusbloader/Controllers/FontSelector.java
@@ -0,0 +1,56 @@
+/*
+ Copyright 2019-2023 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 javafx.fxml.FXMLLoader;
+import javafx.scene.Parent;
+import javafx.scene.Scene;
+import javafx.scene.image.Image;
+import javafx.stage.Stage;
+import nsusbloader.AppPreferences;
+
+import java.util.ResourceBundle;
+
+public class FontSelector {
+ public FontSelector(ResourceBundle resourceBundle) throws Exception{
+ Stage stage = new Stage();
+ stage.setMinWidth(800);
+ stage.setMinHeight(800);
+
+ FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/FontSettings.fxml"));
+ fxmlLoader.setResources(resourceBundle);
+
+ stage.setTitle(resourceBundle.getString("tab2_Btn_ApplicationFont"));
+ stage.getIcons().addAll(
+ new Image("/res/app_icon32x32.png"),
+ new Image("/res/app_icon48x48.png"),
+ new Image("/res/app_icon64x64.png"),
+ new Image("/res/app_icon128x128.png"));
+
+ Parent parent = fxmlLoader.load();
+ Scene fontScene = new Scene(parent, 550, 600);
+
+ fontScene.getStylesheets().add(AppPreferences.getInstance().getTheme());
+ parent.setStyle(AppPreferences.getInstance().getFontStyle());
+
+ stage.setAlwaysOnTop(true);
+ stage.setScene(fontScene);
+ stage.show();
+ }
+}
diff --git a/src/main/java/nsusbloader/Controllers/FontSettingsController.java b/src/main/java/nsusbloader/Controllers/FontSettingsController.java
new file mode 100644
index 0000000..0f7f14c
--- /dev/null
+++ b/src/main/java/nsusbloader/Controllers/FontSettingsController.java
@@ -0,0 +1,153 @@
+/*
+ Copyright 2019-2023 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 javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+import javafx.fxml.FXML;
+import javafx.fxml.Initializable;
+import javafx.scene.control.*;
+import javafx.scene.text.Font;
+import javafx.scene.text.Text;
+import javafx.stage.Stage;
+import nsusbloader.AppPreferences;
+import nsusbloader.MediatorControl;
+
+import java.net.URL;
+import java.util.ResourceBundle;
+
+public class FontSettingsController implements Initializable {
+ private final AppPreferences preferences = AppPreferences.getInstance();
+
+ @FXML
+ private Button applyBtn, cancelBtn, resetBtn;
+
+ @FXML
+ private ListView fontsLv;
+
+ @FXML
+ private Spinner fontSizeSpinner;
+
+ @FXML
+ private Text exampleText;
+
+ @Override
+ public void initialize(URL url, ResourceBundle resourceBundle) {
+ applyBtn.setDefaultButton(true);
+ applyBtn.getStyleClass().add("buttonUp");
+ applyBtn.setOnAction(e -> applyChanges());
+
+ cancelBtn.setCancelButton(true);
+ cancelBtn.setOnAction(e -> closeWindow());
+
+ resetBtn.setOnAction(e -> reset());
+
+ fontsLv.setCellFactory(item -> getCellFactory());
+ fontsLv.setItems(getFonts());
+ fontsLv.getSelectionModel().select(preferences.getFontFamily());
+ fontsLv.getSelectionModel().selectedIndexProperty().addListener(
+ (observableValue, oldValueNumber, newValueNumber) -> setExampleTextFont());
+ fontsLv.setFixedCellSize(40.0);
+
+ fontSizeSpinner.setEditable(false);
+ fontSizeSpinner.setValueFactory(getValueFactory());
+
+ exampleText.setText(resourceBundle.getString("fontPreviewText"));
+
+ fontSizeSpinner.getValueFactory().setValue(preferences.getFontSize());
+ }
+
+ private ListCell getCellFactory(){
+ return new ListCell<>(){
+ @Override
+ protected void updateItem(String item, boolean empty) {
+ super.updateItem(item, empty);
+ if (empty || item == null)
+ return;
+ Font font = Font.font(item);
+ Text itemText = new Text(item);
+ itemText.setFont(font);
+ setGraphic(itemText);
+ }
+ };
+ }
+
+ private ObservableList getFonts(){
+ ObservableList fonts = FXCollections.observableArrayList();
+ fonts.addAll(Font.getFamilies());
+
+ return fonts;
+ }
+
+ private SpinnerValueFactory getValueFactory(){
+ return new SpinnerValueFactory<>() {
+ @Override
+ public void decrement(int i) {
+ double value = getValue() - i;
+ if (value < 4)
+ return;
+
+ setValue(value);
+ setExampleTextFont(value);
+ }
+
+ @Override
+ public void increment(int i) {
+ double value = getValue() + i;
+ if (value > 100)
+ return;
+
+ setValue(value);
+ setExampleTextFont(value);
+ }
+ };
+ }
+
+ private void setExampleTextFont(){
+ setExampleTextFont(fontsLv.getSelectionModel().getSelectedItem(), fontSizeSpinner.getValue());
+ }
+ private void setExampleTextFont(double size){
+ setExampleTextFont(fontsLv.getSelectionModel().getSelectedItem(), size);
+ }
+ private void setExampleTextFont(String font, double size){
+ exampleText.setFont(Font.font(font, size));
+ }
+
+ private void reset(){
+ final Font defaultFont = Font.getDefault();
+ exampleText.setFont(defaultFont);
+
+ fontsLv.getSelectionModel().select(defaultFont.getFamily());
+ fontSizeSpinner.getValueFactory().setValue(defaultFont.getSize());
+ }
+
+ private void applyChanges(){
+ final String fontFamily = fontsLv.getSelectionModel().getSelectedItem();
+ final double fontSize = fontSizeSpinner.getValue().intValue();
+
+ preferences.setFontStyle(fontFamily, fontSize);
+ MediatorControl.getInstance().updateApplicationFont(fontFamily, fontSize);
+
+ closeWindow();
+ }
+
+ private void closeWindow(){
+ ((Stage) cancelBtn.getScene().getWindow()).close();
+ }
+}
diff --git a/src/main/java/nsusbloader/Controllers/SettingsBlockGenericController.java b/src/main/java/nsusbloader/Controllers/SettingsBlockGenericController.java
index 95ef545..3cf3e0f 100644
--- a/src/main/java/nsusbloader/Controllers/SettingsBlockGenericController.java
+++ b/src/main/java/nsusbloader/Controllers/SettingsBlockGenericController.java
@@ -43,6 +43,9 @@ import java.util.ResourceBundle;
public class SettingsBlockGenericController implements Initializable {
@FXML
private ChoiceBox languagesChB;
+ @FXML
+ private Button fontSelectBtn;
+
@FXML
private Button submitLanguageBtn,
driversInstallBtn,
@@ -81,6 +84,14 @@ public class SettingsBlockGenericController implements Initializable {
newVersionHyperlink.setOnAction(e-> hostServices.showDocument(newVersionHyperlink.getText()));
checkForUpdBtn.setOnAction(e->checkForUpdatesAction());
submitLanguageBtn.setOnAction(e->languageButtonAction());
+ fontSelectBtn.setOnAction(e -> openFontSettings());
+ }
+ private void openFontSettings() {
+ try {
+ new FontSelector(resourceBundle);
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
}
private void setDriversInstallFeature(){
diff --git a/src/main/java/nsusbloader/MediatorControl.java b/src/main/java/nsusbloader/MediatorControl.java
index b15b409..a73b239 100644
--- a/src/main/java/nsusbloader/MediatorControl.java
+++ b/src/main/java/nsusbloader/MediatorControl.java
@@ -60,4 +60,8 @@ public class MediatorControl {
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));
+ }
}
diff --git a/src/main/java/nsusbloader/NSLMain.java b/src/main/java/nsusbloader/NSLMain.java
index 040b5bc..fa40c9a 100644
--- a/src/main/java/nsusbloader/NSLMain.java
+++ b/src/main/java/nsusbloader/NSLMain.java
@@ -62,6 +62,7 @@ public class NSLMain extends Application {
);
mainScene.getStylesheets().add(AppPreferences.getInstance().getTheme());
+ root.setStyle(AppPreferences.getInstance().getFontStyle());
primaryStage.setScene(mainScene);
primaryStage.show();
diff --git a/src/main/java/nsusbloader/ServiceWindow.java b/src/main/java/nsusbloader/ServiceWindow.java
index 0565448..3355a32 100644
--- a/src/main/java/nsusbloader/ServiceWindow.java
+++ b/src/main/java/nsusbloader/ServiceWindow.java
@@ -44,7 +44,6 @@ public class ServiceWindow {
alertBox.getDialogPane().setMinWidth(Region.USE_PREF_SIZE);
alertBox.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
alertBox.setResizable(true); // Java bug workaround for JDR11/OpenJFX. TODO: nothing. really.
- alertBox.getDialogPane().getStylesheets().add(AppPreferences.getInstance().getTheme());
Stage dialogStage = (Stage) alertBox.getDialogPane().getScene().getWindow();
dialogStage.setAlwaysOnTop(true);
@@ -54,6 +53,9 @@ public class ServiceWindow {
new Image("/res/warn_ico64x64.png"),
new Image("/res/warn_ico128x128.png")
);
+ alertBox.getDialogPane().getStylesheets().add(AppPreferences.getInstance().getTheme());
+ dialogStage.getScene().getRoot().setStyle(AppPreferences.getInstance().getFontStyle());
+
alertBox.show();
dialogStage.toFront();
}
@@ -68,7 +70,6 @@ public class ServiceWindow {
alertBox.getDialogPane().setMinWidth(Region.USE_PREF_SIZE);
alertBox.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
alertBox.setResizable(true); // Java bug workaround for JDR11/OpenJFX. TODO: nothing. really.
- alertBox.getDialogPane().getStylesheets().add(AppPreferences.getInstance().getTheme());
Stage dialogStage = (Stage) alertBox.getDialogPane().getScene().getWindow();
dialogStage.setAlwaysOnTop(true);
@@ -78,6 +79,10 @@ public class ServiceWindow {
new Image("/res/ask_ico64x64.png"),
new Image("/res/ask_ico128x128.png")
);
+
+ alertBox.getDialogPane().getStylesheets().add(AppPreferences.getInstance().getTheme());
+ dialogStage.getScene().getRoot().setStyle(AppPreferences.getInstance().getFontStyle());
+
dialogStage.toFront();
Optional result = alertBox.showAndWait();
diff --git a/src/main/java/nsusbloader/Utilities/WindowsDrivers/DriversInstall.java b/src/main/java/nsusbloader/Utilities/WindowsDrivers/DriversInstall.java
index 5c5aa36..cdc7cad 100644
--- a/src/main/java/nsusbloader/Utilities/WindowsDrivers/DriversInstall.java
+++ b/src/main/java/nsusbloader/Utilities/WindowsDrivers/DriversInstall.java
@@ -103,6 +103,7 @@ public class DriversInstall {
Scene mainScene = new Scene(parentVBox, 405, 155);
mainScene.getStylesheets().add(AppPreferences.getInstance().getTheme());
+ parentVBox.setStyle(AppPreferences.getInstance().getFontStyle());
stage.setOnHidden(windowEvent -> {
downloadTask.cancel(true );
diff --git a/src/main/resources/FontSettings.fxml b/src/main/resources/FontSettings.fxml
new file mode 100644
index 0000000..b54ecae
--- /dev/null
+++ b/src/main/resources/FontSettings.fxml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/resources/NXDTab.fxml b/src/main/resources/NXDTab.fxml
index dd720f0..60c1741 100644
--- a/src/main/resources/NXDTab.fxml
+++ b/src/main/resources/NXDTab.fxml
@@ -12,21 +12,12 @@
-
-
+
-
-
+
+
diff --git a/src/main/resources/PatchesTab.fxml b/src/main/resources/PatchesTab.fxml
index 6daa977..24e1e6e 100644
--- a/src/main/resources/PatchesTab.fxml
+++ b/src/main/resources/PatchesTab.fxml
@@ -12,18 +12,13 @@
-
-
+
@@ -55,11 +50,7 @@
-
+
@@ -72,11 +63,7 @@
-
+
@@ -94,10 +81,7 @@
-
+
diff --git a/src/main/resources/RcmTab.fxml b/src/main/resources/RcmTab.fxml
index adb7750..85ff20b 100644
--- a/src/main/resources/RcmTab.fxml
+++ b/src/main/resources/RcmTab.fxml
@@ -14,18 +14,13 @@
-
-
+
-
+
@@ -57,11 +52,7 @@
-
+