可以设置失去焦点后自动静音 close #281
This commit is contained in:
@@ -10,6 +10,31 @@ local BGM={
|
||||
--playing=[src:playing SRC]
|
||||
--lastPlayed=[str:lastPlayed ID]
|
||||
}
|
||||
local function task_fadeOut(src)
|
||||
while true do
|
||||
coroutine.yield()
|
||||
local v=src:getVolume()-.025*SETTING.bgm
|
||||
src:setVolume(v>0 and v or 0)
|
||||
if v<=0 then
|
||||
src:pause()
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
local function task_fadeIn(src)
|
||||
while true do
|
||||
coroutine.yield()
|
||||
local v=SETTING.bgm
|
||||
v=math.min(v,src:getVolume()+.025*v)
|
||||
src:setVolume(v)
|
||||
if v>=SETTING.bgm then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
local function check_curFadeOut(task,code,src)
|
||||
return task.code==code and task.args[1]==src
|
||||
end
|
||||
function BGM.setDefault(bgm)
|
||||
BGM.default=bgm
|
||||
end
|
||||
@@ -47,31 +72,6 @@ function BGM.init(list)
|
||||
end
|
||||
end
|
||||
function BGM.loadAll()for name in next,Sources do _load(name)end end
|
||||
local function task_fadeOut(src)
|
||||
while true do
|
||||
coroutine.yield()
|
||||
local v=src:getVolume()-.025*SETTING.bgm
|
||||
src:setVolume(v>0 and v or 0)
|
||||
if v<=0 then
|
||||
src:pause()
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
local function task_fadeIn(src)
|
||||
while true do
|
||||
coroutine.yield()
|
||||
local v=SETTING.bgm
|
||||
v=math.min(v,src:getVolume()+.025*v)
|
||||
src:setVolume(v)
|
||||
if v>=SETTING.bgm then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
local function check_curFadeOut(task,code,src)
|
||||
return task.code==code and task.args[1]==src
|
||||
end
|
||||
function BGM.play(name)
|
||||
name=name or BGM.default
|
||||
if not _load(name)then return end
|
||||
|
||||
@@ -390,11 +390,40 @@ function love.resize(w,h)
|
||||
|
||||
SHADER.warning:send('w',w*SCR.dpi)
|
||||
end
|
||||
local function task_autoSoundOff()
|
||||
while true do
|
||||
coroutine.yield()
|
||||
local v=love.audio.getVolume()
|
||||
love.audio.setVolume(math.max(v-.01,0))
|
||||
if v==0 then return end
|
||||
end
|
||||
end
|
||||
local function task_autoSoundOn()
|
||||
while true do
|
||||
coroutine.yield()
|
||||
local v=love.audio.getVolume()
|
||||
if v<SETTING.mainVol then
|
||||
love.audio.setVolume(math.min(v+.01,SETTING.mainVol,1))
|
||||
else
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
function love.focus(f)
|
||||
if f then
|
||||
love.timer.step()
|
||||
elseif SCN.cur=='game'and SETTING.autoPause then
|
||||
pauseGame()
|
||||
if SETTING.autoMute then
|
||||
TASK.removeTask_code(task_autoSoundOff)
|
||||
TASK.new(task_autoSoundOn)
|
||||
end
|
||||
else
|
||||
if SCN.cur=='game'and SETTING.autoPause then
|
||||
pauseGame()
|
||||
end
|
||||
if SETTING.autoMute then
|
||||
TASK.removeTask_code(task_autoSoundOn)
|
||||
TASK.new(task_autoSoundOff)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -301,6 +301,7 @@ SETTING={--Settings
|
||||
warn=true,
|
||||
|
||||
--Sound
|
||||
autoMute=true,
|
||||
mainVol=1,
|
||||
sfx=1,
|
||||
sfx_spawn=0,
|
||||
|
||||
@@ -384,6 +384,7 @@ return{
|
||||
vib="Vibration",
|
||||
voc="Voice",
|
||||
|
||||
autoMute="Mute while unfocused",
|
||||
fine="Finesse Error SFX",
|
||||
cv="Voice Pack",
|
||||
apply="Apply",
|
||||
|
||||
@@ -349,6 +349,7 @@ return{
|
||||
vib="Vibración",
|
||||
voc="Voces",
|
||||
|
||||
-- autoMute="Mute while unfocused",
|
||||
fine="Sonido de Error de Finesse",
|
||||
cv="Pack de Voces",
|
||||
apply="Aplicar",
|
||||
|
||||
@@ -348,6 +348,7 @@ return{
|
||||
vib="Vibration",
|
||||
voc="Voix",
|
||||
|
||||
-- autoMute="Mute while unfocused",
|
||||
fine="Son d'erreur de Finesse",
|
||||
-- cv="Voice Pack",
|
||||
-- apply="Apply",
|
||||
|
||||
@@ -372,6 +372,7 @@ return{
|
||||
vib="Vibração",
|
||||
voc="Voz",
|
||||
|
||||
-- autoMute="Mute while unfocused",
|
||||
fine="Som Falha de destreza",
|
||||
cv="Pacote de voz",
|
||||
apply="Aplicar",
|
||||
|
||||
@@ -265,6 +265,7 @@ return{
|
||||
warn="!↑↑↑!",
|
||||
vib="=~=",
|
||||
|
||||
autoMute="#x#",
|
||||
fine="12 X 21",
|
||||
voc="~~~",
|
||||
apply="!",
|
||||
|
||||
@@ -383,6 +383,7 @@ return{
|
||||
vib="振动",
|
||||
voc="语音",
|
||||
|
||||
autoMute="失去焦点自动静音",
|
||||
fine="极简操作提示音",
|
||||
cv="语音包",
|
||||
apply="应用",
|
||||
|
||||
@@ -84,6 +84,7 @@ scene.widgetList={
|
||||
WIDGET.newSlider{name="vib", x=300, y=590,w=420,color='lN',unit=10,change=function()VIB(2)end,disp=SETval('vib'),code=SETsto('vib')},
|
||||
WIDGET.newSlider{name="voc", x=300, y=660,w=420,color='lN',change=function()VOC.play('test')end,disp=SETval('voc'),code=SETsto('voc')},
|
||||
|
||||
WIDGET.newSwitch{name="autoMute",x=1150,y=190,disp=SETval('autoMute'),code=SETrev('autoMute')},
|
||||
WIDGET.newSwitch{name="fine", x=1150,y=270,disp=SETval('fine'),code=function()SETTING.fine=not SETTING.fine if SETTING.fine then SFX.play('finesseError',.6)end end},
|
||||
|
||||
WIDGET.newSelector{name="cv", x=1100,y=380,w=200,list={'miya','naki','xiaoya','miku'},disp=function()return cv end,code=function(i)cv=i end},
|
||||
|
||||
Reference in New Issue
Block a user