Refactor: OfflineAccountSkinPane (#6231)

This commit is contained in:
快乐凤爪王 authored and GitHub committed 2026-06-30 20:37:47 +08:00
1 parent c8f66a457d
commit 31642f9185
1 file changed
+57 -45
@@ -25,7 +25,6 @@ import javafx.animation.PauseTransition;
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 class OfflineAccountSkinPane extends StackPane {
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 class OfflineAccountSkinPane extends StackPane {
});
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 class OfflineAccountSkinPane extends StackPane {
}
}, 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
right.getChildren().clear();
gridPane.setPadding(new Insets(0, 0, 45, 10));
gridPane.setHgap(16);
gridPane.setVgap(8);
gridPane.getColumnConstraints().setAll(new ColumnConstraints(), FXUtils.getColumnHgrowing());
if (selectedData != null) {
switch (selectedData) {
case DEFAULT:
case STEVE:
case ALEX:
break;
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"));
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);
hint.setMaxWidth(Double.MAX_VALUE);
// Force top alignment within cells (to avoid vertical offset caused by the baseline)
GridPane.setValignment(hint, VPos.TOP);
right.getChildren().add(hint);
break;
// 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);
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;
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;
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"));