diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/SettingsPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/SettingsPage.java index b6c87089f..aa9f4972c 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/SettingsPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/SettingsPage.java @@ -17,6 +17,7 @@ */ package org.jackhuang.hmcl.ui; +import com.jfoenix.controls.JFXButton; import com.jfoenix.controls.JFXComboBox; import com.jfoenix.controls.JFXTextField; import javafx.beans.property.SimpleStringProperty; @@ -25,6 +26,8 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.fxml.FXML; import javafx.scene.control.Label; +import javafx.scene.control.ScrollPane; +import javafx.scene.control.Tooltip; import javafx.scene.layout.StackPane; import javafx.scene.text.Font; import org.jackhuang.hmcl.Main; @@ -65,6 +68,14 @@ public final class SettingsPage extends StackPane implements DecoratorPage { private FileItem fileBackgroundLocation; @FXML private Label lblDisplay; + @FXML + private Label lblUpdate; + @FXML + private Label lblUpdateSub; + @FXML + private JFXButton btnUpdate; + @FXML + private ScrollPane scroll; { FXUtils.loadFXML(this, "/assets/fxml/setting.fxml"); @@ -72,6 +83,8 @@ public final class SettingsPage extends StackPane implements DecoratorPage { FXUtils.limitWidth(cboLanguage, 400); FXUtils.limitWidth(cboDownloadSource, 400); + FXUtils.smoothScrolling(scroll); + txtProxyHost.setText(Settings.INSTANCE.getProxyHost()); txtProxyHost.textProperty().addListener((a, b, newValue) -> Settings.INSTANCE.setProxyHost(newValue)); @@ -118,6 +131,9 @@ public final class SettingsPage extends StackPane implements DecoratorPage { cboProxyType.getSelectionModel().selectedIndexProperty().addListener((a, b, newValue) -> Settings.INSTANCE.setProxyType(Proxies.getProxyType(newValue.intValue()))); fileCommonLocation.setProperty(Settings.INSTANCE.commonPathProperty()); + + FXUtils.installTooltip(btnUpdate, 0, 5000, 0, new Tooltip(Main.i18n("update.tooltip"))); + checkUpdate(); } public String getTitle() { @@ -132,4 +148,27 @@ public final class SettingsPage extends StackPane implements DecoratorPage { public void setTitle(String title) { this.title.set(title); } + + public void checkUpdate() { + btnUpdate.setVisible(Main.UPDATE_CHECKER.isOutOfDate()); + + if (Main.UPDATE_CHECKER.isOutOfDate()) { + lblUpdateSub.setText(Main.i18n("update.newest_version", Main.UPDATE_CHECKER.getNewVersion().toString())); + lblUpdateSub.getStyleClass().setAll("update-label"); + + lblUpdate.setText(Main.i18n("update.found")); + lblUpdate.getStyleClass().setAll("update-label"); + } else { + lblUpdateSub.setText(Main.i18n("update.latest")); + lblUpdateSub.getStyleClass().setAll("subtitle-label"); + + lblUpdate.setText(Main.i18n("update")); + lblUpdate.getStyleClass().setAll(); + } + } + + @FXML + private void onUpdate() { + Main.UPDATE_CHECKER.checkOutdate(); + } } diff --git a/HMCL/src/main/resources/assets/css/jfoenix-main-demo.css b/HMCL/src/main/resources/assets/css/jfoenix-main-demo.css index ab0bec4fd..270ef424a 100644 --- a/HMCL/src/main/resources/assets/css/jfoenix-main-demo.css +++ b/HMCL/src/main/resources/assets/css/jfoenix-main-demo.css @@ -27,6 +27,10 @@ -fx-text-fill: gray; } +.update-label { + -fx-text-fill: red; +} + .radio-button-title-label { -fx-font-size: 16.0px; -fx-padding: 14.0 0.0 -20.0 0.0; diff --git a/HMCL/src/main/resources/assets/fxml/setting.fxml b/HMCL/src/main/resources/assets/fxml/setting.fxml index b7bfc2c15..8a1cd957f 100644 --- a/HMCL/src/main/resources/assets/fxml/setting.fxml +++ b/HMCL/src/main/resources/assets/fxml/setting.fxml @@ -15,6 +15,23 @@ fitToHeight="true" fitToWidth="true"> + + + + + + + + + + + + + + + diff --git a/HMCL/src/main/resources/assets/lang/I18N.properties b/HMCL/src/main/resources/assets/lang/I18N.properties index 599049684..f53f771c0 100644 --- a/HMCL/src/main/resources/assets/lang/I18N.properties +++ b/HMCL/src/main/resources/assets/lang/I18N.properties @@ -366,11 +366,14 @@ settings.type=Version setting type settings.type.special=Specialized version settings(will not affect other versions) settings.update_version=Update version json. +update=Update update.failed=Failed to check for updates. update.found=Found Update! -update.newest_version=Newest version: +update.newest_version=Newest version: %s +update.latest=This is latest Version. update.no_browser=Cannot open any browser. The link has been copied to the clipboard. Paste it to a browser address bar to update. update.should_open_link=Are you willing to update the launcher? +update.tooltip=Update version.cannot_read=Unable to gather the game version. Cannot continue auto-installing. version.forbidden_name=Forbidden name, do not use this. 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 a03c2acf9..aa0c3c3e4 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties @@ -366,11 +366,14 @@ settings.type=版本设置类型 settings.type.special=单独版本设置(不会影响到其他版本的设定) settings.update_version=更新版本文件 +update=启动器更新 update.failed=检查更新失败 update.found=发现更新 -update.newest_version=最新版本为: +update.newest_version=最新版本为:%s +update.latest=当前版本为最新版本 update.no_browser=无法打开浏览器,网址已经复制到剪贴板了,您可以手动粘贴网址打开页面 update.should_open_link=是否更新? +update.tooltip=更新 version.cannot_read=读取游戏版本失败,无法进行自动安装 version.forbidden_name=此版本名称不受支持,请换一个名字 diff --git a/HMCL/src/main/resources/assets/svg/update.fxml b/HMCL/src/main/resources/assets/svg/update.fxml new file mode 100644 index 000000000..608d83a75 --- /dev/null +++ b/HMCL/src/main/resources/assets/svg/update.fxml @@ -0,0 +1,3 @@ + + +