2020-11-23 12:13:28 +00:00
|
|
|
<template>
|
2020-12-01 23:20:38 +00:00
|
|
|
<li class="world">
|
|
|
|
<span class="world__name">{{ world.title }}</span>
|
|
|
|
<ul class="world__maps">
|
|
|
|
<li :class="{'map': true, 'map--selected': map === currentMap}" v-for="[name, map] in world.maps" :key="name">
|
2020-12-13 02:52:28 +00:00
|
|
|
<button type="button" :title="map.title" @click="setCurrentMap(map.name)" :aria-label="map.title">
|
|
|
|
<SvgIcon :name="getMapIcon(map)"></SvgIcon>
|
|
|
|
</button>
|
2020-11-23 12:13:28 +00:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-11-23 16:16:26 +00:00
|
|
|
import {useStore} from "@/store";
|
2020-12-11 21:38:50 +00:00
|
|
|
import {DynmapWorldMap, DynmapWorld} from "@/dynmap";
|
2020-11-23 12:13:28 +00:00
|
|
|
import {defineComponent} from 'vue';
|
2020-11-23 16:16:26 +00:00
|
|
|
import {MutationTypes} from "@/store/mutation-types";
|
2020-12-13 02:52:28 +00:00
|
|
|
import SvgIcon from "@/components/SvgIcon.vue";
|
2020-11-23 12:13:28 +00:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
name: 'WorldListItem',
|
2020-12-13 02:52:28 +00:00
|
|
|
components: {SvgIcon},
|
2020-11-23 12:13:28 +00:00
|
|
|
props: {
|
|
|
|
world: {
|
|
|
|
type: Object as () => DynmapWorld,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2020-12-11 21:38:50 +00:00
|
|
|
currentMap(): DynmapWorldMap | undefined {
|
2020-11-23 12:13:28 +00:00
|
|
|
return useStore().state.currentMap;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2020-12-11 21:38:50 +00:00
|
|
|
getMapIcon(map: DynmapWorldMap): string {
|
2020-11-23 12:13:28 +00:00
|
|
|
let worldType: string,
|
|
|
|
mapType: string;
|
|
|
|
|
|
|
|
if (this.world.name.endsWith('_nether') || (this.world.name == 'DIM-1')) {
|
|
|
|
worldType = 'nether';
|
|
|
|
mapType = (map.name == 'nether') ? 'surface' : 'flat';
|
|
|
|
} else if (this.world.name.endsWith('the_end') || (this.world.name == 'DIM1')) {
|
|
|
|
worldType = 'the_end';
|
|
|
|
mapType = (map.name == 'the_end') ? 'surface' : 'flat';
|
|
|
|
} else {
|
|
|
|
worldType = 'world';
|
|
|
|
mapType = ['surface', 'flat', 'biome', 'cave'].includes(map.name) ? map.name : 'flat';
|
|
|
|
}
|
|
|
|
|
2020-12-13 02:52:28 +00:00
|
|
|
return `block_${worldType}_${mapType}`;
|
2020-11-23 12:13:28 +00:00
|
|
|
},
|
2020-12-01 23:20:38 +00:00
|
|
|
setCurrentMap(mapName: string) {
|
2020-11-23 12:13:28 +00:00
|
|
|
useStore().commit(MutationTypes.SET_CURRENT_MAP, {
|
2020-12-01 23:20:38 +00:00
|
|
|
worldName: this.world.name,
|
|
|
|
mapName
|
2020-11-23 12:13:28 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-12-01 23:20:38 +00:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.world {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
margin-bottom: .5rem;
|
2020-11-23 12:13:28 +00:00
|
|
|
|
2020-12-01 23:20:38 +00:00
|
|
|
.world__maps {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
margin-left: auto;
|
|
|
|
padding-left: 1rem;
|
|
|
|
padding-right: 0.2rem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.map {
|
|
|
|
width: 3.2rem;
|
|
|
|
height: 3.2rem;
|
|
|
|
|
|
|
|
button {
|
|
|
|
display: block;
|
|
|
|
height: 100%;
|
|
|
|
width: 100%;
|
|
|
|
border-radius: 0.5rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
& + .map {
|
|
|
|
margin-left: 0.5rem;
|
|
|
|
}
|
|
|
|
}
|
2020-12-13 02:52:28 +00:00
|
|
|
</style>
|