Skip to content

Commit

Permalink
Backport map export fix to 1.14
Browse files Browse the repository at this point in the history
  • Loading branch information
Jmr3366 authored and kwvanderlinde committed Nov 3, 2023
1 parent 149696d commit c01880c
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions src/main/java/net/rptools/maptool/client/AppActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -2848,27 +2848,28 @@ protected void executeAction() {
chooser.setSelectedFile(new File(zr.getZone().getName()));
boolean tryAgain = true;
while (tryAgain) {
if (chooser.showSaveDialog(MapTool.getFrame()) == JFileChooser.APPROVE_OPTION) {
File mapFile = chooser.getSelectedFile();
var installDir = AppUtil.getInstallDirectory().toAbsolutePath();
var saveDir = chooser.getSelectedFile().toPath().getParent().toAbsolutePath();
if (saveDir.startsWith(installDir)) {
MapTool.showWarning("msg.warning.saveMapToInstallDir");
} else {
tryAgain = false;
try {
mapFile = getFileWithExtension(mapFile, AppConstants.MAP_FILE_EXTENSION);
if (mapFile.exists()) {
if (!MapTool.confirm("msg.confirm.fileExists")) {
return;
}
if (chooser.showSaveDialog(MapTool.getFrame()) != JFileChooser.APPROVE_OPTION) {
break;
}
File mapFile = chooser.getSelectedFile();
var installDir = AppUtil.getInstallDirectory().toAbsolutePath();
var saveDir = chooser.getSelectedFile().toPath().getParent().toAbsolutePath();
if (saveDir.startsWith(installDir)) {
MapTool.showWarning("msg.warning.saveMapToInstallDir");
} else {
tryAgain = false;
try {
mapFile = getFileWithExtension(mapFile, AppConstants.MAP_FILE_EXTENSION);
if (mapFile.exists()) {
if (!MapTool.confirm("msg.confirm.fileExists")) {
return;
}
PersistenceUtil.saveMap(zr.getZone(), mapFile);
AppPreferences.setSaveMapDir(mapFile.getParentFile());
MapTool.showInformation("msg.info.mapSaved");
} catch (IOException ioe) {
MapTool.showError("msg.error.failedSaveMap", ioe);
}
PersistenceUtil.saveMap(zr.getZone(), mapFile);
AppPreferences.setSaveMapDir(mapFile.getParentFile());
MapTool.showInformation("msg.info.mapSaved");
} catch (IOException ioe) {
MapTool.showError("msg.error.failedSaveMap", ioe);
}
}
}
Expand Down

0 comments on commit c01880c

Please sign in to comment.