可以设置失去焦点后自动静音 close #281
This commit is contained in:
@@ -10,6 +10,31 @@ local BGM={
|
|||||||
--playing=[src:playing SRC]
|
--playing=[src:playing SRC]
|
||||||
--lastPlayed=[str:lastPlayed ID]
|
--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)
|
function BGM.setDefault(bgm)
|
||||||
BGM.default=bgm
|
BGM.default=bgm
|
||||||
end
|
end
|
||||||
@@ -47,31 +72,6 @@ function BGM.init(list)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
function BGM.loadAll()for name in next,Sources do _load(name)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)
|
function BGM.play(name)
|
||||||
name=name or BGM.default
|
name=name or BGM.default
|
||||||
if not _load(name)then return end
|
if not _load(name)then return end
|
||||||
|
|||||||
@@ -390,12 +390,41 @@ function love.resize(w,h)
|
|||||||
|
|
||||||
SHADER.warning:send('w',w*SCR.dpi)
|
SHADER.warning:send('w',w*SCR.dpi)
|
||||||
end
|
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)
|
function love.focus(f)
|
||||||
if f then
|
if f then
|
||||||
love.timer.step()
|
love.timer.step()
|
||||||
elseif SCN.cur=='game'and SETTING.autoPause then
|
if SETTING.autoMute then
|
||||||
|
TASK.removeTask_code(task_autoSoundOff)
|
||||||
|
TASK.new(task_autoSoundOn)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if SCN.cur=='game'and SETTING.autoPause then
|
||||||
pauseGame()
|
pauseGame()
|
||||||
end
|
end
|
||||||
|
if SETTING.autoMute then
|
||||||
|
TASK.removeTask_code(task_autoSoundOn)
|
||||||
|
TASK.new(task_autoSoundOff)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local yield=coroutine.yield
|
local yield=coroutine.yield
|
||||||
|
|||||||
@@ -301,6 +301,7 @@ SETTING={--Settings
|
|||||||
warn=true,
|
warn=true,
|
||||||
|
|
||||||
--Sound
|
--Sound
|
||||||
|
autoMute=true,
|
||||||
mainVol=1,
|
mainVol=1,
|
||||||
sfx=1,
|
sfx=1,
|
||||||
sfx_spawn=0,
|
sfx_spawn=0,
|
||||||
|
|||||||
@@ -384,6 +384,7 @@ return{
|
|||||||
vib="Vibration",
|
vib="Vibration",
|
||||||
voc="Voice",
|
voc="Voice",
|
||||||
|
|
||||||
|
autoMute="Mute while unfocused",
|
||||||
fine="Finesse Error SFX",
|
fine="Finesse Error SFX",
|
||||||
cv="Voice Pack",
|
cv="Voice Pack",
|
||||||
apply="Apply",
|
apply="Apply",
|
||||||
|
|||||||
@@ -349,6 +349,7 @@ return{
|
|||||||
vib="Vibración",
|
vib="Vibración",
|
||||||
voc="Voces",
|
voc="Voces",
|
||||||
|
|
||||||
|
-- autoMute="Mute while unfocused",
|
||||||
fine="Sonido de Error de Finesse",
|
fine="Sonido de Error de Finesse",
|
||||||
cv="Pack de Voces",
|
cv="Pack de Voces",
|
||||||
apply="Aplicar",
|
apply="Aplicar",
|
||||||
|
|||||||
@@ -348,6 +348,7 @@ return{
|
|||||||
vib="Vibration",
|
vib="Vibration",
|
||||||
voc="Voix",
|
voc="Voix",
|
||||||
|
|
||||||
|
-- autoMute="Mute while unfocused",
|
||||||
fine="Son d'erreur de Finesse",
|
fine="Son d'erreur de Finesse",
|
||||||
-- cv="Voice Pack",
|
-- cv="Voice Pack",
|
||||||
-- apply="Apply",
|
-- apply="Apply",
|
||||||
|
|||||||
@@ -372,6 +372,7 @@ return{
|
|||||||
vib="Vibração",
|
vib="Vibração",
|
||||||
voc="Voz",
|
voc="Voz",
|
||||||
|
|
||||||
|
-- autoMute="Mute while unfocused",
|
||||||
fine="Som Falha de destreza",
|
fine="Som Falha de destreza",
|
||||||
cv="Pacote de voz",
|
cv="Pacote de voz",
|
||||||
apply="Aplicar",
|
apply="Aplicar",
|
||||||
|
|||||||
@@ -265,6 +265,7 @@ return{
|
|||||||
warn="!↑↑↑!",
|
warn="!↑↑↑!",
|
||||||
vib="=~=",
|
vib="=~=",
|
||||||
|
|
||||||
|
autoMute="#x#",
|
||||||
fine="12 X 21",
|
fine="12 X 21",
|
||||||
voc="~~~",
|
voc="~~~",
|
||||||
apply="!",
|
apply="!",
|
||||||
|
|||||||
@@ -383,6 +383,7 @@ return{
|
|||||||
vib="振动",
|
vib="振动",
|
||||||
voc="语音",
|
voc="语音",
|
||||||
|
|
||||||
|
autoMute="失去焦点自动静音",
|
||||||
fine="极简操作提示音",
|
fine="极简操作提示音",
|
||||||
cv="语音包",
|
cv="语音包",
|
||||||
apply="应用",
|
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="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.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.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},
|
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