Skip to content

Commit

Permalink
layer paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Durtur committed Jul 4, 2022
1 parent 8495605 commit ebcbf24
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions app/mappingTool/map.admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,30 +422,36 @@ async function onSettingsLoaded() {

}

function getMapImageFromDialog() {
return window.dialog.showOpenDialogSync({
function getMapImageFromDialog(pathKey) {
var localStoragePath = `default_path_${pathKey}`;
var defaultPath = localStorage.getItem(localStoragePath);
var path = window.dialog.showOpenDialogSync({
properties: ['openFile'],
message: "Choose map",
defaultPath: defaultPath || "",
filters: [{ name: 'Images', extensions: constants.imgFilters }]
})[0].replace(/\\/g, "/");
})[0];
localStorage.setItem(localStoragePath, path);
return path.replace(/\\/g, "/");

}

function getBackgroundFromFile(e) {
var path = getMapImageFromDialog();
var path = getMapImageFromDialog("background");
if (path) {
setMapBackground(path, settings.defaultMapSize);
}
};

function getOverlayFromFile(e) {
var path = getMapImageFromDialog();
var path = getMapImageFromDialog("overlay");
if (path) {
setMapOverlay(path, settings.defaultMapSize);
}
}

function getForegroundFromFile(e) {
var path = getMapImageFromDialog();
var path = getMapImageFromDialog("foreground");
if (path) {
setMapForeground(path, settings.defaultMapSize);
settings.currentMap = path;
Expand Down

0 comments on commit ebcbf24

Please sign in to comment.