Skip to content

Commit

Permalink
Merge pull request #68 from RadKod/67
Browse files Browse the repository at this point in the history
feat: add app sound fx option
  • Loading branch information
selimdoyranli authored Mar 1, 2024
2 parents aa44bd5 + 20237a3 commit 36f7241
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 6 deletions.
11 changes: 11 additions & 0 deletions components/Dialog/MenuDialog/MenuDialog.component.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ Dialog.dialog.menu-dialog(
Cell.menu-dialog-nav__item(icon="eye-o" size="large" :title="$t('dialog.menu.darkTheme')")
template(#right-icon)
SwitchInput(v-model="isDark" size="22px" @change="toggleDarkTheme")
Cell.menu-dialog-nav__item(icon="music-o" size="large" :title="$t('dialog.menu.soundFx')")
template(#right-icon)
SwitchInput(v-model="isActiveSoundFx" size="22px" @change="toggleSoundFx")
Cell.menu-dialog-nav__item(
v-if="$route.path === localePath({ name: 'Main' })"
icon="font-o"
Expand Down Expand Up @@ -153,6 +156,12 @@ export default defineComponent({
}
}
const isActiveSoundFx = computed(() => store.getters['app/isActiveSoundFx'])
const toggleSoundFx = isChecked => {
store.commit('app/SET_IS_ACTIVE_SOUND_FX', isChecked)
}
const openSuggestQuestion = () => {
window.open(
'https://docs.google.com/forms/d/e/1FAIpQLSec4_MAFiDOjpd9pywfocFsfJQoXfMpLT3HIaHpO0Lz3clnaA/viewform?usp=sf_link',
Expand Down Expand Up @@ -217,6 +226,8 @@ export default defineComponent({
state,
isDark,
toggleDarkTheme,
isActiveSoundFx,
toggleSoundFx,
openSuggestQuestion,
openRoomSharer,
openAppSharer
Expand Down
41 changes: 35 additions & 6 deletions hooks/useGameScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,29 @@ export default () => {
}
})

const isActiveSoundFx = computed(() => store.getters['app/isActiveSoundFx'])

watch(
() => isActiveSoundFx.value,
value => {
if (value) {
startSoundFx.mute(false)
correctSoundFx.mute(false)
wrongSoundFx.mute(false)
passSoundFx.mute(false)
halfTimeSoundFx.mute(false)
radkodEasterEggSoundFx.mute(false)
} else {
startSoundFx.mute(true)
correctSoundFx.mute(true)
wrongSoundFx.mute(true)
passSoundFx.mute(true)
halfTimeSoundFx.mute(true)
radkodEasterEggSoundFx.mute(true)
}
}
)

const soundFx = reactive({
start: null,
correct: null,
Expand All @@ -325,27 +348,33 @@ export default () => {
})

const startSoundFx = new Howl({
src: [`${WEB_CDN}/assets/sound/fx/start.wav`]
src: [`${WEB_CDN}/assets/sound/fx/start.wav`],
mute: isActiveSoundFx.value ? false : true
})

const correctSoundFx = new Howl({
src: [`${WEB_CDN}/assets/sound/fx/correct.wav`]
src: [`${WEB_CDN}/assets/sound/fx/correct.wav`],
mute: isActiveSoundFx.value ? false : true
})

const wrongSoundFx = new Howl({
src: [`${WEB_CDN}/assets/sound/fx/wrong.wav`]
src: [`${WEB_CDN}/assets/sound/fx/wrong.wav`],
mute: isActiveSoundFx.value ? false : true
})

const passSoundFx = new Howl({
src: [`${WEB_CDN}/assets/sound/fx/pass.wav`]
src: [`${WEB_CDN}/assets/sound/fx/pass.wav`],
mute: isActiveSoundFx.value ? false : true
})

const halfTimeSoundFx = new Howl({
src: [`${WEB_CDN}/assets/sound/fx/half-time.wav`]
src: [`${WEB_CDN}/assets/sound/fx/half-time.wav`],
mute: isActiveSoundFx.value ? false : true
})

const radkodEasterEggSoundFx = new Howl({
src: [`${WEB_CDN}/assets/sound/fx/radkod-easter-egg.mp3`]
src: [`${WEB_CDN}/assets/sound/fx/radkod-easter-egg.mp3`],
mute: isActiveSoundFx.value ? false : true
})

soundFx.start = startSoundFx
Expand Down
1 change: 1 addition & 0 deletions locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export default {
usernameEdit: 'Change the player name',
menu: 'Menu',
darkTheme: 'Dark theme',
soundFx: 'Sound fx',
switchLocale: 'Choose language',
suggestQa: 'Do you want to suggest a question?',
howToPLay: 'How to play?',
Expand Down
1 change: 1 addition & 0 deletions locales/tr.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export default {
usernameEdit: 'Oyuncu adını değiştir',
menu: 'Menü',
darkTheme: 'Koyu tema',
soundFx: 'Ses efekleri',
switchLocale: 'Dil değiştir',
suggestQa: 'Soru önermek ister misin?',
howToPLay: 'Nasıl oynanır?',
Expand Down
3 changes: 3 additions & 0 deletions plugins/vuex-persist.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export default ({ store }) => {
username: state.auth.user.username
}
},
app: {
soundFx: state.app.soundFx
},
daily: {
isGameOver: state.daily.isGameOver,
currentDate: state.daily.currentDate,
Expand Down
1 change: 1 addition & 0 deletions store/app/actions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {}
8 changes: 8 additions & 0 deletions store/app/getters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
root(state) {
return state
},
isActiveSoundFx(state) {
return state.soundFx.isActive
}
}
5 changes: 5 additions & 0 deletions store/app/mutations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
SET_IS_ACTIVE_SOUND_FX(state, isActive) {
state.soundFx.isActive = isActive
}
}
5 changes: 5 additions & 0 deletions store/app/state.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default () => ({
soundFx: {
isActive: true
}
})

0 comments on commit 36f7241

Please sign in to comment.