整理背景加载代码和程序初始化流程
This commit is contained in:
@@ -1,22 +1,33 @@
|
|||||||
|
local BGlist={}
|
||||||
local BG={
|
local BG={
|
||||||
list={},
|
|
||||||
cur="",
|
cur="",
|
||||||
init=NULL,
|
init=nil,
|
||||||
resize=NULL,
|
resize=nil,
|
||||||
update=NULL,
|
update=NULL,
|
||||||
draw=NULL,
|
draw=NULL,
|
||||||
event=NULL,
|
event=nil,
|
||||||
discard=NULL,
|
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
|
if BG.event then
|
||||||
BG.event(data)
|
BG.event(...)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function BG.set(background)
|
function BG.set(background)
|
||||||
if background==BG.cur or not SETTING.bg then return end
|
if background==BG.cur or not SETTING.bg then return end
|
||||||
BG.discard()
|
BG.discard()
|
||||||
background=BG.list[background]
|
background=BGlist[background]
|
||||||
if not background then
|
if not background then
|
||||||
LOG.print("No BG called"..background,"warn")
|
LOG.print("No BG called"..background,"warn")
|
||||||
return
|
return
|
||||||
|
|||||||
20
main.lua
20
main.lua
@@ -107,11 +107,11 @@ GAME={
|
|||||||
}--Global game data
|
}--Global game data
|
||||||
PLAYERS={alive={}}--Players data
|
PLAYERS={alive={}}--Players data
|
||||||
CURMODE=nil--Current mode object
|
CURMODE=nil--Current mode object
|
||||||
|
RANKS={sprint_10=0}
|
||||||
|
|
||||||
|
|
||||||
--Load modules
|
--Load modules
|
||||||
|
require("Zframework")
|
||||||
require("Zframework")--Load Zframework
|
|
||||||
|
|
||||||
require("parts/list")
|
require("parts/list")
|
||||||
require("parts/default_data")
|
require("parts/default_data")
|
||||||
@@ -139,26 +139,10 @@ for _,v in next,fs.getDirectoryItems("parts/scenes")do
|
|||||||
end
|
end
|
||||||
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
|
--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
|
if fs.getInfo("settings.dat")then
|
||||||
FILE.loadSetting()
|
FILE.loadSetting()
|
||||||
else
|
else
|
||||||
-- firstRun=true
|
|
||||||
if MOBILE then
|
if MOBILE then
|
||||||
SETTING.VKSwitch=true
|
SETTING.VKSwitch=true
|
||||||
SETTING.swap=false
|
SETTING.swap=false
|
||||||
|
|||||||
Reference in New Issue
Block a user