Skip to content

Commit 66095c1

Browse files
committed
Cape preview
1 parent 0ce8adc commit 66095c1

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

apps/app-frontend/src/components/ui/skin/CapeButton.vue

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
<script setup lang="ts">
2-
import { ref, computed } from 'vue'
3-
import { ButtonStyled, commonMessages } from '@modrinth/ui'
4-
import { EditIcon } from '@modrinth/assets'
5-
import { useVIntl } from '@vintl/vintl'
6-
import type { Cape, Skin } from '@/helpers/skins.ts'
7-
8-
const { formatMessage } = useVIntl()
2+
import { computed } from 'vue'
3+
import type { Cape } from '@/helpers/skins.ts'
94
105
const emit = defineEmits<{
116
(e: 'select'): void

apps/app-frontend/src/components/ui/skin/EditSkinModal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { computed, useTemplateRef } from 'vue'
44
55
const modal = useTemplateRef('modal')
66
7-
const previewSkin = computed(() => `https://vzge.me/full/350/ProspectorDev.png?no=ears&y=180`)
7+
const previewSkin = computed(() => `https://vzge.me/full/350/ProspectorDev.png?no=ears`)
88
99
function show(e: MouseEvent) {
1010
modal.value?.show(e)

apps/app-frontend/src/components/ui/skin/SelectCapeModal.vue

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,28 @@ const props = defineProps<{
2020
const currentSkin = ref<string | undefined>()
2121
const currentCape = ref<Cape | undefined>()
2222
23-
const previewSkin = computed(() => currentSkin.value ? `https://vzge.me/full/350/${currentSkin.value}.png?no=ears&y=180` : undefined)
23+
const mcUrlRegex = /texture\/([a-fA-F0-9]+)$/
24+
25+
const textureId = computed(() => {
26+
if (!currentCape.value) {
27+
return undefined
28+
}
29+
30+
const mcTextureMatch = currentCape.value.texture.match(mcUrlRegex)
31+
32+
if (mcTextureMatch) {
33+
return mcTextureMatch[1]
34+
} else {
35+
return undefined;
36+
}
37+
})
38+
39+
40+
const capeParams = computed(() => {
41+
return textureId.value ? `&replacecape=${textureId.value}` : ``
42+
})
43+
44+
const previewSkin = computed(() => currentSkin.value ? `https://vzge.me/full/350/${currentSkin.value}.png?no=ears&y=180${capeParams.value}` : undefined)
2445
2546
function show(e: MouseEvent, skin?: string, selected?: Cape) {
2647
currentSkin.value = skin

0 commit comments

Comments
 (0)