Skip to content

Commit

Permalink
Refactor Implementations of #59 #60
Browse files Browse the repository at this point in the history
  • Loading branch information
isHarryh committed Feb 6, 2024
1 parent c2ae601 commit 3253706
Show file tree
Hide file tree
Showing 31 changed files with 1,131 additions and 1,298 deletions.
24 changes: 24 additions & 0 deletions .idea/GrepConsole.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions core/src/cn/harryh/arkpets/ArkPets.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
import cn.harryh.arkpets.animations.AnimData;
import cn.harryh.arkpets.animations.GeneralBehavior;
import cn.harryh.arkpets.assets.AssetItem;
import cn.harryh.arkpets.socket.SocketClient;
import cn.harryh.arkpets.concurrent.SocketClient;
import cn.harryh.arkpets.transitions.TernaryFunction;
import cn.harryh.arkpets.transitions.TransitionFloat;
import cn.harryh.arkpets.transitions.TransitionVector2;
import cn.harryh.arkpets.tray.MemberTrayImpl;
import cn.harryh.arkpets.utils.HWndCtrl;
import cn.harryh.arkpets.utils.Logger;
import cn.harryh.arkpets.utils.Plane;
Expand All @@ -32,7 +33,7 @@ public class ArkPets extends ApplicationAdapter implements InputProcessor {
public Plane plane;
public ArkChar cha;
public ArkConfig config;
public ArkTray tray;
public MemberTrayImpl tray;
public GeneralBehavior behavior;

public TransitionFloat windowAlpha; // Window Opacity Easing
Expand Down Expand Up @@ -88,7 +89,7 @@ public void create() {
ArkConfig.Monitor primaryMonitor = ArkConfig.Monitor.getMonitors()[0];
initWindow((int)(primaryMonitor.size[0] * 0.1f), (int)(primaryMonitor.size[0] * 0.1f));
// 5.Tray icon setup
tray = new ArkTray(this, new SocketClient(), UUID.randomUUID());
tray = new MemberTrayImpl(this, new SocketClient(), UUID.randomUUID());
// Setup complete
Logger.info("App", "Render");
}
Expand Down
254 changes: 0 additions & 254 deletions core/src/cn/harryh/arkpets/ArkTray.java

This file was deleted.

50 changes: 40 additions & 10 deletions core/src/cn/harryh/arkpets/Const.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@
*/
package cn.harryh.arkpets;

import cn.harryh.arkpets.utils.Logger;
import cn.harryh.arkpets.utils.Version;
import javafx.util.Duration;

import javax.swing.*;
import java.awt.*;
import java.io.IOException;
import java.io.InputStream;
import java.util.Objects;


/** Constants definition class.
*/
Expand Down Expand Up @@ -51,21 +58,23 @@ public final class Const {
public static final String configExternal = "ArkPetsConfig.json";
public static final String configInternal = "/ArkPetsConfigDefault.json";
public static final String iconFilePng = "/icons/icon.png";
public static final String fontFileRegular = "/fonts/SourceHanSansCN-Regular.otf";
public static final String fontFileBold = "/fonts/SourceHanSansCN-Bold.otf";
public static final String startupTarget = "ArkPets.exe";
public static final String startUpScript = "ArkPetsStartupService.vbs";

// Changeable constants
public static boolean isHttpsTrustAll = false;
public static boolean isUpdateAvailable = false;
public static boolean isHttpsTrustAll = false;
public static boolean isUpdateAvailable = false;
public static boolean isDatasetIncompatible = false;
public static boolean isNewcomer = false;
public static boolean isNewcomer = false;

// Socket C/S constants
public static final String serverHost = "localhost";
public static final int[] serverPorts = {8686, 8866, 8989, 8899, 8800};
public static final int reconnectPeriodMillis = 5 * 1000;

// Misc constants
public static String ipPortRegex = "^((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(25[0-5]|2[0-4]\\d|[01]?\\d\\d?):\\d{1,5}$";


/** Paths presets definition class.
*/
public static class PathConfig {
Expand Down Expand Up @@ -103,8 +112,29 @@ public static class LogConfig {
public static final String debugArg = "--debug";
}

// SocketServer Ports

public static final int[] serverPorts = {8686, 8866, 8989, 8899, 8800};

public static class FontsConfig {
private static final String fontFileRegular = "/fonts/SourceHanSansCN-Regular.otf";
private static final String fontFileBold = "/fonts/SourceHanSansCN-Bold.otf";

public static void loadFontsToJavafx() {
javafx.scene.text.Font.loadFont(FontsConfig.class.getResourceAsStream(fontFileRegular),
javafx.scene.text.Font.getDefault().getSize());
javafx.scene.text.Font.loadFont(FontsConfig.class.getResourceAsStream(fontFileBold),
javafx.scene.text.Font.getDefault().getSize());
}

public static void loadFontsToSwing() {
try {
InputStream in = Objects.requireNonNull(FontsConfig.class.getResourceAsStream(fontFileRegular));
java.awt.Font font = java.awt.Font.createFont(java.awt.Font.TRUETYPE_FONT, in);
if (font != null) {
UIManager.put("Label.font", font.deriveFont(10f).deriveFont(Font.ITALIC));
UIManager.put("Menu.font", font.deriveFont(11f));
UIManager.put("MenuItem.font", font.deriveFont(11f));
}
} catch (FontFormatException | IOException e) {
Logger.error("System", "Failed to load tray menu font, details see below.", e);
}
}
}
}
Loading

0 comments on commit 3253706

Please sign in to comment.