feat(download): WIP: select game version in download page.
This commit is contained in:
@@ -64,7 +64,7 @@ public class DownloadPage extends BorderPane implements DecoratorPage {
|
|||||||
|
|
||||||
public DownloadPage() {
|
public DownloadPage() {
|
||||||
modpackTab.setNodeSupplier(() -> new ModDownloadListPage(CurseModManager.SECTION_MODPACK, Versions::downloadModpackImpl));
|
modpackTab.setNodeSupplier(() -> new ModDownloadListPage(CurseModManager.SECTION_MODPACK, Versions::downloadModpackImpl));
|
||||||
modTab.setNodeSupplier(() -> new ModDownloadListPage(CurseModManager.SECTION_MOD, (profile, version, file) -> download(profile, version, file, "mods")));
|
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")));
|
resourcePackTab.setNodeSupplier(() -> new ModDownloadListPage(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 ModDownloadListPage(CurseModManager.SECTION_WORLD));
|
||||||
|
|||||||
@@ -19,10 +19,12 @@ package org.jackhuang.hmcl.ui.versions;
|
|||||||
|
|
||||||
import com.jfoenix.controls.*;
|
import com.jfoenix.controls.*;
|
||||||
import javafx.beans.binding.Bindings;
|
import javafx.beans.binding.Bindings;
|
||||||
|
import javafx.beans.binding.ObjectBinding;
|
||||||
import javafx.beans.property.*;
|
import javafx.beans.property.*;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
|
import javafx.geometry.HPos;
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
@@ -42,6 +44,7 @@ import org.jackhuang.hmcl.ui.construct.SpinnerPane;
|
|||||||
import org.jackhuang.hmcl.ui.construct.TwoLineListItem;
|
import org.jackhuang.hmcl.ui.construct.TwoLineListItem;
|
||||||
import org.jackhuang.hmcl.ui.decorator.DecoratorPage;
|
import org.jackhuang.hmcl.ui.decorator.DecoratorPage;
|
||||||
import org.jackhuang.hmcl.util.StringUtils;
|
import org.jackhuang.hmcl.util.StringUtils;
|
||||||
|
import org.jackhuang.hmcl.util.javafx.BindingMapping;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -53,6 +56,7 @@ public class ModDownloadListPage extends Control implements DecoratorPage, Versi
|
|||||||
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 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 ModDownloadPage.DownloadCallback callback;
|
||||||
@@ -69,8 +73,13 @@ public class ModDownloadListPage extends Control implements DecoratorPage, Versi
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ModDownloadListPage(int section, ModDownloadPage.DownloadCallback callback) {
|
public ModDownloadListPage(int section, ModDownloadPage.DownloadCallback callback) {
|
||||||
|
this(section, callback, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ModDownloadListPage(int section, ModDownloadPage.DownloadCallback callback, boolean versionSelection) {
|
||||||
this.section = section;
|
this.section = section;
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
|
this.versionSelection = versionSelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -157,32 +166,47 @@ public class ModDownloadListPage extends Control implements DecoratorPage, Versi
|
|||||||
searchPane.getStyleClass().addAll("card");
|
searchPane.getStyleClass().addAll("card");
|
||||||
BorderPane.setMargin(searchPane, new Insets(10, 10, 0, 10));
|
BorderPane.setMargin(searchPane, new Insets(10, 10, 0, 10));
|
||||||
|
|
||||||
|
ColumnConstraints nameColumn = new ColumnConstraints();
|
||||||
|
nameColumn.setMinWidth(USE_PREF_SIZE);
|
||||||
ColumnConstraints column1 = new ColumnConstraints();
|
ColumnConstraints column1 = new ColumnConstraints();
|
||||||
column1.setPercentWidth(50);
|
|
||||||
column1.setHgrow(Priority.ALWAYS);
|
column1.setHgrow(Priority.ALWAYS);
|
||||||
ColumnConstraints column2 = new ColumnConstraints();
|
ColumnConstraints column2 = new ColumnConstraints();
|
||||||
column2.setHgrow(Priority.ALWAYS);
|
column2.setHgrow(Priority.ALWAYS);
|
||||||
column2.setPercentWidth(50);
|
searchPane.getColumnConstraints().setAll(nameColumn, column1, nameColumn, column2);
|
||||||
searchPane.getColumnConstraints().setAll(column1, column2);
|
|
||||||
|
|
||||||
searchPane.setHgap(16);
|
searchPane.setHgap(16);
|
||||||
searchPane.setVgap(10);
|
searchPane.setVgap(10);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
int rowIndex = 0;
|
||||||
|
|
||||||
|
if (control.versionSelection) {
|
||||||
|
JFXComboBox<String> versionsComboBox = new JFXComboBox<>();
|
||||||
|
GridPane.setColumnSpan(versionsComboBox, 3);
|
||||||
|
versionsComboBox.setMaxWidth(Double.MAX_VALUE);
|
||||||
|
|
||||||
|
searchPane.addRow(rowIndex++, new Label(i18n("version")), versionsComboBox);
|
||||||
|
}
|
||||||
|
|
||||||
JFXTextField nameField = new JFXTextField();
|
JFXTextField nameField = new JFXTextField();
|
||||||
nameField.setPromptText(i18n("mods.name"));
|
nameField.setPromptText(i18n("mods.name"));
|
||||||
searchPane.add(nameField, 0, 0);
|
|
||||||
|
|
||||||
JFXTextField gameVersionField = new JFXTextField();
|
JFXTextField gameVersionField = new JFXTextField();
|
||||||
|
Label lblGameVersion = new Label(i18n("world.game_version"));
|
||||||
gameVersionField.setPromptText(i18n("world.game_version"));
|
gameVersionField.setPromptText(i18n("world.game_version"));
|
||||||
searchPane.add(gameVersionField, 1, 0);
|
searchPane.addRow(rowIndex++, new Label(i18n("mods.name")), nameField, lblGameVersion, gameVersionField);
|
||||||
|
|
||||||
|
ObjectBinding<Boolean> hasVersion = BindingMapping.of(getSkinnable().version)
|
||||||
|
.map(version -> version.getVersion() == null);
|
||||||
|
lblGameVersion.managedProperty().bind(hasVersion);
|
||||||
|
lblGameVersion.visibleProperty().bind(hasVersion);
|
||||||
|
gameVersionField.managedProperty().bind(hasVersion);
|
||||||
|
gameVersionField.visibleProperty().bind(hasVersion);
|
||||||
|
|
||||||
FXUtils.onChangeAndOperate(getSkinnable().version, version -> {
|
FXUtils.onChangeAndOperate(getSkinnable().version, version -> {
|
||||||
searchPane.getChildren().remove(gameVersionField);
|
|
||||||
if (StringUtils.isNotBlank(version.getVersion())) {
|
if (StringUtils.isNotBlank(version.getVersion())) {
|
||||||
GridPane.setColumnSpan(nameField, 2);
|
GridPane.setColumnSpan(nameField, 3);
|
||||||
} else {
|
} else {
|
||||||
searchPane.add(gameVersionField, 1, 0);
|
|
||||||
GridPane.setColumnSpan(nameField, 1);
|
GridPane.setColumnSpan(nameField, 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -204,7 +228,6 @@ public class ModDownloadListPage extends Control implements DecoratorPage, Versi
|
|||||||
}
|
}
|
||||||
categoryComboBox.getItems().setAll(result);
|
categoryComboBox.getItems().setAll(result);
|
||||||
}).start();
|
}).start();
|
||||||
searchPane.add(categoryStackPane, 0, 1);
|
|
||||||
|
|
||||||
StackPane sortStackPane = new StackPane();
|
StackPane sortStackPane = new StackPane();
|
||||||
JFXComboBox<String> sortComboBox = new JFXComboBox<>();
|
JFXComboBox<String> sortComboBox = new JFXComboBox<>();
|
||||||
@@ -220,16 +243,12 @@ public class ModDownloadListPage extends Control implements DecoratorPage, Versi
|
|||||||
i18n("curse.sort.author"),
|
i18n("curse.sort.author"),
|
||||||
i18n("curse.sort.total_downloads"));
|
i18n("curse.sort.total_downloads"));
|
||||||
sortComboBox.getSelectionModel().select(0);
|
sortComboBox.getSelectionModel().select(0);
|
||||||
searchPane.add(sortStackPane, 1, 1);
|
searchPane.addRow(rowIndex++, new Label(i18n("mods.category")), categoryStackPane, new Label(i18n("search.sort")), sortStackPane);
|
||||||
|
|
||||||
VBox vbox = new VBox();
|
|
||||||
vbox.setAlignment(Pos.CENTER_RIGHT);
|
|
||||||
searchPane.add(vbox, 0, 2, 2, 1);
|
|
||||||
|
|
||||||
JFXButton searchButton = new JFXButton();
|
JFXButton searchButton = new JFXButton();
|
||||||
searchButton.setText(i18n("search"));
|
searchButton.setText(i18n("search"));
|
||||||
searchPane.add(searchButton, 0, 2);
|
GridPane.setHalignment(searchButton, HPos.LEFT);
|
||||||
vbox.getChildren().setAll(searchButton);
|
searchPane.addRow(rowIndex++, searchButton);
|
||||||
|
|
||||||
EventHandler<ActionEvent> searchAction = e -> getSkinnable()
|
EventHandler<ActionEvent> searchAction = e -> getSkinnable()
|
||||||
.search(gameVersionField.getText(),
|
.search(gameVersionField.getText(),
|
||||||
|
|||||||
Reference in New Issue
Block a user