Overviewer overlay layers
This commit is contained in:
parent
80bb800e04
commit
a15e9d4b77
@ -24,7 +24,7 @@ import {
|
|||||||
LiveAtlasMarker,
|
LiveAtlasMarker,
|
||||||
LiveAtlasMarkerSet, LiveAtlasPointMarker,
|
LiveAtlasMarkerSet, LiveAtlasPointMarker,
|
||||||
LiveAtlasServerConfig,
|
LiveAtlasServerConfig,
|
||||||
LiveAtlasServerMessageConfig,
|
LiveAtlasServerMessageConfig, LiveAtlasTileLayerOverlay,
|
||||||
LiveAtlasWorldDefinition
|
LiveAtlasWorldDefinition
|
||||||
} from "@/index";
|
} from "@/index";
|
||||||
import {MutationTypes} from "@/store/mutation-types";
|
import {MutationTypes} from "@/store/mutation-types";
|
||||||
@ -87,7 +87,8 @@ export default class OverviewerMapProvider extends MapProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private buildWorlds(serverResponse: any): Array<LiveAtlasWorldDefinition> {
|
private buildWorlds(serverResponse: any): Array<LiveAtlasWorldDefinition> {
|
||||||
const worlds: Map<string, LiveAtlasWorldDefinition> = new Map<string, LiveAtlasWorldDefinition>();
|
const tileSize = serverResponse.CONST.tileSize,
|
||||||
|
worlds: Map<string, LiveAtlasWorldDefinition> = new Map<string, LiveAtlasWorldDefinition>();
|
||||||
|
|
||||||
(serverResponse.worlds || []).forEach((world: string) => {
|
(serverResponse.worlds || []).forEach((world: string) => {
|
||||||
worlds.set(world, {
|
worlds.set(world, {
|
||||||
@ -106,21 +107,26 @@ export default class OverviewerMapProvider extends MapProvider {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tileset?.isOverlay) {
|
const world = worlds.get(tileset.world) as LiveAtlasWorldDefinition,
|
||||||
|
baseUrl = `${this.config}${tileset.base}/${tileset.path}`,
|
||||||
|
prefix = tileset.base,
|
||||||
|
imageFormat = tileset.imgextension,
|
||||||
|
nativeZoomLevels = tileset.zoomLevels,
|
||||||
|
minZoom = tileset.minZoom,
|
||||||
|
maxZoom = tileset.maxZoom;
|
||||||
|
|
||||||
|
//Ignore overlays until all map definitions have been created
|
||||||
|
if(tileset.isOverlay) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const world = worlds.get(tileset.world) as LiveAtlasWorldDefinition,
|
|
||||||
nativeZoomLevels = tileset.zoomLevels,
|
|
||||||
tileSize = serverResponse.CONST.tileSize;
|
|
||||||
|
|
||||||
world.maps.add(new LiveAtlasMapDefinition({
|
world.maps.add(new LiveAtlasMapDefinition({
|
||||||
world,
|
world,
|
||||||
|
|
||||||
name: tileset.path,
|
name: tileset.path,
|
||||||
displayName: tileset.name || tileset.path,
|
displayName: tileset.name || tileset.path,
|
||||||
|
|
||||||
baseUrl: `${this.config}${tileset.base}/${tileset.path}`,
|
baseUrl,
|
||||||
tileSize,
|
tileSize,
|
||||||
projection: new OverviewerProjection({
|
projection: new OverviewerProjection({
|
||||||
upperRight: serverResponse.CONST.UPPERRIGHT,
|
upperRight: serverResponse.CONST.UPPERRIGHT,
|
||||||
@ -130,21 +136,23 @@ export default class OverviewerMapProvider extends MapProvider {
|
|||||||
nativeZoomLevels,
|
nativeZoomLevels,
|
||||||
tileSize,
|
tileSize,
|
||||||
}),
|
}),
|
||||||
prefix: tileset.base,
|
prefix,
|
||||||
|
|
||||||
background: tileset.bgcolor,
|
background: tileset.bgcolor,
|
||||||
imageFormat: tileset.imgextension,
|
imageFormat,
|
||||||
|
|
||||||
nativeZoomLevels,
|
nativeZoomLevels,
|
||||||
minZoom: tileset.minZoom,
|
minZoom,
|
||||||
maxZoom: tileset.maxZoom,
|
maxZoom,
|
||||||
defaultZoom: tileset.defaultZoom,
|
defaultZoom: tileset.defaultZoom,
|
||||||
|
|
||||||
center: {
|
center: {
|
||||||
x: tileset?.center[0] || 0,
|
x: tileset?.center[0] || 0,
|
||||||
y: tileset?.center[1] || 64,
|
y: tileset?.center[1] || 64,
|
||||||
z: tileset?.center[2] || 0,
|
z: tileset?.center[2] || 0,
|
||||||
}
|
},
|
||||||
|
|
||||||
|
overlays: new Map(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
//Spawn marker
|
//Spawn marker
|
||||||
@ -169,9 +177,9 @@ export default class OverviewerMapProvider extends MapProvider {
|
|||||||
iconAnchor: [15, 33],
|
iconAnchor: [15, 33],
|
||||||
tooltip: 'Spawn',
|
tooltip: 'Spawn',
|
||||||
location: {
|
location: {
|
||||||
x: tileset.spawn[0],
|
x: tileset.spawn[0] || 0,
|
||||||
y: tileset.spawn[1],
|
y: tileset.spawn[1] || 64,
|
||||||
z: tileset.spawn[2],
|
z: tileset.spawn[2] || 0,
|
||||||
}
|
}
|
||||||
} as LiveAtlasPointMarker);
|
} as LiveAtlasPointMarker);
|
||||||
|
|
||||||
@ -183,6 +191,38 @@ export default class OverviewerMapProvider extends MapProvider {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Loop over tilesets again to handle overlays and add them to relevant maps
|
||||||
|
(serverResponse.tilesets || []).forEach((tileset: any) => {
|
||||||
|
if(!tileset.isOverlay) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const overlay: LiveAtlasTileLayerOverlay = {
|
||||||
|
id: tileset.path,
|
||||||
|
label: tileset.name || tileset.path,
|
||||||
|
hidden: true,
|
||||||
|
priority: 0,
|
||||||
|
tileLayerOptions: {
|
||||||
|
baseUrl: `${this.config}${tileset.base}/${tileset.path}`,
|
||||||
|
tileSize,
|
||||||
|
prefix: tileset.base,
|
||||||
|
imageFormat: tileset.imgextension,
|
||||||
|
nativeZoomLevels: tileset.zoomLevels,
|
||||||
|
minZoom: tileset.minZoom,
|
||||||
|
maxZoom: tileset.maxZoom,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//Add to listed maps, or all maps in defined world if no maps are listed
|
||||||
|
(worlds.get(tileset.world)?.maps || []).forEach(map => {
|
||||||
|
if(!tileset?.tilesets?.length || tileset.tilesets.includes(map.name)) {
|
||||||
|
map.overlays.set(tileset.path, overlay);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
|
||||||
return Array.from(worlds.values());
|
return Array.from(worlds.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user