Merge 79a2e6f977cf651c0f4bff4652d26265c470f9b4 into bd9ae189f83e33a6977bbe056774c851e96fe0a7

This commit is contained in:
Dime 2025-09-21 17:26:58 +08:00 committed by GitHub
commit bceafd56b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -48,6 +48,7 @@ import java.nio.file.Path;
import java.util.Optional; import java.util.Optional;
import static org.jackhuang.hmcl.util.i18n.I18n.i18n; import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
import static org.jackhuang.hmcl.util.logging.Logger.LOG;
public final class ProfilePage extends BorderPane implements DecoratorPage { public final class ProfilePage extends BorderPane implements DecoratorPage {
private final ReadOnlyObjectWrapper<State> state = new ReadOnlyObjectWrapper<>(); private final ReadOnlyObjectWrapper<State> state = new ReadOnlyObjectWrapper<>();
@ -114,6 +115,24 @@ public final class ProfilePage extends BorderPane implements DecoratorPage {
gameDir.setTitle(i18n("profile.instance_directory.choose")); gameDir.setTitle(i18n("profile.instance_directory.choose"));
gameDir.pathProperty().bindBidirectional(location); gameDir.pathProperty().bindBidirectional(location);
locationProperty().addListener((observable, oldValue, newValue) -> {
LOG.debug("OnChange locationProperty");
var folder = new File(newValue);
var oldFolder = new File(oldValue);
File parentFolder = folder.getParentFile();
File parentOldFolder = oldFolder.getParentFile();
// txtProfileName
if (parentFolder != null) {
if (txtProfileName.getText().isEmpty()) {
txtProfileName.setText(parentFolder.getName());
}
else if (!parentFolder.getName().equals(parentOldFolder.getName())) {
txtProfileName.setText(parentFolder.getName());
}
}
});
toggleUseRelativePath = new OptionToggleButton(); toggleUseRelativePath = new OptionToggleButton();
toggleUseRelativePath.setTitle(i18n("profile.use_relative_path")); toggleUseRelativePath.setTitle(i18n("profile.use_relative_path"));