All per-map default zoom

This commit is contained in:
James Lyne 2022-02-23 14:31:31 +00:00
parent 61194c9c99
commit c4f2d106bf
3 changed files with 15 additions and 7 deletions

View File

@ -192,12 +192,15 @@ export default defineComponent({
} else if(store.state.parsedUrl?.location) { } else if(store.state.parsedUrl?.location) {
viewTarget.location = store.state.parsedUrl.location; viewTarget.location = store.state.parsedUrl.location;
//Determine initial zoom
if(!oldValue) { if(!oldValue) {
if(typeof store.state.parsedUrl?.zoom !== 'undefined') { if(typeof store.state.parsedUrl?.zoom !== 'undefined') { //Zoom from URL
viewTarget.zoom = store.state.parsedUrl?.zoom; viewTarget.zoom = store.state.parsedUrl?.zoom;
} else if(typeof newValue.defaultZoom !== 'undefined') { } else if(typeof store.state.currentMap?.defaultZoom !== 'undefined') { //Map default zoom
viewTarget.zoom = store.state.currentMap?.defaultZoom;
}else if(typeof newValue.defaultZoom !== 'undefined') { //World default zoom
viewTarget.zoom = newValue.defaultZoom; viewTarget.zoom = newValue.defaultZoom;
} else { } else { //Global default zoom
viewTarget.zoom = store.state.configuration.defaultZoom; viewTarget.zoom = store.state.configuration.defaultZoom;
} }
} }
@ -209,9 +212,11 @@ export default defineComponent({
} }
if(viewTarget.zoom == null) { if(viewTarget.zoom == null) {
if(typeof newValue.defaultZoom !== 'undefined') { if(typeof store.state.currentMap?.defaultZoom !== 'undefined') { //Map default zoom
viewTarget.zoom = store.state.currentMap?.defaultZoom;
} else if(typeof newValue.defaultZoom !== 'undefined') { //World default zoom
viewTarget.zoom = newValue.defaultZoom; viewTarget.zoom = newValue.defaultZoom;
} else { } else { //Global default zoom
viewTarget.zoom = store.state.configuration.defaultZoom; viewTarget.zoom = store.state.configuration.defaultZoom;
} }
} }

View File

@ -34,6 +34,7 @@ export interface LiveAtlasMapDefinitionOptions {
projection?: LiveAtlasProjection; projection?: LiveAtlasProjection;
nativeZoomLevels: number; nativeZoomLevels: number;
extraZoomLevels: number; extraZoomLevels: number;
defaultZoom?: number;
tileUpdateInterval?: number; tileUpdateInterval?: number;
center?: Coordinate; center?: Coordinate;
} }
@ -54,6 +55,7 @@ export default class LiveAtlasMapDefinition {
readonly projection?: LiveAtlasProjection; readonly projection?: LiveAtlasProjection;
readonly nativeZoomLevels: number; readonly nativeZoomLevels: number;
readonly extraZoomLevels: number; readonly extraZoomLevels: number;
readonly defaultZoom?: number;
readonly scale: number; readonly scale: number;
readonly tileUpdateInterval?: number; readonly tileUpdateInterval?: number;
readonly center?: Coordinate; readonly center?: Coordinate;
@ -77,6 +79,7 @@ export default class LiveAtlasMapDefinition {
this.nativeZoomLevels = options.nativeZoomLevels || 1; this.nativeZoomLevels = options.nativeZoomLevels || 1;
this.extraZoomLevels = options.extraZoomLevels || 0; this.extraZoomLevels = options.extraZoomLevels || 0;
this.defaultZoom = options.defaultZoom || 0;
this.scale = (1 / Math.pow(2, this.nativeZoomLevels)); this.scale = (1 / Math.pow(2, this.nativeZoomLevels));
this.tileUpdateInterval = options.tileUpdateInterval || undefined; this.tileUpdateInterval = options.tileUpdateInterval || undefined;
this.center = options.center || undefined; this.center = options.center || undefined;

View File

@ -61,7 +61,7 @@ export default class OverviewerMapProvider extends MapProvider {
//Not used by overviewer //Not used by overviewer
expandUI: false, expandUI: false,
defaultZoom: 1, defaultZoom: 0,
defaultMap: undefined, defaultMap: undefined,
defaultWorld: undefined, defaultWorld: undefined,
followMap: undefined, followMap: undefined,
@ -95,7 +95,6 @@ export default class OverviewerMapProvider extends MapProvider {
dimension: 'overworld' as LiveAtlasDimension, dimension: 'overworld' as LiveAtlasDimension,
seaLevel: 64, seaLevel: 64,
center: {x: 0, y: 64, z: 0}, center: {x: 0, y: 64, z: 0},
defaultZoom: undefined,
maps: new Set<LiveAtlasMapDefinition>(), maps: new Set<LiveAtlasMapDefinition>(),
}); });
}); });
@ -122,6 +121,7 @@ export default class OverviewerMapProvider extends MapProvider {
imageFormat: tileset.imgextension, imageFormat: tileset.imgextension,
nativeZoomLevels, nativeZoomLevels,
extraZoomLevels: 0, extraZoomLevels: 0,
defaultZoom: tileset.defaultZoom,
tileSize, tileSize,
prefix: tileset.base, prefix: tileset.base,
projection: new OverviewerProjection({ projection: new OverviewerProjection({