mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-17 07:47:57 -04:00
Display changelog when update
This commit is contained in:
parent
300efb99d2
commit
a141c6b137
@ -35,6 +35,7 @@ public final class Metadata {
|
|||||||
public static final String UPDATE_URL = System.getProperty("hmcl.update_source.override", "https://hmcl.huangyuhui.net/api/update_link");
|
public static final String UPDATE_URL = System.getProperty("hmcl.update_source.override", "https://hmcl.huangyuhui.net/api/update_link");
|
||||||
public static final String CONTACT_URL = "https://hmcl.huangyuhui.net/contact";
|
public static final String CONTACT_URL = "https://hmcl.huangyuhui.net/contact";
|
||||||
public static final String HELP_URL = "https://hmcl.huangyuhui.net/help";
|
public static final String HELP_URL = "https://hmcl.huangyuhui.net/help";
|
||||||
|
public static final String CHANGELOG_URL = "https://hmcl.huangyuhui.net/changelog/";
|
||||||
public static final String PUBLISH_URL = "http://www.mcbbs.net/thread-142335-1-1.html";
|
public static final String PUBLISH_URL = "http://www.mcbbs.net/thread-142335-1-1.html";
|
||||||
|
|
||||||
public static final Path MINECRAFT_DIRECTORY = OperatingSystem.getWorkingDirectory("minecraft");
|
public static final Path MINECRAFT_DIRECTORY = OperatingSystem.getWorkingDirectory("minecraft");
|
||||||
|
82
HMCL/src/main/java/org/jackhuang/hmcl/ui/UpgradeDialog.java
Normal file
82
HMCL/src/main/java/org/jackhuang/hmcl/ui/UpgradeDialog.java
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* Hello Minecraft! Launcher
|
||||||
|
* Copyright (C) 2019 huangyuhui <huanghongxun2008@126.com> 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* Hello Minecraft! Launcher
|
||||||
|
* Copyright (C) 2019 huangyuhui <huanghongxun2008@126.com> 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.jackhuang.hmcl.ui;
|
||||||
|
|
||||||
|
import com.jfoenix.controls.JFXButton;
|
||||||
|
import com.jfoenix.controls.JFXDialogLayout;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.web.WebEngine;
|
||||||
|
import javafx.scene.web.WebView;
|
||||||
|
import org.jackhuang.hmcl.ui.construct.DialogCloseEvent;
|
||||||
|
|
||||||
|
import static org.jackhuang.hmcl.Metadata.CHANGELOG_URL;
|
||||||
|
import static org.jackhuang.hmcl.setting.ConfigHolder.config;
|
||||||
|
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
||||||
|
|
||||||
|
public class UpgradeDialog extends JFXDialogLayout {
|
||||||
|
private final WebView webView = new WebView();
|
||||||
|
|
||||||
|
public UpgradeDialog(Runnable updateRunnable) {
|
||||||
|
{
|
||||||
|
setHeading(new Label(i18n("update.changelog")));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
WebView webView = new WebView();
|
||||||
|
WebEngine engine = webView.getEngine();
|
||||||
|
engine.load(CHANGELOG_URL + config().getUpdateChannel().channelName);
|
||||||
|
engine.getLoadWorker().stateProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
|
String url = engine.getLoadWorker().getMessage().trim();
|
||||||
|
if (!url.startsWith(CHANGELOG_URL)) {
|
||||||
|
engine.getLoadWorker().cancel();
|
||||||
|
FXUtils.openLink(url);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
setBody(webView);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
JFXButton updateButton = new JFXButton(i18n("update.accept"));
|
||||||
|
updateButton.getStyleClass().add("dialog-accept");
|
||||||
|
updateButton.setOnMouseClicked(e -> updateRunnable.run());
|
||||||
|
|
||||||
|
JFXButton cancelButton = new JFXButton(i18n("button.cancel"));
|
||||||
|
cancelButton.getStyleClass().add("dialog-cancel");
|
||||||
|
cancelButton.setOnMouseClicked(e -> fireEvent(new DialogCloseEvent()));
|
||||||
|
|
||||||
|
setActions(updateButton, cancelButton);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -26,6 +26,7 @@ import org.jackhuang.hmcl.Metadata;
|
|||||||
import org.jackhuang.hmcl.task.Task;
|
import org.jackhuang.hmcl.task.Task;
|
||||||
import org.jackhuang.hmcl.task.TaskExecutor;
|
import org.jackhuang.hmcl.task.TaskExecutor;
|
||||||
import org.jackhuang.hmcl.ui.Controllers;
|
import org.jackhuang.hmcl.ui.Controllers;
|
||||||
|
import org.jackhuang.hmcl.ui.UpgradeDialog;
|
||||||
import org.jackhuang.hmcl.ui.construct.MessageDialogPane.MessageType;
|
import org.jackhuang.hmcl.ui.construct.MessageDialogPane.MessageType;
|
||||||
import org.jackhuang.hmcl.util.StringUtils;
|
import org.jackhuang.hmcl.util.StringUtils;
|
||||||
import org.jackhuang.hmcl.util.io.FileUtils;
|
import org.jackhuang.hmcl.util.io.FileUtils;
|
||||||
@ -91,6 +92,7 @@ public final class UpdateHandler {
|
|||||||
public static void updateFrom(RemoteVersion version) {
|
public static void updateFrom(RemoteVersion version) {
|
||||||
checkFxUserThread();
|
checkFxUserThread();
|
||||||
|
|
||||||
|
Controllers.dialog(new UpgradeDialog(() -> {
|
||||||
Path downloaded;
|
Path downloaded;
|
||||||
try {
|
try {
|
||||||
downloaded = Files.createTempFile("hmcl-update-", ".jar");
|
downloaded = Files.createTempFile("hmcl-update-", ".jar");
|
||||||
@ -117,7 +119,6 @@ public final class UpdateHandler {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.log(Level.WARNING, "Failed to update to " + version, e);
|
LOG.log(Level.WARNING, "Failed to update to " + version, e);
|
||||||
Platform.runLater(() -> Controllers.dialog(StringUtils.getStackTrace(e), i18n("update.failed"), MessageType.ERROR));
|
Platform.runLater(() -> Controllers.dialog(StringUtils.getStackTrace(e), i18n("update.failed"), MessageType.ERROR));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -126,6 +127,7 @@ public final class UpdateHandler {
|
|||||||
Platform.runLater(() -> Controllers.dialog(e.toString(), i18n("update.failed"), MessageType.ERROR));
|
Platform.runLater(() -> Controllers.dialog(e.toString(), i18n("update.failed"), MessageType.ERROR));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void applyUpdate(Path target) throws IOException {
|
private static void applyUpdate(Path target) throws IOException {
|
||||||
|
@ -388,6 +388,8 @@ sponsor.bmclapi=To obtain a stable download service, please consider support BMC
|
|||||||
sponsor.hmcl=HMCL is a free, open source Minecraft launcher the enables users to easily manage multiple, separate installations of Minecraft. We're using Afdian so that we can continue to pay for our hosting and project development. Click here for more information.
|
sponsor.hmcl=HMCL is a free, open source Minecraft launcher the enables users to easily manage multiple, separate installations of Minecraft. We're using Afdian so that we can continue to pay for our hosting and project development. Click here for more information.
|
||||||
|
|
||||||
update=Update
|
update=Update
|
||||||
|
update.accept=Update
|
||||||
|
update.changelog=Changelog
|
||||||
update.channel.dev=Update to development version
|
update.channel.dev=Update to development version
|
||||||
update.channel.stable=Update to stable version
|
update.channel.stable=Update to stable version
|
||||||
update.checking=Checking for updates
|
update.checking=Checking for updates
|
||||||
|
@ -386,6 +386,8 @@ sponsor.bmclapi=請贊助 BMCLAPI 從而獲得穩定高速的下載服務,點
|
|||||||
sponsor.hmcl=HMCL 是一個免費、開源的 Minecraft 啟動器,允許玩家方便快捷地安裝、管理、運行遊戲。您的贊助將幫助 HMCL 獲得更好的發展、支持穩定高速的遊戲安裝與文件下載服務。點擊此處查閱更多詳細訊息。
|
sponsor.hmcl=HMCL 是一個免費、開源的 Minecraft 啟動器,允許玩家方便快捷地安裝、管理、運行遊戲。您的贊助將幫助 HMCL 獲得更好的發展、支持穩定高速的遊戲安裝與文件下載服務。點擊此處查閱更多詳細訊息。
|
||||||
|
|
||||||
update=啟動器更新
|
update=啟動器更新
|
||||||
|
update.accept=更新
|
||||||
|
update.changelog=更新日誌
|
||||||
update.channel.dev=更新到開發版
|
update.channel.dev=更新到開發版
|
||||||
update.channel.stable=更新到推薦版本
|
update.channel.stable=更新到推薦版本
|
||||||
update.checking=正在檢查更新
|
update.checking=正在檢查更新
|
||||||
|
@ -386,6 +386,8 @@ sponsor.bmclapi=请赞助 BMCLAPI 从而获得稳定高速的下载服务,点
|
|||||||
sponsor.hmcl=HMCL 是一个免费、开源的 Minecraft 启动器,允许玩家方便快捷地安装、管理、运行游戏。您的赞助将帮助 HMCL 获得更好的发展、支持稳定高速的游戏安装与文件下载服务。点击此处查阅更多详细信息。
|
sponsor.hmcl=HMCL 是一个免费、开源的 Minecraft 启动器,允许玩家方便快捷地安装、管理、运行游戏。您的赞助将帮助 HMCL 获得更好的发展、支持稳定高速的游戏安装与文件下载服务。点击此处查阅更多详细信息。
|
||||||
|
|
||||||
update=启动器更新
|
update=启动器更新
|
||||||
|
update.accept=更新
|
||||||
|
update.changelog=更新日志
|
||||||
update.channel.dev=更新到开发版
|
update.channel.dev=更新到开发版
|
||||||
update.channel.stable=更新到推荐版本
|
update.channel.stable=更新到推荐版本
|
||||||
update.checking=正在检查更新
|
update.checking=正在检查更新
|
||||||
|
Loading…
x
Reference in New Issue
Block a user