Fix #3471: 模组管理内“安装到当前版本”与“下载到本地文件夹”相同 (#3772)

This commit is contained in:
Burning_TNT
2025-04-12 17:39:58 +08:00
committed by GitHub
parent abf1ec3eb8
commit 87c2126e5a
3 changed files with 18 additions and 11 deletions

View File

@@ -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(); if (version == null) version = profile.getSelectedVersion();
Path runDirectory = profile.getRepository().hasVersion(version) ? profile.getRepository().getRunDirectory(version).toPath() : profile.getRepository().getBaseDirectory().toPath(); Path runDirectory = profile.getRepository().hasVersion(version) ? profile.getRepository().getRunDirectory(version).toPath() : profile.getRepository().getBaseDirectory().toPath();

View File

@@ -479,14 +479,17 @@ public class DownloadPage extends Control implements DecoratorPage {
this.setBody(box); this.setBody(box);
JFXButton downloadButton = new JFXButton(type == RemoteModRepository.Type.MODPACK ? i18n("install.modpack") : i18n("mods.install")); JFXButton downloadButton = null;
downloadButton.getStyleClass().add("dialog-accept"); if (selfPage.callback != null) {
downloadButton.setOnAction(e -> { downloadButton = new JFXButton(type == RemoteModRepository.Type.MODPACK ? i18n("install.modpack") : i18n("mods.install"));
if (type == RemoteModRepository.Type.MODPACK || !spinnerPane.isLoading() && spinnerPane.getFailedReason() == null) { downloadButton.getStyleClass().add("dialog-accept");
fireEvent(new DialogCloseEvent()); downloadButton.setOnAction(e -> {
} if (type == RemoteModRepository.Type.MODPACK || !spinnerPane.isLoading() && spinnerPane.getFailedReason() == null) {
selfPage.download(version); fireEvent(new DialogCloseEvent());
}); }
selfPage.download(version);
});
}
JFXButton saveAsButton = new JFXButton(i18n("mods.save_as")); JFXButton saveAsButton = new JFXButton(i18n("mods.save_as"));
saveAsButton.getStyleClass().add("dialog-accept"); saveAsButton.getStyleClass().add("dialog-accept");
@@ -501,7 +504,11 @@ public class DownloadPage extends Control implements DecoratorPage {
cancelButton.getStyleClass().add("dialog-cancel"); cancelButton.getStyleClass().add("dialog-cancel");
cancelButton.setOnAction(e -> fireEvent(new DialogCloseEvent())); 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.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)); this.prefHeightProperty().bind(BindingMapping.of(Controllers.getStage().heightProperty()).map(w -> w.doubleValue() * 0.7));

View File

@@ -446,7 +446,7 @@ class ModListPageSkin extends SkinBase<ModListPage> {
repository instanceof CurseForgeRemoteModRepository ? HMCLLocalizedDownloadListPage.ofCurseForgeMod(null, false) : HMCLLocalizedDownloadListPage.ofModrinthMod(null, false), repository instanceof CurseForgeRemoteModRepository ? HMCLLocalizedDownloadListPage.ofCurseForgeMod(null, false) : HMCLLocalizedDownloadListPage.ofModrinthMod(null, false),
remoteMod, remoteMod,
new Profile.ProfileVersion(ModListPageSkin.this.getSkinnable().getProfile(), ModListPageSkin.this.getSkinnable().getVersionId()), 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); button.setDisable(false);