fix: add sound to every menus

Fixes #85
This commit is contained in:
Kazhnuz 2021-04-11 10:32:49 +02:00
parent 34e2bbead7
commit ddcd393d2a
13 changed files with 41 additions and 10 deletions

View file

@ -70,6 +70,7 @@ function fancy.SubMenuWidget:new(scene, menu_name, newmenu, label)
end end
function fancy.SubMenuWidget:action() function fancy.SubMenuWidget:action()
self.scene.assets:playSFX("mBeep")
self.scene.menusystem:switchMenu(self.newmenu) self.scene.menusystem:switchMenu(self.newmenu)
self.scene.menusystem.menus[self.newmenu]:activationAction() self.scene.menusystem.menus[self.newmenu]:activationAction()
end end

View file

@ -155,6 +155,7 @@ function list.SubMenuWidget:new(scene, menu_name, newmenu, label)
end end
function list.SubMenuWidget:action() function list.SubMenuWidget:action()
self.scene.assets:playSFX("mBeep")
self.scene.menusystem:switchMenu(self.newmenu) self.scene.menusystem:switchMenu(self.newmenu)
self.scene.menusystem.menus[self.newmenu]:activationAction() self.scene.menusystem.menus[self.newmenu]:activationAction()
end end

View file

@ -60,6 +60,7 @@ function menu.SceneWidget:new(scene, menuName, newScene, newSceneName, sceneArgu
end end
function menu.SceneWidget:action() function menu.SceneWidget:action()
self.scene.assets:playSFX("mSelect")
self.scene:flushKeys() self.scene:flushKeys()
if (self.sceneArgument ~= nil) then if (self.sceneArgument ~= nil) then
core.screen:startTransition(defTransitions.default, defTransitions.default, core.screen:startTransition(defTransitions.default, defTransitions.default,

View file

@ -13,17 +13,19 @@ local TweenManager = require "game.modules.tweenmanager"
function DebugMenu:new() function DebugMenu:new()
DebugMenu.super.new(self) DebugMenu.super.new(self)
self.assets:batchImport("scenes.debug.commons.assets") self.assets:batchImport("scenes.menus.assets")
menu.commons.MainMenu(self, "BaseMenu") menu.commons.MainMenu(self, "BaseMenu")
menu.StartGameWidget(self, "BaseMenu") menu.StartGameWidget(self, "BaseMenu")
menu.commons.SceneWidget(self, "BaseMenu", scenes.options, "Options") menu.commons.SceneWidget(self, "BaseMenu", scenes.options, "Options")
self:buildDebugMenu() self:buildDebugMenu()
menu.TitleWidget(self, "BaseMenu") menu.TitleWidget(self, "BaseMenu")
self.menusystem.menus["BaseMenu"]:setCancelWidget()
menu.ExitWidget(self, "BaseMenu") menu.ExitWidget(self, "BaseMenu")
self.menusystem.menus["BaseMenu"]:finalize() self.menusystem.menus["BaseMenu"]:finalize()
self.menusystem:activate() self.menusystem:activate()
self.menusystem:switchMenu("BaseMenu") self.menusystem:switchMenu("BaseMenu")
self.menusystem:setSoundFromSceneAssets("mBeep")
self.panel = panels.Gamedata() self.panel = panels.Gamedata()

View file

@ -27,6 +27,7 @@ function menu.StartGameWidget:new(scene, menuName)
end end
function menu.StartGameWidget:action() function menu.StartGameWidget:action()
self.scene.assets:playSFX("mSelect")
core.screen:startTransition(defTransitions.circle, defTransitions.default, function() scenes.overworld() end, 424/2, 240/2) core.screen:startTransition(defTransitions.circle, defTransitions.default, function() scenes.overworld() end, 424/2, 240/2)
self.scene.tweens:newTween(0, 0.5, {borderY = 0}, "inOutQuart") self.scene.tweens:newTween(0, 0.5, {borderY = 0}, "inOutQuart")
end end
@ -37,6 +38,7 @@ function menu.TitleWidget:new(scene, menuName)
end end
function menu.TitleWidget:action() function menu.TitleWidget:action()
self.scene.assets:playSFX("mBack")
core.screen:startTransition(defTransitions.circle, radTransitions.borders, function() scenes.title(true) end, 424/2, 240/2) core.screen:startTransition(defTransitions.circle, radTransitions.borders, function() scenes.title(true) end, 424/2, 240/2)
end end
@ -46,6 +48,7 @@ function menu.ExitWidget:new(scene, menuName)
end end
function menu.ExitWidget:action() function menu.ExitWidget:action()
self.scene.assets:playSFX("mSelect")
love.event.quit("000") love.event.quit("000")
end end

View file

@ -10,7 +10,7 @@ return {
{"small", "assets/gui/fonts/PixelOperator.ttf", 16} {"small", "assets/gui/fonts/PixelOperator.ttf", 16}
}, },
["imagefonts"] = { ["imagefonts"] = {
{"medium", "assets/gui/fonts/SA2font"}, {"title", "assets/gui/fonts/SA2font"},
}, },
["sfx"] = { ["sfx"] = {
{"mBack", "assets/sfx/menus/back.wav"}, {"mBack", "assets/sfx/menus/back.wav"},

View file

@ -10,7 +10,7 @@ local MenuBack = require "game.modules.gui.menuback"
function OptionsMenu:new() function OptionsMenu:new()
OptionsMenu.super.new(self) OptionsMenu.super.new(self)
self.assets:batchImport("scenes.menus.options.assets") self.assets:batchImport("scenes.menus.assets")
self:addMenu("main", true) self:addMenu("main", true)
self:addSubMenu("video", "Video") self:addSubMenu("video", "Video")
self:addSubMenu("audio", "Audio") self:addSubMenu("audio", "Audio")

View file

@ -37,9 +37,8 @@ function TitleScreen:new(fromMenu)
local fromMenu = (fromMenu == true) local fromMenu = (fromMenu == true)
self.borders = gui.newBorder(424, 30, 8) self.borders = gui.newBorder(424, 30, 8)
self.assets:batchImport("scenes.menus.assets")
self.assets:addImage("logo", "assets/artworks/logo.png") self.assets:addImage("logo", "assets/artworks/logo.png")
self.assets:addImageFont("menu", "assets/gui/fonts/SA2font")
self.assets:addFont("small", "assets/gui/fonts/PixelOperator.ttf", 16)
self.assets:addTileset("charicons", "assets/sprites/characters/charicons") self.assets:addTileset("charicons", "assets/sprites/characters/charicons")
self.assets.fonts["small"]:setLineHeight(16/18) self.assets.fonts["small"]:setLineHeight(16/18)
self.assets.fonts["small"]:setFilter("shadow") self.assets.fonts["small"]:setFilter("shadow")
@ -86,9 +85,11 @@ function TitleScreen:update(dt)
end end
local keys = self:getKeys(1) local keys = self:getKeys(1)
if (keys["start"].isPressed and (self.haveMenu == false)) then if (keys["start"].isPressed and (self.haveMenu == false)) then
self.assets:playSFX("mSelect")
Menu(self) Menu(self)
self.haveMenu = true self.haveMenu = true
self.menusystem:setSoundFromSceneAssets("mBeep")
end end
end end
@ -107,8 +108,8 @@ function TitleScreen:draw()
self.assets:drawImage("logo", 240 - 32, 80 - self.logoX, 0, 1, 1, w/2, h/2) self.assets:drawImage("logo", 240 - 32, 80 - self.logoX, 0, 1, 1, w/2, h/2)
if (self.canShowPressStart) and (self.showPressStart) then if (self.canShowPressStart) and (self.showPressStart) then
local w = self.assets.fonts["menu"]:getWidth("PRESS START") local w = self.assets.fonts["title"]:getWidth("PRESS START")
self.assets.fonts["menu"]:print("PRESS START", 424/2, 240/1.33, "center", 0, 1, 1) self.assets.fonts["title"]:print("PRESS START", 424/2, 240/1.33, "center", 0, 1, 1)
end end
love.graphics.setColor(1, 1, 1, self.flashOpacity) love.graphics.setColor(1, 1, 1, self.flashOpacity)

View file

@ -24,6 +24,7 @@ function SaveMenu:new(scene)
end end
function SaveMenu:cancelAction() function SaveMenu:cancelAction()
self.scene.assets:playSFX("mBack")
self.scene.menusystem:reset() self.scene.menusystem:reset()
self.scene.haveMenu = false self.scene.haveMenu = false
end end
@ -61,6 +62,7 @@ function SaveWidget:drawCanvas()
end end
function SaveWidget:action() function SaveWidget:action()
self.scene.assets:playSFX("mSelect")
game:read(self.saveid) game:read(self.saveid)
core.screen:startTransition(radTransitions.borders, defTransitions.circle, function() scenes.debug.menu() end, 424/2, 240/2) core.screen:startTransition(radTransitions.borders, defTransitions.circle, function() scenes.debug.menu() end, 424/2, 240/2)
end end

View file

@ -86,6 +86,7 @@ function ReturnWidget:action()
self.widgetSelected = i self.widgetSelected = i
end end
end end
self.scene.assets:playSFX("mBack")
self.scene.screens.mainmenu["pause"](self.scene, "character", self.widgetSelected) self.scene.screens.mainmenu["pause"](self.scene, "character", self.widgetSelected)
end end

View file

@ -66,6 +66,7 @@ function ItemsScreen:setMenu(widgetId)
self.scene.menusystem.menus["menu"].isLocked = true self.scene.menusystem.menus["menu"].isLocked = true
self.scene.menusystem.menus["menu"].widget.selected = math.max(1, self.widgetIndex) self.scene.menusystem.menus["menu"].widget.selected = math.max(1, self.widgetIndex)
self.scene.menusystem.menus["menu"].cursorTransition = math.max(0, self.widgetIndex - 1) self.scene.menusystem.menus["menu"].cursorTransition = math.max(0, self.widgetIndex - 1)
self.scene.menusystem:setSoundFromSceneAssets("mBeep")
end end
function ItemsScreen:setUseMenu(item, widgetId) function ItemsScreen:setUseMenu(item, widgetId)
@ -150,7 +151,8 @@ function ItemWidget:selectAction()
self.scene.currentScreen.effects = game.loot:getEffectStrings(self.pocket, self.item.name) self.scene.currentScreen.effects = game.loot:getEffectStrings(self.pocket, self.item.name)
end end
function ItemWidget:action() function ItemWidget:action()
self.scene.assets:playSFX("mSelect")
self.scene.currentScreen:setUseMenu(self.item, self.widgetId) self.scene.currentScreen:setUseMenu(self.item, self.widgetId)
end end
@ -164,6 +166,7 @@ function BackWidget:selectAction()
end end
function BackWidget:action() function BackWidget:action()
self.scene.assets:playSFX("mBack")
self.scene.screens.mainmenu["pause"](self.scene, "main", 3) self.scene.screens.mainmenu["pause"](self.scene, "main", 3)
end end
@ -183,6 +186,9 @@ end
function UseWidget:action() function UseWidget:action()
if (self.itemData.usableOnMap) then if (self.itemData.usableOnMap) then
self.scene.screens.mainmenu["useItems"](self.scene, self.pocket, self.item, self.widgetId) self.scene.screens.mainmenu["useItems"](self.scene, self.pocket, self.item, self.widgetId)
self.scene.assets:playSFX("mSelect")
else
self.scene.assets:playSFX("mError")
end end
end end
@ -219,6 +225,7 @@ function DropWidget:updateSelected()
end end
function DropWidget:action() function DropWidget:action()
self.scene.assets:playSFX("mSelect")
game.loot:removeItem(self.pocket, self.item.name, self.number) game.loot:removeItem(self.pocket, self.item.name, self.number)
self.scene.currentScreen.widgetIndex = self.widgetId self.scene.currentScreen.widgetIndex = self.widgetId
self.scene.currentScreen:removeUseMenu() self.scene.currentScreen:removeUseMenu()
@ -230,6 +237,7 @@ function ResumeWidget:new(scene)
end end
function ResumeWidget:action() function ResumeWidget:action()
self.scene.assets:playSFX("mBack")
self.scene.currentScreen:removeUseMenu() self.scene.currentScreen:removeUseMenu()
end end

View file

@ -54,6 +54,7 @@ function PauseScreen:setMenu()
self.scene.menusystem.menus[self.menuSelected].widget.selected = self.widgetSelected self.scene.menusystem.menus[self.menuSelected].widget.selected = self.widgetSelected
self.scene.menusystem.menus[self.menuSelected].cursorTransition = self.widgetSelected - 1 self.scene.menusystem.menus[self.menuSelected].cursorTransition = self.widgetSelected - 1
end end
self.scene.menusystem:setSoundFromSceneAssets("mBeep")
end end
function PauseScreen:draw() function PauseScreen:draw()
@ -62,12 +63,14 @@ end
-- Character menu -- Character menu
function CharacterMenu:cancelAction() function CharacterMenu:cancelAction()
self.scene.assets:playSFX("mBeep")
self.scene.menusystem:switchMenu("main") self.scene.menusystem:switchMenu("main")
end end
-- Hero custom widget -- Hero custom widget
-- --
function CharacterWidget:action() function CharacterWidget:action()
self.scene.assets:playSFX("mSelect")
self.scene.screens.mainmenu.character(self.scene, self.charName) self.scene.screens.mainmenu.character(self.scene, self.charName)
end end
@ -79,6 +82,7 @@ function TeamWidget:new(scene)
end end
function TeamWidget:action() function TeamWidget:action()
self.scene.assets:playSFX("mBeep")
self.scene.menusystem.menus["character"]:getFocus() self.scene.menusystem.menus["character"]:getFocus()
end end
@ -89,6 +93,7 @@ function ViewWidget:new(scene, name, view)
end end
function ViewWidget:action() function ViewWidget:action()
self.scene.assets:playSFX("mSelect")
self.scene.screens.mainmenu[self.nextView](self.scene) self.scene.screens.mainmenu[self.nextView](self.scene)
end end
@ -100,12 +105,16 @@ function SaveExitWidget:new(scene, menu, name, save, exit)
end end
function SaveExitWidget:action() function SaveExitWidget:action()
if (self.save or self.exit) then
self.scene.assets:playSFX("mSelect")
else
self.scene.assets:playSFX("mBack")
end
if (self.save) then if (self.save) then
self.scene.world:savePosition() self.scene.world:savePosition()
game:write() game:write()
end end
if (self.exit) then if (self.exit) then
core.screen:startTransition(defTransitions.default, defTransitions.circle, function() scenes.debug.menu() end, 424/2, 240/2) core.screen:startTransition(defTransitions.default, defTransitions.circle, function() scenes.debug.menu() end, 424/2, 240/2)
self.scene.tweens:newTween(0, 0.3, {ringBorder=-16}, "inOutQuad") self.scene.tweens:newTween(0, 0.3, {ringBorder=-16}, "inOutQuad")
self.scene.tweens:newTween(0, 0.3, {timeBorder=-20}, "inOutQuad") self.scene.tweens:newTween(0, 0.3, {timeBorder=-20}, "inOutQuad")

View file

@ -77,12 +77,14 @@ end
-- Character menu -- Character menu
function CharacterMenu:cancelAction() function CharacterMenu:cancelAction()
-- Switch à l'écran précédant -- Switch à l'écran précédant
self.scene.assets:playSFX("mBack")
self.scene.currentScreen:goBack() self.scene.currentScreen:goBack()
end end
-- Hero custom widget -- Hero custom widget
-- --
function CharacterWidget:action() function CharacterWidget:action()
self.scene.assets:playSFX("mSelect")
self.scene.currentScreen:useItem(self.charName) self.scene.currentScreen:useItem(self.charName)
end end