diff --git a/src/components/Sidebar.vue b/src/components/Sidebar.vue index 5e49634..5db40e6 100644 --- a/src/components/Sidebar.vue +++ b/src/components/Sidebar.vue @@ -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')), diff --git a/src/components/list/PlayerListItem.vue b/src/components/list/PlayerListItem.vue index beae778..42798a7 100644 --- a/src/components/list/PlayerListItem.vue +++ b/src/components/list/PlayerListItem.vue @@ -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); }), diff --git a/src/components/map/layer/PlayersLayer.vue b/src/components/map/layer/PlayersLayer.vue index de83349..11e5a3d 100644 --- a/src/components/map/layer/PlayersLayer.vue +++ b/src/components/map/layer/PlayersLayer.vue @@ -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); } }); diff --git a/src/components/map/marker/PlayerMarker.vue b/src/components/map/marker/PlayerMarker.vue index 90f9f8b..e4900a0 100644 --- a/src/components/map/marker/PlayerMarker.vue +++ b/src/components/map/marker/PlayerMarker.vue @@ -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), diff --git a/src/components/sidebar/FollowTargetSection.vue b/src/components/sidebar/FollowTargetSection.vue index 223c9fa..75b3029 100644 --- a/src/components/sidebar/FollowTargetSection.vue +++ b/src/components/sidebar/FollowTargetSection.vue @@ -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), diff --git a/src/index.d.ts b/src/index.d.ts index 000d155..25015e2 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -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; diff --git a/src/providers/Pl3xmapMapProvider.ts b/src/providers/Pl3xmapMapProvider.ts index 1301056..8164637 100644 --- a/src/providers/Pl3xmapMapProvider.ts +++ b/src/providers/Pl3xmapMapProvider.ts @@ -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(); diff --git a/src/store/getters.ts b/src/store/getters.ts index 7be4eba..17d17e4 100644 --- a/src/store/getters.ts +++ b/src/store/getters.ts @@ -32,7 +32,7 @@ export type Getters = { export const getters: GetterTree & Getters = { playerMarkersEnabled(state: State): boolean { - return state.components.playerMarkers !== undefined; + return state.components.players.markers !== undefined; }, coordinatesControlEnabled(state: State): boolean { diff --git a/src/store/mutations.ts b/src/store/mutations.ts index a6defb3..5b60459 100644 --- a/src/store/mutations.ts +++ b/src/store/mutations.ts @@ -551,7 +551,7 @@ export const mutations: MutationTree & 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; diff --git a/src/store/state.ts b/src/store/state.ts index e88cc5b..55bbf6d 100644 --- a/src/store/state.ts +++ b/src/store/state.ts @@ -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, }, diff --git a/src/util/dynmap.ts b/src/util/dynmap.ts index af56991..b895a6d 100644 --- a/src/util/dynmap.ts +++ b/src/util/dynmap.ts @@ -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,