diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java index 22f265894..eb7459fdf 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java @@ -49,7 +49,7 @@ import org.jackhuang.hmcl.ui.main.LauncherSettingsPage; import org.jackhuang.hmcl.ui.main.RootPage; import org.jackhuang.hmcl.ui.multiplayer.MultiplayerPage; import org.jackhuang.hmcl.ui.versions.GameListPage; -import org.jackhuang.hmcl.ui.versions.ModDownloadListPage; +import org.jackhuang.hmcl.ui.versions.DownloadListPage; import org.jackhuang.hmcl.ui.versions.VersionPage; import org.jackhuang.hmcl.ui.versions.Versions; import org.jackhuang.hmcl.util.FutureCallback; @@ -86,8 +86,8 @@ public final class Controllers { }); private static Lazy rootPage = new Lazy<>(RootPage::new); private static DecoratorController decorator; - private static Lazy modDownloadListPage = new Lazy<>(() -> { - return new ModDownloadListPage(CurseModManager.SECTION_MODPACK, Versions::downloadModpackImpl) { + private static Lazy modDownloadListPage = new Lazy<>(() -> { + return new DownloadListPage(CurseModManager.SECTION_MODPACK, Versions::downloadModpackImpl) { { state.set(State.fromTitle(i18n("modpack.download"))); } @@ -131,7 +131,7 @@ public final class Controllers { } // FXThread - public static ModDownloadListPage getModpackDownloadListPage() { + public static DownloadListPage getModpackDownloadListPage() { return modDownloadListPage.get(); } 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 8aab79878..426cefb8e 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 @@ -38,7 +38,7 @@ import org.jackhuang.hmcl.ui.construct.AdvancedListBox; import org.jackhuang.hmcl.ui.construct.TabHeader; import org.jackhuang.hmcl.ui.construct.TaskExecutorDialogPane; import org.jackhuang.hmcl.ui.decorator.DecoratorPage; -import org.jackhuang.hmcl.ui.versions.ModDownloadListPage; +import org.jackhuang.hmcl.ui.versions.DownloadListPage; import org.jackhuang.hmcl.ui.versions.VersionPage; import org.jackhuang.hmcl.ui.versions.Versions; import org.jackhuang.hmcl.util.io.NetworkUtils; @@ -53,21 +53,21 @@ import static org.jackhuang.hmcl.util.i18n.I18n.i18n; public class DownloadPage extends BorderPane implements DecoratorPage { private final ReadOnlyObjectWrapper state = new ReadOnlyObjectWrapper<>(DecoratorPage.State.fromTitle(i18n("download"), -1)); private final TabHeader tab; - private final TabHeader.Tab modTab = new TabHeader.Tab<>("modTab"); - private final TabHeader.Tab modpackTab = new TabHeader.Tab<>("modpackTab"); - private final TabHeader.Tab resourcePackTab = new TabHeader.Tab<>("resourcePackTab"); - private final TabHeader.Tab customizationTab = new TabHeader.Tab<>("customizationTab"); - private final TabHeader.Tab worldTab = new TabHeader.Tab<>("worldTab"); + private final TabHeader.Tab modTab = new TabHeader.Tab<>("modTab"); + private final TabHeader.Tab modpackTab = new TabHeader.Tab<>("modpackTab"); + private final TabHeader.Tab resourcePackTab = new TabHeader.Tab<>("resourcePackTab"); + private final TabHeader.Tab customizationTab = new TabHeader.Tab<>("customizationTab"); + private final TabHeader.Tab worldTab = new TabHeader.Tab<>("worldTab"); private final TransitionPane transitionPane = new TransitionPane(); private WeakListenerHolder listenerHolder; public DownloadPage() { - modpackTab.setNodeSupplier(() -> new ModDownloadListPage(CurseModManager.SECTION_MODPACK, Versions::downloadModpackImpl)); - modTab.setNodeSupplier(() -> new ModDownloadListPage(CurseModManager.SECTION_MOD, (profile, version, file) -> download(profile, version, file, "mods"), true)); - resourcePackTab.setNodeSupplier(() -> new ModDownloadListPage(CurseModManager.SECTION_RESOURCE_PACK, (profile, version, file) -> download(profile, version, file, "resourcepacks"))); + modpackTab.setNodeSupplier(() -> new DownloadListPage(CurseModManager.SECTION_MODPACK, Versions::downloadModpackImpl)); + modTab.setNodeSupplier(() -> new DownloadListPage(CurseModManager.SECTION_MOD, (profile, version, file) -> download(profile, version, file, "mods"), true)); + resourcePackTab.setNodeSupplier(() -> new DownloadListPage(CurseModManager.SECTION_RESOURCE_PACK, (profile, version, file) -> download(profile, version, file, "resourcepacks"))); // customizationTab.setNodeSupplier(() -> new ModDownloadListPage(CurseModManager.SECTION_CUSTOMIZATION, this::download)); - worldTab.setNodeSupplier(() -> new ModDownloadListPage(CurseModManager.SECTION_WORLD)); + worldTab.setNodeSupplier(() -> new DownloadListPage(CurseModManager.SECTION_WORLD)); tab = new TabHeader(modpackTab, modTab, resourcePackTab, worldTab); Profiles.registerVersionsListener(this::loadVersions); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModDownloadListPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadListPage.java similarity index 93% rename from HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModDownloadListPage.java rename to HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadListPage.java index c484a26b5..3eeeefd7c 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModDownloadListPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadListPage.java @@ -52,14 +52,14 @@ import java.util.stream.Collectors; import static org.jackhuang.hmcl.util.i18n.I18n.i18n; -public class ModDownloadListPage extends Control implements DecoratorPage, VersionPage.VersionLoadable { +public class DownloadListPage extends Control implements DecoratorPage, VersionPage.VersionLoadable { protected final ReadOnlyObjectWrapper state = new ReadOnlyObjectWrapper<>(); private final BooleanProperty loading = new SimpleBooleanProperty(false); private final BooleanProperty failed = new SimpleBooleanProperty(false); private final boolean versionSelection; private final ObjectProperty version = new SimpleObjectProperty<>(); private final ListProperty items = new SimpleListProperty<>(this, "items", FXCollections.observableArrayList()); - private final ModDownloadPage.DownloadCallback callback; + private final DownloadPage.DownloadCallback callback; private boolean searchInitialized = false; /** @@ -68,15 +68,15 @@ public class ModDownloadListPage extends Control implements DecoratorPage, Versi */ private final int section; - public ModDownloadListPage(int section) { + public DownloadListPage(int section) { this(section, null); } - public ModDownloadListPage(int section, ModDownloadPage.DownloadCallback callback) { + public DownloadListPage(int section, DownloadPage.DownloadCallback callback) { this(section, callback, false); } - public ModDownloadListPage(int section, ModDownloadPage.DownloadCallback callback, boolean versionSelection) { + public DownloadListPage(int section, DownloadPage.DownloadCallback callback, boolean versionSelection) { this.section = section; this.callback = callback; this.versionSelection = versionSelection; @@ -133,7 +133,7 @@ public class ModDownloadListPage extends Control implements DecoratorPage, Versi } return gameVersion; }).thenApplyAsync(gameVersion -> { - return CurseModManager.searchPaginated(gameVersion, category, section, pageOffset, searchFilter, sort); + return searchImpl(gameVersion, category, section, pageOffset, searchFilter, sort); }).whenComplete(Schedulers.javafx(), (result, exception) -> { setLoading(false); if (exception == null) { @@ -145,6 +145,10 @@ public class ModDownloadListPage extends Control implements DecoratorPage, Versi }).start(); } + protected List searchImpl(String gameVersion, int category, int section, int pageOffset, String searchFilter, int sort) throws Exception { + return CurseModManager.searchPaginated(gameVersion, category, section, pageOffset, searchFilter, sort); + } + @Override public ReadOnlyObjectProperty stateProperty() { return state.getReadOnlyProperty(); @@ -155,9 +159,9 @@ public class ModDownloadListPage extends Control implements DecoratorPage, Versi return new ModDownloadListPageSkin(this); } - private static class ModDownloadListPageSkin extends SkinBase { + private static class ModDownloadListPageSkin extends SkinBase { - protected ModDownloadListPageSkin(ModDownloadListPage control) { + protected ModDownloadListPageSkin(DownloadListPage control) { super(control); BorderPane pane = new BorderPane(); @@ -285,7 +289,7 @@ public class ModDownloadListPage extends Control implements DecoratorPage, Versi if (listView.getSelectionModel().getSelectedIndex() < 0) return; CurseAddon selectedItem = listView.getSelectionModel().getSelectedItem(); - Controllers.navigate(new ModDownloadPage(selectedItem, getSkinnable().version.get(), getSkinnable().callback)); + Controllers.navigate(new DownloadPage(selectedItem, getSkinnable().version.get(), getSkinnable().callback)); }); listView.setCellFactory(x -> new FloatListCell(listView) { TwoLineListItem content = new TwoLineListItem(); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModDownloadPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadPage.java similarity index 97% rename from HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModDownloadPage.java rename to HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadPage.java index bdb914ddb..440e4e5f8 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModDownloadPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/DownloadPage.java @@ -64,7 +64,7 @@ import java.util.stream.Collectors; import static org.jackhuang.hmcl.util.i18n.I18n.i18n; -public class ModDownloadPage extends Control implements DecoratorPage { +public class DownloadPage extends Control implements DecoratorPage { private final ReadOnlyObjectWrapper state = new ReadOnlyObjectWrapper<>(); private final ListProperty items = new SimpleListProperty<>(this, "items", FXCollections.observableArrayList()); private final BooleanProperty loading = new SimpleBooleanProperty(false); @@ -73,7 +73,7 @@ public class ModDownloadPage extends Control implements DecoratorPage { private final Profile.ProfileVersion version; private final DownloadCallback callback; - public ModDownloadPage(CurseAddon addon, Profile.ProfileVersion version, @Nullable DownloadCallback callback) { + public DownloadPage(CurseAddon addon, Profile.ProfileVersion version, @Nullable DownloadCallback callback) { this.addon = addon; this.version = version; this.callback = callback; @@ -170,9 +170,9 @@ public class ModDownloadPage extends Control implements DecoratorPage { return new ModDownloadPageSkin(this); } - private static class ModDownloadPageSkin extends SkinBase { + private static class ModDownloadPageSkin extends SkinBase { - protected ModDownloadPageSkin(ModDownloadPage control) { + protected ModDownloadPageSkin(DownloadPage control) { super(control); BorderPane pane = new BorderPane(); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/VersionPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/VersionPage.java index 68c7ce050..7f5bec29a 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/VersionPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/VersionPage.java @@ -51,13 +51,13 @@ import java.util.Optional; import static org.jackhuang.hmcl.util.i18n.I18n.i18n; -public class VersionPage extends Control implements DecoratorPage, ModDownloadPage.DownloadCallback { +public class VersionPage extends Control implements DecoratorPage, DownloadPage.DownloadCallback { private final ReadOnlyObjectWrapper state = new ReadOnlyObjectWrapper<>(); private final BooleanProperty loading = new SimpleBooleanProperty(); private final TabHeader tab; private final TabHeader.Tab versionSettingsTab = new TabHeader.Tab<>("versionSettingsTab"); private final TabHeader.Tab modListTab = new TabHeader.Tab<>("modListTab"); - private final TabHeader.Tab curseModListTab = new TabHeader.Tab<>("modListTab"); + private final TabHeader.Tab curseModListTab = new TabHeader.Tab<>("modListTab"); private final TabHeader.Tab installerListTab = new TabHeader.Tab<>("installerListTab"); private final TabHeader.Tab worldListTab = new TabHeader.Tab<>("worldList"); private final TransitionPane transitionPane = new TransitionPane(); @@ -69,7 +69,7 @@ public class VersionPage extends Control implements DecoratorPage, ModDownloadPa { versionSettingsTab.setNodeSupplier(VersionSettingsPage::new); modListTab.setNodeSupplier(ModListPage::new); - curseModListTab.setNodeSupplier(() -> new ModDownloadListPage(CurseModManager.SECTION_MOD, this)); + curseModListTab.setNodeSupplier(() -> new DownloadListPage(CurseModManager.SECTION_MOD, this)); installerListTab.setNodeSupplier(InstallerListPage::new); worldListTab.setNodeSupplier(WorldListPage::new);