Доработал ComboBox с выбором типа авторизации

This commit is contained in:
Ruslan Yusupov 2019-05-12 17:05:01 +00:00
parent cf9f4ebef9
commit 6e1f4cd495
2 changed files with 35 additions and 21 deletions

View file

@ -5,6 +5,8 @@ var profilesList = [];
var movePoint = null; var movePoint = null;
var pingers = {}; var pingers = {};
var loginData; var loginData;
// Variable which contains all types of auth. Appending data at line 255
var authTypes = {};
function initLauncher() { function initLauncher() {
initLoginScene(); initLoginScene();
@ -188,12 +190,16 @@ function goAuth(event) {
} }
// Get auth // Get auth
/* var auth = authOptions.getSelectionModel().getSelectedItem(); var auth = authOptions.getSelectionModel().getSelectedItem();
if (auth === null) { if (auth === null) {
return; // No auth selected return; // No auth selected
}*/ }
var rsaPassword = null; var rsaPassword = null;
var auth = authOptions.getSelectionModel().getSelectedItem();
if (auth === null) {
return;
}
if (!passwordField.isDisable()) { if (!passwordField.isDisable()) {
var password = passwordField.getText(); var password = passwordField.getText();
if (password !== null && !password.isEmpty()) { if (password !== null && !password.isEmpty()) {
@ -208,7 +214,7 @@ function goAuth(event) {
} }
settings.login = login; settings.login = login;
doAuth(/*auth, */login, rsaPassword); doAuth(/*auth, */login, rsaPassword, authTypes[auth]);
} }
/* ======== Console ======== */ /* ======== Console ======== */
@ -242,17 +248,24 @@ function verifyLauncher(e) {
initOffline(); initOffline();
} }
overlay.swap(0, processing.overlay, function(event) makeAuthAvailabilityRequest(function(result) { overlay.swap(0, processing.overlay, function(event) makeAuthAvailabilityRequest(function(result) {
//result.list; var iter = 0;
//result.list[0].name; authTypes = {};
//result.list[0].displayName;
result.list.forEach(function(auth_type, i, arr) { result.list.forEach(function(auth_type, i, arr) {
(function() { 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); authOptions.getItems().add(auth_type.displayName);
//var sm = authOptions.getSelectionModel(); authTypes[auth_type.displayName] = auth_type.name;
//sm.selectedIndexProperty()["addListener(javafx.beans.value.ChangeListener)"](settings.auth = i); 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) { overlay.swap(0, processing.overlay, function(event) makeProfilesRequest(function(result) {
settings.lastProfiles = result.profiles; settings.lastProfiles = result.profiles;
updateProfilesList(result.profiles); updateProfilesList(result.profiles);
@ -267,13 +280,14 @@ function verifyLauncher(e) {
})); }));
} }
function doAuth(login, rsaPassword) { function doAuth(login, rsaPassword, auth_type) {
processing.resetOverlay(); processing.resetOverlay();
overlay.show(processing.overlay, function (event) { overlay.show(processing.overlay, function (event) {
FunctionalBridge.getHWID.join(); FunctionalBridge.getHWID.join();
makeAuthRequest(login, rsaPassword, function (result) { makeAuthRequest(login, rsaPassword, auth_type, function (result) {
FunctionalBridge.setAuthParams(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 () { overlay.hide(0, function () {
setCurrentScene(menuScene); setCurrentScene(menuScene);

View file

@ -124,9 +124,9 @@ function makeSetProfileRequest(profile, callback) {
startTask(task); startTask(task);
} }
function makeAuthRequest(login, rsaPassword, callback) { function makeAuthRequest(login, rsaPassword, auth_type, callback) {
var task = rsaPassword === null ? newTask(offlineAuthRequest(login)) : 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); processing.setTaskProperties(task, callback, null, true);
task.updateMessage("Авторизация на сервере"); task.updateMessage("Авторизация на сервере");
startTask(task); startTask(task);