diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/OfflineAccountSkinPane.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/OfflineAccountSkinPane.java index cac425257a2..8f3ddc1bebc 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/OfflineAccountSkinPane.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/account/OfflineAccountSkinPane.java @@ -25,7 +25,6 @@ import javafx.application.Platform; import javafx.beans.InvalidationListener; import javafx.geometry.Insets; -import javafx.geometry.VPos; import javafx.scene.control.Label; import javafx.scene.input.DragEvent; import javafx.scene.input.TransferMode; @@ -75,11 +74,11 @@ public OfflineAccountSkinPane(OfflineAccount account) { BorderPane pane = new BorderPane(); - SkinCanvas canvas = new SkinCanvas(TexturesLoader.getDefaultSkinImage(), 300, 300, true); + SkinCanvas canvas = new SkinCanvas(TexturesLoader.getDefaultSkinImage(), 260, 260, true); StackPane canvasPane = new StackPane(canvas); - canvasPane.setPrefWidth(300); - canvasPane.setPrefHeight(300); - pane.setCenter(canvas); + canvasPane.setPrefWidth(260); + canvasPane.setPrefHeight(260); + pane.setCenter(canvasPane); canvas.getAnimationPlayer().addSkinAnimation(new SkinAniWavingArms(100, 2000, 7.5, canvas), new SkinAniRunning(100, 100, 30, canvas)); canvas.enableRotation(.5); @@ -101,12 +100,12 @@ public OfflineAccountSkinPane(OfflineAccount account) { }); StackPane skinOptionPane = new StackPane(); - skinOptionPane.setMaxWidth(300); - VBox optionPane = new VBox(skinItem, skinOptionPane); - pane.setRight(optionPane); + pane.setRight(skinOptionPane); - skinSelector.maxWidthProperty().bind(skinOptionPane.maxWidthProperty().multiply(0.7)); - capeSelector.maxWidthProperty().bind(skinOptionPane.maxWidthProperty().multiply(0.7)); + skinSelector.setMaxWidth(Double.MAX_VALUE); + capeSelector.setMaxWidth(Double.MAX_VALUE); + modelCombobox.setMaxWidth(Double.MAX_VALUE); + cslApiField.setMaxWidth(Double.MAX_VALUE); layout.setBody(pane); @@ -180,50 +179,63 @@ public OfflineAccountSkinPane(OfflineAccount account) { } }, skinItem.selectedDataProperty(), cslApiField.textProperty(), modelCombobox.valueProperty(), skinSelector.valueProperty(), capeSelector.valueProperty()); + VBox right = new VBox(); + right.setPadding(new Insets(0, 0, 0, 10)); + right.setSpacing(12); + right.setPrefWidth(230); + HBox.setHgrow(right, Priority.ALWAYS); + + HBox body = new HBox(20); + skinItem.setPrefWidth(170); + skinItem.setMinWidth(170); + body.getChildren().add(skinItem); + + skinOptionPane.getChildren().setAll(body); + FXUtils.onChangeAndOperate(skinItem.selectedDataProperty(), selectedData -> { - GridPane gridPane = new GridPane(); - // Increase bottom padding to prevent the prompt from overlapping with the dialog action area - - gridPane.setPadding(new Insets(0, 0, 45, 10)); - gridPane.setHgap(16); - gridPane.setVgap(8); - gridPane.getColumnConstraints().setAll(new ColumnConstraints(), FXUtils.getColumnHgrowing()); - - switch (selectedData) { - case DEFAULT: - case STEVE: - case ALEX: - break; - case LITTLE_SKIN: - HintPane hint = new HintPane(MessageDialogPane.MessageType.INFO); - hint.setText(i18n("account.skin.type.little_skin.hint")); - - // Spanning two columns and expanding horizontally - GridPane.setColumnSpan(hint, 2); - GridPane.setHgrow(hint, Priority.ALWAYS); - hint.setMaxWidth(Double.MAX_VALUE); - - // Force top alignment within cells (to avoid vertical offset caused by the baseline) - GridPane.setValignment(hint, VPos.TOP); - - // Set a fixed height as the preferred height to prevent the GridPane from stretching or leaving empty space. - hint.setMaxHeight(Region.USE_PREF_SIZE); - hint.setMinHeight(Region.USE_PREF_SIZE); - - gridPane.addRow(0, hint); - break; - case LOCAL_FILE: - gridPane.setPadding(new Insets(0, 0, 0, 10)); - gridPane.addRow(0, new Label(i18n("account.skin.model")), modelCombobox); - gridPane.addRow(1, new Label(i18n("account.skin")), skinSelector); - gridPane.addRow(2, new Label(i18n("account.cape")), capeSelector); - break; - case CUSTOM_SKIN_LOADER_API: - gridPane.addRow(0, new Label(i18n("account.skin.type.csl_api.location")), cslApiField); - break; + right.getChildren().clear(); + + if (selectedData != null) { + switch (selectedData) { + case DEFAULT: + case STEVE: + case ALEX: + break; + + case LITTLE_SKIN: + HintPane hint = new HintPane(MessageDialogPane.MessageType.INFO); + hint.setText(i18n("account.skin.type.little_skin.hint")); + + hint.setMaxWidth(Double.MAX_VALUE); + + right.getChildren().add(hint); + break; + + case LOCAL_FILE: + right.getChildren().addAll( + new Label(i18n("account.skin.model")), + modelCombobox, + new Label(i18n("account.skin")), + skinSelector, + new Label(i18n("account.cape")), + capeSelector + ); + break; + + case CUSTOM_SKIN_LOADER_API: + right.getChildren().addAll( + new Label(i18n("account.skin.type.csl_api.location")), + cslApiField + ); + break; + } } - skinOptionPane.getChildren().setAll(gridPane); + if (right.getChildren().isEmpty()) { + body.getChildren().remove(right); + } else if (!body.getChildren().contains(right)) { + body.getChildren().add(right); + } }); JFXButton acceptButton = new JFXButton(i18n("button.ok"));