mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-14 14:26:43 -04:00
feat: select authlib-injector server after added
* The most recently added server will be at the top. * In Add Account dialog, after adding an authlib-injector server, it will be automatically selected.
This commit is contained in:
parent
7c11ce53f3
commit
fbb5a03e5d
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Hello Minecraft! Launcher
|
* Hello Minecraft! Launcher
|
||||||
* Copyright (C) 2020 huangyuhui <huanghongxun2008@126.com> and contributors
|
* Copyright (C) 2021 huangyuhui <huanghongxun2008@126.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -87,8 +87,8 @@ public class AddAccountPane extends StackPane {
|
|||||||
cboServers.setCellFactory(jfxListCellFactory(server -> new TwoLineListItem(server.getName(), server.getUrl())));
|
cboServers.setCellFactory(jfxListCellFactory(server -> new TwoLineListItem(server.getName(), server.getUrl())));
|
||||||
cboServers.setConverter(stringConverter(AuthlibInjectorServer::getName));
|
cboServers.setConverter(stringConverter(AuthlibInjectorServer::getName));
|
||||||
Bindings.bindContent(cboServers.getItems(), config().getAuthlibInjectorServers());
|
Bindings.bindContent(cboServers.getItems(), config().getAuthlibInjectorServers());
|
||||||
cboServers.getItems().addListener(onInvalidating(this::selectDefaultServer));
|
cboServers.getItems().addListener(onInvalidating(this::resetServerSelection));
|
||||||
selectDefaultServer();
|
resetServerSelection();
|
||||||
|
|
||||||
cboType.getItems().setAll(Accounts.FACTORIES);
|
cboType.getItems().setAll(Accounts.FACTORIES);
|
||||||
cboType.setConverter(stringConverter(Accounts::getLocalizedLoginTypeName));
|
cboType.setConverter(stringConverter(Accounts::getLocalizedLoginTypeName));
|
||||||
@ -174,12 +174,13 @@ public class AddAccountPane extends StackPane {
|
|||||||
return unmodifiableList(result);
|
return unmodifiableList(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private void resetServerSelection() {
|
||||||
* Selects the first server if no server is selected.
|
if (!cboServers.getItems().isEmpty()) {
|
||||||
*/
|
Platform.runLater(() -> {
|
||||||
private void selectDefaultServer() {
|
// the selection will not be updated as expected
|
||||||
if (!cboServers.getItems().isEmpty() && cboServers.getSelectionModel().isEmpty()) {
|
// if we call it immediately
|
||||||
cboServers.getSelectionModel().select(0);
|
cboServers.getSelectionModel().selectFirst();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Hello Minecraft! Launcher
|
* Hello Minecraft! Launcher
|
||||||
* Copyright (C) 2020 huangyuhui <huanghongxun2008@126.com> and contributors
|
* Copyright (C) 2021 huangyuhui <huanghongxun2008@126.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -129,7 +129,7 @@ public class AddAuthlibInjectorServerPane extends StackPane implements DialogAwa
|
|||||||
@FXML
|
@FXML
|
||||||
private void onAddFinish() {
|
private void onAddFinish() {
|
||||||
if (!config().getAuthlibInjectorServers().contains(serverBeingAdded)) {
|
if (!config().getAuthlibInjectorServers().contains(serverBeingAdded)) {
|
||||||
config().getAuthlibInjectorServers().add(serverBeingAdded);
|
config().getAuthlibInjectorServers().add(0, serverBeingAdded);
|
||||||
}
|
}
|
||||||
fireEvent(new DialogCloseEvent());
|
fireEvent(new DialogCloseEvent());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user