mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-23 03:04:07 -04:00
在未启用 JIT 或硬件渲染加速的环境中启动时弹出提示 (#4487)
This commit is contained in:
parent
15e490f313
commit
b66e249591
@ -75,13 +75,7 @@ public final class Launcher extends Application {
|
||||
CookieHandler.setDefault(COOKIE_MANAGER);
|
||||
|
||||
LOG.info("JavaFX Version: " + System.getProperty("javafx.runtime.version"));
|
||||
try {
|
||||
Object pipeline = Class.forName("com.sun.prism.GraphicsPipeline").getMethod("getPipeline").invoke(null);
|
||||
LOG.info("Prism pipeline: " + (pipeline == null ? "null" : pipeline.getClass().getName()));
|
||||
} catch (Throwable e) {
|
||||
LOG.warning("Failed to get prism pipeline", e);
|
||||
}
|
||||
|
||||
LOG.info("Prism Pipeline: " + FXUtils.GRAPHICS_PIPELINE);
|
||||
LOG.info("Dark Mode: " + Optional.ofNullable(FXUtils.DARK_MODE).map(ObservableBooleanValue::get).orElse(false));
|
||||
LOG.info("Reduced Motion: " + Objects.requireNonNullElse(FXUtils.REDUCED_MOTION, false));
|
||||
|
||||
|
@ -72,6 +72,8 @@ import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
||||
|
||||
public final class Controllers {
|
||||
public static final String JAVA_VERSION_TIP = "javaVersion";
|
||||
public static final String JAVA_INTERPRETED_MODE_TIP = "javaInterpretedMode";
|
||||
public static final String SOFTWARE_RENDERING = "softwareRendering";
|
||||
|
||||
public static final int MIN_WIDTH = 800 + 2 + 16; // bg width + border width*2 + shadow width*2
|
||||
public static final int MIN_HEIGHT = 450 + 2 + 40 + 16; // bg height + border width*2 + toolbar height + shadow width*2
|
||||
@ -347,6 +349,24 @@ public final class Controllers {
|
||||
}
|
||||
}
|
||||
|
||||
// Check whether JIT is enabled in the current environment
|
||||
if (!JavaRuntime.CURRENT_JIT_ENABLED && !Boolean.TRUE.equals(config().getShownTips().get(JAVA_INTERPRETED_MODE_TIP))) {
|
||||
Controllers.dialog(new MessageDialogPane.Builder(i18n("warning.java_interpreted_mode"), i18n("message.warning"), MessageType.WARNING)
|
||||
.ok(null)
|
||||
.addCancel(i18n("button.do_not_show_again"), () ->
|
||||
config().getShownTips().put(JAVA_INTERPRETED_MODE_TIP, true))
|
||||
.build());
|
||||
}
|
||||
|
||||
// Check whether hardware acceleration is enabled
|
||||
if (!FXUtils.GPU_ACCELERATION_ENABLED && !Boolean.TRUE.equals(config().getShownTips().get(SOFTWARE_RENDERING))) {
|
||||
Controllers.dialog(new MessageDialogPane.Builder(i18n("warning.software_rendering"), i18n("message.warning"), MessageType.WARNING)
|
||||
.ok(null)
|
||||
.addCancel(i18n("button.do_not_show_again"), () ->
|
||||
config().getShownTips().put(SOFTWARE_RENDERING, true))
|
||||
.build());
|
||||
}
|
||||
|
||||
if (globalConfig().getAgreementVersion() < 1) {
|
||||
JFXDialogLayout agreementPane = new JFXDialogLayout();
|
||||
agreementPane.setHeading(new Label(i18n("launcher.agreement")));
|
||||
|
@ -109,6 +109,25 @@ public final class FXUtils {
|
||||
|
||||
public static final int JAVAFX_MAJOR_VERSION;
|
||||
|
||||
public static final String GRAPHICS_PIPELINE;
|
||||
public static final boolean GPU_ACCELERATION_ENABLED;
|
||||
|
||||
static {
|
||||
String pipelineName = "";
|
||||
|
||||
try {
|
||||
Object pipeline = Class.forName("com.sun.prism.GraphicsPipeline").getMethod("getPipeline").invoke(null);
|
||||
if (pipeline != null) {
|
||||
pipelineName = pipeline.getClass().getName();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
LOG.warning("Failed to get prism pipeline", e);
|
||||
}
|
||||
|
||||
GRAPHICS_PIPELINE = pipelineName;
|
||||
GPU_ACCELERATION_ENABLED = !pipelineName.endsWith(".SWPipeline");
|
||||
}
|
||||
|
||||
/// @see Platform.Preferences
|
||||
public static final @Nullable ObservableMap<String, Object> PREFERENCES;
|
||||
public static final @Nullable ObservableBooleanValue DARK_MODE;
|
||||
|
@ -179,6 +179,7 @@ button.change_source=Change Download Source
|
||||
button.clear=Clear
|
||||
button.copy_and_exit=Copy and Exit
|
||||
button.delete=Delete
|
||||
button.do_not_show_again=Don't show again
|
||||
button.edit=Edit
|
||||
button.install=Install
|
||||
button.export=Export
|
||||
@ -1487,6 +1488,11 @@ version.search.prompt=Enter the version name to search
|
||||
version.settings=Settings
|
||||
version.update=Update Modpack
|
||||
|
||||
warning.java_interpreted_mode=HMCL is running in an interpreted Java environment, which will greatly affect performance.\n\
|
||||
\n\
|
||||
We recommend using a Java with JIT support to launch HMCL for the best experience.
|
||||
warning.software_rendering=HMCL is currently using software rendering, which will greatly affect performance.
|
||||
|
||||
wiki.tooltip=Minecraft Wiki Page
|
||||
wiki.version.game=https://minecraft.wiki/w/Java_Edition_%s
|
||||
wiki.version.game.snapshot=https://minecraft.wiki/w/Java_Edition_%s
|
||||
|
@ -182,6 +182,7 @@ button.change_source=切換下載源
|
||||
button.clear=清除
|
||||
button.copy_and_exit=複製並退出
|
||||
button.delete=刪除
|
||||
button.do_not_show_again=不再顯示
|
||||
button.edit=編輯
|
||||
button.install=安裝
|
||||
button.export=匯出
|
||||
@ -1271,6 +1272,9 @@ version.search.prompt=輸入版本名稱進行搜尋
|
||||
version.settings=遊戲設定
|
||||
version.update=更新模組包
|
||||
|
||||
warning.java_interpreted_mode=HMCL 正在執行於直譯器模式的 Java 環境中,效能將會受到很大影響。\n我們建議你使用支援 JIT 的 Java 啟動 HMCL 以獲得最佳體驗。
|
||||
warning.software_rendering=HMCL 正在使用軟體渲染,效能將會受到很大影響。
|
||||
|
||||
wiki.tooltip=Minecraft Wiki 頁面
|
||||
wiki.version.game=https://zh.minecraft.wiki/w/Java版%s
|
||||
wiki.version.game.snapshot=https://zh.minecraft.wiki/w/%s
|
||||
|
@ -190,6 +190,7 @@ button.change_source=切换下载源
|
||||
button.clear=清除
|
||||
button.copy_and_exit=复制并退出
|
||||
button.delete=删除
|
||||
button.do_not_show_again=不再显示
|
||||
button.edit=修改
|
||||
button.install=安装
|
||||
button.export=导出
|
||||
@ -1282,6 +1283,9 @@ version.search.prompt=输入版本名称进行搜索
|
||||
version.settings=游戏设置
|
||||
version.update=更新整合包
|
||||
|
||||
warning.java_interpreted_mode=HMCL 正在运行在解释器模式的 Java 环境中,性能将会受到很大影响。\n我们建议你使用支持 JIT 的 Java 启动 HMCL 以获取最佳体验。
|
||||
warning.software_rendering=HMCL 正在使用软件渲染,性能将会受到很大影响。\n你可以访问 https://docs.hmcl.net/help.html 页面寻求帮助。
|
||||
|
||||
wiki.tooltip=Minecraft Wiki 页面
|
||||
wiki.version.game=https://zh.minecraft.wiki/w/Java版%s
|
||||
wiki.version.game.snapshot=https://zh.minecraft.wiki/w/%s
|
||||
|
@ -130,6 +130,7 @@ public final class JavaRuntime implements Comparable<JavaRuntime> {
|
||||
|
||||
public static final JavaRuntime CURRENT_JAVA;
|
||||
public static final int CURRENT_VERSION;
|
||||
public static final boolean CURRENT_JIT_ENABLED;
|
||||
|
||||
public static JavaRuntime getDefault() {
|
||||
return CURRENT_JAVA;
|
||||
@ -152,5 +153,9 @@ public final class JavaRuntime implements Comparable<JavaRuntime> {
|
||||
|
||||
CURRENT_JAVA = executable != null ? JavaRuntime.of(executable, JavaInfo.CURRENT_ENVIRONMENT, false) : null;
|
||||
CURRENT_VERSION = JavaInfo.CURRENT_ENVIRONMENT.getParsedVersion();
|
||||
|
||||
String vmInfo = System.getProperty("java.vm.info", "");
|
||||
CURRENT_JIT_ENABLED = !vmInfo.contains("interpreted mode") // HotSpot
|
||||
&& !vmInfo.contains("JIT disabled"); // J9
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
</module>
|
||||
|
||||
<module name="FileLength"><!-- max line length for single file: http://checkstyle.sourceforge.net/config_sizes.html#FileLength -->
|
||||
<property name="max" value="1500"/>
|
||||
<property name="max" value="2000"/>
|
||||
</module>
|
||||
|
||||
<module name="TreeWalker">
|
||||
|
Loading…
x
Reference in New Issue
Block a user