66import cn .harryh .arkpets .platform .HWndCtrl .NumberedTitleManager ;
77import cn .harryh .arkpets .utils .Logger ;
88import cn .harryh .arkpets .utils .Version ;
9- import com .sun .jna .Platform ;
10- import javafx .util .Duration ;
119
1210import javax .swing .*;
1311import java .awt .*;
@@ -49,11 +47,6 @@ public final class Const {
4947 public static final int behaviorBaseWeight = 320 ;
5048 public static final float droppedThreshold = 10f ;
5149
52- // Duration presets
53- public static final Duration durationFast = new Duration (150 );
54- public static final Duration durationNormal = new Duration (300 );
55- public static final Duration durationLong = new Duration (1500 );
56-
5750 // Encoding presets
5851 public static final String charsetDefault = "UTF-8" ;
5952
@@ -78,11 +71,11 @@ public final class Const {
7871 public static final int reconnectDelayMillis = 5 * 1000 ;
7972
8073 // Platform constants
81- public static boolean isWindows = Platform . isWindows () ;
82- public static boolean isMac = Platform . isMac () ;
83- public static boolean isLinux = Platform . isLinux () ;
84- public static boolean isIntel = Platform . isIntel () ;
85- public static boolean isARM = Platform . isARM () ;
74+ public static boolean isWindows ;
75+ public static boolean isMac ;
76+ public static boolean isLinux ;
77+ public static boolean isIntel ;
78+ public static boolean isARM ;
8679
8780 // Misc constants
8881 public static final Pattern ipPortRegex = Pattern .compile (
@@ -101,6 +94,28 @@ public final class Const {
10194 public static final String gnomePluginName = "arkpets-integration@harryh.cn" ;
10295 public static final String kdePluginName = "ArkPetsIntegration" ;
10396
97+ static {
98+ String osName = System .getProperty ("os.name" );
99+ String arch = System .getProperty ("os.arch" ).toLowerCase ().trim ();
100+ if ("i386" .equals (arch ) || "i686" .equals (arch )) {
101+ arch = "x86" ;
102+ } else if ("x86_64" .equals (arch ) || "amd64" .equals (arch )) {
103+ arch = "x86-64" ;
104+ }
105+ if (arch .startsWith ("x86" )) {
106+ isIntel = true ;
107+ } if (arch .startsWith ("arm" ) || arch .startsWith ("aarch" )) {
108+ isARM = true ;
109+ }
110+ if (osName .startsWith ("Linux" )) {
111+ isLinux = true ;
112+ } else if (osName .startsWith ("Mac" ) || osName .startsWith ("Darwin" )) {
113+ isMac = true ;
114+ } else if (osName .startsWith ("Windows" )) {
115+ isWindows = true ;
116+ }
117+ }
118+
104119 /** Paths presets definition class.
105120 */
106121 public static class PathConfig {
@@ -142,20 +157,13 @@ public static class LogConfig {
142157 /** Fonts provider class.
143158 */
144159 public static class FontsConfig {
145- private static final String fontFileRegular = "/fonts/SourceHanSansCN-Regular.otf" ;
146- private static final String fontFileBold = "/fonts/SourceHanSansCN-Bold.otf" ;
147-
148- public static void loadFontsToJavafx () {
149- javafx .scene .text .Font .loadFont (FontsConfig .class .getResourceAsStream (fontFileRegular ),
150- javafx .scene .text .Font .getDefault ().getSize ());
151- javafx .scene .text .Font .loadFont (FontsConfig .class .getResourceAsStream (fontFileBold ),
152- javafx .scene .text .Font .getDefault ().getSize ());
153- }
160+ public static final String fontFileRegular = "/fonts/SourceHanSansCN-Regular.otf" ;
161+ public static final String fontFileBold = "/fonts/SourceHanSansCN-Bold.otf" ;
154162
155163 public static void loadFontsToSwing () {
156164 try {
157165 InputStream in = Objects .requireNonNull (FontsConfig .class .getResourceAsStream (fontFileRegular ));
158- java . awt . Font font = java . awt . Font .createFont (java . awt . Font .TRUETYPE_FONT , in );
166+ Font font = Font .createFont (Font .TRUETYPE_FONT , in );
159167 if (font != null ) {
160168 UIManager .put ("Label.font" , font .deriveFont (10f ).deriveFont (Font .ITALIC ));
161169 UIManager .put ("Menu.font" , font .deriveFont (11f ));
0 commit comments