diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/setting/Config.java b/HMCL/src/main/java/org/jackhuang/hmcl/setting/Config.java index 714a7ebe03..0a845929b5 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/setting/Config.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/setting/Config.java @@ -567,6 +567,21 @@ public final class Config extends ObservableSetting { this.versionListSource.set(versionListSource); } + @SerializedName("defaultAddonSource") + private final StringProperty defaultAddonSource = new SimpleStringProperty("modrinth"); + + public StringProperty defaultAddonSourceProperty() { + return defaultAddonSource; + } + + public String getDefaultAddonSource() { + return defaultAddonSource.get(); + } + + public void setDefaultAddonSource(String defaultAddonSource) { + this.defaultAddonSource.set(defaultAddonSource); + } + @SerializedName("hasProxy") private final BooleanProperty hasProxy = new SimpleBooleanProperty(); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/DownloadSettingsPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/DownloadSettingsPage.java index d1a154032a..6ef1ff67d5 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/DownloadSettingsPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/DownloadSettingsPage.java @@ -85,7 +85,13 @@ public class DownloadSettingsPage extends StackPane { downloadSourcePane.setItems(DownloadProviders.DIRECT_PROVIDERS.keySet()); downloadSourcePane.valueProperty().bindBidirectional(config().downloadTypeProperty()); - downloadSource.getContent().setAll(autoChooseDownloadSource, versionListSourcePane, downloadSourcePane); + var defaultAddonSourcePane = new LineSelectButton(); + defaultAddonSourcePane.setTitle(i18n("settings.launcher.default_addon_source")); + defaultAddonSourcePane.setConverter(key -> I18n.i18n("mods." + key)); + defaultAddonSourcePane.setItems("modrinth", "curseforge"); + defaultAddonSourcePane.valueProperty().bindBidirectional(config().defaultAddonSourceProperty()); + + downloadSource.getContent().setAll(autoChooseDownloadSource, versionListSourcePane, downloadSourcePane, defaultAddonSourcePane); } content.getChildren().addAll(ComponentList.createComponentListTitle(i18n("settings.launcher.download_source")), downloadSource); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/HMCLLocalizedDownloadListPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/HMCLLocalizedDownloadListPage.java index 8b77f45617..c83632b48d 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/HMCLLocalizedDownloadListPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/HMCLLocalizedDownloadListPage.java @@ -25,6 +25,7 @@ import org.jackhuang.hmcl.util.i18n.I18n; import java.util.MissingResourceException; +import static org.jackhuang.hmcl.setting.ConfigHolder.config; import static org.jackhuang.hmcl.util.i18n.I18n.i18n; import static org.jackhuang.hmcl.util.logging.Logger.LOG; @@ -62,17 +63,29 @@ public final class HMCLLocalizedDownloadListPage extends DownloadListPage { supportChinese.set(true); + boolean supportedCurseForge = CurseForgeRemoteModRepository.isAvailable() && curseForge != null; + downloadSources.setAll("mods.modrinth"); - if (CurseForgeRemoteModRepository.isAvailable()) { + if (supportedCurseForge) { downloadSources.add("mods.curseforge"); } - if (modrinth != null) { - downloadSource.set("mods.modrinth"); - } else if (curseForge != null) { - downloadSource.set("mods.curseforge"); + if ("curseforge".equalsIgnoreCase(config().getDefaultAddonSource())) { + if (supportedCurseForge) { + downloadSource.set("mods.curseforge"); + } else if (modrinth != null) { + downloadSource.set("mods.modrinth"); + } else { + throw new AssertionError("Should not be here."); + } } else { - throw new AssertionError("Should not be here."); + if (modrinth != null) { + downloadSource.set("mods.modrinth"); + } else if (supportedCurseForge) { + downloadSource.set("mods.curseforge"); + } else { + throw new AssertionError("Should not be here."); + } } } diff --git a/HMCL/src/main/resources/assets/lang/I18N.properties b/HMCL/src/main/resources/assets/lang/I18N.properties index bb5233c158..8df871f673 100644 --- a/HMCL/src/main/resources/assets/lang/I18N.properties +++ b/HMCL/src/main/resources/assets/lang/I18N.properties @@ -1441,6 +1441,7 @@ settings.launcher.download.threads.auto=Automatically Determine settings.launcher.download.threads.hint=Too many threads may cause your system to freeze, and your download speed may be affected by your ISP and download servers. It is not always the case that more threads increase your download speed. settings.launcher.download_source=Download Source settings.launcher.download_source.auto=Automatically Choose Download Sources +settings.launcher.default_addon_source=Default Addon Source settings.launcher.enable_game_list=Show instance list in homepage settings.launcher.font=Font settings.launcher.font.anti_aliasing=Anti-aliasing diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh.properties b/HMCL/src/main/resources/assets/lang/I18N_zh.properties index 633f66094e..15965bda5a 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh.properties @@ -1226,6 +1226,7 @@ settings.launcher.download.threads.auto=自動選取執行緒數 settings.launcher.download.threads.hint=執行緒數過高可能導致系統卡頓。你的下載速度會受到網際網路運營商、下載來源伺服器等方面的影響。調高下載執行緒數不一定能大幅提升總下載速度。 settings.launcher.download_source=下載來源 settings.launcher.download_source.auto=自動選取下載來源 +settings.launcher.default_addon_source=遊戲內容預設下載來源 settings.launcher.enable_game_list=在首頁內顯示遊戲清單 settings.launcher.font=字體 settings.launcher.font.anti_aliasing=反鋸齒 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 2cd778cea6..40e622cc70 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties @@ -1231,6 +1231,7 @@ settings.launcher.download.threads.auto=自动选择线程数 settings.launcher.download.threads.hint=线程数过高可能导致系统卡顿。你的下载速度会受到互联网运营商、下载源服务器等方面的影响。调高下载线程数不一定能大幅提升总下载速度。 settings.launcher.download_source=下载源 settings.launcher.download_source.auto=自动选择下载源 +settings.launcher.default_addon_source=游戏内容默认下载源 settings.launcher.enable_game_list=在主页内显示版本列表 settings.launcher.font=字体 settings.launcher.font.anti_aliasing=抗锯齿