1
0
forked from noxious/client

#209 : Improved logic for button presses

This commit is contained in:
2025-02-06 21:20:49 +01:00
parent 557b8aaabb
commit 6383320e8c
4 changed files with 15 additions and 12 deletions

View File

@ -16,11 +16,10 @@ import MapEditor from '@/components/screens/MapEditor.vue'
import BackgroundImageLoader from '@/components/utilities/BackgroundImageLoader.vue'
import Debug from '@/components/utilities/Debug.vue'
import Notifications from '@/components/utilities/Notifications.vue'
import { useGameComposable } from '@/composables/useGameComposable'
import { useMapEditorComposable } from '@/composables/useMapEditorComposable'
import { useGameStore } from '@/stores/gameStore'
import { useMapEditorStore } from '@/stores/mapEditorStore'
import { computed, ref, useTemplateRef, watch } from 'vue'
import { useGameComposable } from '@/composables/useGameComposable'
import { computed, watch } from 'vue'
const gameStore = useGameStore()
@ -45,9 +44,13 @@ watch(
)
// #209: Play sound when a button is pressed
// @TODO: Not all button-like elements will actually be a button, so we need to find a better way to do this
addEventListener('click', (event) => {
if (!(event.target instanceof HTMLButtonElement)) return
const classList = ['btn-cyan', 'btn-red', 'btn-indigo', 'btn-empty', 'btn-sound']
const target = event.target as HTMLElement
// console.log(target) // Uncomment to log the clicked element
if (!classList.some((className) => target.classList.contains(className))) {
return // Only play sound if the clicked element is a button
}
playSound('/assets/sounds/button-click.wav')
})