Skip to content

Commit 9684b35

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/curseforge' into chrome!!!
# Conflicts: # HMCL/src/main/java/org/jackhuang/hmcl/ui/main/SettingsPage.java # HMCL/src/main/resources/assets/lang/I18N.properties # HMCL/src/main/resources/assets/lang/I18N_zh.properties # HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties
2 parents a6554bb + a99e09c commit 9684b35

10 files changed

Lines changed: 153 additions & 74 deletions

File tree

HMCL/src/main/java/org/jackhuang/hmcl/ui/main/SettingsPage.java

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,14 @@
3838
import org.jackhuang.hmcl.ui.SVG;
3939
import org.jackhuang.hmcl.ui.construct.*;
4040
import org.jackhuang.hmcl.ui.construct.MessageDialogPane.MessageType;
41-
import org.jackhuang.hmcl.upgrade.RemoteVersion;
42-
import org.jackhuang.hmcl.upgrade.UpdateChannel;
43-
import org.jackhuang.hmcl.upgrade.UpdateChecker;
44-
import org.jackhuang.hmcl.upgrade.UpdateHandler;
41+
import org.jackhuang.hmcl.upgrade.*;
4542
import org.jackhuang.hmcl.util.Lang;
4643
import org.jackhuang.hmcl.util.StringUtils;
4744
import org.jackhuang.hmcl.util.i18n.I18n;
4845
import org.jackhuang.hmcl.util.i18n.SupportedLocale;
4946
import org.jackhuang.hmcl.util.io.FileUtils;
5047
import org.jackhuang.hmcl.util.io.IOUtils;
48+
import org.jetbrains.annotations.Nullable;
5149
import org.tukaani.xz.XZInputStream;
5250

5351
import java.io.IOException;
@@ -72,7 +70,8 @@
7270

7371
public final class SettingsPage extends ScrollPane {
7472
@SuppressWarnings("FieldCanBeLocal")
75-
private final InvalidationListener updateListener;
73+
@Nullable
74+
private InvalidationListener updateListener;
7675

7776
public SettingsPage() {
7877
this.setFitToWidth(true);
@@ -84,7 +83,7 @@ public SettingsPage() {
8483

8584
{
8685
ComponentList updatePaneList = new ComponentList();
87-
{
86+
if (UpdateChecker.SHOULD_CHECK_UPDATE) {
8887
ObjectProperty<UpdateChannel> updateChannel;
8988
{
9089

@@ -167,6 +166,40 @@ protected int getTrailingTextIndex() {
167166

168167
rootPane.getChildren().addAll(ComponentList.createComponentListTitle(i18n("update")), updatePaneList);
169168
}
169+
{
170+
LineToggleButton disableAutoShowUpdateDialogPane = new LineToggleButton();
171+
disableAutoShowUpdateDialogPane.setTitle(i18n("update.disable_auto_show_update_dialog"));
172+
disableAutoShowUpdateDialogPane.setSubtitle(i18n("update.disable_auto_show_update_dialog.subtitle"));
173+
disableAutoShowUpdateDialogPane.selectedProperty().bindBidirectional(settings().disableAutoShowUpdateDialogProperty());
174+
updatePaneList.getContent().add(disableAutoShowUpdateDialogPane);
175+
}
176+
} else {
177+
var alertLineButton = new LineButton();
178+
alertLineButton.setLargeTitle(true);
179+
alertLineButton.setLeading(SVG.INFO, 32);
180+
181+
if (UpdateChecker.DISABLE_UPDATE_PROPERTY.equalsIgnoreCase("true")) {
182+
alertLineButton.setTitle(i18n("update.disabled.title"));
183+
alertLineButton.setSubtitle(i18n("update.disabled.subtitle"));
184+
} else if (StringUtils.isNotBlank(UpdateChecker.PACKAGE_MANAGER_PROPERTY)) {
185+
alertLineButton.setTitle(i18n("update.packagemanager.title"));
186+
alertLineButton.setSubtitle(i18n("update.packagemanager.subtitle", UpdateChecker.PACKAGE_MANAGER_PROPERTY));
187+
} else if (!IntegrityChecker.DISABLE_SELF_INTEGRITY_CHECK && !IntegrityChecker.isSelfVerified()) {
188+
alertLineButton.setLeading(SVG.WARNING, 32);
189+
190+
alertLineButton.setTitle(i18n("update.unofficial.title"));
191+
alertLineButton.setSubtitle(i18n("update.unofficial.subtitle"));
192+
193+
alertLineButton.setTrailingIcon(SVG.OPEN_IN_NEW);
194+
alertLineButton.setOnAction(event -> FXUtils.openLink(Metadata.DOWNLOAD_URL));
195+
} else {
196+
// should not happen
197+
}
198+
199+
updatePaneList.getContent().add(alertLineButton);
200+
}
201+
202+
rootPane.getChildren().addAll(ComponentList.createComponentListTitle(i18n("update")), updatePaneList);
170203

171204
{
172205
ComponentList languagePaneList = new ComponentList();

HMCL/src/main/java/org/jackhuang/hmcl/upgrade/UpdateChecker.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import javafx.beans.property.*;
2424
import javafx.beans.value.ObservableBooleanValue;
2525
import org.jackhuang.hmcl.Metadata;
26+
import org.jackhuang.hmcl.util.StringUtils;
2627
import org.jackhuang.hmcl.util.io.NetworkUtils;
2728
import org.jackhuang.hmcl.util.versioning.VersionNumber;
2829

@@ -37,6 +38,10 @@ public final class UpdateChecker {
3738
private UpdateChecker() {
3839
}
3940

41+
public static final String PACKAGE_MANAGER_PROPERTY = System.getProperty("hmcl.update.packageManager", "");
42+
public static final String DISABLE_UPDATE_PROPERTY = System.getProperty("hmcl.update.disable", "");
43+
public static final boolean SHOULD_CHECK_UPDATE = shouldCheckUpdate();
44+
4045
private static final ObjectProperty<RemoteVersion> latestVersion = new SimpleObjectProperty<>();
4146
private static final BooleanBinding outdated = Bindings.createBooleanBinding(
4247
() -> {
@@ -55,6 +60,12 @@ private UpdateChecker() {
5560
latestVersion);
5661
private static final ReadOnlyBooleanWrapper checkingUpdate = new ReadOnlyBooleanWrapper(false);
5762

63+
private static boolean shouldCheckUpdate() {
64+
if (DISABLE_UPDATE_PROPERTY.equalsIgnoreCase("true")) return false;
65+
else if (StringUtils.isNotBlank(PACKAGE_MANAGER_PROPERTY)) return false;
66+
else return IntegrityChecker.DISABLE_SELF_INTEGRITY_CHECK || IntegrityChecker.isSelfVerified();
67+
}
68+
5869
public static void init() {
5970
requestCheckUpdate(UpdateChannel.getChannel(), settings().acceptPreviewUpdateProperty().get());
6071
}
@@ -102,6 +113,8 @@ private static boolean isDevelopmentVersion(String version) {
102113
}
103114

104115
public static void requestCheckUpdate(UpdateChannel channel, boolean preview) {
116+
if (!SHOULD_CHECK_UPDATE) return;
117+
105118
Platform.runLater(() -> {
106119
if (isCheckingUpdate())
107120
return;

HMCL/src/main/resources/assets/HMCLauncher.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ else
6060
_HMCL_VM_OPTIONS="-XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=15"
6161
fi
6262

63+
if [ $# -gt 0 ]; then
64+
_HMCL_VM_OPTIONS="$_HMCL_VM_OPTIONS $*"
65+
fi
66+
6367
function show_warning_console() {
6468
echo -e "\033[1;31m$1\033[0m" >&2
6569
}

HMCL/src/main/resources/assets/lang/I18N.properties

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,6 +1784,14 @@ update.channel.nightly.hint=You are currently using a Nightly channel build of t
17841784
update.channel.nightly.title=Nightly Channel Notice
17851785
update.channel.stable=Stable
17861786
update.checking=Checking for updates
1787+
update.disabled.title=Update has been disabled
1788+
update.disabled.subtitle=You have disabled update checking via system properties.
1789+
update.packagemanager.title=Managed by external package manager
1790+
update.packagemanager.subtitle=Launcher updates are managed by "%s". Please use this package manager to update.
1791+
update.unofficial.title=Unofficial build
1792+
update.unofficial.subtitle=You are using an unofficial build of HMCL. Please click here to download the official version to use update features.
1793+
update.disable_auto_show_update_dialog=Do not show update dialog automatically
1794+
update.disable_auto_show_update_dialog.subtitle=Enable this option to prevent HMCL from automatically showing the update dialog.
17871795
update.failed=Failed to update
17881796
update.found=Update Available!
17891797
update.newest_version=Latest version: %s

HMCL/src/main/resources/assets/lang/I18N_zh.properties

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,6 +1571,14 @@ update.channel.nightly.hint=你正在使用 HMCL 預覽版。預覽版更新較
15711571
update.channel.nightly.title=預覽版提示
15721572
update.channel.stable=穩定版
15731573
update.checking=正在檢查更新
1574+
update.disabled.title=更新功能已停用
1575+
update.disabled.subtitle=你已透過系統參數設定禁止更新檢查。
1576+
update.packagemanager.title=由外部套件管理員管理
1577+
update.packagemanager.subtitle=啟動器更新正在由外部套件管理員 "%s" 管理,請透過套件管理員進行更新操作。
1578+
update.unofficial.title=非官方構建
1579+
update.unofficial.subtitle=你正在使用非官方構建的 HMCL,請點擊此處下載官方版本以使用更新功能。
1580+
update.disable_auto_show_update_dialog=不自動顯示更新彈窗
1581+
update.disable_auto_show_update_dialog.subtitle=啟用此選項,HMCL 將不會自動彈出更新彈窗。
15741582
update.failed=更新失敗
15751583
update.found=發現到更新
15761584
update.newest_version=最新版本為:%s

HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,6 +1576,14 @@ update.channel.nightly.hint=你正在使用 HMCL 预览版。预览版更新较
15761576
update.channel.nightly.title=预览版提示
15771577
update.channel.stable=稳定版
15781578
update.checking=正在检查更新
1579+
update.disabled.title=更新功能已禁用
1580+
update.disabled.subtitle=你已通过系统参数配置了禁止更新检查。
1581+
update.packagemanager.title=由外部包管理器管理
1582+
update.packagemanager.subtitle=启动器更新正在由外部包管理器 "%s" 管理,请通过包管理器进行更新操作。
1583+
update.unofficial.title=非官方构建
1584+
update.unofficial.subtitle=你正在使用非官方构建的 HMCL,请点击此处下载官方版本以使用更新功能。
1585+
update.disable_auto_show_update_dialog=不自动显示更新弹窗
1586+
update.disable_auto_show_update_dialog.subtitle=启用此选项,HMCL 将不会自动弹出更新弹窗。
15791587
update.failed=更新失败
15801588
update.found=发现更新
15811589
update.newest_version=最新版本为:%s

buildSrc/src/main/java/org/jackhuang/hmcl/gradle/pack/CreateDeb.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ private String getLauncherScript() {
278278
if [ -z "${HMCL_DEPENDENCIES_DIR:-}" ]; then
279279
export HMCL_DEPENDENCIES_DIR="$HMCL_USER_HOME/dependencies"
280280
fi
281-
exec %s "$@"
281+
exec %s "$@" -Dhmcl.update.packageManager=apt
282282
""".formatted(getCurrentTypeName(), getTargetPath());
283283
}
284284

0 commit comments

Comments
 (0)