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:
James Lyne 2022-02-05 15:11:09 +00:00
parent 9bb797f23a
commit 0b6bf8d206
11 changed files with 48 additions and 34 deletions

View File

@ -93,7 +93,7 @@ export default defineComponent({
messageMarkers = computed(() => store.state.messages.markersHeading),
messagePlayers = computed(() => store.getters.playersHeading),
playerMakersEnabled = computed(() => !!store.state.components.playerMarkers),
playerMakersEnabled = computed(() => store.getters.playerMarkersEnabled),
playersVisible = computed(() => currentlyVisible.value.has('players')),
mapsVisible = computed(() => currentlyVisible.value.has('maps')),

View File

@ -43,11 +43,11 @@ export default defineComponent({
},
setup(props) {
const store = useStore(),
imagesEnabled = computed(() => store.state.components.playerList.showImages),
imagesEnabled = computed(() => store.state.components.players.showImages),
image = ref(defaultImage),
otherWorld = computed(() => {
return store.state.components.playerMarkers?.grayHiddenPlayers
return store.state.components.players.grayHiddenPlayers
&& !props.player.hidden
&& (!store.state.currentWorld || store.state.currentWorld.name !== props.player.location.world);
}),

View File

@ -43,7 +43,7 @@ export default defineComponent({
players = computed(() => store.state.players),
playerCount = computed(() => store.state.players.size),
playersAboveMarkers = computed(() => store.state.ui.playersAboveMarkers),
componentSettings = computed(() => store.state.components.playerMarkers),
componentSettings = computed(() => store.state.components.players.markers),
layerGroup = new LayerGroup([],{
pane: 'players'
});
@ -55,12 +55,12 @@ export default defineComponent({
props.leaflet.getLayerManager().addLayer(
layerGroup,
true,
store.state.components.playerMarkers!.layerName,
store.state.components.players.markers!.layerName,
componentSettings.value!.layerPriority);
} else {
props.leaflet.getLayerManager().addHiddenLayer(
layerGroup,
store.state.components.playerMarkers!.layerName,
store.state.components.players.markers!.layerName,
componentSettings.value!.layerPriority);
}
});

View File

@ -38,7 +38,7 @@ export default defineComponent({
let chatBalloonCutoff = 0; //Not reactive to avoid unnecessary playerChat recalculations
const store = useStore(),
componentSettings = computed(() => store.state.components.playerMarkers),
componentSettings = computed(() => store.state.components.players.markers),
currentMap = computed(() => store.state.currentMap),
currentWorld = computed(() => store.state.currentWorld),
chatBalloonsEnabled = computed(() => store.state.components.chatBalloons),

View File

@ -54,7 +54,7 @@ export default defineComponent({
},
setup(props) {
const store = useStore(),
imagesEnabled = computed(() => store.state.components.playerList.showImages),
imagesEnabled = computed(() => store.state.components.players.showImages),
image = ref(defaultImage),
account = computed(() => props.target.name),

14
src/index.d.ts vendored
View File

@ -261,10 +261,11 @@ interface LiveAtlasComponentConfig {
markers: {
showLabels: boolean;
};
playerMarkers?: LiveAtlasPlayerMarkerConfig;
playerList: {
players: {
markers?: LiveAtlasPlayerMarkerConfig;
showImages: boolean;
},
grayHiddenPlayers: boolean;
};
coordinatesControl?: CoordinatesControlOptions;
clockControl?: ClockControlOptions;
linkControl: boolean;
@ -280,7 +281,11 @@ interface LiveAtlasPartialComponentConfig {
markers?: {
showLabels: boolean;
};
playerMarkers?: LiveAtlasPlayerMarkerConfig;
players?: {
markers?: LiveAtlasPlayerMarkerConfig;
showImages?: boolean;
grayHiddenPlayers?: boolean;
};
coordinatesControl?: CoordinatesControlOptions;
clockControl?: ClockControlOptions;
linkControl?: boolean;
@ -293,7 +298,6 @@ interface LiveAtlasPartialComponentConfig {
}
interface LiveAtlasPlayerMarkerConfig {
grayHiddenPlayers: boolean;
hideByDefault: boolean;
layerName: string;
layerPriority: number;

View File

@ -118,7 +118,12 @@ export default class Pl3xmapMapProvider extends MapProvider {
filteredWorlds.forEach((world: any, index: number) => {
const worldResponse = worldResponses[index],
worldConfig: {components: LiveAtlasPartialComponentConfig } = {
components: {},
components: {
players: {
markers: undefined,
grayHiddenPlayers: true,
}
},
};
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);
worldConfig.components.playerMarkers = {
grayHiddenPlayers: true,
worldConfig.components.players!.markers = {
hideByDefault: !!worldResponse.player_tracker?.default_hidden,
layerName: worldResponse.player_tracker?.label || '',
layerPriority: worldResponse.player_tracker?.priority,
@ -141,8 +145,6 @@ export default class Pl3xmapMapProvider extends MapProvider {
showArmor: armor,
showYaw: true,
}
} else {
worldConfig.components.playerMarkers = undefined;
}
this.worldComponents.set(world.name, worldConfig);
@ -200,16 +202,18 @@ export default class Pl3xmapMapProvider extends MapProvider {
linkControl: !!response.ui?.link?.enabled,
layerControl: !!response.ui?.coordinates?.enabled,
//Configured per-world
playerMarkers: undefined,
players: {
markers: undefined, //Configured per-world
//Not configurable
showImages: true,
grayHiddenPlayers: true,
},
//Not configurable
markers: {
showLabels: false,
},
playerList: {
showImages: true,
},
//Not used by pl3xmap
chatBox: undefined,
@ -536,7 +540,7 @@ export default class Pl3xmapMapProvider extends MapProvider {
private async updatePlayers() {
try {
if(this.store.state.components.playerMarkers) {
if(this.store.getters.playerMarkersEnabled) {
const players = await this.getPlayers();
this.playerUpdateTimestamp = new Date();

View File

@ -32,7 +32,7 @@ export type Getters = {
export const getters: GetterTree<State, State> & Getters = {
playerMarkersEnabled(state: State): boolean {
return state.components.playerMarkers !== undefined;
return state.components.players.markers !== undefined;
},
coordinatesControlEnabled(state: State): boolean {

View File

@ -551,7 +551,7 @@ export const mutations: MutationTree<State> & Mutations = {
state.configuration.title = '';
state.components.markers.showLabels= false;
state.components.playerMarkers = undefined;
state.components.players.markers = undefined;
state.components.coordinatesControl = undefined;
state.components.clockControl = undefined;
state.components.linkControl = false;

View File

@ -144,11 +144,16 @@ export const state: State = {
showLabels: false,
},
// Optional "playermarkers" component. Settings for online player markers.
// If not present, player markers will be disabled
playerMarkers: undefined,
// Settings for player related UI elements and markers
players: {
// 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,
},

View File

@ -164,8 +164,9 @@ export function buildComponents(response: Configuration): LiveAtlasComponentConf
},
chatBox: undefined,
chatBalloons: false,
playerMarkers: undefined,
playerList: {
players: {
markers: undefined,
grayHiddenPlayers: false,
showImages: response.showplayerfacesinmenu || false,
},
coordinatesControl: undefined,
@ -197,8 +198,8 @@ export function buildComponents(response: Configuration): LiveAtlasComponentConf
imageSize = 'body';
}
components.playerMarkers = {
grayHiddenPlayers: response.grayplayerswhenhidden || false,
components.players.grayHiddenPlayers = response.grayplayerswhenhidden || false;
components.players.markers = {
hideByDefault: component.hidebydefault || false,
layerName: component.label || "Players",
layerPriority: component.layerprio || 0,