Support disabling player marker images

- showplayerfaces: false in Dynmap, player-tracker.nameplate.show-head: false in Pl3xmap
- Remove showSkin option in favour of 'none' image size
This commit is contained in:
James Lyne 2021-09-29 19:58:39 +01:00
parent 5896d4504c
commit bf383afb8d
6 changed files with 19 additions and 21 deletions

View File

@ -48,7 +48,6 @@ export default defineComponent({
//The player marker //The player marker
marker = new PlayerMarker(props.player, { marker = new PlayerMarker(props.player, {
showSkin: componentSettings.value!.showSkins,
imageSize: componentSettings.value!.imageSize, imageSize: componentSettings.value!.imageSize,
showHealth: componentSettings.value!.showHealth, showHealth: componentSettings.value!.showHealth,
showArmor: componentSettings.value!.showArmor, showArmor: componentSettings.value!.showArmor,

1
src/index.d.ts vendored
View File

@ -321,7 +321,6 @@ interface LiveAtlasPlayerMarkerConfig {
layerName: string; layerName: string;
layerPriority: number; layerPriority: number;
imageSize: LiveAtlasPlayerImageSize; imageSize: LiveAtlasPlayerImageSize;
showSkins: boolean;
showHealth: boolean; showHealth: boolean;
showArmor: boolean; showArmor: boolean;
} }

View File

@ -28,7 +28,6 @@ playerImage.className = 'player__icon';
export interface PlayerIconOptions extends BaseIconOptions { export interface PlayerIconOptions extends BaseIconOptions {
imageSize: LiveAtlasPlayerImageSize, imageSize: LiveAtlasPlayerImageSize,
showSkin: boolean,
showHealth: boolean, showHealth: boolean,
showArmor: boolean, showArmor: boolean,
} }
@ -68,16 +67,17 @@ export class PlayerIcon extends Layer implements Icon<PlayerIconOptions> {
this._playerName = document.createElement('span'); this._playerName = document.createElement('span');
this._playerName.className = 'player__name'; this._playerName.className = 'player__name';
this._playerImage = playerImage.cloneNode() as HTMLImageElement; if (this.options.imageSize != 'none') {
this._playerImage.height = this._playerImage.width = getImagePixelSize(this.options.imageSize); this._playerImage = playerImage.cloneNode() as HTMLImageElement;
this._playerImage.height = this._playerImage.width = getImagePixelSize(this.options.imageSize);
if (this.options.showSkin) {
getMinecraftHead(this._player, this.options.imageSize).then(head => { getMinecraftHead(this._player, this.options.imageSize).then(head => {
this._playerImage!.src = head.src; this._playerImage!.src = head.src;
}).catch(() => {}); }).catch(() => {});
this._playerInfo.appendChild(this._playerImage);
} }
this._playerInfo.appendChild(this._playerImage);
this._playerInfo.appendChild(this._playerName); this._playerInfo.appendChild(this._playerName);
if (this.options.showHealth) { if (this.options.showHealth) {

View File

@ -21,7 +21,6 @@ import {watch} from "@vue/runtime-core";
import {WatchStopHandle} from "vue"; import {WatchStopHandle} from "vue";
export interface PlayerMarkerOptions extends MarkerOptions { export interface PlayerMarkerOptions extends MarkerOptions {
showSkin: boolean,
imageSize: LiveAtlasPlayerImageSize, imageSize: LiveAtlasPlayerImageSize,
showHealth: boolean, showHealth: boolean,
showArmor: boolean, showArmor: boolean,
@ -40,7 +39,6 @@ export class PlayerMarker extends Marker {
this._PlayerIcon = options.icon = new PlayerIcon(player, { this._PlayerIcon = options.icon = new PlayerIcon(player, {
imageSize: options.imageSize, imageSize: options.imageSize,
showSkin: options.showSkin,
showHealth: options.showHealth, showHealth: options.showHealth,
showArmor: options.showArmor, showArmor: options.showArmor,
}); });

View File

@ -94,15 +94,15 @@ export default class Pl3xmapMapProvider extends MapProvider {
if(worldResponse.player_tracker?.enabled) { if(worldResponse.player_tracker?.enabled) {
const health = !!worldResponse.player_tracker?.nameplates?.show_health, const health = !!worldResponse.player_tracker?.nameplates?.show_health,
armor = !!worldResponse.player_tracker?.nameplates?.show_armor; armor = !!worldResponse.player_tracker?.nameplates?.show_armor,
images = !!worldResponse.player_tracker?.nameplates?.show_heads;
worldConfig.components.playerMarkers = { worldConfig.components.playerMarkers = {
grayHiddenPlayers: true, 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,
imageSize: health && armor ? 'large' : 'small', imageSize: images ? (health && armor ? 'large' : 'small') : 'none',
showSkins: true,
showHealth: health, showHealth: health,
showArmor: armor, showArmor: armor,
} }

View File

@ -22,7 +22,7 @@ import {
LiveAtlasComponentConfig, LiveAtlasComponentConfig,
LiveAtlasDimension, LiveAtlasDimension,
LiveAtlasLine, LiveAtlasLine,
LiveAtlasMarker, LiveAtlasMarker, LiveAtlasPlayerImageSize,
LiveAtlasServerConfig, LiveAtlasServerConfig,
LiveAtlasServerMessageConfig, LiveAtlasServerMessageConfig,
LiveAtlasWorldDefinition LiveAtlasWorldDefinition
@ -139,6 +139,7 @@ export function buildComponents(response: any): LiveAtlasComponentConfig {
(response.components || []).forEach((component: any) => { (response.components || []).forEach((component: any) => {
const type = component.type || "unknown"; const type = component.type || "unknown";
let imageSize: LiveAtlasPlayerImageSize = 'large';
switch (type) { switch (type) {
case "markers": case "markers":
@ -149,23 +150,24 @@ export function buildComponents(response: any): LiveAtlasComponentConfig {
break; break;
case "playermarkers": case "playermarkers":
if(!component.showplayerfaces) {
imageSize = 'none';
} else if(component.smallplayerfaces) {
imageSize = 'small';
} else if(component.showplayerbody) {
imageSize = 'body';
}
components.playerMarkers = { components.playerMarkers = {
grayHiddenPlayers: response.grayplayerswhenhidden || false, grayHiddenPlayers: response.grayplayerswhenhidden || false,
hideByDefault: component.hidebydefault || false, hideByDefault: component.hidebydefault || false,
layerName: component.label || "Players", layerName: component.label || "Players",
layerPriority: component.layerprio || 0, layerPriority: component.layerprio || 0,
showSkins: component.showplayerfaces || false, imageSize,
imageSize: 'large',
showHealth: component.showplayerhealth || false, showHealth: component.showplayerhealth || false,
showArmor: component.showplayerhealth || false, showArmor: component.showplayerhealth || false,
} }
if(component.smallplayerfaces) {
components.playerMarkers.imageSize = 'small'
} else if(component.showplayerbody) {
components.playerMarkers.imageSize = 'body';
}
break; break;
case "coord": case "coord":