From 6d2d7ce56059fb4e5e6afa50e410099038af8e96 Mon Sep 17 00:00:00 2001 From: Harry Huang Date: Mon, 5 Jun 2023 13:11:41 +0800 Subject: [PATCH] Small Update --- core/src/cn/harryh/arkpets/Const.java | 14 +++++++++-- desktop/src/cn/harryh/arkpets/ArkHomeFX.java | 16 ++++++------ .../cn/harryh/arkpets/DesktopLauncher.java | 10 ++++---- .../cn/harryh/arkpets/EmbeddedLauncher.java | 10 ++++---- .../harryh/arkpets/controllers/Homepage.java | 25 +++++++------------ 5 files changed, 39 insertions(+), 36 deletions(-) diff --git a/core/src/cn/harryh/arkpets/Const.java b/core/src/cn/harryh/arkpets/Const.java index 28cdea5e..4ca3788c 100644 --- a/core/src/cn/harryh/arkpets/Const.java +++ b/core/src/cn/harryh/arkpets/Const.java @@ -50,7 +50,7 @@ public final class Const { public static final String charsetDefault = "UTF-8"; public static final String charsetVBS = "GBK"; - // Paths of static files + // Paths of static files and internal files public static final String configExternal = "ArkPetsConfig.json"; public static final String configInternal = "/ArkPetsConfigDefault.json"; public static final String iconFileIco = "/icons/icon.ico"; @@ -61,6 +61,8 @@ public final class Const { public static final String startUpScript = "ArkPetsStartupService.vbs"; + /** Paths presets definition class. + */ public static class PathConfig { public static final String urlApi = "https://arkpets.harryh.cn/p/arkpets/client/api.php"; public static final String urlOfficial = "https://arkpets.harryh.cn/p/arkpets/?from=client"; @@ -76,7 +78,15 @@ public static class PathConfig { } - public static class LogLevels { + /** Logging preset definition class. + */ + public static class LogConfig { + public static final int logCoreMaxKeep = 32; + public static final int logDesktopMaxKeep = 8; + + public static final String logCorePath = "logs/core"; + public static final String logDesktopPath = "logs/desktop"; + public static final String error = "ERROR"; public static final String warn = "WARN"; public static final String info = "INFO"; diff --git a/desktop/src/cn/harryh/arkpets/ArkHomeFX.java b/desktop/src/cn/harryh/arkpets/ArkHomeFX.java index 53f86c11..4f311bf2 100644 --- a/desktop/src/cn/harryh/arkpets/ArkHomeFX.java +++ b/desktop/src/cn/harryh/arkpets/ArkHomeFX.java @@ -96,15 +96,15 @@ public void startArkPets() { protected Boolean call() throws IOException, InterruptedException { // Renew the logging level arg to match the custom value of the Launcher. ArrayList args = new ArrayList<>(Arrays.asList(ArgPending.argCache.clone())); - args.remove(LogLevels.errorArg); - args.remove(LogLevels.warnArg); - args.remove(LogLevels.infoArg); - args.remove(LogLevels.debugArg); + args.remove(LogConfig.errorArg); + args.remove(LogConfig.warnArg); + args.remove(LogConfig.infoArg); + args.remove(LogConfig.debugArg); String temp = switch (ctrl.config.logging_level) { - case LogLevels.error -> LogLevels.errorArg; - case LogLevels.warn -> LogLevels.warnArg; - case LogLevels.info -> LogLevels.infoArg; - case LogLevels.debug -> LogLevels.debugArg; + case LogConfig.error -> LogConfig.errorArg; + case LogConfig.warn -> LogConfig.warnArg; + case LogConfig.info -> LogConfig.infoArg; + case LogConfig.debug -> LogConfig.debugArg; default -> ""; }; args.add(temp); diff --git a/desktop/src/cn/harryh/arkpets/DesktopLauncher.java b/desktop/src/cn/harryh/arkpets/DesktopLauncher.java index fc4cd28a..59b54651 100644 --- a/desktop/src/cn/harryh/arkpets/DesktopLauncher.java +++ b/desktop/src/cn/harryh/arkpets/DesktopLauncher.java @@ -19,27 +19,27 @@ public class DesktopLauncher { public static void main (String[] args) { ArgPending.argCache = args; // Logger - Logger.initialize("logs/desktop", 8); + Logger.initialize(LogConfig.logDesktopPath, LogConfig.logDesktopMaxKeep); try { Logger.setLevel(Objects.requireNonNull(ArkConfig.getConfig()).logging_level); } catch (Exception ignored) { } - new ArgPending(LogLevels.errorArg, args) { + new ArgPending(LogConfig.errorArg, args) { protected void process(String command, String addition) { Logger.setLevel(Logger.ERROR); } }; - new ArgPending(LogLevels.warnArg, args) { + new ArgPending(LogConfig.warnArg, args) { protected void process(String command, String addition) { Logger.setLevel(Logger.WARN); } }; - new ArgPending(LogLevels.infoArg, args) { + new ArgPending(LogConfig.infoArg, args) { protected void process(String command, String addition) { Logger.setLevel(Logger.INFO); } }; - new ArgPending(LogLevels.debugArg, args) { + new ArgPending(LogConfig.debugArg, args) { protected void process(String command, String addition) { Logger.setLevel(Logger.DEBUG); } diff --git a/desktop/src/cn/harryh/arkpets/EmbeddedLauncher.java b/desktop/src/cn/harryh/arkpets/EmbeddedLauncher.java index 4c8a8ec1..c7a29e0e 100644 --- a/desktop/src/cn/harryh/arkpets/EmbeddedLauncher.java +++ b/desktop/src/cn/harryh/arkpets/EmbeddedLauncher.java @@ -28,27 +28,27 @@ public class EmbeddedLauncher { public static void main (String[] args) { ArgPending.argCache = args; // Logger - Logger.initialize("logs/core", 32); + Logger.initialize(LogConfig.logCorePath, LogConfig.logCoreMaxKeep); try { Logger.setLevel(Objects.requireNonNull(ArkConfig.getConfig()).logging_level); } catch (Exception ignored) { } - new ArgPending(LogLevels.errorArg, args) { + new ArgPending(LogConfig.errorArg, args) { protected void process(String command, String addition) { Logger.setLevel(Logger.ERROR); } }; - new ArgPending(LogLevels.warnArg, args) { + new ArgPending(LogConfig.warnArg, args) { protected void process(String command, String addition) { Logger.setLevel(Logger.WARN); } }; - new ArgPending(LogLevels.infoArg, args) { + new ArgPending(LogConfig.infoArg, args) { protected void process(String command, String addition) { Logger.setLevel(Logger.INFO); } }; - new ArgPending(LogLevels.debugArg, args) { + new ArgPending(LogConfig.debugArg, args) { protected void process(String command, String addition) { Logger.setLevel(Logger.DEBUG); } diff --git a/desktop/src/cn/harryh/arkpets/controllers/Homepage.java b/desktop/src/cn/harryh/arkpets/controllers/Homepage.java index a33172f8..805bb4a7 100644 --- a/desktop/src/cn/harryh/arkpets/controllers/Homepage.java +++ b/desktop/src/cn/harryh/arkpets/controllers/Homepage.java @@ -7,8 +7,6 @@ import cn.harryh.arkpets.utils.*; import cn.harryh.arkpets.ArkConfig; import com.alibaba.fastjson.JSONObject; -import com.badlogic.gdx.Graphics; -import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration; import com.jfoenix.controls.*; import org.apache.log4j.Level; @@ -400,7 +398,7 @@ private void initModelManage() { } private void initConfigAdvanced() { - configLoggingLevel.getItems().setAll(LogLevels.debug, LogLevels.info, LogLevels.warn, LogLevels.error); + configLoggingLevel.getItems().setAll(LogConfig.debug, LogConfig.info, LogConfig.warn, LogConfig.error); configLoggingLevel.valueProperty().addListener(observable -> { if (configLoggingLevel.getValue() != null) { Logger.setLevel(Level.toLevel(configLoggingLevel.getValue(), Level.INFO)); @@ -410,14 +408,14 @@ private void initConfigAdvanced() { }); String level = config.logging_level; List args = Arrays.asList(ArgPending.argCache); - if (args.contains(LogLevels.errorArg)) - level = LogLevels.error; - else if (args.contains(LogLevels.warnArg)) - level = LogLevels.warn; - else if (args.contains(LogLevels.infoArg)) - level = LogLevels.info; - else if (args.contains(LogLevels.debugArg)) - level = LogLevels.debug; + if (args.contains(LogConfig.errorArg)) + level = LogConfig.error; + else if (args.contains(LogConfig.warnArg)) + level = LogConfig.warn; + else if (args.contains(LogConfig.infoArg)) + level = LogConfig.info; + else if (args.contains(LogConfig.debugArg)) + level = LogConfig.debug; configLoggingLevel.getSelectionModel().select(level); exploreLogDir.setOnMouseClicked(e -> { @@ -1205,11 +1203,6 @@ private boolean assertModelLoaded(boolean $doPopNotice) { } } - private static int[] getDefaultMonitorInfo() { - Graphics.DisplayMode displayMode = Lwjgl3ApplicationConfiguration.getDisplayMode(); - return new int[] {displayMode.width, displayMode.height, displayMode.refreshRate, displayMode.bitsPerPixel}; - } - private static void fadeInNode(Node $node, Duration $duration, EventHandler $onFinished) { FadeTransition fadeT = new FadeTransition($duration, $node); $node.setVisible(true);