Fix day/night maps. Fixes #9
This commit is contained in:
parent
7a73b3846d
commit
58ad360f84
@ -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();
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user