diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java index d96e511853..ee8971c9be 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java @@ -624,14 +624,15 @@ public static void showToast(String content) { public static void onHyperlinkAction(String href) { if (href.startsWith("hmcl://")) { switch (href) { - case "hmcl://settings/feedback": + case "hmcl://settings/feedback" -> { Controllers.getSettingsPage().showFeedback(); Controllers.navigate(Controllers.getSettingsPage()); - break; - case "hmcl://game/launch": + } + case "hmcl://game/launch" -> { Profile profile = Profiles.getSelectedProfile(); Versions.launch(profile, profile.getSelectedVersion(), LauncherHelper::setKeep); - break; + } + case "hmcl://update/switch-channel/stable" -> getRootPage().getMainPage().onSwitchToStableChannel(); } } else { FXUtils.openLink(href); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java index 894f3821ef..bcdee11920 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java @@ -23,6 +23,7 @@ import javafx.animation.KeyValue; import javafx.animation.Timeline; import javafx.beans.property.*; +import javafx.beans.value.ChangeListener; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.event.EventHandler; @@ -63,6 +64,7 @@ import org.jackhuang.hmcl.ui.versions.GameListPopupMenu; import org.jackhuang.hmcl.ui.versions.Versions; import org.jackhuang.hmcl.upgrade.RemoteVersion; +import org.jackhuang.hmcl.upgrade.UpdateChannel; import org.jackhuang.hmcl.upgrade.UpdateChecker; import org.jackhuang.hmcl.upgrade.UpdateHandler; import org.jackhuang.hmcl.util.*; @@ -368,6 +370,23 @@ private void closeUpdateBubble() { showUpdate.set(false); } + public void onSwitchToStableChannel() { + Controllers.confirm(i18n("update.switch_to_stable.confirm"), i18n("update.switch_to_stable.title"), () -> { + UpdateChecker.requestCheckUpdate(UpdateChannel.STABLE, config().acceptPreviewUpdateProperty().get()); + Holder> holder = new Holder<>(); + holder.value = (observable, old, now) -> { + if (!now) { + UpdateChecker.checkingUpdateProperty().removeListener(holder.value); + RemoteVersion target = UpdateChecker.getLatestVersion(); + if (target != null) { + UpdateHandler.updateFrom(target); + } + } + }; + UpdateChecker.checkingUpdateProperty().addListener(holder.value); + }, null); + } + @Override public ReadOnlyObjectWrapper stateProperty() { return state; diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/upgrade/UpdateChecker.java b/HMCL/src/main/java/org/jackhuang/hmcl/upgrade/UpdateChecker.java index 7d4fa507c6..a5076d1cee 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/upgrade/UpdateChecker.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/upgrade/UpdateChecker.java @@ -118,10 +118,10 @@ public static void requestCheckUpdate(UpdateChannel channel, boolean preview) { RemoteVersion finalResult = result; Platform.runLater(() -> { - checkingUpdate.set(false); if (finalResult != null) { latestVersion.set(finalResult); } + checkingUpdate.set(false); }); }, "Update Checker", true); }); diff --git a/HMCL/src/main/resources/assets/lang/I18N.properties b/HMCL/src/main/resources/assets/lang/I18N.properties index a2b324057d..0d72675c29 100644 --- a/HMCL/src/main/resources/assets/lang/I18N.properties +++ b/HMCL/src/main/resources/assets/lang/I18N.properties @@ -1628,14 +1628,14 @@ update=Update update.accept=Update update.changelog=Changelog update.channel.dev=Beta -update.channel.dev.hint=You are currently using a Beta channel build of the launcher. While it may include some extra features, it is also sometimes less stable than the Stable channel builds.\n\ +update.channel.dev.hint=You are currently using a Beta channel build of the launcher. While it may include some extra features, it is also sometimes less stable than the Stable channel builds. Switch to Stable channel\n\ \n\ If you encounter any bugs or problems, please submit feedback via the channels provided on the Feedback page.\n\ \n\ Follow @huanghongxun on Bilibili to stay up to date on important HMCL news, or @Glavo to learn about HMCL development progress. update.channel.dev.title=Beta Channel Notice update.channel.nightly=Nightly -update.channel.nightly.hint=You are currently using a Nightly channel build of the launcher. While it may include some extra features, it is also always less stable than the other channel builds.\n\ +update.channel.nightly.hint=You are currently using a Nightly channel build of the launcher. While it may include some extra features, it is also always less stable than the other channel builds. Switch to Stable channel\n\ \n\ If you encounter any bugs or problems, please submit feedback via the channels provided on the Feedback page.\n\ \n\ @@ -1654,6 +1654,8 @@ update.note.stable=Suitable for users who prioritize software stability.\nNew fe update.note.dev=Suitable for users who want to experience new features first.\nThe development version includes the latest features and bug fixes,\nbut may also have more issues due to insufficient testing. update.latest=This is the latest version update.no_browser=Cannot open in system browser. But we copied the link to your clipboard, and you can open it manually. +update.switch_to_stable.confirm=Want to switch to the stable channel of HMCL?\nClick "Yes" to download and install the latest stable version of HMCL. +update.switch_to_stable.title=Switch to Stable Channel update.tooltip=Update update.preview=Preview HMCL releases early update.preview.subtitle=Enable this option to receive new versions of HMCL early for testing before their official release. diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh.properties b/HMCL/src/main/resources/assets/lang/I18N_zh.properties index 96ab768a83..ade5e55b60 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh.properties @@ -1417,12 +1417,12 @@ update=啟動器更新 update.accept=更新 update.changelog=更新日誌 update.channel.dev=開發版 -update.channel.dev.hint=你正在使用 HMCL 開發版。開發版包含一些未在穩定版中包含的測試性功能,僅用於體驗新功能。開發版功能未受充分驗證,使用起來可能不穩定!\n\ +update.channel.dev.hint=你正在使用 HMCL 開發版。開發版包含一些未在穩定版中包含的測試性功能,僅用於體驗新功能。開發版功能未受充分驗證,使用起來可能不穩定!切換至穩定管道\n\ \n\ 如果你遇到了使用問題,可以透過設定中 回報頁面 提供的管道進行回報。歡迎關注 Bilibili @huanghongxun 以關注 HMCL 的重要動態,或關注 @Glavo 以瞭解 HMCL 的開發進展。 update.channel.dev.title=開發版提示 update.channel.nightly=預覽版 -update.channel.nightly.hint=你正在使用 HMCL 預覽版。預覽版更新較為頻繁,包含一些未在穩定版和開發版中包含的測試性功能,僅用於體驗新功能。預覽版功能未受充分驗證,使用起來可能不穩定!\n\ +update.channel.nightly.hint=你正在使用 HMCL 預覽版。預覽版更新較為頻繁,包含一些未在穩定版和開發版中包含的測試性功能,僅用於體驗新功能。預覽版功能未受充分驗證,使用起來可能不穩定!切換至穩定管道\n\ \n\ 如果你遇到了使用問題,可以透過設定中 回報頁面 提供的管道進行回報。歡迎關注 Bilibili @huanghongxun 以關注 HMCL 的重要動態,或關注 @Glavo 以瞭解 HMCL 的開發進展。 update.channel.nightly.title=預覽版提示 @@ -1439,6 +1439,8 @@ update.note.stable=適合優先追求軟體穩定性的使用者使用。\n新 update.note.dev=適合希望優先體驗新功能的使用者使用。\n開發版會包含最新功能和錯誤修復,但未經充分測試,可能會存在更多問題。 update.latest=目前版本為最新版本 update.no_browser=無法開啟瀏覽器。網址已經複製到剪貼簿了,你可以手動複製網址開啟頁面。 +update.switch_to_stable.confirm=希望切換至穩定管道嗎?\n這將會下載並安裝最新的 HMCL 穩定版本。 +update.switch_to_stable.title=切換至穩定管道 update.tooltip=更新 update.preview=提前測試 HMCL 預覽版本 update.preview.subtitle=啟用此選項,你將可以提前取得 HMCL 的新版本,以便在正式發布前進行測試。 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 d29478876f..d6d8b417a0 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties @@ -1422,12 +1422,12 @@ update=启动器更新 update.accept=更新 update.changelog=更新日志 update.channel.dev=开发版 -update.channel.dev.hint=你正在使用 HMCL 开发版。开发版包含一些未在稳定版中包含的测试性功能,仅用于体验新功能。开发版功能未受充分验证,使用起来可能不稳定!下载稳定版\n\ +update.channel.dev.hint=你正在使用 HMCL 开发版。开发版包含一些未在稳定版中包含的测试性功能,仅用于体验新功能。开发版功能未受充分验证,使用起来可能不稳定!切换至稳定版\n\ \n\ 如果你使用时遇到了问题,可以通过设置中反馈页面提供的渠道进行反馈。欢迎关注 B 站账号 @huanghongxun 以关注 HMCL 的重要动态,或关注 @Glavo 以了解 HMCL 的开发进展。 update.channel.dev.title=开发版提示 update.channel.nightly=预览版 -update.channel.nightly.hint=你正在使用 HMCL 预览版。预览版更新较为频繁,包含一些未在稳定版和开发版中包含的测试性功能,仅用于体验新功能。预览版功能未受充分验证,使用起来可能不稳定!下载稳定版\n\ +update.channel.nightly.hint=你正在使用 HMCL 预览版。预览版更新较为频繁,包含一些未在稳定版和开发版中包含的测试性功能,仅用于体验新功能。预览版功能未受充分验证,使用起来可能不稳定!切换至稳定版\n\ \n\ 如果你使用时遇到了问题,可以通过设置中反馈页面提供的渠道进行反馈。欢迎关注 B 站账号 @huanghongxun 以关注 HMCL 的重要动态,或关注 @Glavo 以了解 HMCL 的开发进展。 update.channel.nightly.title=预览版提示 @@ -1444,6 +1444,8 @@ update.note.stable=适合优先追求软件稳定性的用户使用。\n新功 update.note.dev=适合希望优先体验新功能的用户使用。\n包含最新功能和错误修复,但未经充分测试,可能会存在更多问题。 update.latest=当前版本为最新版本 update.no_browser=无法打开浏览器。网址已经复制到剪贴板,你可以手动粘贴网址打开页面。 +update.switch_to_stable.confirm=是否切换至稳定版?\n这将会下载并安装最新的 HMCL 稳定版本。 +update.switch_to_stable.title=切换至稳定版 update.tooltip=更新 update.preview=提前预览 HMCL 版本 update.preview.subtitle=启用此选项,你将可以提前获取 HMCL 的新版本,以便在正式发布前进行测试。