Skip to content

Commit

Permalink
MVC: Defaults to GZDoom folder if selected
Browse files Browse the repository at this point in the history
  • Loading branch information
Lemon-King committed Jun 16, 2024
1 parent 6335958 commit e9d337a
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/main/java/lemon/hxdd/gui/MainViewController.java
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,18 @@ public void handle(ActionEvent actionEvent) {
}

protected void BindOpenFolderButton() {
String storedPath = this.mainApp.GetSettings().Get("PATH_GZDOOM");
if (storedPath.equals("")) {
storedPath = "./";
}

String finalStoredPath = storedPath;
btnOpenFolder.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
Desktop desktop = Desktop.getDesktop();
try {
desktop.open(new File("./"));
desktop.open(new File(finalStoredPath));
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down Expand Up @@ -560,11 +566,16 @@ protected File OpenFileDialog(File path, String title, String fileTypeDescriptio
FileChooser.ExtensionFilter ext = new FileChooser.ExtensionFilter(fileTypeDescription, targetExtension);
FileChooser chooser = new FileChooser();

File targetPath;
if (path.exists() && path.isFile()) {
targetPath = new File(path.getParent());
} else {
targetPath = path;
File targetPath = path;
if (path.equals(new File("./")) || path.getPath().equals(new File(""))) {
String storedPath = this.mainApp.GetSettings().Get("PATH_GZDOOM");
if (storedPath.equals("")) {
storedPath = "./";
}
targetPath = new File(storedPath);
}
if (targetPath.exists() && targetPath.isFile()) {
targetPath = new File(targetPath.getParent());
}

chooser.setTitle(title);
Expand Down

0 comments on commit e9d337a

Please sign in to comment.