diff --git a/src/components/map/layer/MapLayer.vue b/src/components/map/layer/MapLayer.vue index b6736b6..fa5f6ce 100644 --- a/src/components/map/layer/MapLayer.vue +++ b/src/components/map/layer/MapLayer.vue @@ -22,6 +22,7 @@ import {useStore} from "@/store"; import {HDMapType} from "@/leaflet/mapType/HDMapType"; import {MutationTypes} from "@/store/mutation-types"; import {ActionTypes} from "@/store/action-types"; +import {getMinecraftTime} from "@/util"; export default defineComponent({ props: { @@ -44,9 +45,11 @@ export default defineComponent({ stopUpdateWatch: Function; const store = useStore(), + night = computed(() => getMinecraftTime(store.state.currentWorldState.timeOfDay).night), layer = new HDMapType({ errorTileUrl: 'images/blank.png', mapSettings: Object.freeze(JSON.parse(JSON.stringify(props.map))), + night: night.value, }), pendingUpdates = computed(() => !!store.state.pendingTileUpdates.length), active = computed(() => props.map === store.state.currentMap), @@ -86,6 +89,11 @@ export default defineComponent({ }; watch(active, (newValue) => newValue ? enableLayer() : disableLayer()); + watch(night, (newValue) => { + if(props.map.nightAndDay && active.value) { + layer.setNight(newValue); + } + }); if(active.value) { enableLayer(); diff --git a/src/leaflet/tileLayer/DynmapTileLayer.ts b/src/leaflet/tileLayer/DynmapTileLayer.ts index cca54b5..8da6706 100644 --- a/src/leaflet/tileLayer/DynmapTileLayer.ts +++ b/src/leaflet/tileLayer/DynmapTileLayer.ts @@ -24,6 +24,7 @@ import {Coordinate, DynmapWorldMap} from "@/dynmap"; export interface DynmapTileLayerOptions extends TileLayerOptions { mapSettings: DynmapWorldMap; errorTileUrl: string; + night?: boolean; } export interface DynmapTileLayer extends TileLayer { @@ -245,7 +246,7 @@ export class DynmapTileLayer extends TileLayer { return { prefix: this._mapSettings.prefix, - nightday: /*(this._mapSettings.nightAndDay && this.options.dynmap.serverday) ? '_day' :*/ '', + nightday: (this._mapSettings.nightAndDay && !this.options.night) ? '_day' : '', scaledx: x >> 5, scaledy: y >> 5, zoom: this.zoomprefix(zoomoutlevel), @@ -259,4 +260,11 @@ export class DynmapTileLayer extends TileLayer { getProjection(): DynmapProjection { return this._projection; } + + setNight(night: boolean) { + if(this.options.night !== night) { + this.options.night = night; + this.redraw(); + } + } }