Введение DirBridge

This commit is contained in:
Gravit 2018-10-21 17:04:06 +07:00
parent ecb904035a
commit e4c1a8ce96
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
8 changed files with 28 additions and 20 deletions

View file

@ -17,11 +17,11 @@ var config = {
}; };
// ====== DON'T TOUCH! ====== // // ====== DON'T TOUCH! ====== //
var dir = IOHelper.HOME_DIR.resolve(config.dir); DirBridge.dir = IOHelper.HOME_DIR.resolve(config.dir);
if (!IOHelper.isDir(dir)) { if (!IOHelper.isDir(DirBridge.dir)) {
java.nio.file.Files.createDirectory(dir); java.nio.file.Files.createDirectory(DirBridge.dir);
} }
var defaultUpdatesDir = dir.resolve("updates"); DirBridge.defaultUpdatesDir = DirBridge.dir.resolve("updates");
if (!IOHelper.isDir(defaultUpdatesDir)) { if (!IOHelper.isDir(DirBridge.defaultUpdatesDir)) {
java.nio.file.Files.createDirectory(defaultUpdatesDir); java.nio.file.Files.createDirectory(DirBridge.defaultUpdatesDir);
} }

View file

@ -10,7 +10,7 @@ function initDialog() {
// Lookup news WebView // Lookup news WebView
news = rootPane.lookup("#news"); news = rootPane.lookup("#news");
var newsEngine = news.getEngine(); var newsEngine = news.getEngine();
newsEngine.setUserDataDirectory(dir.resolve("webview").toFile()); newsEngine.setUserDataDirectory(DirBridge.dir.resolve("webview").toFile());
newsEngine.load(config.newsURL); newsEngine.load(config.newsURL);
// Lookup auth pane and dim // Lookup auth pane and dim

View file

@ -1,5 +1,5 @@
var settings = { var settings = {
file: dir.resolve("settings.bin"), // Settings file file: DirBridge.dir.resolve("settings.bin"), // Settings file
login: null, rsaPassword: null, profile: 0, // Auth login: null, rsaPassword: null, profile: 0, // Auth
updatesDir: null, autoEnter: false, fullScreen: false, ram: 0, // Client updatesDir: null, autoEnter: false, fullScreen: false, ram: 0, // Client

View file

@ -1,6 +1,7 @@
var Launcher = LauncherClass.static; var Launcher = LauncherClass.static;
var LauncherConfig = LauncherConfigClass.static; var LauncherConfig = LauncherConfigClass.static;
var HTTPRequest = HTTPRequestClass.static; var HTTPRequest = HTTPRequestClass.static;
var DirBridge = DirBridgeClass.static;
// Hasher class API imports // Hasher class API imports
var PlayerProfile = PlayerProfileClass.static; var PlayerProfile = PlayerProfileClass.static;

View file

@ -1,10 +1,5 @@
var app, stage, scene; var app, stage, scene;
// internal
function getPathDirHelper() {
return dir;
}
// Override application class // Override application class
var LauncherApp = Java.extend(JSApplication, { var LauncherApp = Java.extend(JSApplication, {
init: function() { init: function() {

View file

@ -16,10 +16,7 @@
import javax.script.ScriptEngine; import javax.script.ScriptEngine;
import javax.script.ScriptException; import javax.script.ScriptException;
import ru.gravit.launcher.client.ClientLauncher; import ru.gravit.launcher.client.*;
import ru.gravit.launcher.client.ClientModuleManager;
import ru.gravit.launcher.client.JSApplication;
import ru.gravit.launcher.client.ServerPinger;
import ru.gravit.launcher.gui.buttons.RingProgressIndicator; import ru.gravit.launcher.gui.buttons.RingProgressIndicator;
import ru.gravit.launcher.gui.buttons.RingProgressIndicatorSkin; import ru.gravit.launcher.gui.buttons.RingProgressIndicatorSkin;
import ru.gravit.launcher.hasher.FileNameMatcher; import ru.gravit.launcher.hasher.FileNameMatcher;
@ -135,6 +132,7 @@ public static void addLauncherClassBindings(Map<String, Object> bindings) {
bindings.put("SecurityHelperClass", SecurityHelper.class); bindings.put("SecurityHelperClass", SecurityHelper.class);
bindings.put("DigestAlgorithmClass", SecurityHelper.DigestAlgorithm.class); bindings.put("DigestAlgorithmClass", SecurityHelper.DigestAlgorithm.class);
bindings.put("VerifyHelperClass", VerifyHelper.class); bindings.put("VerifyHelperClass", VerifyHelper.class);
bindings.put("DirBridgeClass", DirBridge.class);
// Load JS API if available // Load JS API if available
bindings.put("RingProgressIndicatorClass", RingProgressIndicator.class); bindings.put("RingProgressIndicatorClass", RingProgressIndicator.class);
@ -206,7 +204,7 @@ public void start(String... args) throws Throwable {
LogHelper.info("Invoking start() function"); LogHelper.info("Invoking start() function");
Invocable invoker = (Invocable) engine; Invocable invoker = (Invocable) engine;
if (Launcher.isUsingAvanguard()) { if (Launcher.isUsingAvanguard()) {
AvanguardStarter.start((Path) invoker.invokeFunction("getPathDirHelper")); AvanguardStarter.start(DirBridge.dir);
AvanguardStarter.loadVared(); AvanguardStarter.loadVared();
AvanguardStarter.main(false); AvanguardStarter.main(false);
} }

View file

@ -346,10 +346,10 @@ else if(isDownloadJava)
if(JVMHelper.OS_TYPE == OS.MUSTDIE) if(JVMHelper.OS_TYPE == OS.MUSTDIE)
javaBin = IOHelper.resolveJavaBin(JavaBinPath); javaBin = IOHelper.resolveJavaBin(JavaBinPath);
else 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 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(javaBin.toString());
args.add(MAGICAL_INTEL_OPTION); args.add(MAGICAL_INTEL_OPTION);
if (params.ram > 0 && params.ram <= JVMHelper.RAM) { if (params.ram > 0 && params.ram <= JVMHelper.RAM) {

View file

@ -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;
}