diff --git a/Launcher/runtime/config.js b/Launcher/runtime/config.js index c5698103..5d513a54 100644 --- a/Launcher/runtime/config.js +++ b/Launcher/runtime/config.js @@ -17,11 +17,11 @@ var config = { }; // ====== DON'T TOUCH! ====== // -var dir = IOHelper.HOME_DIR.resolve(config.dir); -if (!IOHelper.isDir(dir)) { - java.nio.file.Files.createDirectory(dir); +DirBridge.dir = IOHelper.HOME_DIR.resolve(config.dir); +if (!IOHelper.isDir(DirBridge.dir)) { + java.nio.file.Files.createDirectory(DirBridge.dir); } -var defaultUpdatesDir = dir.resolve("updates"); -if (!IOHelper.isDir(defaultUpdatesDir)) { - java.nio.file.Files.createDirectory(defaultUpdatesDir); +DirBridge.defaultUpdatesDir = DirBridge.dir.resolve("updates"); +if (!IOHelper.isDir(DirBridge.defaultUpdatesDir)) { + java.nio.file.Files.createDirectory(DirBridge.defaultUpdatesDir); } diff --git a/Launcher/runtime/dialog/dialog.js b/Launcher/runtime/dialog/dialog.js index a18fa0a5..47cf8eeb 100644 --- a/Launcher/runtime/dialog/dialog.js +++ b/Launcher/runtime/dialog/dialog.js @@ -10,7 +10,7 @@ function initDialog() { // Lookup news WebView news = rootPane.lookup("#news"); var newsEngine = news.getEngine(); - newsEngine.setUserDataDirectory(dir.resolve("webview").toFile()); + newsEngine.setUserDataDirectory(DirBridge.dir.resolve("webview").toFile()); newsEngine.load(config.newsURL); // Lookup auth pane and dim diff --git a/Launcher/runtime/dialog/overlay/settings/settings.js b/Launcher/runtime/dialog/overlay/settings/settings.js index 3f9ce9f6..fbde59ed 100644 --- a/Launcher/runtime/dialog/overlay/settings/settings.js +++ b/Launcher/runtime/dialog/overlay/settings/settings.js @@ -1,5 +1,5 @@ var settings = { - file: dir.resolve("settings.bin"), // Settings file + file: DirBridge.dir.resolve("settings.bin"), // Settings file login: null, rsaPassword: null, profile: 0, // Auth updatesDir: null, autoEnter: false, fullScreen: false, ram: 0, // Client diff --git a/Launcher/runtime/engine/api.js b/Launcher/runtime/engine/api.js index 1bce51a0..effeb498 100644 --- a/Launcher/runtime/engine/api.js +++ b/Launcher/runtime/engine/api.js @@ -1,6 +1,7 @@ var Launcher = LauncherClass.static; var LauncherConfig = LauncherConfigClass.static; var HTTPRequest = HTTPRequestClass.static; +var DirBridge = DirBridgeClass.static; // Hasher class API imports var PlayerProfile = PlayerProfileClass.static; diff --git a/Launcher/runtime/init.js b/Launcher/runtime/init.js index 0e0e236b..0f7a6137 100644 --- a/Launcher/runtime/init.js +++ b/Launcher/runtime/init.js @@ -1,10 +1,5 @@ var app, stage, scene; -// internal -function getPathDirHelper() { - return dir; -} - // Override application class var LauncherApp = Java.extend(JSApplication, { init: function() { diff --git a/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java b/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java index a8aa183c..f5e49818 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java +++ b/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java @@ -16,10 +16,7 @@ import javax.script.ScriptEngine; import javax.script.ScriptException; -import ru.gravit.launcher.client.ClientLauncher; -import ru.gravit.launcher.client.ClientModuleManager; -import ru.gravit.launcher.client.JSApplication; -import ru.gravit.launcher.client.ServerPinger; +import ru.gravit.launcher.client.*; import ru.gravit.launcher.gui.buttons.RingProgressIndicator; import ru.gravit.launcher.gui.buttons.RingProgressIndicatorSkin; import ru.gravit.launcher.hasher.FileNameMatcher; @@ -135,6 +132,7 @@ public static void addLauncherClassBindings(Map bindings) { bindings.put("SecurityHelperClass", SecurityHelper.class); bindings.put("DigestAlgorithmClass", SecurityHelper.DigestAlgorithm.class); bindings.put("VerifyHelperClass", VerifyHelper.class); + bindings.put("DirBridgeClass", DirBridge.class); // Load JS API if available bindings.put("RingProgressIndicatorClass", RingProgressIndicator.class); @@ -206,7 +204,7 @@ public void start(String... args) throws Throwable { LogHelper.info("Invoking start() function"); Invocable invoker = (Invocable) engine; if (Launcher.isUsingAvanguard()) { - AvanguardStarter.start((Path) invoker.invokeFunction("getPathDirHelper")); + AvanguardStarter.start(DirBridge.dir); AvanguardStarter.loadVared(); AvanguardStarter.main(false); } diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java index 711d5850..1f76eef2 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -346,10 +346,10 @@ else if(isDownloadJava) if(JVMHelper.OS_TYPE == OS.MUSTDIE) javaBin = IOHelper.resolveJavaBin(JavaBinPath); else - javaBin = Paths.get(System.getProperty("java.home") + IOHelper.PLATFORM_SEPARATOR + "bin" + IOHelper.PLATFORM_SEPARATOR + "java"); + javaBin = IOHelper.resolveJavaBin(Paths.get(System.getProperty("java.home"))); } else - javaBin = Paths.get(System.getProperty("java.home") + IOHelper.PLATFORM_SEPARATOR + "bin" + IOHelper.PLATFORM_SEPARATOR + "java"); + javaBin = IOHelper.resolveJavaBin(Paths.get(System.getProperty("java.home"))); args.add(javaBin.toString()); args.add(MAGICAL_INTEL_OPTION); if (params.ram > 0 && params.ram <= JVMHelper.RAM) { diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/DirBridge.java b/Launcher/src/main/java/ru/gravit/launcher/client/DirBridge.java new file mode 100644 index 00000000..056a13d7 --- /dev/null +++ b/Launcher/src/main/java/ru/gravit/launcher/client/DirBridge.java @@ -0,0 +1,14 @@ +package ru.gravit.launcher.client; + +import ru.gravit.launcher.LauncherAPI; + +import java.nio.file.Path; + +public class DirBridge { + @LauncherAPI + public static Path dir; + @LauncherAPI + public static Path dirUpdates; + @LauncherAPI + public static Path defaultUpdatesDir; +}