整理背景加载代码和程序初始化流程
This commit is contained in:
@@ -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
|
||||
|
||||
20
main.lua
20
main.lua
@@ -107,11 +107,11 @@ GAME={
|
||||
}--Global game data
|
||||
PLAYERS={alive={}}--Players data
|
||||
CURMODE=nil--Current mode object
|
||||
RANKS={sprint_10=0}
|
||||
|
||||
|
||||
--Load modules
|
||||
|
||||
require("Zframework")--Load Zframework
|
||||
require("Zframework")
|
||||
|
||||
require("parts/list")
|
||||
require("parts/default_data")
|
||||
@@ -139,26 +139,10 @@ for _,v in next,fs.getDirectoryItems("parts/scenes")do
|
||||
end
|
||||
end
|
||||
|
||||
--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)
|
||||
BG.list[name]=require("parts/backgrounds/"..name)
|
||||
else
|
||||
LOG.print("Dangerous file : %SAVE%/parts/backgrounds/"..v)
|
||||
end
|
||||
end
|
||||
|
||||
--Load files & settings
|
||||
RANKS={sprint_10=0}
|
||||
|
||||
if fs.getInfo("keymap.dat")then fs.remove("keymap.dat")end
|
||||
if fs.getInfo("setting.dat")then fs.remove("setting.dat")end
|
||||
|
||||
if fs.getInfo("settings.dat")then
|
||||
FILE.loadSetting()
|
||||
else
|
||||
-- firstRun=true
|
||||
if MOBILE then
|
||||
SETTING.VKSwitch=true
|
||||
SETTING.swap=false
|
||||
|
||||
Reference in New Issue
Block a user