mirror of
https://github.com/HMCL-dev/HMCL
synced 2026-08-19 22:23:08 -04:00
优化无验证服务器提示 (#6705)
This commit is contained in:
parent
91fcc4e5ef
commit
edbcc1f343
2 changed files with 18 additions and 41 deletions
|
|
@ -67,11 +67,10 @@ import static java.util.Collections.emptyList;
|
|||
import static java.util.Collections.unmodifiableList;
|
||||
import static javafx.beans.binding.Bindings.bindContent;
|
||||
import static javafx.beans.binding.Bindings.createBooleanBinding;
|
||||
import static org.jackhuang.hmcl.setting.SettingsManager.settings;
|
||||
import static org.jackhuang.hmcl.setting.SettingsManager.getAuthlibInjectorServers;
|
||||
import static org.jackhuang.hmcl.setting.SettingsManager.settings;
|
||||
import static org.jackhuang.hmcl.ui.FXUtils.*;
|
||||
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
||||
import static org.jackhuang.hmcl.util.javafx.ExtendedProperties.classPropertyFor;
|
||||
|
||||
public class CreateAccountPane extends JFXDialogLayout implements DialogAware {
|
||||
private static final Pattern USERNAME_CHECKER_PATTERN = Pattern.compile("^[A-Za-z0-9_]+$");
|
||||
|
|
@ -395,13 +394,16 @@ public class CreateAccountPane extends JFXDialogLayout implements DialogAware {
|
|||
() -> Platform.runLater( // the selection will not be updated as expected if we call it immediately
|
||||
cboServers.getSelectionModel()::selectFirst)));
|
||||
cboServers.getSelectionModel().selectFirst();
|
||||
cboServers.setPromptText(i18n("account.injector.empty"));
|
||||
|
||||
Label noServersLabel = new Label(i18n("account.injector.empty"));
|
||||
BooleanBinding noServers = createBooleanBinding(cboServers.getItems()::isEmpty, cboServers.getItems());
|
||||
classPropertyFor(cboServers, "jfx-combo-box-warning").bind(noServers);
|
||||
classPropertyFor(cboServers, "jfx-combo-box").bind(noServers.not());
|
||||
|
||||
HBox.setHgrow(cboServers, Priority.ALWAYS);
|
||||
HBox.setMargin(cboServers, new Insets(0, 10, 0, 0));
|
||||
cboServers.setMaxWidth(Double.MAX_VALUE);
|
||||
HBox.setHgrow(noServersLabel, Priority.ALWAYS);
|
||||
HBox.setMargin(noServersLabel, new Insets(0, 10, 0, 0));
|
||||
noServersLabel.setMaxWidth(Double.MAX_VALUE);
|
||||
|
||||
HBox linksContainer = new HBox();
|
||||
linksContainer.setAlignment(Pos.CENTER);
|
||||
|
|
@ -419,7 +421,13 @@ public class CreateAccountPane extends JFXDialogLayout implements DialogAware {
|
|||
Controllers.dialog(new AddAuthlibInjectorServerPane());
|
||||
});
|
||||
|
||||
HBox boxServers = new HBox(cboServers, linksContainer, btnAddServer);
|
||||
noServersLabel.visibleProperty().bind(noServers);
|
||||
noServersLabel.managedProperty().bind(noServers);
|
||||
cboServers.visibleProperty().bind(noServers.not());
|
||||
cboServers.managedProperty().bind(noServers.not());
|
||||
|
||||
HBox boxServers = new HBox(cboServers, noServersLabel, linksContainer, btnAddServer);
|
||||
boxServers.setAlignment(Pos.CENTER_LEFT);
|
||||
add(boxServers, 1, rowIndex);
|
||||
|
||||
rowIndex++;
|
||||
|
|
|
|||
|
|
@ -22,8 +22,10 @@ import javafx.beans.WeakInvalidationListener;
|
|||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.Property;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.SelectionModel;
|
||||
import javafx.scene.control.Toggle;
|
||||
import javafx.scene.control.ToggleGroup;
|
||||
import org.jackhuang.hmcl.util.Holder;
|
||||
|
||||
import java.util.Objects;
|
||||
|
|
@ -32,7 +34,6 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static javafx.beans.binding.Bindings.createBooleanBinding;
|
||||
import static org.jackhuang.hmcl.util.Pair.pair;
|
||||
|
||||
/**
|
||||
|
|
@ -123,38 +124,6 @@ public final class ExtendedProperties {
|
|||
}
|
||||
// ====
|
||||
|
||||
// ==== CheckBox ====
|
||||
@SuppressWarnings("unchecked")
|
||||
public static ObjectProperty<Boolean> reversedSelectedPropertyFor(CheckBox checkbox) {
|
||||
return (ObjectProperty<Boolean>) checkbox.getProperties().computeIfAbsent(
|
||||
PROP_PREFIX + ".checkbox.reservedSelected",
|
||||
any -> new MappedProperty<Boolean, Boolean>(checkbox, "ext.reservedSelected",
|
||||
checkbox.selectedProperty(), it -> !it, it -> !it));
|
||||
}
|
||||
// ====
|
||||
|
||||
// ==== General ====
|
||||
@SuppressWarnings("unchecked")
|
||||
public static ObjectProperty<Boolean> classPropertyFor(Node node, String cssClass) {
|
||||
return (ObjectProperty<Boolean>) node.getProperties().computeIfAbsent(
|
||||
PROP_PREFIX + ".cssClass." + cssClass,
|
||||
any -> {
|
||||
ObservableList<String> classes = node.getStyleClass();
|
||||
return new ReadWriteComposedProperty<>(node, "extra.cssClass." + cssClass,
|
||||
createBooleanBinding(() -> classes.contains(cssClass), classes),
|
||||
state -> {
|
||||
if (state) {
|
||||
if (!classes.contains(cssClass)) {
|
||||
classes.add(cssClass);
|
||||
}
|
||||
} else {
|
||||
classes.remove(cssClass);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
// ====
|
||||
|
||||
private ExtendedProperties() {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue