From 87c2126e5a8271df5e7a7bec8f29a51085bea976 Mon Sep 17 00:00:00 2001 From: Burning_TNT Date: Sat, 12 Apr 2025 17:39:58 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20#3471:=20=E6=A8=A1=E7=BB=84=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=86=85=E2=80=9C=E5=AE=89=E8=A3=85=E5=88=B0=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E7=89=88=E6=9C=AC=E2=80=9D=E4=B8=8E=E2=80=9C=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E5=88=B0=E6=9C=AC=E5=9C=B0=E6=96=87=E4=BB=B6=E5=A4=B9?= =?UTF-8?q?=E2=80=9D=E7=9B=B8=E5=90=8C=20(#3772)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hmcl/ui/download/DownloadPage.java | 2 +- .../hmcl/ui/versions/DownloadPage.java | 25 ++++++++++++------- .../hmcl/ui/versions/ModListPageSkin.java | 2 +- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/DownloadPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/DownloadPage.java index e97fedf40..f3ec57a3f 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/DownloadPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/download/DownloadPage.java @@ -130,7 +130,7 @@ public class DownloadPage extends DecoratorAnimatedPage implements DecoratorPage }; } - private static void download(Profile profile, @Nullable String version, RemoteMod.Version file, String subdirectoryName) { + public static void download(Profile profile, @Nullable String version, RemoteMod.Version file, String subdirectoryName) { if (version == null) version = profile.getSelectedVersion(); Path runDirectory = profile.getRepository().hasVersion(version) ? profile.getRepository().getRunDirectory(version).toPath() : profile.getRepository().getBaseDirectory().toPath(); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadPage.java index c6ad06f8b..f506d4ed5 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadPage.java @@ -479,14 +479,17 @@ public class DownloadPage extends Control implements DecoratorPage { this.setBody(box); - JFXButton downloadButton = new JFXButton(type == RemoteModRepository.Type.MODPACK ? i18n("install.modpack") : i18n("mods.install")); - downloadButton.getStyleClass().add("dialog-accept"); - downloadButton.setOnAction(e -> { - if (type == RemoteModRepository.Type.MODPACK || !spinnerPane.isLoading() && spinnerPane.getFailedReason() == null) { - fireEvent(new DialogCloseEvent()); - } - selfPage.download(version); - }); + JFXButton downloadButton = null; + if (selfPage.callback != null) { + downloadButton = new JFXButton(type == RemoteModRepository.Type.MODPACK ? i18n("install.modpack") : i18n("mods.install")); + downloadButton.getStyleClass().add("dialog-accept"); + downloadButton.setOnAction(e -> { + if (type == RemoteModRepository.Type.MODPACK || !spinnerPane.isLoading() && spinnerPane.getFailedReason() == null) { + fireEvent(new DialogCloseEvent()); + } + selfPage.download(version); + }); + } JFXButton saveAsButton = new JFXButton(i18n("mods.save_as")); saveAsButton.getStyleClass().add("dialog-accept"); @@ -501,7 +504,11 @@ public class DownloadPage extends Control implements DecoratorPage { cancelButton.getStyleClass().add("dialog-cancel"); cancelButton.setOnAction(e -> fireEvent(new DialogCloseEvent())); - this.setActions(downloadButton, saveAsButton, cancelButton); + if (downloadButton == null) { + this.setActions(saveAsButton, cancelButton); + } else { + this.setActions(downloadButton, saveAsButton, cancelButton); + } this.prefWidthProperty().bind(BindingMapping.of(Controllers.getStage().widthProperty()).map(w -> w.doubleValue() * 0.7)); this.prefHeightProperty().bind(BindingMapping.of(Controllers.getStage().heightProperty()).map(w -> w.doubleValue() * 0.7)); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModListPageSkin.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModListPageSkin.java index ab3391ff4..ad493ea88 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModListPageSkin.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModListPageSkin.java @@ -446,7 +446,7 @@ class ModListPageSkin extends SkinBase { repository instanceof CurseForgeRemoteModRepository ? HMCLLocalizedDownloadListPage.ofCurseForgeMod(null, false) : HMCLLocalizedDownloadListPage.ofModrinthMod(null, false), remoteMod, new Profile.ProfileVersion(ModListPageSkin.this.getSkinnable().getProfile(), ModListPageSkin.this.getSkinnable().getVersionId()), - null + (profile, version, file) -> org.jackhuang.hmcl.ui.download.DownloadPage.download(profile, version, file, "mods") )); }); button.setDisable(false);