Skip to content

Commit

Permalink
0.3.4 - Added configuration system and minor fixes:
Browse files Browse the repository at this point in the history
        - Fixed firmware installation issue (old firmware files are now properly removed to prevent installation conflicts).
        - Updated settings menu: added DevMode option to redirect logs to a file in the application's root directory.
  • Loading branch information
Miroshka000 committed Nov 15, 2024
1 parent 0e56261 commit dc8cb32
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 20 deletions.
6 changes: 2 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ tasks.named<JavaExec>("run") {
jvmArgs = listOf(
"--module-path", configurations.runtimeClasspath.get().joinToString(";"),
"--add-modules", "javafx.controls,javafx.fxml,jdk.crypto.cryptoki",
"-Dapp.version=${project.version}",
"-Dfile.encoding=UTF-8"
"-Dapp.version=${project.version}"
)
}

Expand All @@ -55,8 +54,7 @@ jlink {
jvmArgs = listOf(
"--add-modules", "javafx.controls,javafx.fxml",
"--module-path", configurations.runtimeClasspath.get().asPath,
"-Dapp.version=${project.version}",
"-Dfile.encoding=UTF-8"
"-Dapp.version=${project.version}"
)
}

Expand Down
1 change: 0 additions & 1 deletion src/main/java/miroshka/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ private void onWindowClose() {
Platform.exit();
}


private void initializeApp() {
configManager = new ConfigManager();
String savedLanguage = configManager.getConfigValue("language", "ru");
Expand Down
12 changes: 4 additions & 8 deletions src/main/java/miroshka/config/ConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@ public class ConfigManager {
private static final String CONFIG_FILE_PATH;

static {
File jarFile = null;
try {
jarFile = new File(ConfigManager.class.getProtectionDomain().getCodeSource().getLocation().toURI());
} catch (Exception e) {
throw new RuntimeException(e);
}
String executableDir = jarFile.getParent();
String executableDir = System.getProperty("user.dir");
CONFIG_FILE_PATH = executableDir + File.separator + "miroshka_config.properties";
}

Expand Down Expand Up @@ -44,6 +38,7 @@ public void loadConfig() {
}
}
} catch (IOException e) {
e.printStackTrace();
}
}

Expand All @@ -65,9 +60,10 @@ public void saveConfig() {
}

try (OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8)) {
properties.store(writer, "Конфигурация");
properties.store(writer, "Config");
}
} catch (IOException e) {
e.printStackTrace();
}
}

Expand Down
13 changes: 7 additions & 6 deletions src/main/java/miroshka/controller/UIController.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,14 @@ private void onDevModeToggle() {

private void startLoggingToFile() {
try {
File jarFile = new File(ConfigManager.class.getProtectionDomain().getCodeSource().getLocation().toURI());
String executableDir = jarFile.getParent();
String executableDir = System.getProperty("user.dir");

File logFile = new File(executableDir, "log.txt");
File logFile = new File(executableDir + File.separator + "logs" + File.separator + "log.txt");

File parentDir = logFile.getParentFile();
if (parentDir != null && !parentDir.exists()) {
parentDir.mkdirs();
}

fileStream = new PrintStream(new FileOutputStream(logFile, true), true, StandardCharsets.UTF_8);

Expand All @@ -179,12 +183,9 @@ private void startLoggingToFile() {
System.out.println("Dev Mode enabled: Logs will be saved to " + logFile.getPath());
} catch (IOException e) {
e.printStackTrace();
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}


private void stopLoggingToFile() {
if (fileStream != null) {
fileStream.close();
Expand Down
1 change: 0 additions & 1 deletion src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

requires java.net.http;
requires java.desktop;
requires java.logging;

opens miroshka.controller to javafx.fxml;

Expand Down

0 comments on commit dc8cb32

Please sign in to comment.