Merge pull request #259 from Yshmeel/dev

Доработал ComboBox с выбором типа авторизации
This commit is contained in:
Gravit 2019-05-13 00:09:53 +07:00 committed by GitHub
commit f0d5afb677
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 21 deletions

View file

@ -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();
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;
var iter = 0;
authTypes = {};
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);
//var sm = authOptions.getSelectionModel();
//sm.selectedIndexProperty()["addListener(javafx.beans.value.ChangeListener)"](settings.auth = i);
})();
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);

View file

@ -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);