整理背景加载代码和程序初始化流程

This commit is contained in:
MrZ626
2020-11-06 16:41:13 +08:00
parent 3bf2d41175
commit 7e09d3bf28
2 changed files with 20 additions and 25 deletions

View File

@@ -1,22 +1,33 @@
local BGlist={}
local BG={
list={},
cur="",
init=NULL,
resize=NULL,
init=nil,
resize=nil,
update=NULL,
draw=NULL,
event=NULL,
event=nil,
discard=NULL,
}
function BG.send(data)
--Load Background files from SOURCE ONLY
for _,v in next,love.filesystem.getDirectoryItems("parts/backgrounds")do
if love.filesystem.getRealDirectory("parts/backgrounds/"..v)~=SAVEDIR then
local name=v:sub(1,-5)
BGlist[name]=require("parts/backgrounds/"..name)
else
LOG.print("Dangerous file : %SAVE%/parts/backgrounds/"..v)
end
end
function BG.send(...)
if BG.event then
BG.event(data)
BG.event(...)
end
end
function BG.set(background)
if background==BG.cur or not SETTING.bg then return end
BG.discard()
background=BG.list[background]
background=BGlist[background]
if not background then
LOG.print("No BG called"..background,"warn")
return