diff --git a/application-main/pom.xml b/application-main/pom.xml
index 603b950..48be01c 100644
--- a/application-main/pom.xml
+++ b/application-main/pom.xml
@@ -21,9 +21,15 @@
- com.zyneonstudios
- nexus-zyndex
- 2024.8
+ com.zyneonstudios.nexus
+ zyndex-java
+ 2024.8.2
+ compile
+
+
+ com.zyneonstudios.nexus
+ base-desktop
+ 2024.9-alpha.5
compile
diff --git a/application-main/src/main/java/com/zyneonstudios/Main.java b/application-main/src/main/java/com/zyneonstudios/Main.java
index 300e361..a02d8b8 100644
--- a/application-main/src/main/java/com/zyneonstudios/Main.java
+++ b/application-main/src/main/java/com/zyneonstudios/Main.java
@@ -2,7 +2,7 @@
import com.zyneonstudios.application.frame.ZyneonSplash;
import com.zyneonstudios.application.main.NexusApplication;
-
+import com.zyneonstudios.nexus.desktop.NexusDesktop;
import java.net.MalformedURLException;
public class Main {
@@ -10,6 +10,7 @@ public class Main {
public static ZyneonSplash splash = null;
public static void main(String[] args) throws MalformedURLException {
+ NexusDesktop.init();
splash = new ZyneonSplash();
splash.setVisible(true);
NexusApplication application = new NexusApplication(args);
diff --git a/application-main/src/main/java/com/zyneonstudios/application/download/Download.java b/application-main/src/main/java/com/zyneonstudios/application/download/Download.java
index 73b45d8..bcce3e9 100644
--- a/application-main/src/main/java/com/zyneonstudios/application/download/Download.java
+++ b/application-main/src/main/java/com/zyneonstudios/application/download/Download.java
@@ -95,7 +95,7 @@ public boolean start() {
setFinished(true);
} catch (IOException e) {
state = DownloadManager.DownloadState.FAILED;
- NexusApplication.getLogger().error("Couldn't download \""+url+"\" to \""+path.toString()+"\": " + e.getMessage());
+ NexusApplication.getLogger().err("Couldn't download \""+url+"\" to \""+path.toString()+"\": " + e.getMessage());
return false;
}
return true;
diff --git a/application-main/src/main/java/com/zyneonstudios/application/frame/FrameConnector.java b/application-main/src/main/java/com/zyneonstudios/application/frame/FrameConnector.java
index 6c32769..d5a91f6 100644
--- a/application-main/src/main/java/com/zyneonstudios/application/frame/FrameConnector.java
+++ b/application-main/src/main/java/com/zyneonstudios/application/frame/FrameConnector.java
@@ -27,9 +27,9 @@ public FrameConnector(ApplicationFrame frame,NexusApplication application) {
public void resolveRequest(String request) {
if(ApplicationStorage.test) {
- NexusApplication.getLogger().error("[CONNECTOR] (Request-Reader) resolving "+request+"...");
+ NexusApplication.getLogger().err("[CONNECTOR] (Request-Reader) resolving "+request+"...");
} else {
- NexusApplication.getLogger().debug("[CONNECTOR] (Request-Reader) resolving "+request+"...");
+ NexusApplication.getLogger().dbg("[CONNECTOR] (Request-Reader) resolving "+request+"...");
}
if(request.startsWith("sync.")) {
diff --git a/application-main/src/main/java/com/zyneonstudios/application/frame/web/ApplicationFrame.java b/application-main/src/main/java/com/zyneonstudios/application/frame/web/ApplicationFrame.java
index aa38271..66931b7 100644
--- a/application-main/src/main/java/com/zyneonstudios/application/frame/web/ApplicationFrame.java
+++ b/application-main/src/main/java/com/zyneonstudios/application/frame/web/ApplicationFrame.java
@@ -3,6 +3,8 @@
import com.zyneonstudios.application.frame.FrameConnector;
import com.zyneonstudios.application.main.ApplicationStorage;
import com.zyneonstudios.application.main.NexusApplication;
+import com.zyneonstudios.nexus.desktop.frame.web.NexusWebFrame;
+import org.cef.CefClient;
import org.cef.CefSettings;
import org.cef.browser.CefBrowser;
import org.cef.browser.CefFrame;
@@ -10,22 +12,29 @@
import org.cef.handler.CefLoadHandler;
import org.cef.network.CefRequest;
+import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.util.Objects;
import java.util.concurrent.CompletableFuture;
@SuppressWarnings("unused")
-public class ApplicationFrame extends WebFrame implements ComponentListener {
+public class ApplicationFrame extends NexusWebFrame implements ComponentListener {
private final FrameConnector connector;
private final Dimension minSize = new Dimension(640,360);
- public ApplicationFrame(NexusApplication application, String url, String jcefPath) {
- super(url, jcefPath, application);
+ public ApplicationFrame(NexusApplication application, String url, CefClient client) {
+ super(client, url, true);
+ try {
+ setIconImage(ImageIO.read(Objects.requireNonNull(getClass().getResource("/logo.png"))).getScaledInstance(32, 32, Image.SCALE_SMOOTH));
+ } catch (Exception ignore) {}
addComponentListener(this);
this.connector = new FrameConnector(this,application);
- getClient().addDisplayHandler(new CefDisplayHandlerAdapter() {
+ client.addDisplayHandler(new CefDisplayHandlerAdapter() {
@Override
public boolean onConsoleMessage(CefBrowser browser, CefSettings.LogSeverity level, String message, String source, int line) {
if (message.startsWith("[CONNECTOR] ")) {
@@ -36,16 +45,22 @@ public boolean onConsoleMessage(CefBrowser browser, CefSettings.LogSeverity leve
} else if (message.startsWith("[LOG] ")) {
NexusApplication.getLogger().log(message.replace("[LOG] ",""));
} else if (message.startsWith("[ERR] ")) {
- NexusApplication.getLogger().error(message.replace("[ERR] ",""));
+ NexusApplication.getLogger().err(message.replace("[ERR] ",""));
} else if (message.startsWith("[DEB] ")) {
- NexusApplication.getLogger().debug(message.replace("[DEB] ",""));
+ NexusApplication.getLogger().dbg(message.replace("[DEB] ",""));
} else {
- NexusApplication.getLogger().debug("[FRAME] (Console) "+message);
+ NexusApplication.getLogger().dbg("[FRAME] (Console) "+message);
}
return super.onConsoleMessage(browser, level, message, source, line);
}
});
- getClient().addLoadHandler(new CefLoadHandler() {
+ addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowClosing(WindowEvent e) {
+ NexusApplication.stop();
+ }
+ });
+ client.addLoadHandler(new CefLoadHandler() {
@Override
public void onLoadingStateChange(CefBrowser cefBrowser, boolean b, boolean b1, boolean b2) {
@@ -86,6 +101,12 @@ public void setTitlebar(String title, Color background, Color foreground) {
setTitleForeground(foreground);
}
+ @Override
+ public void setTitleColors(Color background, Color foreground) {
+ setBackground(background);
+ super.setTitleColors(background, foreground);
+ }
+
public void setTitleBackground(Color color) {
setBackground(color);
getRootPane().putClientProperty("JRootPane.titleBarBackground", color);
@@ -95,14 +116,14 @@ public void setTitleForeground(Color color) {
getRootPane().putClientProperty("JRootPane.titleBarForeground", color);
}
- public void executeJavaScript(String command) {
- getBrowser().executeJavaScript(command,getBrowser().getURL(),5);
- }
-
public void openCustomPage(String title, String pageId, String url) {
getBrowser().loadURL(ApplicationStorage.urlBase+ ApplicationStorage.language+"/custom.html?title="+title+"&id="+pageId+"&url="+url);
}
+ public void executeJavaScript(String script) {
+ super.executeJavaScript(script);
+ }
+
@Override
public void componentResized(ComponentEvent e) {
double zoomLevel = ApplicationStorage.getZoomLevel();
diff --git a/application-main/src/main/java/com/zyneonstudios/application/frame/web/CustomApplicationFrame.java b/application-main/src/main/java/com/zyneonstudios/application/frame/web/CustomApplicationFrame.java
index 9ab018e..d2d6f06 100644
--- a/application-main/src/main/java/com/zyneonstudios/application/frame/web/CustomApplicationFrame.java
+++ b/application-main/src/main/java/com/zyneonstudios/application/frame/web/CustomApplicationFrame.java
@@ -2,6 +2,7 @@
import com.zyneonstudios.application.main.ApplicationStorage;
import com.zyneonstudios.application.main.NexusApplication;
+import org.cef.CefClient;
import javax.swing.*;
import java.awt.*;
@@ -15,8 +16,8 @@ public class CustomApplicationFrame extends ApplicationFrame {
private JPanel titleBar;
private boolean border;
- public CustomApplicationFrame(NexusApplication application, String url, String jcefPath) {
- super(application,url,jcefPath);
+ public CustomApplicationFrame(NexusApplication application, String url, CefClient client) {
+ super(application,url,client);
setUndecorated(true);
title = " Zyneon Application (v"+ ApplicationStorage.getApplicationVersion()+", "+ ApplicationStorage.getOS()+")";
JPanel customTitleBar = createCustomTitleBar();
diff --git a/application-main/src/main/java/com/zyneonstudios/application/frame/web/WebFrame.java b/application-main/src/main/java/com/zyneonstudios/application/frame/web/WebFrame.java
deleted file mode 100644
index 461a023..0000000
--- a/application-main/src/main/java/com/zyneonstudios/application/frame/web/WebFrame.java
+++ /dev/null
@@ -1,146 +0,0 @@
-package com.zyneonstudios.application.frame.web;
-
-import com.zyneonstudios.application.main.ApplicationStorage;
-import com.zyneonstudios.application.main.NexusApplication;
-import live.nerotv.shademebaby.ShadeMeBaby;
-import me.friwi.jcefmaven.CefAppBuilder;
-import me.friwi.jcefmaven.CefInitializationException;
-import me.friwi.jcefmaven.MavenCefAppHandlerAdapter;
-import me.friwi.jcefmaven.UnsupportedPlatformException;
-import org.cef.CefApp;
-import org.cef.CefClient;
-import org.cef.CefSettings;
-import org.cef.browser.CefBrowser;
-import org.cef.browser.CefMessageRouter;
-import org.cef.callback.CefBeforeDownloadCallback;
-import org.cef.callback.CefDownloadItem;
-import org.cef.callback.CefDownloadItemCallback;
-import org.cef.handler.CefDownloadHandler;
-import org.cef.handler.CefFocusHandlerAdapter;
-
-import javax.imageio.ImageIO;
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.io.File;
-import java.io.IOException;
-import java.net.URI;
-import java.util.Objects;
-
-@SuppressWarnings("unused")
-public class WebFrame extends JFrame {
-
- private CefApp app;
- private CefClient client;
- private CefBrowser browser;
- private boolean browserFocus;
-
- public WebFrame(String url, String jcefPath, NexusApplication application) {
- try {
- init(url, jcefPath, application);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public CefApp getApp() {
- return app;
- }
-
- public WebFrame getInstance() {
- return this;
- }
-
- public CefClient getClient() {
- return client;
- }
-
- public CefBrowser getBrowser() {
- return browser;
- }
-
- private void init(String url, String jcefPath, NexusApplication application) throws UnsupportedPlatformException, IOException, CefInitializationException, InterruptedException {
- browserFocus = true;
- File installDir = new File(jcefPath);
- ShadeMeBaby.getLogger().debug("[WEBFRAME] Is jCef installed: "+!installDir.mkdirs());
- CefAppBuilder builder = new CefAppBuilder();
- builder.setAppHandler(new MavenCefAppHandlerAdapter() {
- @Override @Deprecated
- public void stateHasChanged(CefApp.CefAppState state) {
- if (state == CefApp.CefAppState.TERMINATED) {
- NexusApplication.stop();
- }
- if(!ApplicationStorage.getOS().startsWith("Windows")) {
- if(state == CefApp.CefAppState.SHUTTING_DOWN) {
- NexusApplication.stop();
- }
- }
- }
- });
- setIconImage(ImageIO.read(Objects.requireNonNull(getClass().getResource("/logo.png"))).getScaledInstance(32, 32, Image.SCALE_SMOOTH));
- builder.getCefSettings().cache_path = (jcefPath+"/cache").replace("\\\\","\\").replace("//","/");
- builder.getCefSettings().log_severity = CefSettings.LogSeverity.LOGSEVERITY_DISABLE;
- builder.getCefSettings().persist_session_cookies = true;
- builder.setInstallDir(installDir);
- builder.install();
- builder.getCefSettings().windowless_rendering_enabled = false;
- app = builder.build();
-
- client = app.createClient();
- client.addDownloadHandler(new CefDownloadHandler() {
- @Override
- public boolean onBeforeDownload(CefBrowser browser, CefDownloadItem item, String sourceURL, CefBeforeDownloadCallback callback) {
- if(Desktop.isDesktopSupported()) {
- try {
- Desktop.getDesktop().browse(new URI(item.getURL()));
- } catch (Exception ignore) {}
- }
- return false;
- }
-
- @Override
- public void onDownloadUpdated(CefBrowser cefBrowser, CefDownloadItem cefDownloadItem, CefDownloadItemCallback cefDownloadItemCallback) {
- // Downloadfortschrittsaktualisierungen behandeln (optional)
- }
- });
- CefMessageRouter messageRouter = CefMessageRouter.create();
- if(client==null) {
- NexusApplication.getLogger().error("[WEBFRAME] Couldn't initialize WebFrame: CefClient client can't be null!");
- System.exit(-1); return;
- }
- client.addMessageRouter(messageRouter);
- browser = client.createBrowser(url, false, false);
- client.addDragHandler((cefBrowser, dragData, i) -> dragData.isFile());
- if(browser==null) {
- NexusApplication.getLogger().error("[WEBFRAME] Couldn't initialize WebFrame: CefBrowser browser can't be null!");
- System.exit(-1); return;
- }
- Component ui = browser.getUIComponent();
- client.addFocusHandler(new CefFocusHandlerAdapter() {
- @Override
- public void onGotFocus(CefBrowser browser) {
- if (browserFocus) return;
- browserFocus = true;
- KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
- browser.setFocus(true);
- }
- @Override
- public void onTakeFocus(CefBrowser browser, boolean next) {
- browserFocus = false;
- }
- });
- getContentPane().add(ui,BorderLayout.CENTER);
- addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- CefApp.getInstance().dispose();
- dispose();
- }
- });
- }
-
- public void executeJavaScript(String command) {
- browser.executeJavaScript(command,browser.getURL(),5);
- }
-}
diff --git a/application-main/src/main/java/com/zyneonstudios/application/main/ApplicationRunner.java b/application-main/src/main/java/com/zyneonstudios/application/main/ApplicationRunner.java
index 249d165..2bb7c93 100644
--- a/application-main/src/main/java/com/zyneonstudios/application/main/ApplicationRunner.java
+++ b/application-main/src/main/java/com/zyneonstudios/application/main/ApplicationRunner.java
@@ -5,10 +5,9 @@
import com.zyneonstudios.application.download.Download;
import com.zyneonstudios.application.download.DownloadManager;
import com.zyneonstudios.application.frame.web.ApplicationFrame;
-import live.nerotv.shademebaby.utils.GsonUtil;
+import com.zyneonstudios.nexus.utilities.json.GsonUtility;
import java.util.UUID;
-import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@@ -119,7 +118,7 @@ protected void run() {
}
try {
- JsonObject json = new Gson().fromJson(GsonUtil.getFromURL("https://raw.githubusercontent.com/zyneonstudios/nexus-nex/main/application/index.json"), JsonObject.class).getAsJsonArray("versions").get(0).getAsJsonObject();
+ JsonObject json = new Gson().fromJson(GsonUtility.getFromURL("https://raw.githubusercontent.com/zyneonstudios/nexus-nex/main/application/index.json"), JsonObject.class).getAsJsonArray("versions").get(0).getAsJsonObject();
checkVersion(json);
} catch (Exception ignore) {
}
@@ -127,13 +126,13 @@ protected void run() {
private boolean runUpdateCheck(JsonObject json) {
if (!ApplicationStorage.test) {
- NexusApplication.getLogger().debug("[RUNNER] Checking for Updates...");
- NexusApplication.getLogger().debug("[RUNNER] Parsed JSON Data...");
+ NexusApplication.getLogger().dbg("[RUNNER] Checking for Updates...");
+ NexusApplication.getLogger().dbg("[RUNNER] Parsed JSON Data...");
String v = json.get("info").getAsJsonObject().get("version").getAsString();
- NexusApplication.getLogger().debug("[RUNNER] Latest version: " + v + "...");
- NexusApplication.getLogger().debug("[RUNNER] Current version: " + version + "...");
+ NexusApplication.getLogger().dbg("[RUNNER] Latest version: " + v + "...");
+ NexusApplication.getLogger().dbg("[RUNNER] Current version: " + version + "...");
if (!v.equals(version)) {
- NexusApplication.getLogger().debug("[RUNNER] The application is not up to date!");
+ NexusApplication.getLogger().dbg("[RUNNER] The application is not up to date!");
return true;
}
}
@@ -145,7 +144,7 @@ private void checkVersion(JsonObject json) {
if (u > 120) {
u = 0;
if (runUpdateCheck(json)) {
- NexusApplication.getLogger().debug("[RUNNER] Sending notification...");
+ NexusApplication.getLogger().dbg("[RUNNER] Sending notification...");
//TODO: Application.getFrame().sendNotification("Update available!", "Version " + v + " has been released!", "InstallDynamic update", v, true);
}
}
diff --git a/application-main/src/main/java/com/zyneonstudios/application/main/ApplicationStorage.java b/application-main/src/main/java/com/zyneonstudios/application/main/ApplicationStorage.java
index 3402a58..431e58b 100644
--- a/application-main/src/main/java/com/zyneonstudios/application/main/ApplicationStorage.java
+++ b/application-main/src/main/java/com/zyneonstudios/application/main/ApplicationStorage.java
@@ -2,9 +2,10 @@
import com.zyneonstudios.Main;
import com.zyneonstudios.application.frame.web.ApplicationFrame;
-import live.nerotv.shademebaby.file.Config;
-import live.nerotv.shademebaby.utils.FileUtil;
-import live.nerotv.shademebaby.utils.StringUtil;
+import com.zyneonstudios.nexus.utilities.file.FileActions;
+import com.zyneonstudios.nexus.utilities.file.FileExtractor;
+import com.zyneonstudios.nexus.utilities.storage.JsonStorage;
+import com.zyneonstudios.nexus.utilities.strings.StringGenerator;
import java.io.File;
import java.net.HttpURLConnection;
@@ -27,12 +28,12 @@ public record ApplicationStorage(String[] args, NexusApplication app) {
public static String theme = "automatic";
public static boolean test = false;
private static UUID applicationId = UUID.randomUUID();
- private static String applicationVersion = StringUtil.generateAlphanumericString(6)+"-"+StringUtil.generateAlphanumericString(3);
+ private static String applicationVersion = StringGenerator.generateAlphanumericString(6)+"-"+StringGenerator.generateAlphanumericString(3);
private static String applicationName = "Unofficial NEXUS App";
private static String applicationPath = null;
- private static Config configuration = null;
+ private static JsonStorage configuration = null;
private static String os = null;
- private static Config updateConfig = null;
+ private static JsonStorage updateConfig = null;
private static String[] arguments = null;
private static boolean driveAccess = false;
private static NexusApplication application = null;
@@ -47,7 +48,7 @@ public ApplicationStorage(String[] args, NexusApplication app) {
for (String arg : args) {
if(arg.startsWith("--test")) {
test = true;
- NexusApplication.getLogger().setDebugEnabled(true);
+ NexusApplication.getLogger().enableDebug();
} else if (arg.startsWith("--ui:")) {
urlBase = arg.replace("--ui:", "");
}
@@ -56,8 +57,8 @@ else if(arg.startsWith("--path:")) {
}
}
- FileUtil.extractResourceFile("nexus.json",getApplicationPath()+"temp/nexus.json", Main.class);
- Config properties = new Config(new File(getApplicationPath() + "temp/nexus.json"));
+ FileExtractor.extractResourceFile("nexus.json",getApplicationPath()+"temp/nexus.json", Main.class);
+ JsonStorage properties = new JsonStorage(new File(getApplicationPath() + "temp/nexus.json"));
if (properties.getString("version") != null) {
applicationVersion = properties.getString("version");
@@ -69,23 +70,23 @@ else if(arg.startsWith("--path:")) {
if(new File(getApplicationPath() + "temp/").exists()) {
try {
- FileUtil.deleteFolder(new File(getApplicationPath() + "temp/"));
+ FileActions.deleteFolder(new File(getApplicationPath() + "temp/"));
} catch (Exception e) {
- NexusApplication.getLogger().error("[CONFIG] Couldn't delete old temp files: "+e.getMessage());
+ NexusApplication.getLogger().err("[CONFIG] Couldn't delete old temp files: "+e.getMessage());
}
}
if(new File(getApplicationPath() + "temp/nexus.json").exists()) {
- NexusApplication.getLogger().debug("[CONFIG] Deleted old properties: "+new File(getApplicationPath() + "temp/nexus.json").delete());
+ NexusApplication.getLogger().dbg("[CONFIG] Deleted old properties: "+new File(getApplicationPath() + "temp/nexus.json").delete());
}
String lang = Locale.getDefault().toLanguageTag();
if(lang.startsWith("de-")) {
- getSettings().checkEntry("settings.language","de");
+ getSettings().ensure("settings.language","de");
} else {
- getSettings().checkEntry("settings.language","en");
+ getSettings().ensure("settings.language","en");
}
- getSettings().checkEntry("settings.applicationId", applicationId);
+ getSettings().ensure("settings.applicationId", applicationId);
applicationId = UUID.fromString(getSettings().getString("settings.applicationId"));
if(getSettings().get("settings.startPage")!=null) {
@@ -98,7 +99,7 @@ else if(arg.startsWith("--path:")) {
theme = getSettings().getString("settings.theme");
}
- configuration.checkEntry("settings.general.appearance.zoomLevel",0);
+ configuration.ensure("settings.general.appearance.zoomLevel",0);
zoomLevel = configuration.getDouble("settings.general.appearance.zoomLevel");
}
@@ -190,16 +191,16 @@ public static String getOS() {
return os;
}
- public static Config getSettings() {
+ public static JsonStorage getSettings() {
if(configuration==null) {
- configuration = new Config(getApplicationPath()+"config/settings.json");
+ configuration = new JsonStorage(getApplicationPath()+"config/settings.json");
}
return configuration;
}
- public static Config getUpdateSettings() {
+ public static JsonStorage getUpdateSettings() {
if(updateConfig==null) {
- updateConfig = new Config(ApplicationStorage.getApplicationPath().replace("\\\\","\\").replace("\\","/").replace("/experimental/","/")+"libs/zyneon/updater.json");
+ updateConfig = new JsonStorage(ApplicationStorage.getApplicationPath().replace("\\\\","\\").replace("\\","/").replace("/experimental/","/")+"libs/zyneon/updater.json");
}
return updateConfig;
}
diff --git a/application-main/src/main/java/com/zyneonstudios/application/main/NexusApplication.java b/application-main/src/main/java/com/zyneonstudios/application/main/NexusApplication.java
index 087882c..32397f8 100644
--- a/application-main/src/main/java/com/zyneonstudios/application/main/NexusApplication.java
+++ b/application-main/src/main/java/com/zyneonstudios/application/main/NexusApplication.java
@@ -1,6 +1,5 @@
package com.zyneonstudios.application.main;
-import com.formdev.flatlaf.FlatDarkLaf;
import com.google.gson.JsonObject;
import com.zyneonstudios.Main;
import com.zyneonstudios.application.download.Download;
@@ -8,9 +7,13 @@
import com.zyneonstudios.application.frame.web.ApplicationFrame;
import com.zyneonstudios.application.frame.web.CustomApplicationFrame;
import com.zyneonstudios.application.modules.ModuleLoader;
-import live.nerotv.shademebaby.logger.Logger;
-import live.nerotv.shademebaby.utils.FileUtil;
-import live.nerotv.shademebaby.utils.GsonUtil;
+import com.zyneonstudios.nexus.desktop.frame.web.NexusWebSetup;
+import com.zyneonstudios.nexus.utilities.file.FileActions;
+import com.zyneonstudios.nexus.utilities.file.FileExtractor;
+import com.zyneonstudios.nexus.utilities.json.GsonUtility;
+import com.zyneonstudios.nexus.utilities.logger.NexusLogger;
+import me.friwi.jcefmaven.MavenCefAppHandlerAdapter;
+import org.cef.CefApp;
import javax.swing.*;
import java.awt.*;
@@ -25,17 +28,13 @@
public class NexusApplication {
private final JFrame frame;
- private static final Logger logger = new Logger("APP");
+ private static final NexusLogger logger = new NexusLogger("APP");
private static ModuleLoader moduleLoader = null;
private final ApplicationRunner runner;
private final DownloadManager downloadManager;
public NexusApplication(String[] args) {
- try {
- FlatDarkLaf.setup();
- UIManager.setLookAndFeel(new FlatDarkLaf());
- } catch (Exception ignore) {}
new ApplicationStorage(args,this);
moduleLoader = new ModuleLoader(this);
logger.log("[APP] Updated application ui: "+update());
@@ -60,17 +59,33 @@ public NexusApplication(String[] args) {
ApplicationStorage.getSettings().delete("cache.restartPage");
} catch (Exception ignore) {}
}
+ NexusWebSetup setup = new NexusWebSetup(ApplicationStorage.getApplicationPath()+"libraries/cef");
+ setup.getBuilder().setAppHandler(new MavenCefAppHandlerAdapter() {
+ @Override @Deprecated
+ public void stateHasChanged(CefApp.CefAppState state) {
+ if (state == CefApp.CefAppState.TERMINATED) {
+ NexusApplication.stop();
+ }
+ if(!ApplicationStorage.getOS().startsWith("Windows")) {
+ if(state == CefApp.CefAppState.SHUTTING_DOWN) {
+ NexusApplication.stop();
+ }
+ }
+ }
+ });
+ setup.enableCache(true); setup.enableCookies(true); setup.setup();
+
if(ApplicationStorage.getOS().startsWith("macOS")|| ApplicationStorage.getOS().startsWith("Windows")||disableCustomFrame) {
- frame = new ApplicationFrame(this, ApplicationStorage.urlBase + ApplicationStorage.language + "/" + startPage, ApplicationStorage.getApplicationPath() + "libs/jcef/");
+ frame = new ApplicationFrame(this, ApplicationStorage.urlBase + ApplicationStorage.language + "/" + startPage, setup.getWebClient());
frame.pack(); frame.setSize(new Dimension(1200,720));
} else {
JFrame frame_ = null;
try {
- frame_ = new CustomApplicationFrame(this, ApplicationStorage.urlBase + ApplicationStorage.language + "/" + startPage, ApplicationStorage.getApplicationPath() + "libs/jcef/");
+ frame_ = new CustomApplicationFrame(this, ApplicationStorage.urlBase + ApplicationStorage.language + "/" + startPage, setup.getWebClient());
frame_.pack(); frame_.setSize(new Dimension(1080,660));
} catch (Exception e) {
- logger.error("[APP] Couldn't load custom Linux frame: "+e.getMessage());
- logger.error("[APP] Disabling custom Linux frame and restarting...");
+ logger.err("[APP] Couldn't load custom Linux frame: "+e.getMessage());
+ logger.err("[APP] Disabling custom Linux frame and restarting...");
ApplicationStorage.getSettings().set("settings.linux.customFrame",false);
restart(false);
}
@@ -95,12 +110,12 @@ public NexusApplication(String[] args) {
try {
moduleLoader.loadModule(moduleLoader.readModule(module));
} catch (Exception e) {
- getLogger().debug("[APP] Cant read module "+module.getName()+": "+e.getMessage());
+ logger.dbg("[APP] Cant read module "+module.getName()+": "+e.getMessage());
}
}
}
} catch (Exception e) {
- getLogger().error("[APP] Can't read modules: "+e.getMessage());
+ logger.err("[APP] Can't read modules: "+e.getMessage());
}
}
}
@@ -114,7 +129,7 @@ public ApplicationRunner getRunner() {
return runner;
}
- public static Logger getLogger() {
+ public static NexusLogger getLogger() {
return logger;
}
@@ -132,9 +147,9 @@ private boolean update() {
File temp = new File(ApplicationStorage.getApplicationPath() + "temp");
if(temp.exists()) {
if(temp.isDirectory()) {
- FileUtil.deleteFolder(temp);
+ logger.dbg("[APP] Deleted temporary files: "+FileActions.deleteFolder(temp));
} else {
- logger.debug("[APP] Deleted temporary files: "+temp.delete());
+ logger.dbg("[APP] Deleted temporary files: "+temp.delete());
}
}
@@ -143,22 +158,22 @@ private boolean update() {
try {
if(new File(ApplicationStorage.getApplicationPath() + "temp/ui/").exists()) {
try {
- FileUtil.deleteFolder(new File(ApplicationStorage.getApplicationPath() + "temp/ui/"));
+ FileActions.deleteFolder(new File(ApplicationStorage.getApplicationPath() + "temp/ui/"));
} catch (Exception e) {
- getLogger().error("Couldn't delete old temporary ui files: "+e.getMessage());
+ logger.err("Couldn't delete old temporary ui files: "+e.getMessage());
}
}
- logger.debug("[APP] Created new ui path: "+new File(ApplicationStorage.getApplicationPath() + "temp/ui/").mkdirs());
- FileUtil.extractResourceFile("content.zip", ApplicationStorage.getApplicationPath()+"temp/content.zip",Main.class);
- FileUtil.unzipFile(ApplicationStorage.getApplicationPath()+"temp/content.zip", ApplicationStorage.getApplicationPath() + "temp/ui");
- logger.debug("[APP] Deleted ui archive: "+new File(ApplicationStorage.getApplicationPath()+"temp/content.zip").delete());
+ logger.dbg("[APP] Created new ui path: "+new File(ApplicationStorage.getApplicationPath() + "temp/ui/").mkdirs());
+ FileExtractor.extractResourceFile("content.zip", ApplicationStorage.getApplicationPath()+"temp/content.zip",Main.class);
+ FileExtractor.unzipFile(ApplicationStorage.getApplicationPath()+"temp/content.zip", ApplicationStorage.getApplicationPath() + "temp/ui");
+ logger.dbg("[APP] Deleted ui archive: "+new File(ApplicationStorage.getApplicationPath()+"temp/content.zip").delete());
updated = true;
} catch (Exception e) {
- logger.error("[APP] Couldn't update application user interface: "+e.getMessage());
+ logger.err("[APP] Couldn't update application user interface: "+e.getMessage());
updated = false;
}
- logger.debug("[APP] Deleted old updatar json: "+new File(ApplicationStorage.getApplicationPath() + "updater.json").delete());
- logger.debug("[APP] Deleted older updater json: "+new File(ApplicationStorage.getApplicationPath() + "version.json").delete());
+ logger.dbg("[APP] Deleted old updatar json: "+new File(ApplicationStorage.getApplicationPath() + "updater.json").delete());
+ logger.dbg("[APP] Deleted older updater json: "+new File(ApplicationStorage.getApplicationPath() + "version.json").delete());
return updated;
}
@@ -170,9 +185,9 @@ private boolean updateModules() {
boolean updated = false;
File modules = new File(ApplicationStorage.getApplicationPath() + "temp/modules/");
if (modules.exists()) {
- FileUtil.deleteFolder(modules);
+ FileActions.deleteFolder(modules);
}
- logger.debug("[APP] Created modules path: " + modules.mkdirs());
+ logger.dbg("[APP] Created modules path: " + modules.mkdirs());
if(!ApplicationStorage.isOffline()) {
try {
@@ -186,17 +201,17 @@ private boolean updateModules() {
updated = true;
} catch (Exception e) {
- logger.error("[APP] Couldn't update online modules: "+e.getMessage());
+ logger.err("[APP] Couldn't update online modules: "+e.getMessage());
}
}
if(!updated) {
try {
- FileUtil.extractResourceFile("modules.zip", ApplicationStorage.getApplicationPath() + "temp/modules.zip", NexusApplication.class);
- FileUtil.unzipFile(ApplicationStorage.getApplicationPath() + "temp/modules.zip", ApplicationStorage.getApplicationPath() + "temp/modules/");
- logger.debug("[APP] Deleted modules archive: " + new File(ApplicationStorage.getApplicationPath() + "temp/modules.zip").delete());
+ FileExtractor.extractResourceFile("modules.zip", ApplicationStorage.getApplicationPath() + "temp/modules.zip", NexusApplication.class);
+ FileExtractor.unzipFile(ApplicationStorage.getApplicationPath() + "temp/modules.zip", ApplicationStorage.getApplicationPath() + "temp/modules/");
+ logger.dbg("[APP] Deleted modules archive: " + new File(ApplicationStorage.getApplicationPath() + "temp/modules.zip").delete());
} catch (Exception e) {
- logger.error("[APP] Couldn't extract fallback modules: " + e.getMessage());
+ logger.err("[APP] Couldn't extract fallback modules: " + e.getMessage());
}
}
@@ -207,7 +222,7 @@ private boolean updateModules() {
try {
moduleLoader.loadModule(moduleLoader.readModule(module));
} catch (Exception e) {
- getLogger().error("Couldn't load module " + module.getName() + ": " + e.getMessage());
+ getLogger().err("Couldn't load module " + module.getName() + ": " + e.getMessage());
}
}
}
@@ -218,7 +233,7 @@ private boolean updateModules() {
}
private void downloadModule(String jsonUrl, File folder, ArrayList blacklist) throws MalformedURLException {
- JsonObject module = GsonUtil.getObject(jsonUrl).getAsJsonObject("module");
+ JsonObject module = GsonUtility.getObject(jsonUrl).getAsJsonObject("module");
String id = module.getAsJsonObject("meta").get("id").getAsString();
if(!blacklist.contains(id)) {
Download download = new Download(id+".jar",new URL(module.getAsJsonObject("meta").get("download").getAsString()), Path.of(folder.getAbsolutePath()+"/"+id+".jar"));
@@ -257,7 +272,7 @@ public void restart(boolean soft) {
try {
pb.start();
} catch (Exception e) {
- logger.error("[APP] Couldn't restart application: "+e.getMessage());
+ logger.err("[APP] Couldn't restart application: "+e.getMessage());
}
getModuleLoader().deactivateModules();
System.exit(0);
@@ -285,7 +300,7 @@ public void restart(boolean soft) {
try {
pb.start();
} catch (Exception e) {
- logger.error("[APP] Couldn't restart application: " + e.getMessage());
+ logger.err("[APP] Couldn't restart application: " + e.getMessage());
}
stop();
}
@@ -295,7 +310,7 @@ public void restart(boolean soft) {
public static void stop() {
moduleLoader.deactivateModules();
- FileUtil.deleteFolder(new File(ApplicationStorage.getApplicationPath() + "temp/"));
+ FileActions.deleteFolder(new File(ApplicationStorage.getApplicationPath() + "temp/"));
System.exit(0);
}
}
\ No newline at end of file
diff --git a/application-main/src/main/java/com/zyneonstudios/application/modules/ApplicationModule.java b/application-main/src/main/java/com/zyneonstudios/application/modules/ApplicationModule.java
index abe2158..200bf3f 100644
--- a/application-main/src/main/java/com/zyneonstudios/application/modules/ApplicationModule.java
+++ b/application-main/src/main/java/com/zyneonstudios/application/modules/ApplicationModule.java
@@ -14,7 +14,7 @@ public class ApplicationModule {
private final NexusApplication application;
public ApplicationModule(NexusApplication application, String id, String name, String version, String authors) {
- NexusApplication.getLogger().debug("[MODULES] Creating object for "+name+" ("+id+") v"+version);
+ NexusApplication.getLogger().dbg("[MODULES] Creating object for "+name+" ("+id+") v"+version);
this.id = id;
this.name = name;
diff --git a/application-main/src/main/java/com/zyneonstudios/application/modules/ModuleLoader.java b/application-main/src/main/java/com/zyneonstudios/application/modules/ModuleLoader.java
index 4ab3fee..f9977c5 100644
--- a/application-main/src/main/java/com/zyneonstudios/application/modules/ModuleLoader.java
+++ b/application-main/src/main/java/com/zyneonstudios/application/modules/ModuleLoader.java
@@ -58,7 +58,7 @@ public ApplicationModule readModule(File moduleJar) {
version = array.get(0).getAsJsonObject().get("version").getAsString();
authors = array.get(0).getAsJsonObject().get("authors").getAsJsonArray().toString();
} catch (Exception e) {
- NexusApplication.getLogger().error("[MODULES] Couldn't read module "+moduleJar.getPath()+": "+e.getMessage());
+ NexusApplication.getLogger().err("[MODULES] Couldn't read module "+moduleJar.getPath()+": "+e.getMessage());
return null;
}
URLClassLoader classLoader = new URLClassLoader(new URL[]{moduleJar.toURI().toURL()});
@@ -66,7 +66,7 @@ public ApplicationModule readModule(File moduleJar) {
Constructor> constructor = module.getConstructor(NexusApplication.class, String.class, String.class, String.class, String.class);
return (ApplicationModule) constructor.newInstance(application, id, name, version, authors);
} catch (Exception e) {
- NexusApplication.getLogger().error("[MODULES] Couldn't read module "+moduleJar.getPath()+": "+e.getMessage());
+ NexusApplication.getLogger().err("[MODULES] Couldn't read module "+moduleJar.getPath()+": "+e.getMessage());
return null;
}
}
@@ -93,11 +93,11 @@ public ArrayList readModules(File moduleJar) {
return modules;
}
} catch (Exception e) {
- NexusApplication.getLogger().error("[MODULES] Couldn't read module "+moduleJar.getPath()+": "+e.getMessage());
+ NexusApplication.getLogger().err("[MODULES] Couldn't read module "+moduleJar.getPath()+": "+e.getMessage());
return null;
}
} catch (Exception e) {
- NexusApplication.getLogger().error("[MODULES] Couldn't read module "+moduleJar.getPath()+": "+e.getMessage());
+ NexusApplication.getLogger().err("[MODULES] Couldn't read module "+moduleJar.getPath()+": "+e.getMessage());
return null;
}
}
diff --git a/application-main/src/main/java/com/zyneonstudios/application/utils/FileStorage.java b/application-main/src/main/java/com/zyneonstudios/application/utils/FileStorage.java
deleted file mode 100644
index 392b14f..0000000
--- a/application-main/src/main/java/com/zyneonstudios/application/utils/FileStorage.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package com.zyneonstudios.application.utils;
-
-import live.nerotv.shademebaby.file.Config;
-
-public class FileStorage implements Storage {
-
- private final Config config;
-
- public FileStorage(String path) {
- this.config = new Config(path);
- }
-
- @Override
- public Object get(String path) {
- return config.get(path);
- }
-
- @Override
- public boolean getBool(String path) {
- return config.getBool(path);
- }
-
- @Override
- public Boolean getBoolean(String path) {
- return config.getBoolean(path);
- }
-
- @Override
- public double getDoub(String path) {
- return config.getDoub(path);
- }
-
- @Override
- public Double getDouble(String path) {
- return config.getDouble(path);
- }
-
- @Override
- public int getInt(String path) {
- return config.getInt(path);
- }
-
- @Override
- public Integer getInteger(String path) {
- return config.getInteger(path);
- }
-
- @Override
- public String getString(String path) {
- return config.getString(path);
- }
-}
\ No newline at end of file