From 7fa547c307100e53d0f19f96ebf1072a105c4285 Mon Sep 17 00:00:00 2001 From: Ishaan Bhardwaj Date: Mon, 20 Sep 2021 23:33:27 -0400 Subject: [PATCH] Two quick changes (read comments) Added mouse wheel support to the mode select menu BGM now interatcs with pausing correctly --- load/bgm.lua | 14 +++++++++++--- main.lua | 10 +++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/load/bgm.lua b/load/bgm.lua index 2eb03c6..9e28b94 100644 --- a/load/bgm.lua +++ b/load/bgm.lua @@ -7,6 +7,7 @@ bgm = { local current_bgm = nil local bgm_locked = false +local unfocused = false function switchBGM(sound, subsound) if current_bgm ~= nil then @@ -56,7 +57,7 @@ end function resetBGMFadeout(time) current_bgm:setVolume(config.bgm_volume) fading_bgm = false - current_bgm:play() + resumeBGM() end function processBGMFadeout(dt) @@ -70,13 +71,20 @@ function processBGMFadeout(dt) end end -function pauseBGM() +function pauseBGM(f) + if f then + unfocused = true + end if current_bgm ~= nil then current_bgm:pause() end end -function resumeBGM() +function resumeBGM(f) + if f and scene.paused and unfocused then + unfocused = false + return + end if current_bgm ~= nil then current_bgm:play() end diff --git a/main.lua b/main.lua index 4c8c67e..0c23970 100644 --- a/main.lua +++ b/main.lua @@ -259,11 +259,15 @@ function love.joystickhat(joystick, hat, direction) end end +function love.wheelmoved(x, y) + scene:onInputPress({input=nil, type="wheel", x=x, y=y}) +end + function love.focus(f) - if f and (scene.title ~= "Game" or not scene.paused) then - resumeBGM() + if f then + resumeBGM(true) else - pauseBGM() + pauseBGM(true) end end