移除SFX和VOC模块的loadOne方法

This commit is contained in:
MrZ626
2021-07-21 04:40:20 +08:00
parent 3d128d4850
commit d5ab596749
2 changed files with 3 additions and 19 deletions

View File

@@ -1,6 +1,5 @@
local SFX={ local SFX={
getCount=function()return 0 end, getCount=function()return 0 end,
loadOne=function()error("Cannot load before init!")end,
loadAll=function()error("Cannot load before init!")end, loadAll=function()error("Cannot load before init!")end,
fieldPlay=NULL, fieldPlay=NULL,
play=NULL, play=NULL,
@@ -13,7 +12,7 @@ function SFX.init(list)
local Sources={} local Sources={}
local count=#list function SFX.getCount()return count end local count=#list function SFX.getCount()return count end
local function load(skip) function SFX.loadAll()
for i=1,count do for i=1,count do
local N='media/SFX/'..list[i]..'.ogg' local N='media/SFX/'..list[i]..'.ogg'
if love.filesystem.getInfo(N)then if love.filesystem.getInfo(N)then
@@ -21,11 +20,7 @@ function SFX.init(list)
else else
MES.new('warn',"No SFX file: "..N,.1) MES.new('warn',"No SFX file: "..N,.1)
end end
if not skip and i~=count then
coroutine.yield()
end
end end
SFX.loadOne=nil
function SFX.play(s,vol,pos) function SFX.play(s,vol,pos)
if SETTING.sfx==0 or vol==0 then return end if SETTING.sfx==0 or vol==0 then return end
@@ -88,8 +83,5 @@ function SFX.init(list)
end end
end end
end end
SFX.loadOne=coroutine.wrap(load)
function SFX.loadAll()load(true)end
end end
return SFX return SFX

View File

@@ -1,7 +1,6 @@
local VOC={ local VOC={
getCount=function()return 0 end, getCount=function()return 0 end,
getQueueCount=function()return 0 end, getQueueCount=function()return 0 end,
loadOne=function()error("Cannot load before init!")end,
loadAll=function()error("Cannot load before init!")end, loadAll=function()error("Cannot load before init!")end,
getFreeChannel=NULL, getFreeChannel=NULL,
play=NULL, play=NULL,
@@ -19,7 +18,7 @@ function VOC.init(list)
local function loadVoiceFile(N,vocName) local function loadVoiceFile(N,vocName)
local fileName='media/VOICE/'..SETTING.cv..'/'..vocName..'.ogg' local fileName='media/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,'stream')}
table.insert(Source[N],vocName) table.insert(Source[N],vocName)
return true return true
end end
@@ -38,7 +37,7 @@ function VOC.init(list)
return L[n] return L[n]
--Load voice with string --Load voice with string
end end
local function load(skip) function VOC.loadAll()
for i=1,count do for i=1,count do
Source[list[i]]={} Source[list[i]]={}
@@ -51,11 +50,7 @@ function VOC.init(list)
end end
end end
if not Source[list[i]][1]then Source[list[i]]=nil end if not Source[list[i]][1]then Source[list[i]]=nil end
if not skip and i~=count then
coroutine.yield()
end
end end
VOC.loadOne=nil
function VOC.getQueueCount() function VOC.getQueueCount()
return #voiceQueue return #voiceQueue
@@ -119,8 +114,5 @@ function VOC.init(list)
end end
end end
end end
VOC.loadOne=coroutine.wrap(load)
function VOC.loadAll()load(true)end
end end
return VOC return VOC