fix: fixes menus sounds

Fixes #96
Fixes #95
This commit is contained in:
Kazhnuz 2021-04-23 11:10:52 +02:00
parent 8abd42b020
commit 9ea2e659d3
5 changed files with 13 additions and 2 deletions

View file

@ -28,9 +28,11 @@ function CharacterScreen:update(dt)
local keys = self.scene:getKeys(1)
if (keys["left"].isPressed) then
self:setPage(self.pageIndex - 1)
self.scene.assets.sfx["mBeep"]:play()
end
if (keys["right"].isPressed) then
self:setPage(self.pageIndex + 1)
self.scene.assets.sfx["mBeep"]:play()
end
end
@ -66,6 +68,7 @@ function CharacterScreen:setMenu()
customMenu.isLocked = true
customMenu.isVisible = true
end
self.scene.menusystem:setSoundFromSceneAssets("mBeep")
end
function CharacterScreen:draw()

View file

@ -41,6 +41,7 @@ end
function Widget:action()
self.page:menuResponses(self.num)
self.scene.assets.sfx["mBeep"]:play()
end
return PageParent

View file

@ -11,6 +11,7 @@ local PLAYER_MESSAGE = 240 - 24
function StatPage:new(view, character)
StatPage.super.new(self, view, character, {"See skill"})
self.message = ""
self.showMessage = false
end
function StatPage:getCustomMenus()
@ -20,11 +21,12 @@ end
function StatPage:menuResponses(i)
if (#self.character.skills > 0) then
self.view.scene.menusystem:switchMenu("equip")
self.showMessage = true
end
end
function StatPage:drawOverEverything()
if (not utils.string.isEmpty(self.message)) then
if (not utils.string.isEmpty(self.message) and self.showMessage) then
love.graphics.setColor(0,0,0, 0.66)
love.graphics.rectangle("fill", 0, PLAYER_MESSAGE, 424, 16)
self.view.scene.assets.fonts["small"]:setColor(1,1,1, 1)
@ -52,7 +54,8 @@ end
function SkillMenu:cancelAction()
self.scene.menusystem.menus["menu"]:getFocus()
self.page:setMessage("")
self.page.showMessage = false
self.scene.assets.sfx["mBack"]:play()
end
function SkillWidget:new(page, skill)

View file

@ -60,6 +60,7 @@ end
function EquipMenu:cancelAction()
self.scene.menusystem.menus["menu"]:getFocus()
self.scene.assets.sfx["mBack"]:play()
end
function EquipWidget:new(page, type)
@ -82,6 +83,7 @@ function EquipWidget:action()
self.page:removeEquip(self.type)
self.label = self:getLabel()
self:redrawCanvas()
self.scene.assets.sfx["mSelect"]:play()
end
return StatPage

View file

@ -32,10 +32,12 @@ function ItemsScreen:update(dt)
if (keys["left"].isPressed) then
self.widgetIndex = 1
self:getMenu(self.menuIndex - 1)
self.scene.assets.sfx["mBeep"]:play()
end
if (keys["right"].isPressed) then
self.widgetIndex = 1
self:getMenu(self.menuIndex + 1)
self.scene.assets.sfx["mBeep"]:play()
end
end
end