From 9afe07491c0cc65c5173310e26ea1a1c80bc4529 Mon Sep 17 00:00:00 2001 From: litwak913 Date: Mon, 16 Sep 2024 07:51:50 +0800 Subject: [PATCH 1/9] feat: add window system settings --- assets/ArkPetsConfigDefault.json | 3 ++- core/src/cn/harryh/arkpets/ArkConfig.java | 2 ++ .../harryh/arkpets/platform/WindowSystem.java | 18 ++++++++++++++++-- .../cn/harryh/arkpets/EmbeddedLauncher.java | 13 ++++++++++--- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/assets/ArkPetsConfigDefault.json b/assets/ArkPetsConfigDefault.json index d9677978..c29566c1 100644 --- a/assets/ArkPetsConfigDefault.json +++ b/assets/ArkPetsConfigDefault.json @@ -33,5 +33,6 @@ "transition_duration":0.3, "transition_type":"EASE_OUT_CUBIC", "window_style_toolwindow":true, - "window_style_topmost":true + "window_style_topmost":true, + "window_system":0 } \ No newline at end of file diff --git a/core/src/cn/harryh/arkpets/ArkConfig.java b/core/src/cn/harryh/arkpets/ArkConfig.java index aea4c781..504913f3 100644 --- a/core/src/cn/harryh/arkpets/ArkConfig.java +++ b/core/src/cn/harryh/arkpets/ArkConfig.java @@ -100,6 +100,8 @@ public class ArkConfig implements Serializable { public boolean window_style_toolwindow; /** @since ArkPets 3.2 */ @JSONField(defaultValue = "true") public boolean window_style_topmost; + /** @since ArkPets 3.3 */ @JSONField(defaultValue = "0") + public int window_system; private ArkConfig() { } diff --git a/core/src/cn/harryh/arkpets/platform/WindowSystem.java b/core/src/cn/harryh/arkpets/platform/WindowSystem.java index abfa11c6..9ad0638c 100644 --- a/core/src/cn/harryh/arkpets/platform/WindowSystem.java +++ b/core/src/cn/harryh/arkpets/platform/WindowSystem.java @@ -41,10 +41,24 @@ public static WindowSystem detectWindowSystem() { } /** Initializes the platform window system. + * @param platform WindowSystem to initialize. */ - public static void init() { - PLATFORM = detectWindowSystem(); + public static void init(WindowSystem platform) { + PLATFORM = platform; + if (PLATFORM == WindowSystem.AUTO){ + PLATFORM = detectWindowSystem(); + } Logger.info("System", "Using " + PLATFORM.toString() + " Window System"); + switch (PLATFORM) { + // TODO + } + } + + /** Get current WindowSystem. + * @return The current WindowSystem. + */ + public static WindowSystem getWindowSystem() { + return PLATFORM; } /** Finds a window. diff --git a/desktop/src/cn/harryh/arkpets/EmbeddedLauncher.java b/desktop/src/cn/harryh/arkpets/EmbeddedLauncher.java index 70776e5d..191f65f9 100644 --- a/desktop/src/cn/harryh/arkpets/EmbeddedLauncher.java +++ b/desktop/src/cn/harryh/arkpets/EmbeddedLauncher.java @@ -82,15 +82,22 @@ protected void process(String command, String addition) { Logger.info("System", "Entering the app of EmbeddedLauncher"); Logger.info("System", "ArkPets version is " + appVersion); Logger.debug("System", "Default charset is " + Charset.defaultCharset()); - + ArkConfig appConfig = Objects.requireNonNull(ArkConfig.getConfig(), "ArkConfig returns a null instance, please check the config file."); + WindowSystem windowSystem; + try { + windowSystem = WindowSystem.values()[appConfig.window_system]; + } catch (ArrayIndexOutOfBoundsException e) { + Logger.warn("System", "Invalid window system,using auto detect"); + windowSystem = WindowSystem.AUTO; + } try { - WindowSystem.init(); + WindowSystem.init(windowSystem); Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration(); // Configure FPS config.setForegroundFPS(fpsDefault); config.setIdleFPS(fpsDefault); // Configure window layout - config.setDecorated(false); + config.setDecorated(WindowSystem.getWindowSystem() == WindowSystem.NULL); config.setResizable(false); config.setWindowedMode(coreWidthDefault, coreHeightDefault); config.setWindowPosition(0, 0); From 49069e05d7bdb5d43e41e8d43e8bdfb79e9bd41a Mon Sep 17 00:00:00 2001 From: litwak913 Date: Mon, 16 Sep 2024 08:12:29 +0800 Subject: [PATCH 2/9] feat(SettingsModule): window system settings ui --- assets/UI/SettingsModule.fxml | 5 ++ .../arkpets/controllers/SettingsModule.java | 62 +++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/assets/UI/SettingsModule.fxml b/assets/UI/SettingsModule.fxml index 08992c70..6910c8a9 100644 --- a/assets/UI/SettingsModule.fxml +++ b/assets/UI/SettingsModule.fxml @@ -116,6 +116,11 @@ + +