Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 30 additions & 7 deletions HMCL/src/main/java/org/jackhuang/hmcl/ui/main/SettingsPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,15 @@
import org.jackhuang.hmcl.ui.SVG;
import org.jackhuang.hmcl.ui.construct.*;
import org.jackhuang.hmcl.ui.construct.MessageDialogPane.MessageType;
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.upgrade.*;
import org.jackhuang.hmcl.util.AprilFools;
import org.jackhuang.hmcl.util.Lang;
import org.jackhuang.hmcl.util.StringUtils;
import org.jackhuang.hmcl.util.i18n.I18n;
import org.jackhuang.hmcl.util.i18n.SupportedLocale;
import org.jackhuang.hmcl.util.io.FileUtils;
import org.jackhuang.hmcl.util.io.IOUtils;
import org.jetbrains.annotations.Nullable;
import org.tukaani.xz.XZInputStream;

import java.io.IOException;
Expand All @@ -71,7 +69,8 @@

public final class SettingsPage extends ScrollPane {
@SuppressWarnings("FieldCanBeLocal")
private final InvalidationListener updateListener;
@Nullable
private InvalidationListener updateListener;

public SettingsPage() {
this.setFitToWidth(true);
Expand All @@ -83,7 +82,7 @@ public SettingsPage() {

{
ComponentList updatePaneList = new ComponentList();
{
if (UpdateChecker.SHOULD_CHECK_UPDATE) {
ObjectProperty<UpdateChannel> updateChannel;
{

Expand Down Expand Up @@ -161,10 +160,34 @@ protected int getTrailingTextIndex() {
disableAutoShowUpdateDialogPane.selectedProperty().bindBidirectional(config().disableAutoShowUpdateDialogProperty());
updatePaneList.getContent().add(disableAutoShowUpdateDialogPane);
}
} else {
var alertLineButton = new LineButton();
alertLineButton.setLargeTitle(true);
alertLineButton.setLeading(SVG.INFO, 32);

if (UpdateChecker.DISABLE_UPDATE_PROPERTY.equalsIgnoreCase("true")) {
alertLineButton.setTitle(i18n("update.disabled.title"));
alertLineButton.setSubtitle(i18n("update.disabled.subtitle"));
} else if (StringUtils.isNotBlank(UpdateChecker.PACKAGE_MANAGER_PROPERTY)) {
alertLineButton.setTitle(i18n("update.packagemanager.title"));
alertLineButton.setSubtitle(i18n("update.packagemanager.subtitle", UpdateChecker.PACKAGE_MANAGER_PROPERTY));
} else if (!IntegrityChecker.DISABLE_SELF_INTEGRITY_CHECK && !IntegrityChecker.isSelfVerified()) {
alertLineButton.setLeading(SVG.WARNING, 32);

alertLineButton.setTitle(i18n("update.unofficial.title"));
alertLineButton.setSubtitle(i18n("update.unofficial.subtitle"));

alertLineButton.setTrailingIcon(SVG.OPEN_IN_NEW);
alertLineButton.setOnAction(event -> FXUtils.openLink(Metadata.DOWNLOAD_URL));
} else {
// should not happen
}

rootPane.getChildren().addAll(ComponentList.createComponentListTitle(i18n("update")), updatePaneList);
updatePaneList.getContent().add(alertLineButton);
}
Comment thread
CiiLu marked this conversation as resolved.

rootPane.getChildren().addAll(ComponentList.createComponentListTitle(i18n("update")), updatePaneList);

{
ComponentList languagePaneList = new ComponentList();

Expand Down
15 changes: 14 additions & 1 deletion HMCL/src/main/java/org/jackhuang/hmcl/upgrade/UpdateChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,25 @@
import javafx.beans.property.*;
import javafx.beans.value.ObservableBooleanValue;
import org.jackhuang.hmcl.Metadata;
import org.jackhuang.hmcl.util.StringUtils;
import org.jackhuang.hmcl.util.io.NetworkUtils;
import org.jackhuang.hmcl.util.versioning.VersionNumber;

import java.io.IOException;
import java.util.LinkedHashMap;

import static org.jackhuang.hmcl.setting.ConfigHolder.config;
import static org.jackhuang.hmcl.util.Lang.*;
import static org.jackhuang.hmcl.util.Lang.thread;
import static org.jackhuang.hmcl.util.logging.Logger.LOG;

public final class UpdateChecker {
private UpdateChecker() {
}

public static final String PACKAGE_MANAGER_PROPERTY = System.getProperty("hmcl.update.packageManager", "");
public static final String DISABLE_UPDATE_PROPERTY = System.getProperty("hmcl.update.disable", "");
public static final boolean SHOULD_CHECK_UPDATE = shouldCheckUpdate();

private static final ObjectProperty<RemoteVersion> latestVersion = new SimpleObjectProperty<>();
private static final BooleanBinding outdated = Bindings.createBooleanBinding(
() -> {
Expand All @@ -55,6 +60,12 @@ private UpdateChecker() {
latestVersion);
private static final ReadOnlyBooleanWrapper checkingUpdate = new ReadOnlyBooleanWrapper(false);

private static boolean shouldCheckUpdate() {
if (DISABLE_UPDATE_PROPERTY.equalsIgnoreCase("true")) return false;
else if (StringUtils.isNotBlank(PACKAGE_MANAGER_PROPERTY)) return false;
else return IntegrityChecker.DISABLE_SELF_INTEGRITY_CHECK || IntegrityChecker.isSelfVerified();
}

public static void init() {
requestCheckUpdate(UpdateChannel.getChannel(), config().isAcceptPreviewUpdate());
}
Expand Down Expand Up @@ -102,6 +113,8 @@ private static boolean isDevelopmentVersion(String version) {
}

public static void requestCheckUpdate(UpdateChannel channel, boolean preview) {
if (!SHOULD_CHECK_UPDATE) return;

Platform.runLater(() -> {
Comment thread
CiiLu marked this conversation as resolved.
if (isCheckingUpdate())
return;
Expand Down
4 changes: 4 additions & 0 deletions HMCL/src/main/resources/assets/HMCLauncher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ else
_HMCL_VM_OPTIONS="-XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=15"
fi

if [ $# -gt 0 ]; then
_HMCL_VM_OPTIONS="$_HMCL_VM_OPTIONS $*"
fi

function show_warning_console() {
echo -e "\033[1;31m$1\033[0m" >&2
}
Expand Down
6 changes: 6 additions & 0 deletions HMCL/src/main/resources/assets/lang/I18N.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1647,6 +1647,12 @@ update.channel.nightly.hint=You are currently using a Nightly channel build of t
update.channel.nightly.title=Nightly Channel Notice
update.channel.stable=Stable
update.checking=Checking for updates
update.disabled.title=Update has been disabled
update.disabled.subtitle=You have disabled update checking via system properties.
update.packagemanager.title=Managed by external package manager
update.packagemanager.subtitle=Launcher updates are managed by "%s". Please use this package manager to update.
update.unofficial.title=Unofficial build
update.unofficial.subtitle=You are using an unofficial build of HMCL. Please click here to download the official version to use update features.
update.disable_auto_show_update_dialog=Do not show update dialog automatically
update.disable_auto_show_update_dialog.subtitle=Enable this option to prevent HMCL from automatically showing the update dialog.
update.failed=Failed to update
Expand Down
6 changes: 6 additions & 0 deletions HMCL/src/main/resources/assets/lang/I18N_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1433,6 +1433,12 @@ update.channel.nightly.hint=你正在使用 HMCL 預覽版。預覽版更新較
update.channel.nightly.title=預覽版提示
update.channel.stable=穩定版
update.checking=正在檢查更新
update.disabled.title=更新功能已停用
update.disabled.subtitle=你已透過系統參數設定禁止更新檢查。
update.packagemanager.title=由外部套件管理員管理
update.packagemanager.subtitle=啟動器更新正在由外部套件管理員 "%s" 管理,請透過套件管理員進行更新操作。
update.unofficial.title=非官方構建
update.unofficial.subtitle=你正在使用非官方構建的 HMCL,請點擊此處下載官方版本以使用更新功能。
update.disable_auto_show_update_dialog=不自動顯示更新彈窗
update.disable_auto_show_update_dialog.subtitle=啟用此選項,HMCL 將不會自動彈出更新彈窗。
update.failed=更新失敗
Expand Down
6 changes: 6 additions & 0 deletions HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1438,6 +1438,12 @@ update.channel.nightly.hint=你正在使用 HMCL 预览版。预览版更新较
update.channel.nightly.title=预览版提示
update.channel.stable=稳定版
update.checking=正在检查更新
update.disabled.title=更新功能已禁用
update.disabled.subtitle=你已通过系统参数配置了禁止更新检查。
update.packagemanager.title=由外部包管理器管理
update.packagemanager.subtitle=启动器更新正在由外部包管理器 "%s" 管理,请通过包管理器进行更新操作。
update.unofficial.title=非官方构建
update.unofficial.subtitle=你正在使用非官方构建的 HMCL,请点击此处下载官方版本以使用更新功能。
update.disable_auto_show_update_dialog=不自动显示更新弹窗
update.disable_auto_show_update_dialog.subtitle=启用此选项,HMCL 将不会自动弹出更新弹窗。
update.failed=更新失败
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ private String getLauncherScript() {
if [ -z "${HMCL_DEPENDENCIES_DIR:-}" ]; then
export HMCL_DEPENDENCIES_DIR="$HMCL_USER_HOME/dependencies"
fi
exec %s "$@"
exec %s "$@" -Dhmcl.update.packageManager=apt
""".formatted(getCurrentTypeName(), getTargetPath());
}

Expand Down
Loading