Cape preview

This commit is contained in:
Prospector
2025-05-13 13:32:22 -07:00
committed by Alejandro González
parent 161dc73d5d
commit 5a8bbae244
3 changed files with 25 additions and 9 deletions

View File

@@ -1,11 +1,6 @@
<script setup lang="ts">
import { ref, computed } from 'vue'
import { ButtonStyled, commonMessages } from '@modrinth/ui'
import { EditIcon } from '@modrinth/assets'
import { useVIntl } from '@vintl/vintl'
import type { Cape, Skin } from '@/helpers/skins.ts'
const { formatMessage } = useVIntl()
import { computed } from 'vue'
import type { Cape } from '@/helpers/skins.ts'
const emit = defineEmits<{
(e: 'select'): void

View File

@@ -4,7 +4,7 @@ import { computed, useTemplateRef } from 'vue'
const modal = useTemplateRef('modal')
const previewSkin = computed(() => `https://vzge.me/full/350/ProspectorDev.png?no=ears&y=180`)
const previewSkin = computed(() => `https://vzge.me/full/350/ProspectorDev.png?no=ears`)
function show(e: MouseEvent) {
modal.value?.show(e)

View File

@@ -20,7 +20,28 @@ const props = defineProps<{
const currentSkin = ref<string | undefined>()
const currentCape = ref<Cape | undefined>()
const previewSkin = computed(() => currentSkin.value ? `https://vzge.me/full/350/${currentSkin.value}.png?no=ears&y=180` : undefined)
const mcUrlRegex = /texture\/([a-fA-F0-9]+)$/
const textureId = computed(() => {
if (!currentCape.value) {
return undefined
}
const mcTextureMatch = currentCape.value.texture.match(mcUrlRegex)
if (mcTextureMatch) {
return mcTextureMatch[1]
} else {
return undefined;
}
})
const capeParams = computed(() => {
return textureId.value ? `&replacecape=${textureId.value}` : ``
})
const previewSkin = computed(() => currentSkin.value ? `https://vzge.me/full/350/${currentSkin.value}.png?no=ears&y=180${capeParams.value}` : undefined)
function show(e: MouseEvent, skin?: string, selected?: Cape) {
currentSkin.value = skin