diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AddAccountPane.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AddAccountPane.java index b1a9daf70..7aab8b9e4 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AddAccountPane.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/AddAccountPane.java @@ -20,6 +20,7 @@ package org.jackhuang.hmcl.ui.account; import com.jfoenix.concurrency.JFXUtilities; import com.jfoenix.controls.*; +import javafx.beans.InvalidationListener; import javafx.beans.binding.Bindings; import javafx.beans.property.ReadOnlyObjectProperty; import javafx.fxml.FXML; @@ -90,6 +91,9 @@ public class AddAccountPane extends StackPane { cboType.setConverter(stringConverter(Accounts::getAccountTypeName)); cboType.getSelectionModel().select(0); + cboServers.getItems().addListener(onInvalidating(this::checkIfNoServer)); + checkIfNoServer(); + ReadOnlyObjectProperty> loginType = cboType.getSelectionModel().selectedItemProperty(); txtPassword.visibleProperty().bind(loginType.isNotEqualTo(Accounts.FACTORY_OFFLINE)); @@ -122,6 +126,13 @@ public class AddAccountPane extends StackPane { } } + private void checkIfNoServer() { + if (cboServers.getItems().isEmpty()) + cboServers.getStyleClass().setAll("jfx-combo-box-warning"); + else + cboServers.getStyleClass().setAll("jfx-combo-box"); + } + /** * Gets the additional data that needs to be passed into {@link AccountFactory#create(CharacterSelector, String, String, Object)}. */ diff --git a/HMCL/src/main/resources/assets/css/root.css b/HMCL/src/main/resources/assets/css/root.css index 94fe55876..57e7fde41 100644 --- a/HMCL/src/main/resources/assets/css/root.css +++ b/HMCL/src/main/resources/assets/css/root.css @@ -1007,6 +1007,15 @@ -jfx-focus-color: -fx-base-check-color; } +.jfx-combo-box-warning { + -jfx-focus-color: #D34336; + -jfx-unfocus-color: #D34336; +} + +.jfx-combo-box-warning .text { + -fx-fill: #D34336; +} + .combo-box-popup .list-view .jfx-list-cell .label, .combo-box-popup .list-view .jfx-list-cell:filled:hover .label { -fx-text-fill: BLACK;