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 6ad979833..72d033ca8 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 @@ -69,7 +69,6 @@ public class DownloadPage extends DecoratorAnimatedPage implements DecoratorPage 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 final DownloadNavigator versionPageNavigator = new DownloadNavigator(); @@ -80,7 +79,7 @@ public class DownloadPage extends DecoratorAnimatedPage implements DecoratorPage newGameTab.setNodeSupplier(loadVersionFor(() -> new VersionsPage(versionPageNavigator, i18n("install.installer.choose", i18n("install.installer.game")), "", DownloadProviders.getDownloadProvider(), "game", versionPageNavigator::onGameSelected))); modpackTab.setNodeSupplier(loadVersionFor(() -> { - ModpackDownloadListPage page = new ModpackDownloadListPage(Versions::downloadModpackImpl, false); + DownloadListPage page = HMCLLocalizedDownloadListPage.ofModPack(Versions::downloadModpackImpl, false); JFXButton installLocalModpackButton = FXUtils.newRaisedButton(i18n("install.modpack")); installLocalModpackButton.setOnAction(e -> Versions.importModpack()); @@ -88,9 +87,8 @@ public class DownloadPage extends DecoratorAnimatedPage implements DecoratorPage page.getActions().add(installLocalModpackButton); return page; })); - modTab.setNodeSupplier(loadVersionFor(() -> new ModDownloadListPage((profile, version, file) -> download(profile, version, file, "mods"), true))); - resourcePackTab.setNodeSupplier(loadVersionFor(() -> new ResourcePackDownloadListPage((profile, version, file) -> download(profile, version, file, "resourcepacks"), true))); - customizationTab.setNodeSupplier(loadVersionFor(() -> new DownloadListPage(CurseForgeRemoteModRepository.CUSTOMIZATIONS))); + modTab.setNodeSupplier(loadVersionFor(() -> HMCLLocalizedDownloadListPage.ofMod((profile, version, file) -> download(profile, version, file, "mods"), true))); + resourcePackTab.setNodeSupplier(loadVersionFor(() -> HMCLLocalizedDownloadListPage.ofResourcePack((profile, version, file) -> download(profile, version, file, "resourcepacks"), true))); worldTab.setNodeSupplier(loadVersionFor(() -> new DownloadListPage(CurseForgeRemoteModRepository.WORLDS))); tab = new TabHeader(newGameTab, modpackTab, modTab, resourcePackTab, worldTab); @@ -129,12 +127,6 @@ public class DownloadPage extends DecoratorAnimatedPage implements DecoratorPage item.activeProperty().bind(tab.getSelectionModel().selectedItemProperty().isEqualTo(resourcePackTab)); item.setOnAction(e -> tab.select(resourcePackTab)); }) -// .addNavigationDrawerItem(item -> { -// item.setTitle(i18n("download.curseforge.customization")); -// item.setLeftGraphic(wrap(SVG::script)); -// item.activeProperty().bind(tab.getSelectionModel().selectedItemProperty().isEqualTo(customizationTab)); -// item.setOnAction(e -> selectTabIfCurseForgeAvailable(customizationTab)); -// }) .addNavigationDrawerItem(item -> { item.setTitle(i18n("world")); item.setLeftGraphic(wrap(SVG.EARTH)); @@ -212,9 +204,6 @@ public class DownloadPage extends DecoratorAnimatedPage implements DecoratorPage 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/ResourcePackDownloadListPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/HMCLLocalizedDownloadListPage.java similarity index 58% rename from HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ResourcePackDownloadListPage.java rename to HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/HMCLLocalizedDownloadListPage.java index cf430a476..a7cedd0c9 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ResourcePackDownloadListPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/HMCLLocalizedDownloadListPage.java @@ -28,11 +28,23 @@ import java.util.MissingResourceException; import static org.jackhuang.hmcl.util.logging.Logger.LOG; import static org.jackhuang.hmcl.util.i18n.I18n.i18n; -public class ResourcePackDownloadListPage extends DownloadListPage { - public ResourcePackDownloadListPage(DownloadPage.DownloadCallback callback, boolean versionSelection) { +public final class HMCLLocalizedDownloadListPage extends DownloadListPage { + public static DownloadListPage ofMod(DownloadPage.DownloadCallback callback, boolean versionSelection) { + return new HMCLLocalizedDownloadListPage(callback, versionSelection, RemoteModRepository.Type.MOD, CurseForgeRemoteModRepository.MODS, ModrinthRemoteModRepository.MODS); + } + + public static DownloadListPage ofModPack(DownloadPage.DownloadCallback callback, boolean versionSelection) { + return new HMCLLocalizedDownloadListPage(callback, versionSelection, RemoteModRepository.Type.MODPACK, CurseForgeRemoteModRepository.MODPACKS, ModrinthRemoteModRepository.MODPACKS); + } + + public static DownloadListPage ofResourcePack(DownloadPage.DownloadCallback callback, boolean versionSelection) { + return new HMCLLocalizedDownloadListPage(callback, versionSelection, RemoteModRepository.Type.RESOURCE_PACK, CurseForgeRemoteModRepository.RESOURCE_PACKS, ModrinthRemoteModRepository.RESOURCE_PACKS); + } + + private HMCLLocalizedDownloadListPage(DownloadPage.DownloadCallback callback, boolean versionSelection, RemoteModRepository.Type type, CurseForgeRemoteModRepository curseForge, ModrinthRemoteModRepository modrinth) { super(null, callback, versionSelection); - repository = new Repository(); + repository = new Repository(type, curseForge, modrinth); supportChinese.set(true); downloadSources.get().setAll("mods.curseforge", "mods.modrinth"); @@ -43,13 +55,22 @@ public class ResourcePackDownloadListPage extends DownloadListPage { } private class Repository extends LocalizedRemoteModRepository { + private final RemoteModRepository.Type type; + private final CurseForgeRemoteModRepository curseForge; + private final ModrinthRemoteModRepository modrinth; + + public Repository(Type type, CurseForgeRemoteModRepository curseForge, ModrinthRemoteModRepository modrinth) { + this.type = type; + this.curseForge = curseForge; + this.modrinth = modrinth; + } @Override protected RemoteModRepository getBackedRemoteModRepository() { if ("mods.modrinth".equals(downloadSource.get())) { - return ModrinthRemoteModRepository.RESOURCE_PACKS; + return modrinth; } else { - return CurseForgeRemoteModRepository.RESOURCE_PACKS; + return curseForge; } } @@ -64,19 +85,17 @@ public class ResourcePackDownloadListPage extends DownloadListPage { @Override public Type getType() { - return Type.MOD; + return type; } } @Override protected String getLocalizedCategory(String category) { - String key; - if ("mods.modrinth".equals(downloadSource.get())) { - key = "modrinth.category." + category; - } else { - key = "curse.category." + category; + if (category.isEmpty()) { + return ""; } + String key = ("mods.modrinth".equals(downloadSource.get()) ? "modrinth" : "curse") + ".category." + category; try { return I18n.getResourceBundle().getString(key); } catch (MissingResourceException e) { diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModDownloadListPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModDownloadListPage.java deleted file mode 100644 index 5deea4029..000000000 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModDownloadListPage.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Hello Minecraft! Launcher - * Copyright (C) 2021 huangyuhui and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.jackhuang.hmcl.ui.versions; - -import org.jackhuang.hmcl.game.LocalizedRemoteModRepository; -import org.jackhuang.hmcl.mod.RemoteModRepository; -import org.jackhuang.hmcl.mod.curse.CurseForgeRemoteModRepository; -import org.jackhuang.hmcl.mod.modrinth.ModrinthRemoteModRepository; - -import static org.jackhuang.hmcl.util.i18n.I18n.i18n; - -public class ModDownloadListPage extends DownloadListPage { - public ModDownloadListPage(DownloadPage.DownloadCallback callback, boolean versionSelection) { - super(null, callback, versionSelection); - - repository = new Repository(); - - supportChinese.set(true); - downloadSources.get().setAll("mods.curseforge", "mods.modrinth"); - if (CurseForgeRemoteModRepository.isAvailable()) - downloadSource.set("mods.curseforge"); - else - downloadSource.set("mods.modrinth"); - } - - private class Repository extends LocalizedRemoteModRepository { - - @Override - protected RemoteModRepository getBackedRemoteModRepository() { - if ("mods.modrinth".equals(downloadSource.get())) { - return ModrinthRemoteModRepository.MODS; - } else { - return CurseForgeRemoteModRepository.MODS; - } - } - - @Override - protected SortType getBackedRemoteModRepositorySortOrder() { - if ("mods.modrinth".equals(downloadSource.get())) { - return SortType.NAME; - } else { - return SortType.POPULARITY; - } - } - - @Override - public Type getType() { - return Type.MOD; - } - } - - @Override - protected String getLocalizedCategory(String category) { - if ("mods.modrinth".equals(downloadSource.get())) { - return i18n("modrinth.category." + category); - } else { - return i18n("curse.category." + category); - } - } - - @Override - protected String getLocalizedOfficialPage() { - if ("mods.modrinth".equals(downloadSource.get())) { - return i18n("mods.modrinth"); - } else { - return i18n("mods.curseforge"); - } - } -} diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModpackDownloadListPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModpackDownloadListPage.java deleted file mode 100644 index 91ee40d05..000000000 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModpackDownloadListPage.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Hello Minecraft! Launcher - * Copyright (C) 2022 huangyuhui and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.jackhuang.hmcl.ui.versions; - -import org.jackhuang.hmcl.game.LocalizedRemoteModRepository; -import org.jackhuang.hmcl.mod.RemoteModRepository; -import org.jackhuang.hmcl.mod.curse.CurseForgeRemoteModRepository; -import org.jackhuang.hmcl.mod.modrinth.ModrinthRemoteModRepository; - -import static org.jackhuang.hmcl.util.i18n.I18n.i18n; - -public class ModpackDownloadListPage extends DownloadListPage { - public ModpackDownloadListPage(DownloadPage.DownloadCallback callback, boolean versionSelection) { - super(null, callback, versionSelection); - - repository = new Repository(); - - supportChinese.set(true); - downloadSources.get().setAll("mods.curseforge", "mods.modrinth"); - if (CurseForgeRemoteModRepository.isAvailable()) - downloadSource.set("mods.curseforge"); - else - downloadSource.set("mods.modrinth"); - } - - private class Repository extends LocalizedRemoteModRepository { - - @Override - protected RemoteModRepository getBackedRemoteModRepository() { - if ("mods.modrinth".equals(downloadSource.get())) { - return ModrinthRemoteModRepository.MODPACKS; - } else { - return CurseForgeRemoteModRepository.MODPACKS; - } - } - - @Override - protected SortType getBackedRemoteModRepositorySortOrder() { - if ("mods.modrinth".equals(downloadSource.get())) { - return SortType.NAME; - } else { - return SortType.POPULARITY; - } - } - - @Override - public Type getType() { - return Type.MODPACK; - } - } - - @Override - protected String getLocalizedCategory(String category) { - if ("mods.modrinth".equals(downloadSource.get())) { - return i18n("modrinth.category." + category); - } else { - return i18n("curse.category." + category); - } - } - - @Override - protected String getLocalizedOfficialPage() { - if ("mods.modrinth".equals(downloadSource.get())) { - return i18n("mods.modrinth"); - } else { - return i18n("mods.curseforge"); - } - } -} diff --git a/HMCL/src/main/resources/assets/lang/I18N.properties b/HMCL/src/main/resources/assets/lang/I18N.properties index cbafeefbb..18b995dac 100644 --- a/HMCL/src/main/resources/assets/lang/I18N.properties +++ b/HMCL/src/main/resources/assets/lang/I18N.properties @@ -320,7 +320,6 @@ download=Download download.hint=Install games and modpacks or download mods, resource packs and worlds download.code.404=File not found on the remote server: %s download.content=Addons -download.curseforge.customization=Shaders, and game customization download.curseforge.unavailable=HMCL nightly build does not support access to CurseForge, please use release version or beta version to download. download.existing=The file cannot be saved because it already exists. You can use 'Save As' to save the file elsewhere. download.external_link=Open Download Website diff --git a/HMCL/src/main/resources/assets/lang/I18N_es.properties b/HMCL/src/main/resources/assets/lang/I18N_es.properties index 4a3022886..a629abbda 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_es.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_es.properties @@ -295,7 +295,6 @@ download=Descargar download.hint=Instalar juegos y modpacks o descargar mods, paquetes de recursos y mapas download.code.404=Archivo no encontrado en el servidor remoto: %s download.content=Complementos -download.curseforge.customization=Luz y sombras, y personalización del juego download.existing=El archivo no se puede guardar porque ya existe. Puedes usar 'Guardar como' para guardar el archivo en otro lugar. download.external_link=Abrir sitio web download.failed=Falló la descarga de %1$s, código de respuesta: %2$d diff --git a/HMCL/src/main/resources/assets/lang/I18N_ja.properties b/HMCL/src/main/resources/assets/lang/I18N_ja.properties index d311cd315..d77dd2b54 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_ja.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_ja.properties @@ -277,7 +277,6 @@ download=ダウンロード download.hint=ゲームや modpack をインストールするか、mod、リソース パック、マップをダウンロードします download.code.404=リモートサーバーにファイルが見つかりません:%s download.content=ゲームコンテンツ -download.curseforge.customization=光と影、およびゲームのカスタマイズ download.existing=ファイルは既に存在するため、保存できません。「名前を付けて保存」を選択して、ファイルを別の場所に保存できます。 download.external_link=ダウンロードサイトを開く download.failed=%1$s のダウンロードに失敗しました、応答コード:%2$d diff --git a/HMCL/src/main/resources/assets/lang/I18N_ru.properties b/HMCL/src/main/resources/assets/lang/I18N_ru.properties index 9b7ca88be..928b699d2 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_ru.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_ru.properties @@ -293,7 +293,6 @@ download=Скачать download.hint=Установите игры и пакеты модов или загрузите моды, пакеты ресурсов и карты download.code.404=Файл не найден на удалённом сервере: %s download.content=Игровой контент -download.curseforge.customization=Свет и тень, а также настройка игры download.curseforge.unavailable=Лаунчер версии Nightly не поддерживает доступ к CurseForge, используйте Release или Beta для скачивания. download.existing=Файл существует и по этому не может быть сохранён. Можно использовать «Сохранить как», чтобы сохранить файл в другом месте. download.external_link=Открыть сайт diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh.properties b/HMCL/src/main/resources/assets/lang/I18N_zh.properties index 2cdb8948d..dc00ac149 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh.properties @@ -329,7 +329,6 @@ download=下載 download.hint=安裝遊戲和整合包或下載模組、資源包和地圖 download.code.404=遠端伺服器沒有需要下載的檔案: %s download.content=遊戲內容 -download.curseforge.customization=光影與遊戲定制 download.curseforge.unavailable=HMCL 預覽版暫不支持訪問 CurseForge,請使用穩定版或測試版進行下載。 download.existing=檔案已存在,無法保存。你可以選擇另存為將檔案保存至其他地方。 download.external_link=打開下載網站 diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties index ac4cb2e15..8a5028d8f 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties @@ -330,7 +330,6 @@ download=下载 download.hint=安装游戏和整合包或下载模组、资源包和地图 download.code.404=远程服务器不包含需要下载的文件: %s download.content=游戏内容 -download.curseforge.customization=光影与游戏定制 download.curseforge.unavailable=HMCL 预览版暂不支持访问 CurseForge,请使用稳定版或测试版进行下载。 download.existing=文件已存在,无法保存。你可以在模组选择栏中的右侧按钮另存为将文件保存至其他地方。 download.external_link=打开下载网站