2020-11-23 16:16:26 +00:00
|
|
|
import {GetterTree} from "vuex";
|
|
|
|
import {State} from "@/store/state";
|
2020-12-10 02:22:29 +00:00
|
|
|
import Util from "@/util";
|
2020-11-23 16:16:26 +00:00
|
|
|
|
|
|
|
export type Getters = {
|
2020-11-24 01:56:03 +00:00
|
|
|
playerMarkersEnabled(state: State): boolean;
|
2020-12-01 23:20:38 +00:00
|
|
|
coordinatesControlEnabled(state: State): boolean;
|
|
|
|
clockControlEnabled(state: State): boolean;
|
2020-12-10 02:22:29 +00:00
|
|
|
night(state: State): boolean;
|
2020-12-11 15:29:20 +00:00
|
|
|
mapBackground(state: State, getters: GetterTree<State, State> & Getters): string;
|
2020-12-13 02:50:17 +00:00
|
|
|
url(state: State, getters: GetterTree<State, State> & Getters): string;
|
2020-11-23 16:16:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const getters: GetterTree<State, State> & Getters = {
|
2020-11-24 01:56:03 +00:00
|
|
|
playerMarkersEnabled(state: State): boolean {
|
|
|
|
return state.components.playerMarkers !== undefined;
|
2020-12-01 23:20:38 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
coordinatesControlEnabled(state: State): boolean {
|
|
|
|
return state.components.coordinatesControl !== undefined;
|
|
|
|
},
|
|
|
|
|
|
|
|
clockControlEnabled(state: State): boolean {
|
|
|
|
return state.components.clockControl !== undefined;
|
2020-12-10 02:22:29 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
night(state: State): boolean {
|
|
|
|
return Util.getMinecraftTime(state.currentWorldState.timeOfDay).night;
|
|
|
|
},
|
|
|
|
|
|
|
|
mapBackground(state: State): string {
|
|
|
|
if(!state.currentMap) {
|
|
|
|
return 'transparent';
|
|
|
|
}
|
|
|
|
|
|
|
|
if(state.currentMap.nightAndDay) {
|
2020-12-11 15:29:20 +00:00
|
|
|
if(Util.getMinecraftTime(state.currentWorldState.timeOfDay).night) {
|
2020-12-10 02:22:29 +00:00
|
|
|
return state.currentMap.backgroundNight || state.currentMap.background || 'transparent';
|
|
|
|
}
|
|
|
|
|
|
|
|
return state.currentMap.backgroundDay || state.currentMap.background || 'transparent';
|
|
|
|
}
|
|
|
|
|
|
|
|
return state.currentMap.background || 'transparent';
|
2020-12-13 02:50:17 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
url(state: State): string {
|
|
|
|
const x = Math.round(state.currentLocation.x),
|
|
|
|
y = Math.round(state.currentLocation.y),
|
|
|
|
z = Math.round(state.currentLocation.z),
|
|
|
|
locationString = `${x},${y},${z}`,
|
|
|
|
zoom = state.currentZoom;
|
|
|
|
|
|
|
|
if(!state.currentWorld || !state.currentMap) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
return `#${state.currentWorld.name};${state.currentMap.name};${locationString};${zoom}`;
|
2020-11-24 01:56:03 +00:00
|
|
|
}
|
2020-11-23 16:16:26 +00:00
|
|
|
}
|