Skip to content

Commit

Permalink
Small Update
Browse files Browse the repository at this point in the history
  • Loading branch information
isHarryh committed Jun 5, 2023
1 parent 2aef47e commit 6d2d7ce
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 36 deletions.
14 changes: 12 additions & 2 deletions core/src/cn/harryh/arkpets/Const.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
Expand All @@ -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";
Expand Down
16 changes: 8 additions & 8 deletions desktop/src/cn/harryh/arkpets/ArkHomeFX.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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);
Expand Down
10 changes: 5 additions & 5 deletions desktop/src/cn/harryh/arkpets/DesktopLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
10 changes: 5 additions & 5 deletions desktop/src/cn/harryh/arkpets/EmbeddedLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
25 changes: 9 additions & 16 deletions desktop/src/cn/harryh/arkpets/controllers/Homepage.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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));
Expand All @@ -410,14 +408,14 @@ private void initConfigAdvanced() {
});
String level = config.logging_level;
List<String> 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 -> {
Expand Down Expand Up @@ -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<ActionEvent> $onFinished) {
FadeTransition fadeT = new FadeTransition($duration, $node);
$node.setVisible(true);
Expand Down

0 comments on commit 6d2d7ce

Please sign in to comment.