From 123250246c06b8aee41411574beba04f9949d0ef Mon Sep 17 00:00:00 2001 From: Gravit Date: Sun, 23 Dec 2018 23:26:57 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B2=D0=BE=D0=B4=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D0=BE=D0=B2=20=D0=BD=D0=B0?= =?UTF-8?q?=20Json=20=D1=87=D0=B0=D1=81=D1=82=D1=8C=204=20=D0=9F=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BA=D0=B8=20=D1=80=D0=B0=D0=BD=D1=82=D0=B0=D0=B9?= =?UTF-8?q?=D0=BC=D0=B0=20=D0=9A=D0=BE=D0=BC=D0=BF=D0=BB=D0=B8=D1=80=D1=83?= =?UTF-8?q?=D0=B5=D1=82=D1=81=D1=8F,=20=D0=BF=D0=BE=D0=BA=D0=B0=20=D0=BD?= =?UTF-8?q?=D0=B5=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/gravit/launchserver/LaunchServer.java | 9 +++++++++ Launcher/runtime/dialog/dialog.js | 18 +++++++++--------- .../runtime/dialog/overlay/options/options.js | 6 +++--- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index 3e35b5ea..ede68a93 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -1,5 +1,6 @@ package ru.gravit.launchserver; +import com.google.gson.GsonBuilder; import ru.gravit.launcher.Launcher; import ru.gravit.launcher.LauncherConfig; import ru.gravit.launcher.hasher.HashedDir; @@ -299,6 +300,7 @@ public LaunchServer(Path dir) throws IOException, InvalidKeySpecException { modulesManager = new ModulesManager(this); modulesManager.autoload(dir.resolve("modules")); modulesManager.preInitModules(); + initGson(); // Read LaunchServer config generateConfigIfNotExists(); @@ -350,6 +352,13 @@ public LaunchServer(Path dir) throws IOException, InvalidKeySpecException { modulesManager.postInitModules(); } + public static void initGson() + { + if(Launcher.gson != null) return; + Launcher.gsonBuilder = new GsonBuilder(); + Launcher.gson = Launcher.gsonBuilder.create(); + } + private LauncherBinary binary() { if (config.launch4j.enabled) return new EXEL4JLauncherBinary(this); return new EXELauncherBinary(this); diff --git a/Launcher/runtime/dialog/dialog.js b/Launcher/runtime/dialog/dialog.js index 93aa62e2..1d55b1d5 100644 --- a/Launcher/runtime/dialog/dialog.js +++ b/Launcher/runtime/dialog/dialog.js @@ -225,24 +225,24 @@ function doAuth(login, rsaPassword) { } function doUpdate(profile, pp, accessToken) { -var digest = profile.object.isUpdateFastCheck(); +var digest = profile.isUpdateFastCheck(); overlay.swap(0, update.overlay, function(event) { // Update asset dir update.resetOverlay("Обновление файлов ресурсов"); - var assetDirName = profile.object.block.getEntryValue("assetDir", StringConfigEntryClass); + var assetDirName = profile.block.getEntryValue("assetDir", StringConfigEntryClass); var assetDir = settings.updatesDir.resolve(assetDirName); - var assetMatcher = profile.object.getAssetUpdateMatcher(); - makeSetProfileRequest(profile.object, function() { - ClientLauncher.setProfile(profile.object); + var assetMatcher = profile.getAssetUpdateMatcher(); + makeSetProfileRequest(profile, function() { + ClientLauncher.setProfile(profile); makeUpdateRequest(assetDirName, assetDir, assetMatcher, digest, function(assetHDir) { settings.lastHDirs.put(assetDirName, assetHDir); // Update client dir update.resetOverlay("Обновление файлов клиента"); - var clientDirName = profile.object.block.getEntryValue("dir", StringConfigEntryClass); + var clientDirName = profile.block.getEntryValue("dir", StringConfigEntryClass); var clientDir = settings.updatesDir.resolve(clientDirName); - var clientMatcher = profile.object.getClientUpdateMatcher(); + var clientMatcher = profile.getClientUpdateMatcher(); makeUpdateRequest(clientDirName, clientDir, clientMatcher, digest, function(clientHDir) { settings.lastHDirs.put(clientDirName, clientHDir); doLaunchClient(assetDir, assetHDir, clientDir, clientHDir, profile, pp, accessToken); @@ -278,7 +278,7 @@ function updateProfilesList(profiles) { serverList.getChildren().clear(); var index = 0; profiles.forEach(function (profile, i, arr) { - pingers[profile.object] = new ServerPinger(profile.object.getServerSocketAddress(), profile.object.getVersion()); + pingers[profile] = new ServerPinger(profile.getServerSocketAddress(), profile.getVersion()); var serverBtn = new javafx.scene.control.ToggleButton(profile); (function () { profilesList[serverBtn] = profile; @@ -303,7 +303,7 @@ function updateProfilesList(profiles) { function pingServer(btn) { var profile = profilesList[btn]; setServerStatus("..."); - var task = newTask(function() pingers[profile.object].ping()); + var task = newTask(function() pingers[profile].ping()); task.setOnSucceeded(function(event) { var result = task.getValue(); if(btn==serverHolder.old){ diff --git a/Launcher/runtime/dialog/overlay/options/options.js b/Launcher/runtime/dialog/overlay/options/options.js index 22949c05..4abdfce0 100644 --- a/Launcher/runtime/dialog/overlay/options/options.js +++ b/Launcher/runtime/dialog/overlay/options/options.js @@ -35,9 +35,9 @@ var options = { var sortIndex = input.readInt(); var profile = null; settings.lastProfiles.forEach(function(hprofile,i,arr) { - if(hprofile.object.getSortIndex() == sortIndex) + if(hprofile.getSortIndex() == sortIndex) { - profile = hprofile.object; + profile = hprofile; } }); for(var j = 0; j < listSize; j++) @@ -62,7 +62,7 @@ var options = { output.writeInt(config.settingsMagic); output.writeInt(settings.lastProfiles.length); settings.lastProfiles.forEach(function(hprofile,i,arr) { - var profile = hprofile.object; + var profile = hprofile; LogHelper.debug("Save options %s",profile.getTitle()); var list = profile.getOptional(); output.writeInt(list.size());