chore: rename ModDownloadPage -> DownloadPage.

This commit is contained in:
huanghongxun 2021-09-11 21:38:46 +08:00
parent 8927260b75
commit 0df1b62c3e
5 changed files with 34 additions and 30 deletions

View File

@ -49,7 +49,7 @@ import org.jackhuang.hmcl.ui.main.LauncherSettingsPage;
import org.jackhuang.hmcl.ui.main.RootPage; import org.jackhuang.hmcl.ui.main.RootPage;
import org.jackhuang.hmcl.ui.multiplayer.MultiplayerPage; import org.jackhuang.hmcl.ui.multiplayer.MultiplayerPage;
import org.jackhuang.hmcl.ui.versions.GameListPage; 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.VersionPage;
import org.jackhuang.hmcl.ui.versions.Versions; import org.jackhuang.hmcl.ui.versions.Versions;
import org.jackhuang.hmcl.util.FutureCallback; import org.jackhuang.hmcl.util.FutureCallback;
@ -86,8 +86,8 @@ public final class Controllers {
}); });
private static Lazy<RootPage> rootPage = new Lazy<>(RootPage::new); private static Lazy<RootPage> rootPage = new Lazy<>(RootPage::new);
private static DecoratorController decorator; private static DecoratorController decorator;
private static Lazy<ModDownloadListPage> modDownloadListPage = new Lazy<>(() -> { private static Lazy<DownloadListPage> modDownloadListPage = new Lazy<>(() -> {
return new ModDownloadListPage(CurseModManager.SECTION_MODPACK, Versions::downloadModpackImpl) { return new DownloadListPage(CurseModManager.SECTION_MODPACK, Versions::downloadModpackImpl) {
{ {
state.set(State.fromTitle(i18n("modpack.download"))); state.set(State.fromTitle(i18n("modpack.download")));
} }
@ -131,7 +131,7 @@ public final class Controllers {
} }
// FXThread // FXThread
public static ModDownloadListPage getModpackDownloadListPage() { public static DownloadListPage getModpackDownloadListPage() {
return modDownloadListPage.get(); return modDownloadListPage.get();
} }

View File

@ -38,7 +38,7 @@ import org.jackhuang.hmcl.ui.construct.AdvancedListBox;
import org.jackhuang.hmcl.ui.construct.TabHeader; import org.jackhuang.hmcl.ui.construct.TabHeader;
import org.jackhuang.hmcl.ui.construct.TaskExecutorDialogPane; import org.jackhuang.hmcl.ui.construct.TaskExecutorDialogPane;
import org.jackhuang.hmcl.ui.decorator.DecoratorPage; 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.VersionPage;
import org.jackhuang.hmcl.ui.versions.Versions; import org.jackhuang.hmcl.ui.versions.Versions;
import org.jackhuang.hmcl.util.io.NetworkUtils; 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 { public class DownloadPage extends BorderPane implements DecoratorPage {
private final ReadOnlyObjectWrapper<DecoratorPage.State> state = new ReadOnlyObjectWrapper<>(DecoratorPage.State.fromTitle(i18n("download"), -1)); private final ReadOnlyObjectWrapper<DecoratorPage.State> state = new ReadOnlyObjectWrapper<>(DecoratorPage.State.fromTitle(i18n("download"), -1));
private final TabHeader tab; private final TabHeader tab;
private final TabHeader.Tab<ModDownloadListPage> modTab = new TabHeader.Tab<>("modTab"); private final TabHeader.Tab<DownloadListPage> modTab = new TabHeader.Tab<>("modTab");
private final TabHeader.Tab<ModDownloadListPage> modpackTab = new TabHeader.Tab<>("modpackTab"); private final TabHeader.Tab<DownloadListPage> modpackTab = new TabHeader.Tab<>("modpackTab");
private final TabHeader.Tab<ModDownloadListPage> resourcePackTab = new TabHeader.Tab<>("resourcePackTab"); private final TabHeader.Tab<DownloadListPage> resourcePackTab = new TabHeader.Tab<>("resourcePackTab");
private final TabHeader.Tab<ModDownloadListPage> customizationTab = new TabHeader.Tab<>("customizationTab"); private final TabHeader.Tab<DownloadListPage> customizationTab = new TabHeader.Tab<>("customizationTab");
private final TabHeader.Tab<ModDownloadListPage> worldTab = new TabHeader.Tab<>("worldTab"); private final TabHeader.Tab<DownloadListPage> worldTab = new TabHeader.Tab<>("worldTab");
private final TransitionPane transitionPane = new TransitionPane(); private final TransitionPane transitionPane = new TransitionPane();
private WeakListenerHolder listenerHolder; private WeakListenerHolder listenerHolder;
public DownloadPage() { public DownloadPage() {
modpackTab.setNodeSupplier(() -> new ModDownloadListPage(CurseModManager.SECTION_MODPACK, Versions::downloadModpackImpl)); modpackTab.setNodeSupplier(() -> new DownloadListPage(CurseModManager.SECTION_MODPACK, Versions::downloadModpackImpl));
modTab.setNodeSupplier(() -> new ModDownloadListPage(CurseModManager.SECTION_MOD, (profile, version, file) -> download(profile, version, file, "mods"), true)); modTab.setNodeSupplier(() -> new DownloadListPage(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"))); 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)); // 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); tab = new TabHeader(modpackTab, modTab, resourcePackTab, worldTab);
Profiles.registerVersionsListener(this::loadVersions); Profiles.registerVersionsListener(this::loadVersions);

View File

@ -52,14 +52,14 @@ import java.util.stream.Collectors;
import static org.jackhuang.hmcl.util.i18n.I18n.i18n; 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> state = new ReadOnlyObjectWrapper<>(); protected final ReadOnlyObjectWrapper<State> state = new ReadOnlyObjectWrapper<>();
private final BooleanProperty loading = new SimpleBooleanProperty(false); private final BooleanProperty loading = new SimpleBooleanProperty(false);
private final BooleanProperty failed = new SimpleBooleanProperty(false); private final BooleanProperty failed = new SimpleBooleanProperty(false);
private final boolean versionSelection; private final boolean versionSelection;
private final ObjectProperty<Profile.ProfileVersion> version = new SimpleObjectProperty<>(); private final ObjectProperty<Profile.ProfileVersion> version = new SimpleObjectProperty<>();
private final ListProperty<CurseAddon> items = new SimpleListProperty<>(this, "items", FXCollections.observableArrayList()); private final ListProperty<CurseAddon> items = new SimpleListProperty<>(this, "items", FXCollections.observableArrayList());
private final ModDownloadPage.DownloadCallback callback; private final DownloadPage.DownloadCallback callback;
private boolean searchInitialized = false; private boolean searchInitialized = false;
/** /**
@ -68,15 +68,15 @@ public class ModDownloadListPage extends Control implements DecoratorPage, Versi
*/ */
private final int section; private final int section;
public ModDownloadListPage(int section) { public DownloadListPage(int section) {
this(section, null); this(section, null);
} }
public ModDownloadListPage(int section, ModDownloadPage.DownloadCallback callback) { public DownloadListPage(int section, DownloadPage.DownloadCallback callback) {
this(section, callback, false); 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.section = section;
this.callback = callback; this.callback = callback;
this.versionSelection = versionSelection; this.versionSelection = versionSelection;
@ -133,7 +133,7 @@ public class ModDownloadListPage extends Control implements DecoratorPage, Versi
} }
return gameVersion; return gameVersion;
}).thenApplyAsync(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) -> { }).whenComplete(Schedulers.javafx(), (result, exception) -> {
setLoading(false); setLoading(false);
if (exception == null) { if (exception == null) {
@ -145,6 +145,10 @@ public class ModDownloadListPage extends Control implements DecoratorPage, Versi
}).start(); }).start();
} }
protected List<CurseAddon> 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 @Override
public ReadOnlyObjectProperty<State> stateProperty() { public ReadOnlyObjectProperty<State> stateProperty() {
return state.getReadOnlyProperty(); return state.getReadOnlyProperty();
@ -155,9 +159,9 @@ public class ModDownloadListPage extends Control implements DecoratorPage, Versi
return new ModDownloadListPageSkin(this); return new ModDownloadListPageSkin(this);
} }
private static class ModDownloadListPageSkin extends SkinBase<ModDownloadListPage> { private static class ModDownloadListPageSkin extends SkinBase<DownloadListPage> {
protected ModDownloadListPageSkin(ModDownloadListPage control) { protected ModDownloadListPageSkin(DownloadListPage control) {
super(control); super(control);
BorderPane pane = new BorderPane(); BorderPane pane = new BorderPane();
@ -285,7 +289,7 @@ public class ModDownloadListPage extends Control implements DecoratorPage, Versi
if (listView.getSelectionModel().getSelectedIndex() < 0) if (listView.getSelectionModel().getSelectedIndex() < 0)
return; return;
CurseAddon selectedItem = listView.getSelectionModel().getSelectedItem(); 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<CurseAddon>(listView) { listView.setCellFactory(x -> new FloatListCell<CurseAddon>(listView) {
TwoLineListItem content = new TwoLineListItem(); TwoLineListItem content = new TwoLineListItem();

View File

@ -64,7 +64,7 @@ import java.util.stream.Collectors;
import static org.jackhuang.hmcl.util.i18n.I18n.i18n; 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> state = new ReadOnlyObjectWrapper<>(); private final ReadOnlyObjectWrapper<State> state = new ReadOnlyObjectWrapper<>();
private final ListProperty<CurseAddon.LatestFile> items = new SimpleListProperty<>(this, "items", FXCollections.observableArrayList()); private final ListProperty<CurseAddon.LatestFile> items = new SimpleListProperty<>(this, "items", FXCollections.observableArrayList());
private final BooleanProperty loading = new SimpleBooleanProperty(false); 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 Profile.ProfileVersion version;
private final DownloadCallback callback; 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.addon = addon;
this.version = version; this.version = version;
this.callback = callback; this.callback = callback;
@ -170,9 +170,9 @@ public class ModDownloadPage extends Control implements DecoratorPage {
return new ModDownloadPageSkin(this); return new ModDownloadPageSkin(this);
} }
private static class ModDownloadPageSkin extends SkinBase<ModDownloadPage> { private static class ModDownloadPageSkin extends SkinBase<DownloadPage> {
protected ModDownloadPageSkin(ModDownloadPage control) { protected ModDownloadPageSkin(DownloadPage control) {
super(control); super(control);
BorderPane pane = new BorderPane(); BorderPane pane = new BorderPane();

View File

@ -51,13 +51,13 @@ import java.util.Optional;
import static org.jackhuang.hmcl.util.i18n.I18n.i18n; 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> state = new ReadOnlyObjectWrapper<>(); private final ReadOnlyObjectWrapper<State> state = new ReadOnlyObjectWrapper<>();
private final BooleanProperty loading = new SimpleBooleanProperty(); private final BooleanProperty loading = new SimpleBooleanProperty();
private final TabHeader tab; private final TabHeader tab;
private final TabHeader.Tab<VersionSettingsPage> versionSettingsTab = new TabHeader.Tab<>("versionSettingsTab"); private final TabHeader.Tab<VersionSettingsPage> versionSettingsTab = new TabHeader.Tab<>("versionSettingsTab");
private final TabHeader.Tab<ModListPage> modListTab = new TabHeader.Tab<>("modListTab"); private final TabHeader.Tab<ModListPage> modListTab = new TabHeader.Tab<>("modListTab");
private final TabHeader.Tab<ModDownloadListPage> curseModListTab = new TabHeader.Tab<>("modListTab"); private final TabHeader.Tab<DownloadListPage> curseModListTab = new TabHeader.Tab<>("modListTab");
private final TabHeader.Tab<InstallerListPage> installerListTab = new TabHeader.Tab<>("installerListTab"); private final TabHeader.Tab<InstallerListPage> installerListTab = new TabHeader.Tab<>("installerListTab");
private final TabHeader.Tab<WorldListPage> worldListTab = new TabHeader.Tab<>("worldList"); private final TabHeader.Tab<WorldListPage> worldListTab = new TabHeader.Tab<>("worldList");
private final TransitionPane transitionPane = new TransitionPane(); private final TransitionPane transitionPane = new TransitionPane();
@ -69,7 +69,7 @@ public class VersionPage extends Control implements DecoratorPage, ModDownloadPa
{ {
versionSettingsTab.setNodeSupplier(VersionSettingsPage::new); versionSettingsTab.setNodeSupplier(VersionSettingsPage::new);
modListTab.setNodeSupplier(ModListPage::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); installerListTab.setNodeSupplier(InstallerListPage::new);
worldListTab.setNodeSupplier(WorldListPage::new); worldListTab.setNodeSupplier(WorldListPage::new);