From 6e1f4cd495577f51900fae91bcd4acef2c0cf640 Mon Sep 17 00:00:00 2001 From: Ruslan Yusupov Date: Sun, 12 May 2019 17:05:01 +0000 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=D0=BB=20ComboBox=20=D1=81=20=D0=B2=D1=8B=D0=B1=D0=BE?= =?UTF-8?q?=D1=80=D0=BE=D0=BC=20=D1=82=D0=B8=D0=BF=D0=B0=20=D0=B0=D0=B2?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Launcher/runtime/dialog/dialog.js | 52 ++++++++++++------- .../dialog/overlay/processing/processing.js | 4 +- 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/Launcher/runtime/dialog/dialog.js b/Launcher/runtime/dialog/dialog.js index 77cf4281..483e49e6 100644 --- a/Launcher/runtime/dialog/dialog.js +++ b/Launcher/runtime/dialog/dialog.js @@ -5,6 +5,8 @@ var profilesList = []; var movePoint = null; var pingers = {}; var loginData; +// Variable which contains all types of auth. Appending data at line 255 +var authTypes = {}; function initLauncher() { initLoginScene(); @@ -188,12 +190,16 @@ function goAuth(event) { } // Get auth - /* var auth = authOptions.getSelectionModel().getSelectedItem(); - if (auth === null) { - return; // No auth selected - }*/ + var auth = authOptions.getSelectionModel().getSelectedItem(); + if (auth === null) { + return; // No auth selected + } var rsaPassword = null; + var auth = authOptions.getSelectionModel().getSelectedItem(); + if (auth === null) { + return; + } if (!passwordField.isDisable()) { var password = passwordField.getText(); if (password !== null && !password.isEmpty()) { @@ -208,7 +214,7 @@ function goAuth(event) { } settings.login = login; - doAuth(/*auth, */login, rsaPassword); + doAuth(/*auth, */login, rsaPassword, authTypes[auth]); } /* ======== Console ======== */ @@ -242,17 +248,24 @@ function verifyLauncher(e) { initOffline(); } overlay.swap(0, processing.overlay, function(event) makeAuthAvailabilityRequest(function(result) { - //result.list; - //result.list[0].name; - //result.list[0].displayName; - result.list.forEach(function(auth_type, i, arr) { - (function() { - authOptions.getItems().add(auth_type.displayName); - //var sm = authOptions.getSelectionModel(); - //sm.selectedIndexProperty()["addListener(javafx.beans.value.ChangeListener)"](settings.auth = i); - })(); - - }); + var iter = 0; + authTypes = {}; + result.list.forEach(function(auth_type, i, arr) { + var serverAuth = new com.jfoenix.controls.JFXComboBox(); + serverAuth.getStyleClass().add("authOptions"); + // add display name to items and add name with iter to variable authTypes + authOptions.getItems().add(auth_type.displayName); + authTypes[auth_type.displayName] = auth_type.name; + iter++; + }); + var sm = authOptions.getSelectionModel().selectedIndexProperty(); + // add listener to authOptions select + sm.addListener(new javafx.beans.value.ChangeListener({ + changed: function (observableValue, oldSelection, newSelection) { + // get auth name from authTypes + settings.auth = authTypes[authOptions.getSelectionModel().getSelectedItem()]; + } + })); overlay.swap(0, processing.overlay, function(event) makeProfilesRequest(function(result) { settings.lastProfiles = result.profiles; updateProfilesList(result.profiles); @@ -267,13 +280,14 @@ function verifyLauncher(e) { })); } -function doAuth(login, rsaPassword) { +function doAuth(login, rsaPassword, auth_type) { processing.resetOverlay(); overlay.show(processing.overlay, function (event) { FunctionalBridge.getHWID.join(); - makeAuthRequest(login, rsaPassword, function (result) { + makeAuthRequest(login, rsaPassword, auth_type, function (result) { FunctionalBridge.setAuthParams(result); - loginData = { pp: result.playerProfile , accessToken: result.accessToken, permissions: result.permissions}; + loginData = { pp: result.playerProfile , accessToken: result.accessToken, permissions: result.permissions, + auth_type: settings.auth}; overlay.hide(0, function () { setCurrentScene(menuScene); diff --git a/Launcher/runtime/dialog/overlay/processing/processing.js b/Launcher/runtime/dialog/overlay/processing/processing.js index f14a6638..568cc2ee 100644 --- a/Launcher/runtime/dialog/overlay/processing/processing.js +++ b/Launcher/runtime/dialog/overlay/processing/processing.js @@ -124,9 +124,9 @@ function makeSetProfileRequest(profile, callback) { startTask(task); } -function makeAuthRequest(login, rsaPassword, callback) { +function makeAuthRequest(login, rsaPassword, auth_type, callback) { var task = rsaPassword === null ? newTask(offlineAuthRequest(login)) : - newRequestTask(new AuthRequest(login, rsaPassword, FunctionalBridge.getHWID())); + newRequestTask(new AuthRequest(login, rsaPassword, FunctionalBridge.getHWID(), auth_type)); processing.setTaskProperties(task, callback, null, true); task.updateMessage("Авторизация на сервере"); startTask(task);