From 9d5f8a9f0e05e1e08f220a49ae3db771b9de66b3 Mon Sep 17 00:00:00 2001 From: Glavo Date: Thu, 11 Sep 2025 00:15:13 +0800 Subject: [PATCH] =?UTF-8?q?[release/3.6]=20=E4=BF=AE=E5=A4=8D=20LWJGL=20?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E6=98=BE=E7=A4=BA=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#4447)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/HMCL-dev/HMCL/pull/4192 Co-authored-by: 辞庐 <109708109+CiiLu@users.noreply.github.com> --- .../versions/AdvancedVersionSettingPage.java | 28 ++++++++++++++++--- .../resources/assets/lang/I18N.properties | 1 + .../resources/assets/lang/I18N_zh.properties | 1 + .../assets/lang/I18N_zh_CN.properties | 1 + 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/AdvancedVersionSettingPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/AdvancedVersionSettingPage.java index 1acaf3c9b..c47cb30df 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/AdvancedVersionSettingPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/AdvancedVersionSettingPage.java @@ -18,8 +18,9 @@ import org.jackhuang.hmcl.ui.FXUtils; import org.jackhuang.hmcl.ui.construct.*; import org.jackhuang.hmcl.ui.decorator.DecoratorPage; import org.jackhuang.hmcl.util.platform.OperatingSystem; +import org.jackhuang.hmcl.util.platform.Platform; +import org.jetbrains.annotations.Nullable; -import java.nio.file.Paths; import java.util.Arrays; import java.util.Locale; @@ -52,7 +53,7 @@ public final class AdvancedVersionSettingPage extends StackPane implements Decor private final MultiFileItem.FileOption nativesDirCustomOption; private final JFXComboBox cboRenderer; - public AdvancedVersionSettingPage(Profile profile, String versionId, VersionSetting versionSetting) { + public AdvancedVersionSettingPage(Profile profile, @Nullable String versionId, VersionSetting versionSetting) { this.profile = profile; this.versionId = versionId; this.versionSetting = versionSetting; @@ -239,8 +240,27 @@ public final class AdvancedVersionSettingPage extends StackPane implements Decor useNativeOpenALPane.selectedProperty().bindBidirectional(versionSetting.useNativeOpenALProperty()); nativesDirItem.selectedDataProperty().bindBidirectional(versionSetting.nativesDirTypeProperty()); - nativesDirSublist.subtitleProperty().bind(Bindings.createStringBinding(() -> Paths.get(profile.getRepository().getRunDirectory(versionId).getAbsolutePath() + "/natives").normalize().toString(), - versionSetting.nativesDirProperty(), versionSetting.nativesDirTypeProperty())); + nativesDirSublist.subtitleProperty().bind(Bindings.createStringBinding(() -> { + if (versionSetting.getNativesDirType() == NativesDirectoryType.VERSION_FOLDER) { + String nativesDirName = "natives-" + Platform.SYSTEM_PLATFORM; + if (versionId == null) { + return String.format("%s/%s/%s", + profile.getRepository().getBaseDirectory().toPath().resolve("versions").toAbsolutePath().normalize(), + i18n("settings.advanced.natives_directory.default.version_id"), + nativesDirName + ); + } else { + return profile.getRepository().getVersionRoot(versionId).toPath() + .toAbsolutePath().normalize() + .resolve(nativesDirName) + .toString(); + } + } else if (versionSetting.getNativesDirType() == NativesDirectoryType.CUSTOM) { + return versionSetting.getNativesDir(); + } else { + return null; + } + }, versionSetting.nativesDirProperty(), versionSetting.nativesDirTypeProperty())); } void unbindProperties() { diff --git a/HMCL/src/main/resources/assets/lang/I18N.properties b/HMCL/src/main/resources/assets/lang/I18N.properties index bc31ada0c..d45ec740b 100644 --- a/HMCL/src/main/resources/assets/lang/I18N.properties +++ b/HMCL/src/main/resources/assets/lang/I18N.properties @@ -1269,6 +1269,7 @@ settings.advanced.natives_directory=Native Library Path settings.advanced.natives_directory.choose=Choose the location of the desired native library settings.advanced.natives_directory.custom=Custom settings.advanced.natives_directory.default=Default +settings.advanced.natives_directory.default.version_id= settings.advanced.natives_directory.hint=This option is intended only for users of Apple silicon or other not officially supported platforms. Please do not edit this option unless you know what you are doing.\n\ \n\ Before proceeding, please make sure all libraries (e.g. lwjgl.dll, libopenal.so) are provided in your desired directory.\n\ diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh.properties b/HMCL/src/main/resources/assets/lang/I18N_zh.properties index 41627fa6d..9b5001c00 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh.properties @@ -1064,6 +1064,7 @@ settings.advanced.natives_directory=本機庫路徑 (LWJGL) settings.advanced.natives_directory.choose=選取本機庫路徑 settings.advanced.natives_directory.custom=自訂 (由你提供遊戲需要的本機庫) settings.advanced.natives_directory.default=預設 (由啟動器提供遊戲本機庫) +settings.advanced.natives_directory.default.version_id=<版本 ID> settings.advanced.natives_directory.hint=本選項提供給 Apple Silicon 等未受遊戲官方支援的平台來自訂遊戲本機庫。如果你不知道本選項的含義,請你不要修改本選項,否則會導致遊戲無法啟動。\n\n如果你要修改本選項,你需要保證自訂目錄下有遊戲所需的本機庫檔案,如 lwjgl.dll (liblwjgl.so), openal.dll (libopenal.so) 等檔案。啟動器不會幫你補全缺少的本機庫檔案。\n\n注意:建議指定的本機庫檔案路徑使用全英文字元,否則可能導致遊戲啟動失敗。 settings.advanced.no_jvm_args=不新增預設的 Java 虛擬機參數 settings.advanced.precall_command=遊戲啟動前執行指令 diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties index 81dd6554d..ceb63e736 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties @@ -1074,6 +1074,7 @@ settings.advanced.natives_directory=本地库路径 (LWJGL) settings.advanced.natives_directory.choose=选择本地库路径 settings.advanced.natives_directory.custom=自定义 (由你提供游戏需要的本地库) settings.advanced.natives_directory.default=默认 (由启动器提供游戏本地库) +settings.advanced.natives_directory.default.version_id=<版本 ID> settings.advanced.natives_directory.hint=本选项提供给 Apple Silicon 等未受游戏官方支持的平台来自定义游戏本地库。如果你不知道本选项的含义,请不要修改本选项,否则会导致游戏无法启动!\n\n如果你要修改本选项,你需要保证自定义文件夹下有游戏所需的本地库文件,如 lwjgl.dll (liblwjgl.so)、openal.dll (libopenal.so) 等文件。启动器不会帮你补全缺少的本地库文件!\n\n注意:指定的本地库文件路径建议只包含英文大小写字母、数字和下划线,否则可能会导致启动游戏失败。 settings.advanced.no_jvm_args=不添加默认的 Java 虚拟机参数 settings.advanced.precall_command=游戏启动前执行命令