mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-14 14:26:43 -04:00
use result of prev task instead of AutoTypingMap
This commit is contained in:
parent
28d002f6d3
commit
8bb6cb714c
@ -119,16 +119,16 @@ public final class LeftPaneController extends AdvancedListBox {
|
|||||||
if (repository.getVersionCount() == 0) {
|
if (repository.getVersionCount() == 0) {
|
||||||
File modpackFile = new File("modpack.zip").getAbsoluteFile();
|
File modpackFile = new File("modpack.zip").getAbsoluteFile();
|
||||||
if (modpackFile.exists()) {
|
if (modpackFile.exists()) {
|
||||||
Task.ofResult("encoding", () -> CompressingUtils.findSuitableEncoding(modpackFile.toPath()))
|
Task.ofResult(() -> CompressingUtils.findSuitableEncoding(modpackFile.toPath()))
|
||||||
.then(Task.ofResult("modpack", var -> ModpackHelper.readModpackManifest(modpackFile.toPath(), var.get("encoding"))))
|
.thenResult(encoding -> ModpackHelper.readModpackManifest(modpackFile.toPath(), encoding))
|
||||||
.then(Task.of(var -> {
|
.thenResult(modpack -> {
|
||||||
AtomicReference<Region> region = new AtomicReference<>();
|
AtomicReference<Region> region = new AtomicReference<>();
|
||||||
Modpack modpack = var.get("modpack");
|
|
||||||
TaskExecutor executor = ModpackHelper.getInstallTask(repository.getProfile(), modpackFile, modpack.getName(), modpack)
|
TaskExecutor executor = ModpackHelper.getInstallTask(repository.getProfile(), modpackFile, modpack.getName(), modpack)
|
||||||
.with(Task.of(Schedulers.javafx(), this::checkAccount)).executor();
|
.with(Task.of(Schedulers.javafx(), this::checkAccount)).executor();
|
||||||
region.set(Controllers.taskDialog(executor, i18n("modpack.installing")));
|
region.set(Controllers.taskDialog(executor, i18n("modpack.installing")));
|
||||||
executor.start();
|
executor.start();
|
||||||
})).start();
|
return null;
|
||||||
|
}).start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,25 +59,19 @@ public class AccountLoginPane extends StackPane {
|
|||||||
String password = txtPassword.getText();
|
String password = txtPassword.getText();
|
||||||
progressBar.setVisible(true);
|
progressBar.setVisible(true);
|
||||||
lblCreationWarning.setText("");
|
lblCreationWarning.setText("");
|
||||||
Task.ofResult("login", () -> {
|
Task.ofResult(() -> oldAccount.logInWithPassword(password))
|
||||||
try {
|
.finalizedResult(Schedulers.javafx(), authInfo -> {
|
||||||
return oldAccount.logInWithPassword(password);
|
success.accept(authInfo);
|
||||||
} catch (Exception e) {
|
fireEvent(new DialogCloseEvent());
|
||||||
return e;
|
progressBar.setVisible(false);
|
||||||
}
|
}, e -> {
|
||||||
}).subscribe(Schedulers.javafx(), variable -> {
|
if (e instanceof NoSelectedCharacterException) {
|
||||||
Object account = variable.get("login");
|
fireEvent(new DialogCloseEvent());
|
||||||
if (account instanceof AuthInfo) {
|
} else {
|
||||||
success.accept(((AuthInfo) account));
|
lblCreationWarning.setText(AddAccountPane.accountException(e));
|
||||||
fireEvent(new DialogCloseEvent());
|
}
|
||||||
} else if (account instanceof NoSelectedCharacterException) {
|
progressBar.setVisible(false);
|
||||||
fireEvent(new DialogCloseEvent());
|
}).start();
|
||||||
} else if (account instanceof Exception) {
|
|
||||||
lblCreationWarning.setText(AddAccountPane.accountException((Exception) account));
|
|
||||||
}
|
|
||||||
|
|
||||||
progressBar.setVisible(false);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -160,10 +160,8 @@ public class AddAccountPane extends StackPane {
|
|||||||
AccountFactory<?> factory = cboType.getSelectionModel().getSelectedItem();
|
AccountFactory<?> factory = cboType.getSelectionModel().getSelectedItem();
|
||||||
Object additionalData = getAuthAdditionalData();
|
Object additionalData = getAuthAdditionalData();
|
||||||
|
|
||||||
Task.ofResult("create_account", () -> factory.create(new Selector(), username, password, additionalData))
|
Task.ofResult(() -> factory.create(new Selector(), username, password, additionalData))
|
||||||
.finalized(Schedulers.javafx(), variables -> {
|
.finalizedResult(Schedulers.javafx(), account -> {
|
||||||
|
|
||||||
Account account = variables.get("create_account");
|
|
||||||
int oldIndex = Accounts.getAccounts().indexOf(account);
|
int oldIndex = Accounts.getAccounts().indexOf(account);
|
||||||
if (oldIndex == -1) {
|
if (oldIndex == -1) {
|
||||||
Accounts.getAccounts().add(account);
|
Accounts.getAccounts().add(account);
|
||||||
|
@ -109,10 +109,9 @@ public final class ModpackPage extends StackPane implements WizardPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
spinnerPane.showSpinner();
|
spinnerPane.showSpinner();
|
||||||
Task.ofResult("encoding", () -> CompressingUtils.findSuitableEncoding(selectedFile.toPath()))
|
Task.ofResult(() -> CompressingUtils.findSuitableEncoding(selectedFile.toPath()))
|
||||||
.then(Task.ofResult("manifest", var ->
|
.thenResult(encoding -> manifest = ModpackHelper.readModpackManifest(selectedFile.toPath(), encoding))
|
||||||
manifest = ModpackHelper.readModpackManifest(selectedFile.toPath(), var.get("encoding"))))
|
.finalizedResult(Schedulers.javafx(), manifest -> {
|
||||||
.finalized(Schedulers.javafx(), var -> {
|
|
||||||
spinnerPane.hideSpinner();
|
spinnerPane.hideSpinner();
|
||||||
controller.getSettings().put(MODPACK_MANIFEST, manifest);
|
controller.getSettings().put(MODPACK_MANIFEST, manifest);
|
||||||
lblName.setText(manifest.getName());
|
lblName.setText(manifest.getName());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user