Support disabling player images in player list

- showplayerfacesinmenu in Dynmap
- Player image is removed entirely rather than mirroring Dynmap behaviour of showing a Steve head, to be consistent with player markers and chat.
- Images are also disabled in FollowTarget
This commit is contained in:
James Lyne 2021-09-29 21:16:31 +01:00
parent fac72fd615
commit dc479ca6e8
7 changed files with 55 additions and 34 deletions

View File

@ -19,11 +19,9 @@
<h2>{{ heading }}</h2> <h2>{{ heading }}</h2>
<div :class="{'following__target': true, 'following__target--hidden': target.hidden}"> <div :class="{'following__target': true, 'following__target--hidden': target.hidden}">
<img width="32" height="32" class="target__icon" :src="image" alt="" /> <img v-if="imagesEnabled" width="32" height="32" class="target__icon" :src="image" alt="" />
<span class="target__info">
<span class="target__name" v-html="target.displayName"></span> <span class="target__name" v-html="target.displayName"></span>
<span class="target__status" v-show="target.hidden">{{ messageHidden }}</span> <span class="target__status" v-show="target.hidden">{{ messageHidden }}</span>
</span>
<button class="target__unfollow" type="button" :title="messageUnfollowTitle" <button class="target__unfollow" type="button" :title="messageUnfollowTitle"
@click.prevent="unfollow" :aria-label="messageUnfollow"> @click.prevent="unfollow" :aria-label="messageUnfollow">
<SvgIcon name="cross"></SvgIcon> <SvgIcon name="cross"></SvgIcon>
@ -53,6 +51,7 @@ export default defineComponent({
}, },
setup(props) { setup(props) {
const store = useStore(), const store = useStore(),
imagesEnabled = computed(() => store.state.components.playerList.showImages),
image = ref(defaultImage), image = ref(defaultImage),
account = ref(props.target.name), account = ref(props.target.name),
@ -67,7 +66,7 @@ export default defineComponent({
updatePlayerImage = async () => { updatePlayerImage = async () => {
image.value = defaultImage; image.value = defaultImage;
if(store.state.components.playerMarkers && store.state.components.playerMarkers.showSkins) { if(imagesEnabled.value) {
try { try {
const result = await getMinecraftHead(props.target, 'small'); const result = await getMinecraftHead(props.target, 'small');
image.value = result.src; image.value = result.src;
@ -79,6 +78,7 @@ export default defineComponent({
onMounted(() => updatePlayerImage()); onMounted(() => updatePlayerImage());
return { return {
imagesEnabled,
image, image,
unfollow, unfollow,
heading, heading,
@ -97,7 +97,11 @@ export default defineComponent({
flex: 0 0 auto; flex: 0 0 auto;
.following__target { .following__target {
display: flex; display: grid;
grid-template-columns: min-content 1fr;
grid-template-rows: 1fr min-content min-content 1fr;
grid-template-areas: "icon ." "icon name" "icon status" "icon .";
grid-auto-flow: column;
align-items: center; align-items: center;
.target__unfollow { .target__unfollow {
@ -118,16 +122,19 @@ export default defineComponent({
} }
} }
.target__info { .target__icon {
margin-left: 2rem; margin-right: 2rem;
display: flex; grid-area: icon;
flex-direction: column; }
justify-content: flex-start;
.target__name {
grid-area: name;
}
.target__status { .target__status {
grid-area: status;
font-size: 1.3rem; font-size: 1.3rem;
} }
}
&.following__target--hidden { &.following__target--hidden {
.target__icon { .target__icon {

View File

@ -20,7 +20,7 @@
<label :for="`player-${player.name}`" <label :for="`player-${player.name}`"
:class="{'player': true, 'player--hidden' : !!player.hidden, 'player--other-world': otherWorld}" :title="title" :class="{'player': true, 'player--hidden' : !!player.hidden, 'player--other-world': otherWorld}" :title="title"
@click.prevent="onLabelClick"> @click.prevent="onLabelClick">
<img width="16" height="16" class="player__icon" :src="image" alt="" aria-hidden="true" /> <img v-if="imagesEnabled" width="16" height="16" class="player__icon" :src="image" alt="" aria-hidden="true" />
<span class="player__name" v-html="player.displayName"></span> <span class="player__name" v-html="player.displayName"></span>
</label> </label>
</template> </template>
@ -43,6 +43,9 @@ export default defineComponent({
}, },
setup(props) { setup(props) {
const store = useStore(), const store = useStore(),
imagesEnabled = computed(() => store.state.components.playerList.showImages),
image = ref(defaultImage),
otherWorld = computed(() => { otherWorld = computed(() => {
return store.state.components.playerMarkers?.grayHiddenPlayers return store.state.components.playerMarkers?.grayHiddenPlayers
&& !props.player.hidden && !props.player.hidden
@ -88,15 +91,14 @@ export default defineComponent({
} }
}; };
let image = ref(defaultImage);
onMounted(() => { onMounted(() => {
if(store.state.components.playerMarkers && store.state.components.playerMarkers.showSkins) { if(imagesEnabled.value) {
getMinecraftHead(props.player, 'small').then((result) => image.value = result.src).catch(() => {}); getMinecraftHead(props.player, 'small').then((result) => image.value = result.src).catch(() => {});
} }
}); });
return { return {
imagesEnabled,
image, image,
title, title,
otherWorld, otherWorld,
@ -113,19 +115,14 @@ export default defineComponent({
@import '../../scss/mixins'; @import '../../scss/mixins';
.player { .player {
.player__icon { display: flex !important;
position: absolute; align-items: center;
display: block;
top: 0;
bottom: 0;
left: 0.7rem;
pointer-events: none;
margin: auto;
z-index: 2;
}
.player__name { .player__icon {
padding-left: 2.7rem; position: relative;
pointer-events: none;
z-index: 2;
padding-right: 1.2rem;
} }
&.player--hidden:not(:hover), &.player--hidden:not(:hover),

3
src/index.d.ts vendored
View File

@ -288,6 +288,9 @@ interface LiveAtlasComponentConfig {
showLabels: boolean; showLabels: boolean;
}; };
playerMarkers?: LiveAtlasPlayerMarkerConfig; playerMarkers?: LiveAtlasPlayerMarkerConfig;
playerList: {
showImages: boolean;
},
coordinatesControl?: CoordinatesControlOptions; coordinatesControl?: CoordinatesControlOptions;
clockControl?: ClockControlOptions; clockControl?: ClockControlOptions;
linkControl: boolean; linkControl: boolean;

View File

@ -160,9 +160,6 @@ export default class Pl3xmapMapProvider extends MapProvider {
private static buildComponents(response: any): LiveAtlasComponentConfig { private static buildComponents(response: any): LiveAtlasComponentConfig {
const components: LiveAtlasComponentConfig = { const components: LiveAtlasComponentConfig = {
markers: {
showLabels: false,
},
coordinatesControl: undefined, coordinatesControl: undefined,
linkControl: !!response.ui?.link?.enabled, linkControl: !!response.ui?.link?.enabled,
layerControl: !!response.ui?.coordinates?.enabled, layerControl: !!response.ui?.coordinates?.enabled,
@ -170,6 +167,14 @@ export default class Pl3xmapMapProvider extends MapProvider {
//Configured per-world //Configured per-world
playerMarkers: undefined, playerMarkers: undefined,
//Not configurable
markers: {
showLabels: false,
},
playerList: {
showImages: true,
},
//Not used by pl3xmap //Not used by pl3xmap
chatBox: undefined, chatBox: undefined,
chatBalloons: false, chatBalloons: false,

View File

@ -225,6 +225,8 @@ input {
height: 1px; height: 1px;
width: 1px; width: 1px;
position: absolute; position: absolute;
padding: 0;
border: none;
& + label { & + label {
@include button; @include button;

View File

@ -198,6 +198,10 @@ export const state: State = {
// If not present, player markers will be disabled // If not present, player markers will be disabled
playerMarkers: undefined, playerMarkers: undefined,
playerList: {
showImages: false,
},
//Optional "coords" component. Adds control showing coordinates on map mouseover //Optional "coords" component. Adds control showing coordinates on map mouseover
coordinatesControl: undefined, coordinatesControl: undefined,

View File

@ -129,6 +129,9 @@ export function buildComponents(response: any): LiveAtlasComponentConfig {
chatBox: undefined, chatBox: undefined,
chatBalloons: false, chatBalloons: false,
playerMarkers: undefined, playerMarkers: undefined,
playerList: {
showImages: response.showplayerfacesinmenu || false,
},
coordinatesControl: undefined, coordinatesControl: undefined,
layerControl: response.showlayercontrol && response.showlayercontrol !== 'false', //Sent as a string for some reason layerControl: response.showlayercontrol && response.showlayercontrol !== 'false', //Sent as a string for some reason
linkControl: false, linkControl: false,