Skip to content

Commit

Permalink
Show simpler world list for map plugins that have 1 map per world
Browse files Browse the repository at this point in the history
  • Loading branch information
JLyne committed Jul 10, 2023
1 parent aa30b28 commit 592969b
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 16 deletions.
45 changes: 29 additions & 16 deletions src/components/list/WorldListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,33 @@
-->

<template>
<div v-if="maps.length" class="world">
<span class="world__name" aria-hidden="true">{{ world.displayName }}</span>
<div class="world__maps menu">
<template v-for="map in maps" :key="`${map.world.name}_${map.name}`">
<input :id="`${name}-${map.world.name}-${map.name}`" type="radio" :name="name"
v-bind:value="[map.world.name,map.name]" v-model="currentMap"
:aria-labelledby="`${name}-${map.world.name}-${map.name}-label`">
<label :id="`${name}-${map.world.name}-${map.name}-label`" class="map"
:for="`${name}-${map.world.name}-${map.name}`"
:title="`${map.world.displayName} - ${map.displayName}`">
<img v-if="map.hasCustomIcon()" :src="map.getIcon()" alt="" />
<SvgIcon v-else :name="map.getIcon()"></SvgIcon>
</label>
</template>
</div>
</div>
<template v-if="singleMapWorlds">
<input :id="`${name}-${maps[0].world.name}-${maps[0].name}`" type="radio" :name="name"
v-bind:value="[maps[0].world.name, maps[0].name]" v-model="currentMap"
:aria-labelledby="`${name}-${maps[0].world.name}-${maps[0].name}-label`">
<label :id="`${name}-${maps[0].world.name}-${maps[0].name}-label`"
:for="`${name}-${maps[0].world.name}-${maps[0].name}`">
{{ maps[0].world.displayName }}
</label>
</template>
<template v-else>
<div v-if="maps.length" class="world">
<span class="world__name" aria-hidden="true">{{ world.displayName }}</span>
<div class="world__maps menu">
<template v-for="map in maps" :key="`${map.world.name}_${map.name}`">
<input :id="`${name}-${map.world.name}-${map.name}`" type="radio" :name="name"
v-bind:value="[map.world.name,map.name]" v-model="currentMap"
:aria-labelledby="`${name}-${map.world.name}-${map.name}-label`">
<label :id="`${name}-${map.world.name}-${map.name}-label`" class="map"
:for="`${name}-${map.world.name}-${map.name}`"
:title="`${map.world.displayName} - ${map.displayName}`">
<img v-if="map.hasCustomIcon()" :src="map.getIcon()" alt="" />
<SvgIcon v-else :name="map.getIcon()"></SvgIcon>
</label>
</template>
</div>
</div>
</template>
</template>

<script lang="ts">
Expand Down Expand Up @@ -68,6 +79,7 @@ export default defineComponent({
setup(props) {
const store = useStore(),
singleMapWorlds = computed(() => store.state.configuration.singleMapWorlds),
maps = computed(() => {
const maps: LiveAtlasMapDefinition[] = [];
Expand All @@ -90,6 +102,7 @@ export default defineComponent({
return {
currentMap,
singleMapWorlds,
maps
}
}
Expand Down
1 change: 1 addition & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ interface LiveAtlasServerConfig {
followZoom?: number;
title: string;
expandUI: boolean;
singleMapWorlds: boolean;
}

interface LiveAtlasComponentConfig {
Expand Down
1 change: 1 addition & 0 deletions src/providers/OverviewerMapProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export default class OverviewerMapProvider extends MapProvider {
private static buildServerConfig(ignore: any): LiveAtlasServerConfig {
return {
title: useStore().state.initialTitle,
singleMapWorlds: false,

//Not used by overviewer
expandUI: false,
Expand Down
1 change: 1 addition & 0 deletions src/providers/Pl3xmapMapProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export default class Pl3xmapMapProvider extends MapProvider {
return {
title: (response.ui?.title || 'Pl3xmap').replace(titleColoursRegex, ''),
expandUI: response.ui?.sidebar?.pinned === 'pinned',
singleMapWorlds: true,

//Not used by pl3xmap
defaultZoom: 1,
Expand Down
1 change: 1 addition & 0 deletions src/store/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export const state: State = {
followZoom: 0,
title: '',
expandUI: false,
singleMapWorlds: false,
},
configurationHash: undefined,

Expand Down
1 change: 1 addition & 0 deletions src/util/dynmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export function buildServerConfig(response: Options): LiveAtlasServerConfig {
followMap: response.followmap || undefined,
followZoom: isNaN(followZoom) ? undefined : followZoom,
title: title,
singleMapWorlds: false,
expandUI: !!response.sidebaropened && response.sidebaropened !== 'false', //Sent as a string for some reason
};
}
Expand Down

0 comments on commit 592969b

Please sign in to comment.