Перевод конфигов на Json часть 4

Правки рантайма
Комплируется, пока не работает
This commit is contained in:
Gravit 2018-12-23 23:26:57 +07:00
parent 79891d711e
commit 123250246c
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
3 changed files with 21 additions and 12 deletions

View file

@ -1,5 +1,6 @@
package ru.gravit.launchserver; package ru.gravit.launchserver;
import com.google.gson.GsonBuilder;
import ru.gravit.launcher.Launcher; import ru.gravit.launcher.Launcher;
import ru.gravit.launcher.LauncherConfig; import ru.gravit.launcher.LauncherConfig;
import ru.gravit.launcher.hasher.HashedDir; import ru.gravit.launcher.hasher.HashedDir;
@ -299,6 +300,7 @@ public LaunchServer(Path dir) throws IOException, InvalidKeySpecException {
modulesManager = new ModulesManager(this); modulesManager = new ModulesManager(this);
modulesManager.autoload(dir.resolve("modules")); modulesManager.autoload(dir.resolve("modules"));
modulesManager.preInitModules(); modulesManager.preInitModules();
initGson();
// Read LaunchServer config // Read LaunchServer config
generateConfigIfNotExists(); generateConfigIfNotExists();
@ -350,6 +352,13 @@ public LaunchServer(Path dir) throws IOException, InvalidKeySpecException {
modulesManager.postInitModules(); modulesManager.postInitModules();
} }
public static void initGson()
{
if(Launcher.gson != null) return;
Launcher.gsonBuilder = new GsonBuilder();
Launcher.gson = Launcher.gsonBuilder.create();
}
private LauncherBinary binary() { private LauncherBinary binary() {
if (config.launch4j.enabled) return new EXEL4JLauncherBinary(this); if (config.launch4j.enabled) return new EXEL4JLauncherBinary(this);
return new EXELauncherBinary(this); return new EXELauncherBinary(this);

View file

@ -225,24 +225,24 @@ function doAuth(login, rsaPassword) {
} }
function doUpdate(profile, pp, accessToken) { function doUpdate(profile, pp, accessToken) {
var digest = profile.object.isUpdateFastCheck(); var digest = profile.isUpdateFastCheck();
overlay.swap(0, update.overlay, function(event) { overlay.swap(0, update.overlay, function(event) {
// Update asset dir // Update asset dir
update.resetOverlay("Обновление файлов ресурсов"); update.resetOverlay("Обновление файлов ресурсов");
var assetDirName = profile.object.block.getEntryValue("assetDir", StringConfigEntryClass); var assetDirName = profile.block.getEntryValue("assetDir", StringConfigEntryClass);
var assetDir = settings.updatesDir.resolve(assetDirName); var assetDir = settings.updatesDir.resolve(assetDirName);
var assetMatcher = profile.object.getAssetUpdateMatcher(); var assetMatcher = profile.getAssetUpdateMatcher();
makeSetProfileRequest(profile.object, function() { makeSetProfileRequest(profile, function() {
ClientLauncher.setProfile(profile.object); ClientLauncher.setProfile(profile);
makeUpdateRequest(assetDirName, assetDir, assetMatcher, digest, function(assetHDir) { makeUpdateRequest(assetDirName, assetDir, assetMatcher, digest, function(assetHDir) {
settings.lastHDirs.put(assetDirName, assetHDir); settings.lastHDirs.put(assetDirName, assetHDir);
// Update client dir // Update client dir
update.resetOverlay("Обновление файлов клиента"); update.resetOverlay("Обновление файлов клиента");
var clientDirName = profile.object.block.getEntryValue("dir", StringConfigEntryClass); var clientDirName = profile.block.getEntryValue("dir", StringConfigEntryClass);
var clientDir = settings.updatesDir.resolve(clientDirName); var clientDir = settings.updatesDir.resolve(clientDirName);
var clientMatcher = profile.object.getClientUpdateMatcher(); var clientMatcher = profile.getClientUpdateMatcher();
makeUpdateRequest(clientDirName, clientDir, clientMatcher, digest, function(clientHDir) { makeUpdateRequest(clientDirName, clientDir, clientMatcher, digest, function(clientHDir) {
settings.lastHDirs.put(clientDirName, clientHDir); settings.lastHDirs.put(clientDirName, clientHDir);
doLaunchClient(assetDir, assetHDir, clientDir, clientHDir, profile, pp, accessToken); doLaunchClient(assetDir, assetHDir, clientDir, clientHDir, profile, pp, accessToken);
@ -278,7 +278,7 @@ function updateProfilesList(profiles) {
serverList.getChildren().clear(); serverList.getChildren().clear();
var index = 0; var index = 0;
profiles.forEach(function (profile, i, arr) { 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); var serverBtn = new javafx.scene.control.ToggleButton(profile);
(function () { (function () {
profilesList[serverBtn] = profile; profilesList[serverBtn] = profile;
@ -303,7 +303,7 @@ function updateProfilesList(profiles) {
function pingServer(btn) { function pingServer(btn) {
var profile = profilesList[btn]; var profile = profilesList[btn];
setServerStatus("..."); setServerStatus("...");
var task = newTask(function() pingers[profile.object].ping()); var task = newTask(function() pingers[profile].ping());
task.setOnSucceeded(function(event) { task.setOnSucceeded(function(event) {
var result = task.getValue(); var result = task.getValue();
if(btn==serverHolder.old){ if(btn==serverHolder.old){

View file

@ -35,9 +35,9 @@ var options = {
var sortIndex = input.readInt(); var sortIndex = input.readInt();
var profile = null; var profile = null;
settings.lastProfiles.forEach(function(hprofile,i,arr) { 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++) for(var j = 0; j < listSize; j++)
@ -62,7 +62,7 @@ var options = {
output.writeInt(config.settingsMagic); output.writeInt(config.settingsMagic);
output.writeInt(settings.lastProfiles.length); output.writeInt(settings.lastProfiles.length);
settings.lastProfiles.forEach(function(hprofile,i,arr) { settings.lastProfiles.forEach(function(hprofile,i,arr) {
var profile = hprofile.object; var profile = hprofile;
LogHelper.debug("Save options %s",profile.getTitle()); LogHelper.debug("Save options %s",profile.getTitle());
var list = profile.getOptional(); var list = profile.getOptional();
output.writeInt(list.size()); output.writeInt(list.size());