From e0e7eaae103c6420606d6cfedee3606296598e2d Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 20 Apr 2019 18:09:24 +0200 Subject: [PATCH] examples/options: add sfx --- examples/menus/options/init.lua | 7 +++++++ examples/menus/options/widgets.lua | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/examples/menus/options/init.lua b/examples/menus/options/init.lua index d0c935f..533e414 100644 --- a/examples/menus/options/init.lua +++ b/examples/menus/options/init.lua @@ -31,6 +31,11 @@ function OptionsMenu:new() OptionsMenu.super.new(self) self.assets:addImageFont("medium", "examples/mainmenu/assets/medium") self.assets:setMusic("examples/menus/options/assets/music.ogg") + + self.assets:addSFX("navigate", "examples/mainmenu/assets/menu_move.mp3") + self.assets:addSFX("confirm", "examples/mainmenu/assets/menu_confirm.mp3") + self.assets:addSFX("cancel", "examples/mainmenu/assets/menu_error.mp3") + self.assets:playMusic() self:addMenu("main", true) @@ -54,6 +59,8 @@ function OptionsMenu:new() Widgets.Exit(self, "main") self.menusystem:switchMenu("main") + self.menusystem:setSoundFromSceneAssets("navigate") + self.keyDetector = {} self.keyDetector.widget = nil end diff --git a/examples/menus/options/widgets.lua b/examples/menus/options/widgets.lua index 7798dab..f072fd9 100644 --- a/examples/menus/options/widgets.lua +++ b/examples/menus/options/widgets.lua @@ -68,6 +68,7 @@ function widgets.SubMenu:new(scene, menu, newmenu, fullname, order, label2) end function widgets.SubMenu:action() + self.scene.assets:playSFX("confirm") self.scene.menusystem:switchMenu(self.newmenu) end @@ -95,6 +96,7 @@ function widgets.Exit:new(scene, menu) end function widgets.Exit:action() + self.scene.assets:playSFX("confirm") core.scenemanager:setStoredScene("mainmenu") end @@ -150,6 +152,7 @@ end function widgets.Switch:action() self:modifyKey() + self.scene.assets:playSFX("confirm") self.label2 = self:getLabel() core.options:write() self:invalidateCanvas() @@ -178,6 +181,7 @@ function widgets.Resolution:action() end self.label2 = self:getLabel() core.screen:applySettings() + self.scene.assets:playSFX("confirm") self:invalidateCanvas() core.options:write() end @@ -195,6 +199,7 @@ function widgets.Lang:new(scene, menu, lang) end function widgets.Lang:action() + self.scene.assets:playSFX("confirm") core.options:setLanguage(self.lang) --self.scene.menusystem:invalidateAllWidgets() end @@ -214,6 +219,7 @@ function widgets.PlayerSubMenu:new(scene, menu, sourceid) end function widgets.PlayerSubMenu:action() + self.scene.assets:playSFX("confirm") self.scene.menusystem:switchMenu(self.newmenu) end @@ -240,11 +246,13 @@ function widgets.Key:getLabel() end function widgets.Key:action() + self.scene.assets:playSFX("navigate") self.scene:changeKey(self) self.scene.menusystem:deactivate() end function widgets.Key:receiveKey( key ) + self.scene.assets:playSFX("confirm") core.options:setInputKey(self.source, self.key, key) self.label2 = self:getLabel() self:invalidateCanvas() @@ -305,6 +313,7 @@ end function widgets.Audio:action() local value = self:getVolume() self:setVolume(value - 20) + self.scene.assets:playSFX("confirm") self.scene.assets.music:setVolume(core.options.data.audio.music / 100) core.options:write() end