|
18 | 18 | import org.jackhuang.hmcl.ui.construct.*; |
19 | 19 | import org.jackhuang.hmcl.ui.decorator.DecoratorPage; |
20 | 20 | import org.jackhuang.hmcl.util.platform.OperatingSystem; |
| 21 | +import org.jackhuang.hmcl.util.platform.Platform; |
| 22 | +import org.jetbrains.annotations.Nullable; |
21 | 23 |
|
22 | | -import java.nio.file.Paths; |
23 | 24 | import java.util.Arrays; |
24 | 25 | import java.util.Locale; |
25 | 26 |
|
@@ -52,7 +53,7 @@ public final class AdvancedVersionSettingPage extends StackPane implements Decor |
52 | 53 | private final MultiFileItem.FileOption<NativesDirectoryType> nativesDirCustomOption; |
53 | 54 | private final JFXComboBox<Renderer> cboRenderer; |
54 | 55 |
|
55 | | - public AdvancedVersionSettingPage(Profile profile, String versionId, VersionSetting versionSetting) { |
| 56 | + public AdvancedVersionSettingPage(Profile profile, @Nullable String versionId, VersionSetting versionSetting) { |
56 | 57 | this.profile = profile; |
57 | 58 | this.versionId = versionId; |
58 | 59 | this.versionSetting = versionSetting; |
@@ -239,8 +240,27 @@ void bindProperties() { |
239 | 240 | useNativeOpenALPane.selectedProperty().bindBidirectional(versionSetting.useNativeOpenALProperty()); |
240 | 241 |
|
241 | 242 | nativesDirItem.selectedDataProperty().bindBidirectional(versionSetting.nativesDirTypeProperty()); |
242 | | - nativesDirSublist.subtitleProperty().bind(Bindings.createStringBinding(() -> Paths.get(profile.getRepository().getRunDirectory(versionId).getAbsolutePath() + "/natives").normalize().toString(), |
243 | | - versionSetting.nativesDirProperty(), versionSetting.nativesDirTypeProperty())); |
| 243 | + nativesDirSublist.subtitleProperty().bind(Bindings.createStringBinding(() -> { |
| 244 | + if (versionSetting.getNativesDirType() == NativesDirectoryType.VERSION_FOLDER) { |
| 245 | + String nativesDirName = "natives-" + Platform.SYSTEM_PLATFORM; |
| 246 | + if (versionId == null) { |
| 247 | + return String.format("%s/%s/%s", |
| 248 | + profile.getRepository().getBaseDirectory().toPath().resolve("versions").toAbsolutePath().normalize(), |
| 249 | + i18n("settings.advanced.natives_directory.default.version_id"), |
| 250 | + nativesDirName |
| 251 | + ); |
| 252 | + } else { |
| 253 | + return profile.getRepository().getVersionRoot(versionId).toPath() |
| 254 | + .toAbsolutePath().normalize() |
| 255 | + .resolve(nativesDirName) |
| 256 | + .toString(); |
| 257 | + } |
| 258 | + } else if (versionSetting.getNativesDirType() == NativesDirectoryType.CUSTOM) { |
| 259 | + return versionSetting.getNativesDir(); |
| 260 | + } else { |
| 261 | + return null; |
| 262 | + } |
| 263 | + }, versionSetting.nativesDirProperty(), versionSetting.nativesDirTypeProperty())); |
244 | 264 | } |
245 | 265 |
|
246 | 266 | void unbindProperties() { |
|
0 commit comments