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 a467c3c32..971032b9f 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 @@ -93,7 +93,7 @@ public class DownloadPage extends DecoratorAnimatedPage implements DecoratorPage return page; })); modTab.setNodeSupplier(loadVersionFor(() -> new ModDownloadListPage((profile, version, file) -> download(profile, version, file, "mods"), true))); - resourcePackTab.setNodeSupplier(loadVersionFor(() -> new DownloadListPage(CurseForgeRemoteModRepository.RESOURCE_PACKS, (profile, version, file) -> download(profile, version, file, "resourcepacks")))); + resourcePackTab.setNodeSupplier(loadVersionFor(() -> new DownloadListPage(CurseForgeRemoteModRepository.RESOURCE_PACKS, (profile, version, file) -> download(profile, version, file, "resourcepacks"), true))); customizationTab.setNodeSupplier(loadVersionFor(() -> new DownloadListPage(CurseForgeRemoteModRepository.CUSTOMIZATIONS))); worldTab.setNodeSupplier(loadVersionFor(() -> new DownloadListPage(CurseForgeRemoteModRepository.WORLDS))); tab = new TabHeader(newGameTab, modpackTab, modTab, resourcePackTab, worldTab); @@ -193,24 +193,26 @@ public class DownloadPage extends DecoratorAnimatedPage implements DecoratorPage } private void loadVersions(Profile profile) { - WeakListenerHolder listenerHolder = new WeakListenerHolder(); + listenerHolder = new WeakListenerHolder(); runInFX(() -> { if (profile == Profiles.getSelectedProfile()) { - if (modTab.isInitialized()) { - modTab.getNode().loadVersion(profile, null); - } - if (modpackTab.isInitialized()) { - modpackTab.getNode().loadVersion(profile, null); - } - if (resourcePackTab.isInitialized()) { - resourcePackTab.getNode().loadVersion(profile, null); - } - if (customizationTab.isInitialized()) { - customizationTab.getNode().loadVersion(profile, null); - } - if (worldTab.isInitialized()) { - worldTab.getNode().loadVersion(profile, null); - } + listenerHolder.add(FXUtils.onWeakChangeAndOperate(profile.selectedVersionProperty(), version -> { + if (modTab.isInitialized()) { + modTab.getNode().loadVersion(profile, null); + } + if (modpackTab.isInitialized()) { + modpackTab.getNode().loadVersion(profile, null); + } + if (resourcePackTab.isInitialized()) { + resourcePackTab.getNode().loadVersion(profile, null); + } + if (customizationTab.isInitialized()) { + customizationTab.getNode().loadVersion(profile, null); + } + if (worldTab.isInitialized()) { + worldTab.getNode().loadVersion(profile, null); + } + })); } }); } diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadListPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadListPage.java index cba2b7371..3e2e9d889 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadListPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadListPage.java @@ -238,19 +238,28 @@ public class DownloadListPage extends Control implements DecoratorPage, VersionP { int rowIndex = 0; - if (control.versionSelection && control.downloadSources.getSize() > 1) { + if (control.versionSelection) { JFXComboBox versionsComboBox = new JFXComboBox<>(); versionsComboBox.setMaxWidth(Double.MAX_VALUE); Bindings.bindContent(versionsComboBox.getItems(), control.versions); selectedItemPropertyFor(versionsComboBox).bindBidirectional(control.selectedVersion); - JFXComboBox downloadSourceComboBox = new JFXComboBox<>(); - downloadSourceComboBox.setMaxWidth(Double.MAX_VALUE); - downloadSourceComboBox.getItems().setAll(control.downloadSources.get()); - downloadSourceComboBox.setConverter(stringConverter(I18n::i18n)); - selectedItemPropertyFor(downloadSourceComboBox).bindBidirectional(control.downloadSource); + searchPane.addRow(rowIndex, new Label(i18n("version")), versionsComboBox); - searchPane.addRow(rowIndex++, new Label(i18n("version")), versionsComboBox, new Label(i18n("settings.launcher.download_source")), downloadSourceComboBox); + if (control.downloadSources.getSize() > 1) { + JFXComboBox downloadSourceComboBox = new JFXComboBox<>(); + downloadSourceComboBox.setMaxWidth(Double.MAX_VALUE); + downloadSourceComboBox.getItems().setAll(control.downloadSources.get()); + downloadSourceComboBox.setConverter(stringConverter(I18n::i18n)); + selectedItemPropertyFor(downloadSourceComboBox).bindBidirectional(control.downloadSource); + + searchPane.add(new Label(i18n("settings.launcher.download_source")), 2, rowIndex); + searchPane.add(downloadSourceComboBox, 3, rowIndex); + } else { + GridPane.setColumnSpan(versionsComboBox, 3); + } + + rowIndex++; } JFXTextField nameField = new JFXTextField();