diff --git a/Launcher/runtime/config.js b/Launcher/runtime/config.js
index 5dabe0d..54d885a 100755
--- a/Launcher/runtime/config.js
+++ b/Launcher/runtime/config.js
@@ -10,7 +10,7 @@
linkURL: new java.net.URL("http://bit.ly/1SP0Rl8"), // URL for link under "Auth" button
// Settings defaults
- settingsMagic: 0xBEEF, // Ancient magic, don't touch
+ settingsMagic: 0xC0DE5, // Ancient magic, don't touch
autoEnterDefault: false, // Should autoEnter be enabled by default?
fullScreenDefault: false, // Should fullScreen be enabled by default?
ramDefault: 1024, // Default RAM amount (0 for auto)
@@ -23,10 +23,10 @@
// ====== DON'T TOUCH! ====== //
var dir = IOHelper.HOME_DIR.resolve(config.dir);
-if(!IOHelper.isDir(dir)) {
+if (!IOHelper.isDir(dir)) {
java.nio.file.Files.createDirectory(dir);
}
-var updatesDir = dir.resolve("updates");
-if(!IOHelper.isDir(updatesDir)) {
- java.nio.file.Files.createDirectory(updatesDir);
+var defaultUpdatesDir = dir.resolve("updates");
+if (!IOHelper.isDir(defaultUpdatesDir)) {
+ java.nio.file.Files.createDirectory(defaultUpdatesDir);
}
diff --git a/Launcher/runtime/dialog/dialog.js b/Launcher/runtime/dialog/dialog.js
index 0e3bba3..c41b662 100755
--- a/Launcher/runtime/dialog/dialog.js
+++ b/Launcher/runtime/dialog/dialog.js
@@ -33,14 +33,14 @@
// Lookup login field
loginField = pane.lookup("#login");
loginField.setOnAction(goAuth);
- if(settings.login !== null) {
+ if (settings.login !== null) {
loginField.setText(settings.login);
}
// Lookup password field
passwordField = pane.lookup("#password");
passwordField.setOnAction(goAuth);
- if(settings.rsaPassword !== null) {
+ if (settings.rsaPassword !== null) {
passwordField.getStyleClass().add("hasSaved");
passwordField.setPromptText("*** Сохранённый ***");
}
@@ -67,28 +67,28 @@
/* ======== Handler functions ======== */
function goAuth(event) {
// Verify there's no other overlays
- if(overlay.current !== null) {
+ if (overlay.current !== null) {
return;
}
// Get profile
var profile = profilesBox.getSelectionModel().getSelectedItem();
- if(profile === null) {
+ if (profile === null) {
return; // No profile selected
}
// Get login
var login = loginField.getText();
- if(login.isEmpty()) {
+ if (login.isEmpty()) {
return; // Maybe throw exception?)
}
// Get password
var rsaPassword;
var password = passwordField.getText();
- if(!password.isEmpty()) {
+ if (!password.isEmpty()) {
rsaPassword = settings.setPassword(password);
- } else if(settings.rsaPassword !== null) {
+ } else if (settings.rsaPassword !== null) {
rsaPassword = settings.rsaPassword;
} else {
return; // No password - no auth, sorry :C
@@ -104,7 +104,7 @@
function goSettings(event) {
// Verify there's no other overlays
- if(overlay.current !== null) {
+ if (overlay.current !== null) {
return;
}
@@ -112,7 +112,7 @@
overlay.show(settings.overlay, null);
}
-/* ======== Processing functions ======== */
+/* ======== Processing functions ======== */
function verifyLauncher(e) {
processing.resetOverlay();
overlay.show(processing.overlay, function(event) makeLauncherRequest(function(result) {
@@ -122,7 +122,7 @@
// Hide overlay
overlay.hide(0, function() {
- if(cliParams.autoLogin) {
+ if (cliParams.autoLogin) {
goAuth(null);
}
});
@@ -139,15 +139,15 @@
function doUpdate(profile, pp, accessToken) {
update.resetOverlay("Обновление файлов JVM");
overlay.swap(0, update.overlay, function(event) {
- var jvmDir = updatesDir.resolve(jvmDirName);
+ var jvmDir = settings.updatesDir.resolve(jvmDirName);
makeUpdateRequest(jvmDirName, jvmDir, null, function(jvmHDir) {
update.resetOverlay("Обновление файлов ресурсов");
var assetDirName = profile.object.block.getEntryValue("assetDir", StringConfigEntryClass);
- var assetDir = updatesDir.resolve(assetDirName);
+ var assetDir = settings.updatesDir.resolve(assetDirName);
makeUpdateRequest(assetDirName, assetDir, null, function(assetHDir) {
update.resetOverlay("Обновление файлов клиента");
var clientDirName = profile.object.block.getEntryValue("dir", StringConfigEntryClass);
- var clientDir = updatesDir.resolve(clientDirName);
+ var clientDir = settings.updatesDir.resolve(clientDirName);
makeUpdateRequest(clientDirName, clientDir, profile.object.getUpdateMatcher(), function(clientHDir)
doLaunchClient(jvmDir, jvmHDir, clientHDir, assetDir, clientDir, profile, pp, accessToken)
);
@@ -165,7 +165,7 @@
}
function doDebugClient(process) {
- if(!LogHelper.isDebugEnabled()) {
+ if (!LogHelper.isDebugEnabled()) {
javafx.application.Platform.exit();
return;
}
@@ -175,11 +175,11 @@
overlay.swap(0, debug.overlay, function(event) debugProcess(process));
}
-/* ======== Server handler functions ======== */
+/* ======== Server handler functions ======== */
function updateProfilesList() {
// Set profiles items
profilesBox.setItems(javafx.collections.FXCollections.observableList(profiles));
- for each(var profile in profiles) {
+ for each (var profile in profiles) {
pingers[profile.object] = new ServerPinger(profile.object.getServerSocketAddress(), profile.object.getVersion());
}
@@ -206,7 +206,7 @@
updateItem: function(item, empty) {
Java.super(cell).updateItem(item, empty);
cell.setGraphic(empty ? null : statusBox);
- if(empty) { // No need to update state
+ if (empty) { // No need to update state
return;
}
@@ -239,7 +239,7 @@
/* ======== Overlay helper functions ======== */
function fade(region, delay, from, to, onFinished) {
var transition = new javafx.animation.FadeTransition(javafx.util.Duration.millis(100), region);
- if(onFinished !== null) {
+ if (onFinished !== null) {
transition.setOnFinished(onFinished);
}
@@ -290,7 +290,7 @@
// Reset overlay state
overlay.current = null;
- if(onFinished !== null) {
+ if (onFinished !== null) {
onFinished();
}
});
diff --git a/Launcher/runtime/dialog/overlay/debug/debug.js b/Launcher/runtime/dialog/overlay/debug/debug.js
index a9d386d..bebabce 100755
--- a/Launcher/runtime/dialog/overlay/debug/debug.js
+++ b/Launcher/runtime/dialog/overlay/debug/debug.js
@@ -23,7 +23,7 @@
debug.action = debug.overlay.lookup("#action");
debug.action.setOnAction(function(event) {
var process = debug.process;
- if(process !== null && process.isAlive()) {
+ if (process !== null && process.isAlive()) {
process.destroyForcibly();
debug.updateActionButton(true);
return;
@@ -74,7 +74,7 @@
java.nio.charset.Charset.defaultCharset());
var appendFunction = function(line)
javafx.application.Platform.runLater(function() debug.append(line));
- for(var length = reader.read(buffer); length >= 0; length = reader.read(buffer)) {
+ for (var length = reader.read(buffer); length >= 0; length = reader.read(buffer)) {
appendFunction(new java.lang.String(buffer, 0, length));
}
diff --git a/Launcher/runtime/dialog/overlay/processing/processing.js b/Launcher/runtime/dialog/overlay/processing/processing.js
index 1d02f9a..48bdd1b 100755
--- a/Launcher/runtime/dialog/overlay/processing/processing.js
+++ b/Launcher/runtime/dialog/overlay/processing/processing.js
@@ -35,13 +35,13 @@
task.setOnFailed(function(event) {
processing.description.textProperty().unbind();
processing.setError(task.getException());
- if(hide) {
+ if (hide) {
overlay.hide(2500, null);
}
});
task.setOnSucceeded(function(event) {
processing.description.textProperty().unbind();
- if(callback !== null) {
+ if (callback !== null) {
callback(task.getValue());
}
});
diff --git a/Launcher/runtime/dialog/overlay/settings/settings.fxml b/Launcher/runtime/dialog/overlay/settings/settings.fxml
index c4c4066..5342feb 100755
--- a/Launcher/runtime/dialog/overlay/settings/settings.fxml
+++ b/Launcher/runtime/dialog/overlay/settings/settings.fxml
@@ -3,6 +3,7 @@
+
@@ -24,17 +25,17 @@
Выделение памяти:
- ...
+
-
+
Директория загрузок:
- ...
+
-
+
diff --git a/Launcher/runtime/dialog/overlay/settings/settings.js b/Launcher/runtime/dialog/overlay/settings/settings.js
index 132d7ba..11847a5 100755
--- a/Launcher/runtime/dialog/overlay/settings/settings.js
+++ b/Launcher/runtime/dialog/overlay/settings/settings.js
@@ -1,6 +1,7 @@
var settings = {
file: dir.resolve("settings.bin"), // Settings file
login: null, rsaPassword: null, profile: 0, // Auth
+ updatesDir: null, // Client download
autoEnter: false, fullScreen: false, ram: 0, // Client
/* Settings and overlay functions */
@@ -26,13 +27,13 @@
// Internal functions
read: function(input) {
var magic = input.readInt();
- if(magic != config.settingsMagic) {
+ if (magic != config.settingsMagic) {
throw new java.io.IOException("Settings magic mismatch: " + java.lang.Integer.toString(magic, 16));
}
// Launcher settings
var debug = input.readBoolean();
- if(!LogHelper.isDebugEnabled() && debug) {
+ if (!LogHelper.isDebugEnabled() && debug) {
LogHelper.setDebugEnabled(true);
}
@@ -41,10 +42,13 @@
settings.rsaPassword = input.readBoolean() ? input.readByteArray(IOHelper.BUFFER_SIZE) : null;
settings.profile = input.readLength(0);
+ // Client download settings
+ settings.updatesDir = IOHelper.toPath(input.readString(0));
+
// Client settings
settings.autoEnter = input.readBoolean();
settings.fullScreen = input.readBoolean();
- settings.setRAM(input.readLength(0));
+ settings.setRAM(input.readLength(JVMHelper.RAM));
// Apply CLI params
cliParams.applySettings();
@@ -58,14 +62,17 @@
// Auth settings
output.writeBoolean(settings.login !== null);
- if(settings.login !== null) {
+ if (settings.login !== null) {
output.writeString(settings.login, 255);
}
output.writeBoolean(settings.rsaPassword !== null);
- if(settings.rsaPassword !== null) {
+ if (settings.rsaPassword !== null) {
output.writeByteArray(settings.rsaPassword, IOHelper.BUFFER_SIZE);
}
output.writeLength(settings.profile, 0);
+
+ // Client download settings
+ output.writeString(IOHelper.toString(settings.updatesDir), 0);
// Client settings
output.writeBoolean(settings.autoEnter);
@@ -79,6 +86,9 @@
settings.rsaPassword = null;
settings.profile = 0;
+ // Client download settings
+ settings.updatesDir = defaultUpdatesDir;
+
// Client settings
settings.autoEnter = config.autoEnterDefault;
settings.fullScreen = config.fullScreenDefault;
@@ -139,16 +149,28 @@
// Lookup dir label
settings.dirLabel = settings.overlay.lookup("#dirLabel");
+ settings.dirLabel.setOnAction(function(event)
+ app.getHostServices().showDocument(settings.updatesDir.toUri()));
settings.updateDirLabel();
- // Lookup open dir button
- settings.overlay.lookup("#openDir").setOnAction(function(event)
- app.getHostServices().showDocument(updatesDir.toUri()));
+ // Lookup change dir button
+ settings.overlay.lookup("#changeDir").setOnAction(function(event) {
+ var chooser = new javafx.stage.DirectoryChooser();
+ chooser.setTitle("Сменить директорию загрузок");
+ chooser.setInitialDirectory(dir.toFile());
+
+ // Set new result
+ var newDir = chooser.showDialog(stage);
+ if (newDir !== null) {
+ settings.updatesDir = newDir.toPath();
+ settings.updateDirLabel();
+ }
+ });
// Lookup delete dir button
var deleteDirButton = settings.overlay.lookup("#deleteDir");
deleteDirButton.setOnAction(function(event) {
- if(!settings.deleteDirPressedAgain) {
+ if (!settings.deleteDirPressedAgain) {
settings.deleteDirPressedAgain = true;
deleteDirButton.setText("Подтвердить вменяемость");
return;
@@ -188,59 +210,75 @@
},
updateDirLabel: function() {
- settings.dirLabel.setText(IOHelper.toString(updatesDir));
+ settings.dirLabel.setText(IOHelper.toString(settings.updatesDir));
}
};
/* ====================== CLI PARAMS ===================== */
var cliParams = {
login: null, password: null, profile: -1, autoLogin: false, // Auth
+ updatesDir: null, // Client download
autoEnter: null, fullScreen: null, ram: -1, // Client
init: function(params) {
var named = params.getNamed();
var unnamed = params.getUnnamed();
- // Set auth cli params
+ // Read auth cli params
cliParams.login = named.get("login");
cliParams.password = named.get("password");
- if(named.containsKey("profile")) {
- cliParams.profile = java.lang.Integer.parseUnsignedInt(named.get("profile"));
+ var profile = named.get("profile");
+ if (profile !== null) {
+ cliParams.profile = java.lang.Integer.parseInt(profile);
}
cliParams.autoLogin = unnamed.contains("--autoLogin");
+
+ // Read client download cli params
+ var updatesDir = named.get("updatesDir");
+ if (updatesDir !== null) {
+ cliParams.updatesDir = IOHelper.toPath(named.get("updatesDir"));
+ }
- // Set client cli params
- if(named.containsKey("autoEnter")) {
- cliParams.autoEnter = java.lang.Boolean.parseBoolean(named.get("autoEnter"));
+ // Read client cli params
+ var autoEnter = named.get("autoEnter");
+ if (autoEnter !== null) {
+ cliParams.autoEnter = java.lang.Boolean.parseBoolean(autoEnter);
}
- if(named.containsKey("fullScreen")) {
- cliParams.fullScreen = java.lang.Boolean.parseBoolean(named.get("fullScreen"));
+ var fullScreen = named.get("fullScreen");
+ if (fullScreen !== null) {
+ cliParams.fullScreen = java.lang.Boolean.parseBoolean(fullScreen);
}
- if(named.containsKey("ram")) {
- cliParams.ram = java.lang.Integer.parseUnsignedInt(named.get("ram"));
+ var ram = named.get("ram");
+ if (ram !== null) {
+ cliParams.ram = java.lang.Integer.parseInt(ram);
}
},
applySettings: function() {
- // Update auth settings
- if(cliParams.login !== null) {
+ // Apply auth settings
+ if (cliParams.login !== null) {
settings.login = cliParams.login;
}
- if(cliParams.password !== null) {
+ if (cliParams.password !== null) {
settings.setPassword(cliParams.password);
}
- if(cliParams.profile >= 0) {
+ if (cliParams.profile >= 0) {
settings.profile = cliParams.profile;
}
+
+ // Apply client download settings
+ if (cliParams.updatesDir !== null) {
+ settings.updatesDir = cliParams.updatesDir;
+ }
- // Update client settings
- if(cliParams.autoEnter !== null) {
+ // Apply client settings
+ if (cliParams.autoEnter !== null) {
settings.autoLogin = cliParams.autoEnter;
}
- if(cliParams.fullScreen !== null) {
+ if (cliParams.fullScreen !== null) {
settings.fullScreen = cliParams.fullScreen;
}
- if(cliParams.ram >= 0) {
+ if (cliParams.ram >= 0) {
settings.setRAM(cliParams.ram);
}
}
diff --git a/Launcher/runtime/dialog/overlay/update/update.js b/Launcher/runtime/dialog/overlay/update/update.js
index ec0fac8..15638ab 100755
--- a/Launcher/runtime/dialog/overlay/update/update.js
+++ b/Launcher/runtime/dialog/overlay/update/update.js
@@ -64,7 +64,7 @@
task.setOnSucceeded(function(event) {
update.description.textProperty().unbind();
update.progress.progressProperty().unbind();
- if(callback !== null) {
+ if (callback !== null) {
callback(task.getValue());
}
});
@@ -73,7 +73,7 @@
/* Export functions */
function makeUpdateRequest(dirName, dir, matcher, callback) {
- var request = new UpdateRequest(dirName, updatesDir.resolve(dirName), matcher);
+ var request = new UpdateRequest(dirName, dir, matcher);
var task = newRequestTask(request);
update.setTaskProperties(task, request, callback);
task.updateMessage("Состояние: Хеширование");
diff --git a/Launcher/runtime/init.js b/Launcher/runtime/init.js
index d0c9f77..3aba4da 100755
--- a/Launcher/runtime/init.js
+++ b/Launcher/runtime/init.js
@@ -19,7 +19,7 @@
stage.setTitle(config.title);
// Set icons
- for each(var icon in config.icons) {
+ for each (var icon in config.icons) {
var iconURL = Launcher.getResourceURL(icon).toString();
stage.getIcons().add(new javafx.scene.image.Image(iconURL));
}
@@ -56,7 +56,7 @@
function start(args) {
// Set JVM dir name
LogHelper.debug("Setting JVM dir name");
- switch(JVMHelper.OS_TYPE) {
+ switch (JVMHelper.OS_TYPE) {
case JVMHelperOS.MUSTDIE: jvmDirName = JVMHelper.OS_BITS === 32 ? config.jvmMustdie32Dir : // 32-bit Mustdie
jvmDirName = JVMHelper.OS_BITS === 64 ? config.jvmMustdie64Dir : config.jvmUnknownDir; break; // 64-bit Mustdie
case JVMHelperOS.LINUX: jvmDirName = JVMHelper.OS_BITS === 32 ? config.jvmLinux32Dir : // 32-bit Linux
@@ -67,7 +67,6 @@
// Set font rendering properties
LogHelper.debug("Setting FX properties");
- java.lang.System.setProperty("prism.text", "t2k");
java.lang.System.setProperty("prism.lcdtext", "false");
// Start laucher JavaFX stage
diff --git a/Launcher/source/Launcher.java b/Launcher/source/Launcher.java
index 732e3f5..d55483f 100644
--- a/Launcher/source/Launcher.java
+++ b/Launcher/source/Launcher.java
@@ -70,7 +70,7 @@
private static final AtomicReference CONFIG = new AtomicReference<>();
// Version info
- @LauncherAPI public static final String VERSION = "15.0";
+ @LauncherAPI public static final String VERSION = "15.1";
@LauncherAPI public static final String BUILD = readBuildNumber();
@LauncherAPI public static final int PROTOCOL_MAGIC = 0x724724_16;