From 22c66b2790a7ed5c4a66fc5415667e8adf63ff85 Mon Sep 17 00:00:00 2001 From: Calboot Date: Tue, 23 Dec 2025 22:25:21 +0800 Subject: [PATCH] =?UTF-8?q?[Bugfix]=20=E4=BF=AE=E5=A4=8D=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E6=95=B4=E5=90=88=E5=8C=85=E6=9C=89=E5=85=B3=E4=BB=A5=E5=8F=8A?= =?UTF-8?q?NBT=E6=96=87=E4=BB=B6=E6=9F=A5=E7=9C=8B=E6=9C=89=E5=85=B3?= =?UTF-8?q?=E7=9A=84=E7=95=8C=E9=9D=A2=E6=A0=B7=E5=BC=8F=E5=8F=8A=E6=B7=B1?= =?UTF-8?q?=E8=89=B2=E6=A8=A1=E5=BC=8F=E9=97=AE=E9=A2=98=20(#5043)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #5042 --- .../ui/export/ModpackFileSelectionPage.java | 12 +++--- .../ui/export/ModpackTypeSelectionPage.java | 5 +-- .../jackhuang/hmcl/ui/nbt/NBTEditorPage.java | 5 ++- .../jackhuang/hmcl/ui/nbt/NBTTreeView.java | 9 ++-- HMCL/src/main/resources/assets/css/root.css | 41 +++++++++++++++++++ 5 files changed, 60 insertions(+), 12 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/export/ModpackFileSelectionPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/export/ModpackFileSelectionPage.java index f002dd548..ed7664a9d 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/export/ModpackFileSelectionPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/export/ModpackFileSelectionPage.java @@ -18,10 +18,10 @@ package org.jackhuang.hmcl.ui.export; import com.jfoenix.controls.JFXButton; +import com.jfoenix.controls.JFXCheckBox; import com.jfoenix.controls.JFXTreeView; import javafx.geometry.Insets; import javafx.geometry.Pos; -import javafx.scene.control.CheckBox; import javafx.scene.control.CheckBoxTreeItem; import javafx.scene.control.Label; import javafx.scene.control.TreeItem; @@ -44,6 +44,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import static org.jackhuang.hmcl.ui.FXUtils.onEscPressed; import static org.jackhuang.hmcl.util.Lang.mapOf; import static org.jackhuang.hmcl.util.Pair.pair; import static org.jackhuang.hmcl.util.i18n.I18n.i18n; @@ -67,6 +68,8 @@ public final class ModpackFileSelectionPage extends BorderPane implements Wizard rootNode = getTreeItem(profile.getRepository().getRunDirectory(version), "minecraft"); treeView.setRoot(rootNode); treeView.setSelectionModel(new NoneMultipleSelectionModel<>()); + onEscPressed(treeView, () -> controller.onPrev(true)); + setMargin(treeView, new Insets(10, 10, 5, 10)); this.setCenter(treeView); HBox nextPane = new HBox(); @@ -142,15 +145,14 @@ public final class ModpackFileSelectionPage extends BorderPane implements Wizard } HBox graphic = new HBox(); - CheckBox checkBox = new CheckBox(); + JFXCheckBox checkBox = new JFXCheckBox(); checkBox.selectedProperty().bindBidirectional(node.selectedProperty()); checkBox.indeterminateProperty().bindBidirectional(node.indeterminateProperty()); graphic.getChildren().add(checkBox); if (TRANSLATION.containsKey(basePath)) { - Label comment = new Label(); - comment.setText(TRANSLATION.get(basePath)); - comment.setStyle("-fx-text-fill: gray;"); + Label comment = new Label(TRANSLATION.get(basePath)); + comment.setStyle("-fx-text-fill: -monet-on-surface-variant;"); comment.setMouseTransparent(true); graphic.getChildren().add(comment); } diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/export/ModpackTypeSelectionPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/export/ModpackTypeSelectionPage.java index 62da3f0fc..9f0f7bb41 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/export/ModpackTypeSelectionPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/export/ModpackTypeSelectionPage.java @@ -20,10 +20,10 @@ package org.jackhuang.hmcl.ui.export; import com.jfoenix.controls.JFXButton; import javafx.geometry.Insets; import javafx.geometry.Pos; +import javafx.scene.Node; import javafx.scene.control.Label; import javafx.scene.layout.BorderPane; import javafx.scene.layout.VBox; -import javafx.scene.shape.SVGPath; import org.jackhuang.hmcl.mod.ModpackExportInfo; import org.jackhuang.hmcl.mod.mcbbs.McbbsModpackExportTask; import org.jackhuang.hmcl.mod.multimc.MultiMCModpackExportTask; @@ -77,8 +77,7 @@ public final class ModpackTypeSelectionPage extends VBox implements WizardPage { graphic.setMouseTransparent(true); graphic.setLeft(new TwoLineListItem(i18n("modpack.type." + type), i18n("modpack.type." + type + ".export"))); - SVGPath arrow = new SVGPath(); - arrow.setContent(SVG.ARROW_FORWARD.getPath()); + Node arrow = SVG.ARROW_FORWARD.createIcon(); BorderPane.setAlignment(arrow, Pos.CENTER); graphic.setRight(arrow); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/nbt/NBTEditorPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/nbt/NBTEditorPage.java index 3632aa741..fca15907b 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/nbt/NBTEditorPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/nbt/NBTEditorPage.java @@ -89,7 +89,10 @@ public final class NBTEditorPage extends SpinnerPane implements DecoratorPage { .whenComplete(Schedulers.javafx(), (result, exception) -> { if (exception == null) { setLoading(false); - root.setCenter(new NBTTreeView(result)); + NBTTreeView view = new NBTTreeView(result); + BorderPane.setMargin(view, new Insets(10)); + onEscPressed(view, cancelButton::fire); + root.setCenter(view); } else { LOG.warning("Fail to open nbt file", exception); Controllers.dialog(i18n("nbt.open.failed") + "\n\n" + StringUtils.getStackTrace(exception), null, MessageDialogPane.MessageType.WARNING, cancelButton::fire); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/nbt/NBTTreeView.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/nbt/NBTTreeView.java index 86a5594c5..650d02cbd 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/nbt/NBTTreeView.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/nbt/NBTTreeView.java @@ -20,7 +20,10 @@ package org.jackhuang.hmcl.ui.nbt; import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.ListTag; import com.github.steveice10.opennbt.tag.builtin.Tag; -import javafx.scene.control.*; +import com.jfoenix.controls.JFXTreeView; +import javafx.scene.control.TreeCell; +import javafx.scene.control.TreeItem; +import javafx.scene.control.TreeView; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.util.Callback; @@ -34,7 +37,7 @@ import static org.jackhuang.hmcl.util.i18n.I18n.i18n; /** * @author Glavo */ -public final class NBTTreeView extends TreeView { +public final class NBTTreeView extends JFXTreeView { public NBTTreeView(NBTTreeView.Item tree) { this.setRoot(tree); @@ -45,7 +48,7 @@ public final class NBTTreeView extends TreeView { Holder lastCell = new Holder<>(); EnumMap icons = new EnumMap<>(NBTTagType.class); - return view -> new TreeCell() { + return view -> new TreeCell<>() { private void setTagText(String text) { String name = ((Item) getTreeItem()).getName(); diff --git a/HMCL/src/main/resources/assets/css/root.css b/HMCL/src/main/resources/assets/css/root.css index e033d11e5..ac93303b3 100644 --- a/HMCL/src/main/resources/assets/css/root.css +++ b/HMCL/src/main/resources/assets/css/root.css @@ -1573,6 +1573,47 @@ -fx-fill: transparent; } +/******************************************************************************* + * * + * JFX Tree View * + * * + ******************************************************************************/ + +.tree-view { + -fx-padding: 5; + -fx-background-radius: 6; + -fx-background-color: -monet-surface-container-low; + -fx-border-radius: 6; +} + +.tree-cell { + -fx-padding: 5; + -fx-background-radius: 6; + -fx-background-color: transparent; + -fx-text-fill: -monet-on-surface; + -fx-border-radius: 6; +} + +.tree-cell:focused { + -fx-background-color: -monet-secondary-container; +} + +.tree-cell .arrow { + -fx-background-color: -monet-on-surface; +} + +.tree-cell .jfx-rippler { + -jfx-rippler-disabled: true; +} + +.tree-view > .virtual-flow > .scroll-bar { + -fx-skin: "org.jackhuang.hmcl.ui.construct.FloatScrollBarSkin"; +} + +.tree-view > .virtual-flow > .scroll-bar .track { + -fx-fill: transparent; +} + /******************************************************************************* * * * JFX Decorator *