From e2af667e5e81ffdb3fec4e7278a87a5d746926fc Mon Sep 17 00:00:00 2001 From: "Lukas Rieger (Blue)" Date: Mon, 6 Jun 2022 22:50:19 +0200 Subject: [PATCH] Update to new settings.json-s --- BlueMapWeb | 2 +- src/components/Menu/SettingsMenu.vue | 13 ++++++-- src/js/BlueMapApp.js | 48 +++++++++++++++++----------- 3 files changed, 42 insertions(+), 21 deletions(-) diff --git a/BlueMapWeb b/BlueMapWeb index a0f5548..889d3cf 160000 --- a/BlueMapWeb +++ b/BlueMapWeb @@ -1 +1 @@ -Subproject commit a0f5548293f0e22e9fe2ec57207cde754d60b24f +Subproject commit 889d3cf94ce760a4c202735c7060df0744346d54 diff --git a/src/components/Menu/SettingsMenu.vue b/src/components/Menu/SettingsMenu.vue index dd7ecae..ea43d19 100644 --- a/src/components/Menu/SettingsMenu.vue +++ b/src/components/Menu/SettingsMenu.vue @@ -21,9 +21,9 @@ - {{ $t("renderDistance.hiresLayer") }} - {{ $t("renderDistance.lowersLayer") }} @@ -79,6 +79,15 @@ name: "SettingsMenu", return { appState: this.$bluemap.appState, mapViewer: this.$bluemap.mapViewer.data, + settings: { + ...{ + hiresSliderMax: 500, + hiresSliderMin: 50, + lowresSliderMax: 10000, + lowresSliderMin: 500 + }, + ...this.$bluemap.settings + }, qualityStages: qualityStages, themes: themes, diff --git a/src/js/BlueMapApp.js b/src/js/BlueMapApp.js index a712f7e..efc4a60 100644 --- a/src/js/BlueMapApp.js +++ b/src/js/BlueMapApp.js @@ -55,7 +55,20 @@ export class BlueMapApp { /** @type {MarkerFileManager} */ this.markerFileManager = null; - /** @type {{useCookies: boolean, freeFlightEnabled: boolean, maps: []}} */ + /** @type {{ + * useCookies: boolean, + * freeFlightEnabled: boolean, + * resolutionDefault: number, + * hiresSliderMax: number, + * hiresSliderDefault: number, + * hiresSliderMin: number, + * lowresSliderMax: number, + * lowresSliderDefault: number, + * lowresSliderMin: number, + * startLocation: string, + * maps: string[] + * }} + **/ this.settings = null; this.savedUserSettings = new Map(); @@ -116,7 +129,7 @@ export class BlueMapApp { oldMaps.forEach(map => map.dispose()); // load maps - this.maps = this.loadMaps(); + this.maps = await this.loadMaps(); for (let map of this.maps) { this.mapsMap.set(map.data.id, map); this.appState.maps.push(map.data); @@ -220,33 +233,28 @@ export class BlueMapApp { } /** - * @returns BlueMapMap[] + * @returns Promise */ - loadMaps() { + async loadMaps() { let settings = this.settings; let maps = []; // create maps if (settings.maps !== undefined){ - for (let mapId in settings.maps) { - if (!Object.prototype.hasOwnProperty.call(settings.maps, mapId)) continue; + for (let mapId of settings.maps) { + let map = new BlueMapMap(mapId, this.dataUrl + mapId + "/", this.mapViewer.events); + maps.push(map); - let mapSettings = settings.maps[mapId]; - if (mapSettings.enabled) { - let map = new BlueMapMap(mapId, this.dataUrl + mapId + "/", this.dataUrl + "settings.json", this.dataUrl + mapId + "/textures.json", this.mapViewer.events); - maps.push(map); - - map.loadSettings() - .catch(error => { - alert(this.events, `Failed to load settings for map '${map.data.id}':` + error, "warning"); - }); - } + await map.loadSettings() + .catch(error => { + alert(this.events, `Failed to load settings for map '${map.data.id}':` + error, "warning"); + }); } } // sort maps maps.sort((map1, map2) => { - let sort = settings.maps[map1.data.id].ordinal - settings.maps[map2.data.id].ordinal; + let sort = map1.data.sorting - map2.data.sorting; if (isNaN(sort)) return 0; return sort; }); @@ -487,6 +495,10 @@ export class BlueMapApp { } async loadUserSettings(){ + if (!isNaN(this.settings.resolutionDefault)) this.mapViewer.data.superSampling = this.settings.resolutionDefault; + if (!isNaN(this.settings.hiresSliderDefault)) this.mapViewer.data.loadedHiresViewDistance = this.settings.hiresSliderDefault; + if (!isNaN(this.settings.lowresSliderDefault)) this.mapViewer.data.loadedLowresViewDistance = this.settings.lowresSliderDefault; + if (!this.settings.useCookies) return; if (this.loadUserSetting("resetSettings", false)) { @@ -574,7 +586,7 @@ export class BlueMapApp { } loadPageAddress = async () => { - let hash = window.location.hash.substr(1); + let hash = window.location.hash.substring(1) || this.settings.startLocation; let values = hash.split(":"); if (values.length !== 10) return false;