mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-12 21:36:21 -04:00
fix: (modpack download): add default category.
This commit is contained in:
parent
37fb9a0d65
commit
d35fb9a486
@ -175,13 +175,16 @@ public class ModDownloadListPage extends Control implements DecoratorPage {
|
||||
|
||||
StackPane categoryStackPane = new StackPane();
|
||||
JFXComboBox<CategoryIndented> categoryComboBox = new JFXComboBox<>();
|
||||
categoryComboBox.getItems().setAll(new CategoryIndented(0, 0));
|
||||
categoryStackPane.getChildren().setAll(categoryComboBox);
|
||||
categoryComboBox.prefWidthProperty().bind(categoryStackPane.widthProperty());
|
||||
categoryComboBox.getStyleClass().add("fit-width");
|
||||
categoryComboBox.setPromptText(i18n("mods.category"));
|
||||
categoryComboBox.getSelectionModel().select(0);
|
||||
Task.supplyAsync(() -> CurseModManager.getCategories(getSkinnable().section))
|
||||
.thenAcceptAsync(Schedulers.javafx(), categories -> {
|
||||
List<CategoryIndented> result = new ArrayList<>();
|
||||
result.add(new CategoryIndented(0, 0));
|
||||
for (CurseModManager.Category category : categories) {
|
||||
resolveCategory(category, 0, result);
|
||||
}
|
||||
@ -214,8 +217,7 @@ public class ModDownloadListPage extends Control implements DecoratorPage {
|
||||
searchButton.setOnAction(e -> {
|
||||
getSkinnable().search(gameVersionField.getText(),
|
||||
Optional.ofNullable(categoryComboBox.getSelectionModel().getSelectedItem())
|
||||
.map(CategoryIndented::getCategory)
|
||||
.map(CurseModManager.Category::getId)
|
||||
.map(CategoryIndented::getCategoryId)
|
||||
.orElse(0),
|
||||
0,
|
||||
nameField.getText(),
|
||||
@ -289,29 +291,29 @@ public class ModDownloadListPage extends Control implements DecoratorPage {
|
||||
|
||||
private static class CategoryIndented {
|
||||
private final int indent;
|
||||
private final CurseModManager.Category category;
|
||||
private final int categoryId;
|
||||
|
||||
public CategoryIndented(int indent, CurseModManager.Category category) {
|
||||
public CategoryIndented(int indent, int categoryId) {
|
||||
this.indent = indent;
|
||||
this.category = category;
|
||||
this.categoryId = categoryId;
|
||||
}
|
||||
|
||||
public int getIndent() {
|
||||
return indent;
|
||||
}
|
||||
|
||||
public CurseModManager.Category getCategory() {
|
||||
return category;
|
||||
public int getCategoryId() {
|
||||
return categoryId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return StringUtils.repeats(' ', indent) + i18n("curse.category." + category.getId());
|
||||
return StringUtils.repeats(' ', indent) + i18n("curse.category." + categoryId);
|
||||
}
|
||||
}
|
||||
|
||||
private static void resolveCategory(CurseModManager.Category category, int indent, List<CategoryIndented> result) {
|
||||
result.add(new CategoryIndented(indent, category));
|
||||
result.add(new CategoryIndented(indent, category.getId()));
|
||||
for (CurseModManager.Category subcategory : category.getSubcategories()) {
|
||||
resolveCategory(subcategory, indent + 1, result);
|
||||
}
|
||||
|
@ -98,6 +98,9 @@ color.custom=Custom Color
|
||||
crash.NoClassDefFound=Please verify that the "Hello Minecraft! Launcher" software is not corrupted.
|
||||
crash.user_fault=Your OS or Java environment may not be properly installed which may result in a crash, please check your Java Runtime Environment or your computer!
|
||||
|
||||
curse.category.0=All
|
||||
|
||||
# https://addons-ecs.forgesvc.net/api/v2/category/section/4471
|
||||
curse.category.4474=Sci-Fi
|
||||
curse.category.4481=Small / Light
|
||||
curse.category.4483=Combat
|
||||
|
@ -98,6 +98,8 @@ color.custom=自定义颜色
|
||||
crash.NoClassDefFound=请确认 Hello Minecraft! Launcher 本体是否完整,或更新您的 Java。
|
||||
crash.user_fault=您的系统或 Java 环境可能安装不当导致本软件崩溃,请检查您的 Java 环境或您的电脑!可以尝试重新安装 Java。
|
||||
|
||||
curse.category.0=全部
|
||||
|
||||
# https://addons-ecs.forgesvc.net/api/v2/category/section/4471
|
||||
curse.category.4474=科幻
|
||||
curse.category.4481=轻量整合包
|
||||
|
Loading…
x
Reference in New Issue
Block a user