多语音包系统实装,等待naki语音

This commit is contained in:
MrZ626
2020-11-03 21:55:41 +08:00
parent 477d27f264
commit c688fef3f6
6 changed files with 28 additions and 22 deletions

View File

@@ -242,6 +242,8 @@ return{
bgm="BGM", bgm="BGM",
vib="Vibration", vib="Vibration",
voc="Voice", voc="Voice",
cv="Voice Pack",
apply="Apply",
}, },
setting_control={ setting_control={
title="Control Settings", title="Control Settings",

View File

@@ -86,7 +86,7 @@ return{
spawn="出块", spawn="出块",
bgm="", bgm="",
vib="嗡嗡", vib="嗡嗡",
voc="语音", cv="",
}, },
setting_control={ setting_control={
title="改控制", title="改控制",

View File

@@ -245,6 +245,8 @@ return{
bgm="音乐", bgm="音乐",
vib="振动", vib="振动",
voc="语音", voc="语音",
cv="语音包",
apply="应用",
}, },
setting_control={ setting_control={
title="控制设置", title="控制设置",

View File

@@ -10,28 +10,25 @@ VOC.name={
"perfect_clear","half_clear", "perfect_clear","half_clear",
"win","lose","bye", "win","lose","bye",
"test","happy","doubt","sad","egg", "test","happy","doubt","sad","egg",
"welcome_voc" "welcome_voc",
} }
VOC.list={} VOC.list={}
local function loadVoiceFile(N,vocName) local function loadVoiceFile(N,vocName)
local fileName="VOICE/"..vocName..".ogg" local fileName="VOICE/"..SETTING.cv.."/"..vocName..".ogg"
if love.filesystem.getInfo(fileName)then if love.filesystem.getInfo(fileName)then
bank[vocName]={love.audio.newSource(fileName,"static")} bank[vocName]={love.audio.newSource(fileName,"static")}
table.insert(VOC.list[N],vocName) table.insert(VOC.list[N],vocName)
return true return true
end end
end end
function VOC.loadOne(_) function VOC.loadOne(name)
local N=VOC.name[_] local N=VOC.name[name]
VOC.list[N]={} VOC.list[N]={}
local i=1
while true do local i=0
if not loadVoiceFile(N,N.."_"..i)then repeat i=i+1 until not loadVoiceFile(N,N.."_"..i)
break
end
i=i+1
end
if i==1 then if i==1 then
if not loadVoiceFile(N,N)then if not loadVoiceFile(N,N)then
LOG.print("No VOICE file: "..N,5,color.orange) LOG.print("No VOICE file: "..N,5,color.orange)
@@ -43,6 +40,7 @@ function VOC.loadAll()
for i=1,#VOC.name do for i=1,#VOC.name do
VOC.loadOne(i) VOC.loadOne(i)
end end
collectgarbage()
end end
function VOC.getFreeChannel() function VOC.getFreeChannel()

View File

@@ -44,6 +44,7 @@ SETTING={
stereo=.6, stereo=.6,
vib=0, vib=0,
voc=0, voc=0,
cv="miya",
--Virtualkey --Virtualkey
VKSFX=.2,--SFX volume VKSFX=.2,--SFX volume

View File

@@ -6,8 +6,9 @@ local rnd=math.random
function sceneInit.setting_sound() function sceneInit.setting_sound()
sceneTemp={ sceneTemp={
last=0,--Last sound time last=0,--Last touch time
jump=0,--Animation timer(10 to 0) jump=0,--Animation timer(10 to 0)
cv=SETTING.cv,
} }
BG.set("space") BG.set("space")
end end
@@ -64,5 +65,7 @@ WIDGET.init("setting_sound",{
WIDGET.newSlider({name="bgm", x=180, y=400,w=400, font=35,change=function()BGM.freshVolume()end, disp=WIDGET.lnk.SETval("bgm"),code=WIDGET.lnk.SETsto("bgm")}), WIDGET.newSlider({name="bgm", x=180, y=400,w=400, font=35,change=function()BGM.freshVolume()end, disp=WIDGET.lnk.SETval("bgm"),code=WIDGET.lnk.SETsto("bgm")}),
WIDGET.newSlider({name="vib", x=750, y=200,w=400,unit=5, font=25,change=function()VIB(2)end, disp=WIDGET.lnk.SETval("vib"),code=WIDGET.lnk.SETsto("vib")}), WIDGET.newSlider({name="vib", x=750, y=200,w=400,unit=5, font=25,change=function()VIB(2)end, disp=WIDGET.lnk.SETval("vib"),code=WIDGET.lnk.SETsto("vib")}),
WIDGET.newSlider({name="voc", x=750, y=300,w=400, font=35,change=function()VOC.play("test")end, disp=WIDGET.lnk.SETval("voc"),code=WIDGET.lnk.SETsto("voc")}), WIDGET.newSlider({name="voc", x=750, y=300,w=400, font=35,change=function()VOC.play("test")end, disp=WIDGET.lnk.SETval("voc"),code=WIDGET.lnk.SETsto("voc")}),
WIDGET.newSelector({name="cv", x=1100, y=380,w=200, list={"miya"}, disp=WIDGET.lnk.STPval("cv"),code=WIDGET.lnk.STPsto("cv")}),
WIDGET.newButton({name="apply", x=1100, y=460,w=180,h=80, code=function()SETTING.cv=sceneTemp.cv VOC.loadAll()end,hide=function()return SETTING.cv==sceneTemp.cv end}),
WIDGET.newButton({name="back", x=1140, y=640,w=170,h=80, font=40,code=WIDGET.lnk.BACK}), WIDGET.newButton({name="back", x=1140, y=640,w=170,h=80, font=40,code=WIDGET.lnk.BACK}),
}) })