Merge playerMarkers and playerList components in store state
- Merged playerMarkers and playerList into players - playerMarkers is now players.markers - Moved grayHiddenPlayers outside of players.markers, as it doesn't apply to markers
This commit is contained in:
parent
9bb797f23a
commit
0b6bf8d206
@ -93,7 +93,7 @@ export default defineComponent({
|
|||||||
messageMarkers = computed(() => store.state.messages.markersHeading),
|
messageMarkers = computed(() => store.state.messages.markersHeading),
|
||||||
messagePlayers = computed(() => store.getters.playersHeading),
|
messagePlayers = computed(() => store.getters.playersHeading),
|
||||||
|
|
||||||
playerMakersEnabled = computed(() => !!store.state.components.playerMarkers),
|
playerMakersEnabled = computed(() => store.getters.playerMarkersEnabled),
|
||||||
|
|
||||||
playersVisible = computed(() => currentlyVisible.value.has('players')),
|
playersVisible = computed(() => currentlyVisible.value.has('players')),
|
||||||
mapsVisible = computed(() => currentlyVisible.value.has('maps')),
|
mapsVisible = computed(() => currentlyVisible.value.has('maps')),
|
||||||
|
@ -43,11 +43,11 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
const store = useStore(),
|
const store = useStore(),
|
||||||
imagesEnabled = computed(() => store.state.components.playerList.showImages),
|
imagesEnabled = computed(() => store.state.components.players.showImages),
|
||||||
image = ref(defaultImage),
|
image = ref(defaultImage),
|
||||||
|
|
||||||
otherWorld = computed(() => {
|
otherWorld = computed(() => {
|
||||||
return store.state.components.playerMarkers?.grayHiddenPlayers
|
return store.state.components.players.grayHiddenPlayers
|
||||||
&& !props.player.hidden
|
&& !props.player.hidden
|
||||||
&& (!store.state.currentWorld || store.state.currentWorld.name !== props.player.location.world);
|
&& (!store.state.currentWorld || store.state.currentWorld.name !== props.player.location.world);
|
||||||
}),
|
}),
|
||||||
|
@ -43,7 +43,7 @@ export default defineComponent({
|
|||||||
players = computed(() => store.state.players),
|
players = computed(() => store.state.players),
|
||||||
playerCount = computed(() => store.state.players.size),
|
playerCount = computed(() => store.state.players.size),
|
||||||
playersAboveMarkers = computed(() => store.state.ui.playersAboveMarkers),
|
playersAboveMarkers = computed(() => store.state.ui.playersAboveMarkers),
|
||||||
componentSettings = computed(() => store.state.components.playerMarkers),
|
componentSettings = computed(() => store.state.components.players.markers),
|
||||||
layerGroup = new LayerGroup([],{
|
layerGroup = new LayerGroup([],{
|
||||||
pane: 'players'
|
pane: 'players'
|
||||||
});
|
});
|
||||||
@ -55,12 +55,12 @@ export default defineComponent({
|
|||||||
props.leaflet.getLayerManager().addLayer(
|
props.leaflet.getLayerManager().addLayer(
|
||||||
layerGroup,
|
layerGroup,
|
||||||
true,
|
true,
|
||||||
store.state.components.playerMarkers!.layerName,
|
store.state.components.players.markers!.layerName,
|
||||||
componentSettings.value!.layerPriority);
|
componentSettings.value!.layerPriority);
|
||||||
} else {
|
} else {
|
||||||
props.leaflet.getLayerManager().addHiddenLayer(
|
props.leaflet.getLayerManager().addHiddenLayer(
|
||||||
layerGroup,
|
layerGroup,
|
||||||
store.state.components.playerMarkers!.layerName,
|
store.state.components.players.markers!.layerName,
|
||||||
componentSettings.value!.layerPriority);
|
componentSettings.value!.layerPriority);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -38,7 +38,7 @@ export default defineComponent({
|
|||||||
let chatBalloonCutoff = 0; //Not reactive to avoid unnecessary playerChat recalculations
|
let chatBalloonCutoff = 0; //Not reactive to avoid unnecessary playerChat recalculations
|
||||||
|
|
||||||
const store = useStore(),
|
const store = useStore(),
|
||||||
componentSettings = computed(() => store.state.components.playerMarkers),
|
componentSettings = computed(() => store.state.components.players.markers),
|
||||||
currentMap = computed(() => store.state.currentMap),
|
currentMap = computed(() => store.state.currentMap),
|
||||||
currentWorld = computed(() => store.state.currentWorld),
|
currentWorld = computed(() => store.state.currentWorld),
|
||||||
chatBalloonsEnabled = computed(() => store.state.components.chatBalloons),
|
chatBalloonsEnabled = computed(() => store.state.components.chatBalloons),
|
||||||
|
@ -54,7 +54,7 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
const store = useStore(),
|
const store = useStore(),
|
||||||
imagesEnabled = computed(() => store.state.components.playerList.showImages),
|
imagesEnabled = computed(() => store.state.components.players.showImages),
|
||||||
image = ref(defaultImage),
|
image = ref(defaultImage),
|
||||||
account = computed(() => props.target.name),
|
account = computed(() => props.target.name),
|
||||||
|
|
||||||
|
14
src/index.d.ts
vendored
14
src/index.d.ts
vendored
@ -261,10 +261,11 @@ interface LiveAtlasComponentConfig {
|
|||||||
markers: {
|
markers: {
|
||||||
showLabels: boolean;
|
showLabels: boolean;
|
||||||
};
|
};
|
||||||
playerMarkers?: LiveAtlasPlayerMarkerConfig;
|
players: {
|
||||||
playerList: {
|
markers?: LiveAtlasPlayerMarkerConfig;
|
||||||
showImages: boolean;
|
showImages: boolean;
|
||||||
},
|
grayHiddenPlayers: boolean;
|
||||||
|
};
|
||||||
coordinatesControl?: CoordinatesControlOptions;
|
coordinatesControl?: CoordinatesControlOptions;
|
||||||
clockControl?: ClockControlOptions;
|
clockControl?: ClockControlOptions;
|
||||||
linkControl: boolean;
|
linkControl: boolean;
|
||||||
@ -280,7 +281,11 @@ interface LiveAtlasPartialComponentConfig {
|
|||||||
markers?: {
|
markers?: {
|
||||||
showLabels: boolean;
|
showLabels: boolean;
|
||||||
};
|
};
|
||||||
playerMarkers?: LiveAtlasPlayerMarkerConfig;
|
players?: {
|
||||||
|
markers?: LiveAtlasPlayerMarkerConfig;
|
||||||
|
showImages?: boolean;
|
||||||
|
grayHiddenPlayers?: boolean;
|
||||||
|
};
|
||||||
coordinatesControl?: CoordinatesControlOptions;
|
coordinatesControl?: CoordinatesControlOptions;
|
||||||
clockControl?: ClockControlOptions;
|
clockControl?: ClockControlOptions;
|
||||||
linkControl?: boolean;
|
linkControl?: boolean;
|
||||||
@ -293,7 +298,6 @@ interface LiveAtlasPartialComponentConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface LiveAtlasPlayerMarkerConfig {
|
interface LiveAtlasPlayerMarkerConfig {
|
||||||
grayHiddenPlayers: boolean;
|
|
||||||
hideByDefault: boolean;
|
hideByDefault: boolean;
|
||||||
layerName: string;
|
layerName: string;
|
||||||
layerPriority: number;
|
layerPriority: number;
|
||||||
|
@ -118,7 +118,12 @@ export default class Pl3xmapMapProvider extends MapProvider {
|
|||||||
filteredWorlds.forEach((world: any, index: number) => {
|
filteredWorlds.forEach((world: any, index: number) => {
|
||||||
const worldResponse = worldResponses[index],
|
const worldResponse = worldResponses[index],
|
||||||
worldConfig: {components: LiveAtlasPartialComponentConfig } = {
|
worldConfig: {components: LiveAtlasPartialComponentConfig } = {
|
||||||
components: {},
|
components: {
|
||||||
|
players: {
|
||||||
|
markers: undefined,
|
||||||
|
grayHiddenPlayers: true,
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
this.worldMarkerUpdateIntervals.set(world.name, worldResponse.marker_update_interval || 3000);
|
this.worldMarkerUpdateIntervals.set(world.name, worldResponse.marker_update_interval || 3000);
|
||||||
@ -131,8 +136,7 @@ export default class Pl3xmapMapProvider extends MapProvider {
|
|||||||
|
|
||||||
this.worldPlayerUpdateIntervals.set(world.name, updateInterval);
|
this.worldPlayerUpdateIntervals.set(world.name, updateInterval);
|
||||||
|
|
||||||
worldConfig.components.playerMarkers = {
|
worldConfig.components.players!.markers = {
|
||||||
grayHiddenPlayers: true,
|
|
||||||
hideByDefault: !!worldResponse.player_tracker?.default_hidden,
|
hideByDefault: !!worldResponse.player_tracker?.default_hidden,
|
||||||
layerName: worldResponse.player_tracker?.label || '',
|
layerName: worldResponse.player_tracker?.label || '',
|
||||||
layerPriority: worldResponse.player_tracker?.priority,
|
layerPriority: worldResponse.player_tracker?.priority,
|
||||||
@ -141,8 +145,6 @@ export default class Pl3xmapMapProvider extends MapProvider {
|
|||||||
showArmor: armor,
|
showArmor: armor,
|
||||||
showYaw: true,
|
showYaw: true,
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
worldConfig.components.playerMarkers = undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.worldComponents.set(world.name, worldConfig);
|
this.worldComponents.set(world.name, worldConfig);
|
||||||
@ -200,16 +202,18 @@ export default class Pl3xmapMapProvider extends MapProvider {
|
|||||||
linkControl: !!response.ui?.link?.enabled,
|
linkControl: !!response.ui?.link?.enabled,
|
||||||
layerControl: !!response.ui?.coordinates?.enabled,
|
layerControl: !!response.ui?.coordinates?.enabled,
|
||||||
|
|
||||||
//Configured per-world
|
players: {
|
||||||
playerMarkers: undefined,
|
markers: undefined, //Configured per-world
|
||||||
|
|
||||||
|
//Not configurable
|
||||||
|
showImages: true,
|
||||||
|
grayHiddenPlayers: true,
|
||||||
|
},
|
||||||
|
|
||||||
//Not configurable
|
//Not configurable
|
||||||
markers: {
|
markers: {
|
||||||
showLabels: false,
|
showLabels: false,
|
||||||
},
|
},
|
||||||
playerList: {
|
|
||||||
showImages: true,
|
|
||||||
},
|
|
||||||
|
|
||||||
//Not used by pl3xmap
|
//Not used by pl3xmap
|
||||||
chatBox: undefined,
|
chatBox: undefined,
|
||||||
@ -536,7 +540,7 @@ export default class Pl3xmapMapProvider extends MapProvider {
|
|||||||
|
|
||||||
private async updatePlayers() {
|
private async updatePlayers() {
|
||||||
try {
|
try {
|
||||||
if(this.store.state.components.playerMarkers) {
|
if(this.store.getters.playerMarkersEnabled) {
|
||||||
const players = await this.getPlayers();
|
const players = await this.getPlayers();
|
||||||
|
|
||||||
this.playerUpdateTimestamp = new Date();
|
this.playerUpdateTimestamp = new Date();
|
||||||
|
@ -32,7 +32,7 @@ export type Getters = {
|
|||||||
|
|
||||||
export const getters: GetterTree<State, State> & Getters = {
|
export const getters: GetterTree<State, State> & Getters = {
|
||||||
playerMarkersEnabled(state: State): boolean {
|
playerMarkersEnabled(state: State): boolean {
|
||||||
return state.components.playerMarkers !== undefined;
|
return state.components.players.markers !== undefined;
|
||||||
},
|
},
|
||||||
|
|
||||||
coordinatesControlEnabled(state: State): boolean {
|
coordinatesControlEnabled(state: State): boolean {
|
||||||
|
@ -551,7 +551,7 @@ export const mutations: MutationTree<State> & Mutations = {
|
|||||||
state.configuration.title = '';
|
state.configuration.title = '';
|
||||||
|
|
||||||
state.components.markers.showLabels= false;
|
state.components.markers.showLabels= false;
|
||||||
state.components.playerMarkers = undefined;
|
state.components.players.markers = undefined;
|
||||||
state.components.coordinatesControl = undefined;
|
state.components.coordinatesControl = undefined;
|
||||||
state.components.clockControl = undefined;
|
state.components.clockControl = undefined;
|
||||||
state.components.linkControl = false;
|
state.components.linkControl = false;
|
||||||
|
@ -144,11 +144,16 @@ export const state: State = {
|
|||||||
showLabels: false,
|
showLabels: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Optional "playermarkers" component. Settings for online player markers.
|
// Settings for player related UI elements and markers
|
||||||
// If not present, player markers will be disabled
|
players: {
|
||||||
playerMarkers: undefined,
|
// Settings for online player markers
|
||||||
|
// (playermarkers component in Dynmap, world-settings.x.player-tracker in squaremap)
|
||||||
|
// If not present, player markers will be disabled
|
||||||
|
markers: undefined,
|
||||||
|
|
||||||
playerList: {
|
grayHiddenPlayers: true,
|
||||||
|
|
||||||
|
// ("showplayerfacesinmenu" setting in dynmap)
|
||||||
showImages: false,
|
showImages: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -164,8 +164,9 @@ export function buildComponents(response: Configuration): LiveAtlasComponentConf
|
|||||||
},
|
},
|
||||||
chatBox: undefined,
|
chatBox: undefined,
|
||||||
chatBalloons: false,
|
chatBalloons: false,
|
||||||
playerMarkers: undefined,
|
players: {
|
||||||
playerList: {
|
markers: undefined,
|
||||||
|
grayHiddenPlayers: false,
|
||||||
showImages: response.showplayerfacesinmenu || false,
|
showImages: response.showplayerfacesinmenu || false,
|
||||||
},
|
},
|
||||||
coordinatesControl: undefined,
|
coordinatesControl: undefined,
|
||||||
@ -197,8 +198,8 @@ export function buildComponents(response: Configuration): LiveAtlasComponentConf
|
|||||||
imageSize = 'body';
|
imageSize = 'body';
|
||||||
}
|
}
|
||||||
|
|
||||||
components.playerMarkers = {
|
components.players.grayHiddenPlayers = response.grayplayerswhenhidden || false;
|
||||||
grayHiddenPlayers: response.grayplayerswhenhidden || false,
|
components.players.markers = {
|
||||||
hideByDefault: component.hidebydefault || false,
|
hideByDefault: component.hidebydefault || false,
|
||||||
layerName: component.label || "Players",
|
layerName: component.label || "Players",
|
||||||
layerPriority: component.layerprio || 0,
|
layerPriority: component.layerprio || 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user