Skip to content

Commit

Permalink
Show a warning message before the application startup.
Browse files Browse the repository at this point in the history
  • Loading branch information
burningtnt committed Dec 23, 2023
1 parent 882583f commit d15d6ea
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 0 deletions.
30 changes: 30 additions & 0 deletions HMCL/src/main/java/net/burningtnt/hmclprs/Hooks.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package net.burningtnt.hmclprs;

import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;

import javax.swing.*;
import java.util.Optional;

import static org.jackhuang.hmcl.util.i18n.I18n.i18n;

public final class Hooks {
private Hooks() {
}

public static void onApplicationLaunch() {
try {
Optional<ButtonType> opt = new Alert(Alert.AlertType.CONFIRMATION, i18n("prs.warning")).showAndWait();
if (opt.isPresent() && opt.get() == ButtonType.YES) {
return;
}
} catch (Throwable ignored) {
if (JOptionPane.showConfirmDialog(
null, i18n("prs.warning"), i18n("message.warning"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE
) == JOptionPane.OK_OPTION) {
return;
}
}
System.exit(1);
}
}
2 changes: 2 additions & 0 deletions HMCL/src/main/java/org/jackhuang/hmcl/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ private Main() {
}

public static void main(String[] args) {
net.burningtnt.hmclprs.Hooks.onApplicationLaunch();

System.setProperty("java.net.useSystemProxies", "true");
System.setProperty("javafx.autoproxy.disable", "true");
System.getProperties().putIfAbsent("http.agent", "HMCL/" + Metadata.VERSION);
Expand Down
5 changes: 5 additions & 0 deletions HMCL/src/main/resources/assets/lang/I18N.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1239,3 +1239,8 @@ wizard.prev=< Prev
wizard.failed=Failed
wizard.finish=Finish
wizard.next=Next >

prs.warning=You are using a non-official version of HMCL, which collects many features and bug fixes from the pull requests towards HMCL GitHub Repository.\n\
The title of this application is still HMCL because the compatibility have to be kept. But DO REMEMBER THIS IS NOT AN OFFICIAL VERSION!\n\
If you don't know why you are using this version, please close this applicatio immediately and download the official version!\n\
You can continue using this application only if you are clear about this fact. If you have any problem, close this application immediately and go to https://github.com/huanghongxun/HMCL/pull/2608 for more information.
5 changes: 5 additions & 0 deletions HMCL/src/main/resources/assets/lang/I18N_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1097,3 +1097,8 @@ wizard.prev=< 上一步
wizard.failed=失敗
wizard.finish=完成
wizard.next=下一步 >

prs.warning=你正在使用非官方的 HMCL 版本。本版本帶有很多來自 HMCL GitHub PR 的功能和錯誤修復。 \n\
本應用的名稱仍然為 HMCL,這是處於兼容性的考慮。 \n\
如果你不知道自己在做什麼,請立刻關閉本應用,並下載官方版本。 \n\
請僅在你已經確保理解了本段文字的情況下繼續使用本應用。如果你有任何問題,請立刻關閉本應用,可前往 https://github.com/huanghongxun/HMCL/pull/2608 獲取更多信息。
5 changes: 5 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 @@ -1098,3 +1098,8 @@ wizard.prev=< 上一步
wizard.failed=失败
wizard.finish=完成
wizard.next=下一步 >

prs.warning=你正在使用非官方的 HMCL 版本。本版本带有很多来自 HMCL GitHub PR 的功能和错误修复。\n\
本应用的名称仍然为 HMCL,这是处于兼容性的考虑。\n\
如果你不知道自己在做什么,请立刻关闭本应用,并下载官方版本。\n\
请仅在你已经确保理解了本段文字的情况下继续使用本应用。如果你有任何问题,请立刻关闭本应用,可前往 https://github.com/huanghongxun/HMCL/pull/2608 获取更多信息。

0 comments on commit d15d6ea

Please sign in to comment.