Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions HMCL/src/main/java/org/jackhuang/hmcl/ui/profile/ProfilePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import java.util.Optional;

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 {
private final ReadOnlyObjectWrapper<State> state = new ReadOnlyObjectWrapper<>();
Expand Down Expand Up @@ -113,6 +114,24 @@ protected void eval() {
gameDir.setTitle(i18n("profile.instance_directory.choose"));
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.setTitle(i18n("profile.use_relative_path"));

Expand Down