Respect pl3xmap show-armor setting

This commit is contained in:
James Lyne 2021-09-28 18:54:51 +01:00
parent c71e8289dd
commit bfc0a381a8
6 changed files with 26 additions and 12 deletions

View File

@ -52,6 +52,7 @@ export default defineComponent({
showSkinFace: componentSettings.value!.showSkinFaces,
showBody: componentSettings.value!.showBodies,
showHealth: componentSettings.value!.showHealth,
showArmor: componentSettings.value!.showArmor,
pane: 'players',
}),

1
src/index.d.ts vendored
View File

@ -323,6 +323,7 @@ interface LiveAtlasPlayerMarkerConfig {
showBodies: boolean;
showSkinFaces: boolean;
showHealth: boolean;
showArmor: boolean;
smallFaces: boolean;
}

View File

@ -46,6 +46,7 @@ export interface PlayerIconOptions extends BaseIconOptions {
showSkinFace: boolean,
showBody: boolean,
showHealth: boolean,
showArmor: boolean,
}
export class PlayerIcon extends Layer implements Icon<PlayerIconOptions> {
@ -120,24 +121,25 @@ export class PlayerIcon extends Layer implements Icon<PlayerIconOptions> {
if (this.options.showHealth) {
this._playerHealth = document.createElement('div');
this._playerHealth.className = 'player__health';
this._playerArmor = document.createElement('div');
this._playerArmor.className = 'player__armor';
this._playerHealth.hidden = true;
this._playerHealthBar = document.createElement('div');
this._playerHealthBar.className = 'player__health-bar';
this._playerHealth.appendChild(this._playerHealthBar);
this._playerInfo.appendChild(this._playerHealth);
}
if (this.options.showArmor) {
this._playerArmor = document.createElement('div');
this._playerArmor.className = 'player__armor';
this._playerArmor.hidden = true;
this._playerArmorBar = document.createElement('div');
this._playerArmorBar.className = 'player__armor-bar';
this._playerHealth.appendChild(this._playerHealthBar);
this._playerArmor.appendChild(this._playerArmorBar);
this._playerInfo.appendChild(this._playerHealth);
this._playerInfo.appendChild(this._playerArmor);
this._playerHealth.hidden = this._playerArmor.hidden = true;
} else {
this._playerName.classList.add('playerNameNoHealth');
}
this._container.style.marginTop = `-${offset}px`;
@ -161,13 +163,19 @@ export class PlayerIcon extends Layer implements Icon<PlayerIconOptions> {
}
if(this.options.showHealth) {
if (this._player.health !== undefined && this._player.armor !== undefined) {
if (this._player.health !== undefined) {
this._playerHealth!.hidden = false;
this._playerArmor!.hidden = false;
this._playerHealthBar!.style.width = Math.ceil(this._player.health * 2.5) + 'px';
this._playerArmorBar!.style.width = Math.ceil(this._player.armor * 2.5) + 'px';
} else {
this._playerHealth!.hidden = true;
}
}
if(this.options.showArmor) {
if(this._player.armor !== undefined) {
this._playerArmor!.hidden = false;
this._playerArmorBar!.style.width = Math.ceil(this._player.armor * 2.5) + 'px';
} else {
this._playerArmor!.hidden = true;
}
}

View File

@ -25,6 +25,7 @@ export interface PlayerMarkerOptions extends MarkerOptions {
showSkinFace: boolean,
showBody: boolean,
showHealth: boolean,
showArmor: boolean,
}
export class PlayerMarker extends Marker {
@ -43,6 +44,7 @@ export class PlayerMarker extends Marker {
showSkinFace: options.showSkinFace,
showBody: options.showBody,
showHealth: options.showHealth,
showArmor: options.showArmor,
});
Util.setOptions(this, options);

View File

@ -93,6 +93,7 @@ export default class Pl3xmapMapProvider extends MapProvider {
showBodies: false,
showSkinFaces: true,
showHealth: !!worldResponse.player_tracker?.nameplates?.show_health,
showArmor: !!worldResponse.player_tracker?.nameplates?.show_armor,
smallFaces: true,
}
} else {

View File

@ -153,6 +153,7 @@ export function buildComponents(response: any): LiveAtlasComponentConfig {
showBodies: component.showplayerbody || false,
showSkinFaces: component.showplayerfaces || false,
showHealth: component.showplayerhealth || false,
showArmor: component.showplayerhealth || false,
smallFaces: component.smallplayerfaces || false,
}