diff --git a/src/components/screens/Characters.vue b/src/components/screens/Characters.vue index 68869c5..2994d1c 100644 --- a/src/components/screens/Characters.vue +++ b/src/components/screens/Characters.vue @@ -22,7 +22,7 @@
@@ -40,22 +40,27 @@ - - - - - - - - - - - +
+ + +
+
+ Hair color +
+ +
+
Hairstyle
@@ -65,9 +70,8 @@ Empty button
-
Hair sprite @@ -75,13 +79,6 @@
-
- Hair color -
- - -
-
@@ -89,7 +86,6 @@
Loading
-
@@ -129,7 +125,7 @@ import { useSoundComposable } from '@/composables/useSoundComposable' import { socketManager } from '@/managers/SocketManager' import { CharacterHairStorage } from '@/storage/storages' import { useGameStore } from '@/stores/gameStore' -import { onBeforeUnmount, onMounted, ref, watch } from 'vue' +import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue' const { playSound } = useSoundComposable() const gameStore = useGameStore() @@ -141,6 +137,31 @@ const newCharacterName = ref('') const characterHairs = ref([]) const selectedHairId = ref(null) +const selectedHairColor = ref(null) +const uniqueHairColors = computed(() => { + return [...new Set(characterHairs.value.map((hair) => hair.color))] +}) + +const filteredHairs = computed(() => { + if (!selectedHairColor.value) return characterHairs.value + return characterHairs.value.filter((hair) => hair.color === selectedHairColor.value) +}) + +function handleHairColorChange(color: string | null) { + selectedHairColor.value = color + // Reset hair selection if the current selection doesn't exist in filtered results + if (!filteredHairs.value.find((hair) => hair.id === selectedHairId.value)) { + selectedHairId.value = null + } +} + +function getHairColorStyle(color: string | null) { + return { + backgroundColor: color, + border: selectedHairColor.value === color ? '1px solid white' : '1px solid rgba(255, 255, 255, 0.2)' + } +} + // Fetch characters setTimeout(() => { socketManager.emit(SocketEvent.CHARACTER_LIST) @@ -151,7 +172,6 @@ socketManager.on(SocketEvent.CHARACTER_LIST, (data: any) => { isLoading.value = false }) -// Select character logics function loginWithCharacter() { if (!selectedCharacterId.value) return