diff --git a/src/model/LiveAtlasMapDefinition.ts b/src/model/LiveAtlasMapDefinition.ts index 6197e7e..493c4c4 100644 --- a/src/model/LiveAtlasMapDefinition.ts +++ b/src/model/LiveAtlasMapDefinition.ts @@ -21,20 +21,28 @@ import {ImageFormat} from "dynmap"; export interface LiveAtlasMapDefinitionOptions { world: LiveAtlasWorldDefinition; appendedWorld?: LiveAtlasWorldDefinition; // append_to_world + name: string; displayName?: string; icon?: string; + + baseUrl: string; + tileSize: number; + imageFormat: ImageFormat; + projection?: LiveAtlasProjection; + prefix?: string; + background?: string; nightAndDay?: boolean; backgroundDay?: string; backgroundNight?: string; - imageFormat: ImageFormat; - tileSize: number; - prefix?: string; - projection?: LiveAtlasProjection; + nativeZoomLevels: number; - extraZoomLevels: number; + extraZoomLevels?: number; + minZoom?: number; + maxZoom?: number; defaultZoom?: number; + tileUpdateInterval?: number; center?: Coordinate; } @@ -42,47 +50,62 @@ export interface LiveAtlasMapDefinitionOptions { export default class LiveAtlasMapDefinition { readonly world: LiveAtlasWorldDefinition; readonly appendedWorld?: LiveAtlasWorldDefinition; + readonly name: string; - readonly icon?: string; readonly displayName: string; - readonly background: string; - readonly nightAndDay: boolean; - readonly backgroundDay?: string; - readonly backgroundNight?: string; + readonly icon?: string; + + readonly baseUrl: string; readonly imageFormat: ImageFormat; readonly tileSize: number; - readonly prefix: string; readonly projection?: LiveAtlasProjection; + readonly prefix: string; + + readonly background: string; + readonly nightAndDay: boolean; + readonly backgroundDay: string; + readonly backgroundNight: string; + readonly nativeZoomLevels: number; readonly extraZoomLevels: number; + readonly minZoom: number; + readonly maxZoom?: number; readonly defaultZoom?: number; - readonly scale: number; + readonly tileUpdateInterval?: number; readonly center?: Coordinate; + readonly scale: number; + constructor(options: LiveAtlasMapDefinitionOptions) { this.world = options.world; this.appendedWorld = options.appendedWorld; // append_to_world + this.name = options.name; - this.icon = options.icon || undefined; this.displayName = options.displayName || ''; + this.icon = options.icon || undefined; this.background = options.background || '#000000'; this.nightAndDay = options.nightAndDay || false; this.backgroundDay = options.backgroundDay || '#000000'; this.backgroundNight = options.backgroundNight || '#000000'; + this.baseUrl = options.baseUrl; this.imageFormat = options.imageFormat; this.tileSize = options.tileSize; - this.prefix = options.prefix || ''; this.projection = options.projection || undefined; + this.prefix = options.prefix || ''; this.nativeZoomLevels = options.nativeZoomLevels || 1; this.extraZoomLevels = options.extraZoomLevels || 0; - this.defaultZoom = options.defaultZoom || 0; - this.scale = (1 / Math.pow(2, this.nativeZoomLevels)); + this.minZoom = options.minZoom || 0; + this.maxZoom = options.maxZoom || undefined; + this.defaultZoom = options.defaultZoom || undefined; + this.tileUpdateInterval = options.tileUpdateInterval || undefined; this.center = options.center || undefined; + + this.scale = (1 / Math.pow(2, this.nativeZoomLevels)); } locationToLatLng(location: Coordinate): LatLng { diff --git a/src/providers/DynmapMapProvider.ts b/src/providers/DynmapMapProvider.ts index 340b6e2..4ecc546 100644 --- a/src/providers/DynmapMapProvider.ts +++ b/src/providers/DynmapMapProvider.ts @@ -141,7 +141,7 @@ export default class DynmapMapProvider extends MapProvider { this.store.commit(MutationTypes.SET_SERVER_CONFIGURATION_HASH, response.confighash || 0); this.store.commit(MutationTypes.SET_MAX_PLAYERS, response.maxcount || 0); this.store.commit(MutationTypes.SET_SERVER_MESSAGES, buildMessagesConfig(response)); - this.store.commit(MutationTypes.SET_WORLDS, buildWorlds(response)); + this.store.commit(MutationTypes.SET_WORLDS, buildWorlds(response, this.config)); this.store.commit(MutationTypes.SET_COMPONENTS, buildComponents(response, this.config)); this.store.commit(MutationTypes.SET_LOGGED_IN, response.loggedin || false); } diff --git a/src/providers/OverviewerMapProvider.ts b/src/providers/OverviewerMapProvider.ts index 67651e6..bd815f5 100644 --- a/src/providers/OverviewerMapProvider.ts +++ b/src/providers/OverviewerMapProvider.ts @@ -115,15 +115,12 @@ export default class OverviewerMapProvider extends MapProvider { world.maps.add(new LiveAtlasMapDefinition({ world, + name: tileset.path, displayName: tileset.name || tileset.path, - background: tileset.bgcolor, - imageFormat: tileset.imgextension, - nativeZoomLevels, - extraZoomLevels: 0, - defaultZoom: tileset.defaultZoom, + + baseUrl: this.config, tileSize, - prefix: tileset.base, projection: new OverviewerProjection({ upperRight: serverResponse.CONST.UPPERRIGHT, lowerLeft: serverResponse.CONST.LOWERLEFT, @@ -132,9 +129,19 @@ export default class OverviewerMapProvider extends MapProvider { nativeZoomLevels, tileSize, }), + prefix: tileset.base, + + background: tileset.bgcolor, + imageFormat: tileset.imgextension, + + nativeZoomLevels, + minZoom: tileset.minZoom, + maxZoom: tileset.maxZoom, + defaultZoom: tileset.defaultZoom, + center: { x: tileset?.center[0] || 0, - y: tileset?.center[1] || 0, + y: tileset?.center[1] || 64, z: tileset?.center[2] || 0, } })); diff --git a/src/providers/Pl3xmapMapProvider.ts b/src/providers/Pl3xmapMapProvider.ts index 76b813d..ccaa520 100644 --- a/src/providers/Pl3xmapMapProvider.ts +++ b/src/providers/Pl3xmapMapProvider.ts @@ -183,17 +183,20 @@ export default class Pl3xmapMapProvider extends MapProvider { maps.add(Object.freeze(new LiveAtlasMapDefinition({ world: w, + name: 'flat', + displayName: 'Flat', + icon: world.icon ? `${this.config}images/icon/${world.icon}.png` : undefined, + + baseUrl: `${this.config}tiles/`, + imageFormat: 'png', + tileSize: 512, + background: 'transparent', backgroundDay: 'transparent', backgroundNight: 'transparent', - icon: world.icon ? `${this.config}images/icon/${world.icon}.png` : undefined, - imageFormat: 'png', - tileSize: 512, - name: 'flat', - displayName: 'Flat', nativeZoomLevels: worldResponse.zoom.max || 1, - extraZoomLevels: worldResponse.zoom.extra || 0, + extraZoomLevels: worldResponse.zoom.extra, tileUpdateInterval: worldResponse.tiles_update_interval ? worldResponse.tiles_update_interval * 1000 : undefined, }))); diff --git a/src/util/dynmap.ts b/src/util/dynmap.ts index 81730a7..b44bc4c 100644 --- a/src/util/dynmap.ts +++ b/src/util/dynmap.ts @@ -91,7 +91,7 @@ export function buildMessagesConfig(response: Options): LiveAtlasServerMessageCo } } -export function buildWorlds(response: Configuration): Array { +export function buildWorlds(response: Configuration, config: DynmapUrlConfig): Array { const worlds: Map = new Map(); //Get all the worlds first so we can handle append_to_world properly @@ -138,24 +138,29 @@ export function buildWorlds(response: Configuration): Array