update prompt

This commit is contained in:
huangyuhui
2018-02-13 12:16:53 +08:00
parent 46917af37c
commit 6443770670
6 changed files with 71 additions and 2 deletions

View File

@@ -17,6 +17,7 @@
*/ */
package org.jackhuang.hmcl.ui; package org.jackhuang.hmcl.ui;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXComboBox; import com.jfoenix.controls.JFXComboBox;
import com.jfoenix.controls.JFXTextField; import com.jfoenix.controls.JFXTextField;
import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.SimpleStringProperty;
@@ -25,6 +26,8 @@ import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.StackPane; import javafx.scene.layout.StackPane;
import javafx.scene.text.Font; import javafx.scene.text.Font;
import org.jackhuang.hmcl.Main; import org.jackhuang.hmcl.Main;
@@ -65,6 +68,14 @@ public final class SettingsPage extends StackPane implements DecoratorPage {
private FileItem fileBackgroundLocation; private FileItem fileBackgroundLocation;
@FXML @FXML
private Label lblDisplay; 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"); 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(cboLanguage, 400);
FXUtils.limitWidth(cboDownloadSource, 400); FXUtils.limitWidth(cboDownloadSource, 400);
FXUtils.smoothScrolling(scroll);
txtProxyHost.setText(Settings.INSTANCE.getProxyHost()); txtProxyHost.setText(Settings.INSTANCE.getProxyHost());
txtProxyHost.textProperty().addListener((a, b, newValue) -> Settings.INSTANCE.setProxyHost(newValue)); 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()))); cboProxyType.getSelectionModel().selectedIndexProperty().addListener((a, b, newValue) -> Settings.INSTANCE.setProxyType(Proxies.getProxyType(newValue.intValue())));
fileCommonLocation.setProperty(Settings.INSTANCE.commonPathProperty()); fileCommonLocation.setProperty(Settings.INSTANCE.commonPathProperty());
FXUtils.installTooltip(btnUpdate, 0, 5000, 0, new Tooltip(Main.i18n("update.tooltip")));
checkUpdate();
} }
public String getTitle() { public String getTitle() {
@@ -132,4 +148,27 @@ public final class SettingsPage extends StackPane implements DecoratorPage {
public void setTitle(String title) { public void setTitle(String title) {
this.title.set(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();
}
} }

View File

@@ -27,6 +27,10 @@
-fx-text-fill: gray; -fx-text-fill: gray;
} }
.update-label {
-fx-text-fill: red;
}
.radio-button-title-label { .radio-button-title-label {
-fx-font-size: 16.0px; -fx-font-size: 16.0px;
-fx-padding: 14.0 0.0 -20.0 0.0; -fx-padding: 14.0 0.0 -20.0 0.0;

View File

@@ -15,6 +15,23 @@
fitToHeight="true" fitToWidth="true"> fitToHeight="true" fitToWidth="true">
<VBox fx:id="rootPane" style="-fx-padding: 20;"> <VBox fx:id="rootPane" style="-fx-padding: 20;">
<ComponentList fx:id="settingsPane"> <ComponentList fx:id="settingsPane">
<BorderPane> <!-- Update -->
<left>
<VBox>
<Label fx:id="lblUpdate" text="%update" BorderPane.alignment="CENTER_LEFT"/>
<Label fx:id="lblUpdateSub" styleClass="subtitle-label"/>
</VBox>
</left>
<right>
<JFXButton fx:id="btnUpdate" onMouseClicked="#onUpdate" styleClass="toggle-icon4">
<graphic>
<fx:include source="/assets/svg/update.fxml" />
</graphic>
</JFXButton>
</right>
</BorderPane>
<FileItem fx:id="fileCommonLocation" name="%launcher.common_location" title="%launcher.choose_commonpath" tooltip="%settings.launcher.common_path.tooltip" /> <FileItem fx:id="fileCommonLocation" name="%launcher.common_location" title="%launcher.choose_commonpath" tooltip="%settings.launcher.common_path.tooltip" />
<!--FileItem fx:id="fileBackgroundLocation" name="%launcher.background_location" title="%launcher.choose_bgpath" tooltip="%launcher.background_tooltip" /--> <!--FileItem fx:id="fileBackgroundLocation" name="%launcher.background_location" title="%launcher.choose_bgpath" tooltip="%launcher.background_tooltip" /-->
<BorderPane><left><Label text="%settings.launcher.download_source" BorderPane.alignment="CENTER_LEFT" /></left><right><JFXComboBox fx:id="cboDownloadSource"> <BorderPane><left><Label text="%settings.launcher.download_source" BorderPane.alignment="CENTER_LEFT" /></left><right><JFXComboBox fx:id="cboDownloadSource">

View File

@@ -366,11 +366,14 @@ settings.type=Version setting type
settings.type.special=Specialized version settings(will not affect other versions) settings.type.special=Specialized version settings(will not affect other versions)
settings.update_version=Update version json. settings.update_version=Update version json.
update=Update
update.failed=Failed to check for updates. update.failed=Failed to check for updates.
update.found=Found Update! 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.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.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.cannot_read=Unable to gather the game version. Cannot continue auto-installing.
version.forbidden_name=Forbidden name, do not use this. version.forbidden_name=Forbidden name, do not use this.

View File

@@ -366,11 +366,14 @@ settings.type=版本设置类型
settings.type.special=单独版本设置(不会影响到其他版本的设定) settings.type.special=单独版本设置(不会影响到其他版本的设定)
settings.update_version=更新版本文件 settings.update_version=更新版本文件
update=启动器更新
update.failed=检查更新失败 update.failed=检查更新失败
update.found=发现更新 update.found=发现更新
update.newest_version=最新版本为: update.newest_version=最新版本为:%s
update.latest=当前版本为最新版本
update.no_browser=无法打开浏览器,网址已经复制到剪贴板了,您可以手动粘贴网址打开页面 update.no_browser=无法打开浏览器,网址已经复制到剪贴板了,您可以手动粘贴网址打开页面
update.should_open_link=是否更新? update.should_open_link=是否更新?
update.tooltip=更新
version.cannot_read=读取游戏版本失败,无法进行自动安装 version.cannot_read=读取游戏版本失败,无法进行自动安装
version.forbidden_name=此版本名称不受支持,请换一个名字 version.forbidden_name=此版本名称不受支持,请换一个名字

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.shape.SVGPath?>
<javafx.scene.shape.SVGPath fill="black" content="M21,10.12H14.22L16.96,7.3C14.23,4.6 9.81,4.5 7.08,7.2C4.35,9.91 4.35,14.28 7.08,17C9.81,19.7 14.23,19.7 16.96,17C18.32,15.65 19,14.08 19,12.1H21C21,14.08 20.12,16.65 18.36,18.39C14.85,21.87 9.15,21.87 5.64,18.39C2.14,14.92 2.11,9.28 5.62,5.81C9.13,2.34 14.76,2.34 18.27,5.81L21,3V10.12M12.5,8V12.25L16,14.33L15.28,15.54L11,13V8H12.5Z" />