From f4adc90f03967c074f9df55579eac430f2ef7a54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minecraft=E4=B8=80=E8=A7=92=E9=92=B1?= <122196845+MinecraftYJQ@users.noreply.github.com> Date: Tue, 19 Aug 2025 10:28:59 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=9C=A8?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B8=B8=E6=88=8F=E7=9B=AE=E5=BD=95=E6=97=B6?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E7=9B=AE=E5=BD=95=E5=90=8E=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=A1=AB=E5=86=99=E6=96=87=E4=BB=B6=E5=A4=B9=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hmcl/ui/profile/ProfilePage.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfilePage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfilePage.java index 71f27f099..56dc8c999 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfilePage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfilePage.java @@ -41,12 +41,14 @@ import org.jackhuang.hmcl.ui.construct.FileItem; import org.jackhuang.hmcl.ui.construct.OptionToggleButton; import org.jackhuang.hmcl.ui.construct.PageCloseEvent; import org.jackhuang.hmcl.ui.decorator.DecoratorPage; +import org.jackhuang.hmcl.util.Holder; import org.jackhuang.hmcl.util.StringUtils; import java.io.File; import java.util.Optional; import static org.jackhuang.hmcl.util.i18n.I18n.i18n; +import static org.jackhuang.hmcl.util.logging.Logger.LOG; public final class ProfilePage extends BorderPane implements DecoratorPage { private final ReadOnlyObjectWrapper state = new ReadOnlyObjectWrapper<>(); @@ -113,6 +115,24 @@ public final class ProfilePage extends BorderPane implements DecoratorPage { gameDir.setTitle(i18n("profile.instance_directory.choose")); gameDir.pathProperty().bindBidirectional(location); + locationProperty().addListener((observable, oldValue, newValue) -> { + LOG.debug("OnChange locationProperty"); + + var folder = new File(newValue); + var oldFolder = new File(oldValue); + File parentFolder = folder.getParentFile(); + File parentOldFolder = oldFolder.getParentFile(); + // txtProfileName + if(parentFolder != null) { + if(txtProfileName.getText().isEmpty()){ + txtProfileName.setText(parentFolder.getName()); + } + else if(!parentFolder.getName().equals(parentOldFolder.getName())){ + txtProfileName.setText(parentFolder.getName()); + } + } + }); + toggleUseRelativePath = new OptionToggleButton(); toggleUseRelativePath.setTitle(i18n("profile.use_relative_path")); From e67edfbb9701f63c38938852388d348000076ea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minecraft=E4=B8=80=E8=A7=92=E9=92=B1?= <122196845+MinecraftYJQ@users.noreply.github.com> Date: Tue, 19 Aug 2025 16:20:28 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E6=A0=BC=E5=BC=8F=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/jackhuang/hmcl/ui/profile/ProfilePage.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfilePage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfilePage.java index 56dc8c999..4d838f8c2 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfilePage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfilePage.java @@ -41,7 +41,6 @@ import org.jackhuang.hmcl.ui.construct.FileItem; import org.jackhuang.hmcl.ui.construct.OptionToggleButton; import org.jackhuang.hmcl.ui.construct.PageCloseEvent; import org.jackhuang.hmcl.ui.decorator.DecoratorPage; -import org.jackhuang.hmcl.util.Holder; import org.jackhuang.hmcl.util.StringUtils; import java.io.File; @@ -123,11 +122,11 @@ public final class ProfilePage extends BorderPane implements DecoratorPage { File parentFolder = folder.getParentFile(); File parentOldFolder = oldFolder.getParentFile(); // txtProfileName - if(parentFolder != null) { - if(txtProfileName.getText().isEmpty()){ + if (parentFolder != null) { + if (txtProfileName.getText().isEmpty()) { txtProfileName.setText(parentFolder.getName()); } - else if(!parentFolder.getName().equals(parentOldFolder.getName())){ + else if (!parentFolder.getName().equals(parentOldFolder.getName())) { txtProfileName.setText(parentFolder.getName()); } }