整理代码,清除问题
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
local gc=love.graphics
|
||||
local int,ceil,rnd,abs=math.floor,math.ceil,math.random,math.abs
|
||||
local max,min,sin,cos=math.max,math.min,math.sin,math.cos
|
||||
local int,ceil,rnd=math.floor,math.ceil,math.random
|
||||
local max,min,sin=math.max,math.min,math.sin
|
||||
local ins,rem=table.insert,table.remove
|
||||
|
||||
local BG
|
||||
local function NULL(...)end
|
||||
local SCR=SCR
|
||||
local BGvars={_G=_G,SHADER=SHADER}
|
||||
|
||||
local BG
|
||||
local back={}
|
||||
back.none={
|
||||
draw=function()
|
||||
@@ -208,7 +208,7 @@ back.aura={
|
||||
t=rnd()*3600
|
||||
BG.resize(SCR.w,SCR.h)
|
||||
end,
|
||||
resize=function(w,h)
|
||||
resize=function(_,h)
|
||||
SHADER.aura:send("w",SCR.W)
|
||||
SHADER.aura:send("h",h*SCR.dpi)
|
||||
end,
|
||||
@@ -225,9 +225,9 @@ back.aura={
|
||||
back.bg1={
|
||||
init=function()
|
||||
t=0
|
||||
BG.resize(SCR.w)
|
||||
BG.resize()
|
||||
end,
|
||||
resize=function(w)
|
||||
resize=function()
|
||||
SHADER.gradient1:send("w",SCR.W)
|
||||
end,
|
||||
update=function(dt)
|
||||
@@ -245,7 +245,7 @@ back.bg2={
|
||||
t=0
|
||||
BG.resize(nil,SCR.h)
|
||||
end,
|
||||
resize=function(w,h)
|
||||
resize=function(_,h)
|
||||
SHADER.gradient2:send("h",h*SCR.dpi)
|
||||
end,
|
||||
update=function(dt)
|
||||
@@ -263,7 +263,7 @@ back.rainbow={
|
||||
t=0
|
||||
BG.resize(SCR.w,SCR.h)
|
||||
end,
|
||||
resize=function(w,h)
|
||||
resize=function(_,h)
|
||||
SHADER.rgb1:send("w",SCR.W)
|
||||
SHADER.rgb1:send("h",h*SCR.dpi)
|
||||
end,
|
||||
@@ -282,7 +282,7 @@ back.rainbow2={
|
||||
t=0
|
||||
BG.resize(SCR.w,SCR.h)
|
||||
end,
|
||||
resize=function(w,h)
|
||||
resize=function(_,h)
|
||||
SHADER.rgb2:send("w",SCR.W)
|
||||
SHADER.rgb2:send("h",h*SCR.dpi)
|
||||
end,
|
||||
@@ -365,7 +365,7 @@ back.space={
|
||||
W,H=SCR.w+20,SCR.h+20
|
||||
BG.resize(SCR.w,SCR.h)
|
||||
end,
|
||||
resize=function(w,h)
|
||||
resize=function()
|
||||
local S=stars
|
||||
for i=1,1260,5 do
|
||||
local s=rnd(26,40)*.1
|
||||
@@ -376,7 +376,7 @@ back.space={
|
||||
S[i+4]=(rnd()-.5)*.01*s --Vy
|
||||
end
|
||||
end,
|
||||
update=function(dt)
|
||||
update=function()
|
||||
local S=stars
|
||||
--Star moving
|
||||
for i=1,1260,5 do
|
||||
@@ -404,31 +404,31 @@ back.space={
|
||||
|
||||
--Make BG vars invisible
|
||||
for _,bg in next,back do
|
||||
if not bg.init then bg.init= NULL end setfenv(bg.init ,BGvars)
|
||||
if not bg.resize then bg.resize= NULL end setfenv(bg.resize ,BGvars)
|
||||
if not bg.update then bg.update= NULL end setfenv(bg.update ,BGvars)
|
||||
if not bg.draw then bg.draw= NULL end setfenv(bg.draw ,BGvars)
|
||||
if not bg.event then bg.event= NULL end setfenv(bg.event ,BGvars)
|
||||
if not bg.discard then bg.discard=NULL end setfenv(bg.discard ,BGvars)
|
||||
if bg.init then setfenv(bg.init ,BGvars)end
|
||||
if bg.resize then setfenv(bg.resize ,BGvars)end
|
||||
if bg.update then setfenv(bg.update ,BGvars)end
|
||||
if bg.draw then setfenv(bg.draw ,BGvars)end
|
||||
if bg.event then setfenv(bg.event ,BGvars)end
|
||||
if bg.discard then setfenv(bg.discard ,BGvars)end
|
||||
end
|
||||
|
||||
BG={
|
||||
cur="none",
|
||||
init=NULL,
|
||||
resize=NULL,
|
||||
update=NULL,
|
||||
draw=back.none.draw,
|
||||
event=NULL,
|
||||
discard=NULL,
|
||||
}
|
||||
function BG.send(data)
|
||||
if BG.event then
|
||||
BG.event(data)
|
||||
end
|
||||
end
|
||||
function BG.set(bg,data)
|
||||
function BG.set(bg)
|
||||
if bg==BG.cur or not SETTING.bg then return end
|
||||
if BG.discard then
|
||||
BG.discard()
|
||||
collectgarbage()
|
||||
end
|
||||
BG.discard()
|
||||
if not back[bg]then
|
||||
LOG.print("No BG called"..bg,"warn")
|
||||
return
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
local min=math.min
|
||||
local rem=table.remove
|
||||
|
||||
local function fadeOut(id)
|
||||
local src=BGM.list[id]
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
local fs=love.filesystem
|
||||
local int=math.floor
|
||||
local toN,toS=tonumber,tostring
|
||||
|
||||
local files={
|
||||
data= fs.newFile("data.dat"),
|
||||
|
||||
@@ -23,7 +23,7 @@ local IMG={
|
||||
}
|
||||
local list={}
|
||||
local count=0
|
||||
for k,v in next,IMG do
|
||||
for k,_ in next,IMG do
|
||||
count=count+1
|
||||
list[count]=k
|
||||
end
|
||||
|
||||
@@ -21,7 +21,7 @@ LIGHT= require("Zframework/light")
|
||||
local ms=love.mouse
|
||||
local gc=love.graphics
|
||||
local int,rnd,abs=math.floor,math.random,math.abs
|
||||
local max,min=math.max,math.min
|
||||
local min=math.min
|
||||
local ins,rem=table.insert,table.remove
|
||||
local SCR=SCR
|
||||
|
||||
@@ -85,7 +85,7 @@ local keyDown,keyUp=keyDown,keyUp
|
||||
local gamepadDown,gamepadUp=gamepadDown,gamepadUp
|
||||
-------------------------------------------------------------
|
||||
local lastX,lastY=0,0--Last clickDown pos
|
||||
function love.mousepressed(x,y,k,touch,num)
|
||||
function love.mousepressed(x,y,k,touch)
|
||||
if touch then return end
|
||||
mouseShow=true
|
||||
mx,my=xOy:inverseTransformPoint(x,y)
|
||||
@@ -112,12 +112,12 @@ function love.mousemoved(x,y,dx,dy,t)
|
||||
mouseMove[SCN.cur](mx,my,dx,dy)
|
||||
end
|
||||
if ms.isDown(1) then
|
||||
WIDGET.drag(mx,my,dx,dy)
|
||||
WIDGET.drag(mx,my)
|
||||
else
|
||||
WIDGET.moveCursor(mx,my)
|
||||
end
|
||||
end
|
||||
function love.mousereleased(x,y,k,touch,num)
|
||||
function love.mousereleased(x,y,k,touch)
|
||||
if touch or SCN.swapping then return end
|
||||
mx,my=xOy:inverseTransformPoint(x,y)
|
||||
WIDGET.release(mx,my)
|
||||
@@ -155,7 +155,7 @@ function love.touchmoved(id,x,y,dx,dy)
|
||||
end
|
||||
if WIDGET.sel then
|
||||
if touching then
|
||||
WIDGET.drag(x,y,dx,dy)
|
||||
WIDGET.drag(x,y)
|
||||
end
|
||||
else
|
||||
WIDGET.moveCursor(x,y)
|
||||
@@ -281,7 +281,7 @@ local keyMirror={
|
||||
start="return",
|
||||
back="escape",
|
||||
}
|
||||
function love.gamepadpressed(joystick,i)
|
||||
function love.gamepadpressed(_,i)
|
||||
mouseShow=false
|
||||
if SCN.swapping then return end
|
||||
if gamepadDown[SCN.cur]then gamepadDown[SCN.cur](i)
|
||||
@@ -290,7 +290,7 @@ function love.gamepadpressed(joystick,i)
|
||||
else WIDGET.gamepadPressed(i)
|
||||
end
|
||||
end
|
||||
function love.gamepadreleased(joystick,i)
|
||||
function love.gamepadreleased(_,i)
|
||||
if SCN.swapping then return end
|
||||
if gamepadUp[SCN.cur]then gamepadUp[SCN.cur](i)
|
||||
end
|
||||
@@ -336,7 +336,7 @@ function love.resize(w,h)
|
||||
SCR.x,SCR.y=(w-h*16/9)*.5,0
|
||||
end
|
||||
xOy=xOy:setTransformation(w*.5,h*.5,nil,SCR.k,nil,640,360)
|
||||
BG.resize(w,h)
|
||||
if BG.resize then BG.resize(w,h)end
|
||||
|
||||
SHADER.warning:send("w",w*SCR.dpi)
|
||||
SHADER.warning:send("h",h*SCR.dpi)
|
||||
@@ -366,7 +366,7 @@ function love.errorhandler(msg)
|
||||
c=3
|
||||
end
|
||||
end
|
||||
print(table.concat(err,"\n"),1,c-2)
|
||||
DBP(table.concat(err,"\n"),1,c-2)
|
||||
gc.reset()
|
||||
local CAP
|
||||
local function _(_)CAP=gc.newImage(_)end
|
||||
@@ -380,7 +380,7 @@ function love.errorhandler(msg)
|
||||
local count=0
|
||||
return function()
|
||||
PUMP()
|
||||
for E,a,b,c,d,e in POLL()do
|
||||
for E,a,b in POLL()do
|
||||
if E=="quit"or a=="escape"then
|
||||
destroyPlayers()
|
||||
return 1
|
||||
@@ -445,7 +445,6 @@ function love.run()
|
||||
local mini=love.window.isMinimized
|
||||
local PUMP,POLL=love.event.pump,love.event.poll
|
||||
|
||||
local waitTime=1/60
|
||||
local frameTimeList={}
|
||||
|
||||
local lastFrame=Timer()
|
||||
|
||||
@@ -2996,7 +2996,6 @@ end
|
||||
local langMeta={__index=langList[1]}
|
||||
for i=2,#langList do setmetatable(langList[i],langMeta)end
|
||||
|
||||
local gc=love.graphics
|
||||
local LANG={}
|
||||
local drawableTextLoad={
|
||||
"anykey",
|
||||
@@ -3013,7 +3012,7 @@ end
|
||||
function LANG.set(l)
|
||||
text=langList[l]
|
||||
for S,L in next,Widgets do
|
||||
for N,W in next,L do
|
||||
for _,W in next,L do
|
||||
W.text=text.WidgetText[S][W.name]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -62,7 +62,7 @@ function LIGHT.draw()
|
||||
Lights[i]:draw()
|
||||
end
|
||||
end
|
||||
function LIGHT.clear(L)
|
||||
function LIGHT.clear()
|
||||
for i=#Lights,1,-1 do
|
||||
Lights[i]:destroy()
|
||||
Lights[i]=nil
|
||||
|
||||
@@ -179,7 +179,7 @@ do--httpRequest
|
||||
end
|
||||
end
|
||||
else
|
||||
function httpRequest(tick,url,method)
|
||||
function httpRequest(...)
|
||||
LOG.print("[NO NETlib]",5,color.yellow)
|
||||
end
|
||||
end
|
||||
@@ -235,7 +235,7 @@ do--json
|
||||
return "\\" .. (escape_char_map[c] or string.format("u%04x", c:byte()))
|
||||
end
|
||||
|
||||
local function encode_nil(val) return "null" end
|
||||
local function encode_nil() return "null" end
|
||||
|
||||
local function encode_table(val, stack)
|
||||
local res = {}
|
||||
@@ -257,7 +257,7 @@ do--json
|
||||
end
|
||||
if n ~= #val then error("invalid table: sparse array") end
|
||||
-- Encode
|
||||
for i, v in ipairs(val) do table.insert(res, encode(v, stack)) end
|
||||
for _, v in ipairs(val) do table.insert(res, encode(v, stack)) end
|
||||
stack[val] = nil
|
||||
return "[" .. table.concat(res, ",") .. "]"
|
||||
|
||||
|
||||
@@ -102,7 +102,6 @@ function button:FX()
|
||||
self.y-ATV,
|
||||
self.w+2*ATV,
|
||||
self.h+2*ATV
|
||||
,5
|
||||
)
|
||||
end
|
||||
function button:update()
|
||||
@@ -329,7 +328,6 @@ local slider={
|
||||
pos=0,--Position shown
|
||||
}
|
||||
local sliderShowFunc={
|
||||
none=NULL,
|
||||
int=function(S)
|
||||
return S.disp()
|
||||
end,
|
||||
@@ -733,7 +731,7 @@ function WIDGET.press(x,y)
|
||||
end
|
||||
if W.hide and W.hide()then WIDGET.sel=nil end
|
||||
end
|
||||
function WIDGET.drag(x,y,dx,dy)
|
||||
function WIDGET.drag(x,y)
|
||||
local W=WIDGET.sel
|
||||
if not W then return end
|
||||
if W.type=="slider"then
|
||||
@@ -851,7 +849,7 @@ function WIDGET.keyPressed(key)
|
||||
end
|
||||
end
|
||||
else
|
||||
for k,v in next,WIDGET.active do
|
||||
for _,v in next,WIDGET.active do
|
||||
if v.isAbove then
|
||||
WIDGET.sel=v
|
||||
break
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
local rnd=math.random
|
||||
local ins,rem=table.insert,table.remove
|
||||
local mobileHide=(SYSTEM=="Android"or SYSTEM=="iOS")and function()return true end
|
||||
local function BACK()SCN.back()end
|
||||
local virtualkeySet={
|
||||
@@ -102,7 +101,6 @@ local function SETsto(k) return function(i) SETTING[k]=i end end
|
||||
local function STPval(k) return function() return sceneTemp[k] end end
|
||||
local function STPrev(k) return function() sceneTemp[k]=not sceneTemp[k] end end
|
||||
local function STPeq(k,v) return function() return sceneTemp[k]==v end end
|
||||
local function STPsto(k) return function(i) sceneTemp[k]=i end end
|
||||
|
||||
local function prevSkin(n) return function() SKIN.prev(n) end end
|
||||
local function nextSkin(n) return function() SKIN.next(n) end end
|
||||
@@ -644,20 +642,20 @@ local Widgets={
|
||||
},
|
||||
dict={
|
||||
newText({name="title", x=20,y=5,font=70,align="L"}),
|
||||
newKey({name="link", x=1140,y=650,w=200,h=80, font=35,code=pressKey("link"),hide=function()return not sceneTemp.url end}),
|
||||
newButton({name="back", x=1165,y=60,w=170,h=80, font=40,code=BACK}),
|
||||
newKey({name="link", x=1140,y=650,w=200,h=80,font=35,code=pressKey("link"),hide=function()return not sceneTemp.url end}),
|
||||
newButton({name="back", x=1165,y=60,w=170,h=80,font=40,code=BACK}),
|
||||
},
|
||||
staff={
|
||||
newButton({name="back", x=1140, y=640,w=170,h=80, font=40,code=BACK}),
|
||||
newButton({name="back", x=1140, y=640,w=170,h=80,font=40,code=BACK}),
|
||||
},
|
||||
history={
|
||||
newKey({name="prev", x=1155, y=170,w=180, font=65,code=pressKey("up"),hide=STPeq("pos",1)}),
|
||||
newKey({name="next", x=1155, y=400,w=180, font=65,code=pressKey("down"),hide=function()return sceneTemp.pos==#sceneTemp.text end}),
|
||||
newButton({name="back", x=1140, y=640,w=170,h=80, font=40,code=BACK}),
|
||||
newKey({name="prev", x=1155, y=170,w=180,font=65,code=pressKey("up"),hide=STPeq("pos",1)}),
|
||||
newKey({name="next", x=1155, y=400,w=180,font=65,code=pressKey("down"),hide=function()return sceneTemp.pos==#sceneTemp.text end}),
|
||||
newButton({name="back", x=1140, y=640,w=170,h=80,font=40,code=BACK}),
|
||||
},
|
||||
stat={
|
||||
newButton({name="path", x=980, y=620,w=250,h=80, font=25,code=function()love.system.openURL(love.filesystem.getSaveDirectory())end,hide=mobileHide}),
|
||||
newButton({name="back", x=640, y=620,w=200,h=80, font=35,code=BACK}),
|
||||
newButton({name="path", x=980, y=620,w=250,h=80,font=25,code=function()love.system.openURL(love.filesystem.getSaveDirectory())end,hide=mobileHide}),
|
||||
newButton({name="back", x=640, y=620,w=200,h=80,font=35,code=BACK}),
|
||||
},
|
||||
login={
|
||||
newText({name="title", x=80,y=50,font=70,align="L"}),
|
||||
@@ -676,20 +674,20 @@ local Widgets={
|
||||
},
|
||||
p15={
|
||||
newButton({name="reset", x=160,y=100,w=180,h=100,color="lGreen", font=40,code=pressKey("space")}),
|
||||
newSlider({name="color", x=110,y=250,w=170,unit=4,show=false, font=30,disp=STPval("color"), code=function(v)if sceneTemp.state~=1 then sceneTemp.color=v end end,hide=STPeq("state",1)}),
|
||||
newSwitch({name="blind", x=240,y=330,w=60, font=40,disp=STPval("blind"), code=pressKey("w"), hide=STPeq("state",1)}),
|
||||
newSwitch({name="slide", x=240,y=420,w=60, font=40,disp=STPval("slide"), code=pressKey("e"), hide=STPeq("state",1)}),
|
||||
newSwitch({name="pathVis", x=240,y=510,w=60, font=40,disp=STPval("pathVis"), code=pressKey("r"), hide=function()return sceneTemp.state==1 or not sceneTemp.slide end}),
|
||||
newSwitch({name="revKB", x=240,y=600,w=60, font=40,disp=STPval("revKB"), code=pressKey("t"), hide=STPeq("state",1)}),
|
||||
newButton({name="back", x=1140,y=640,w=170,h=80, font=40,code=BACK}),
|
||||
newSlider({name="color", x=110,y=250,w=170,unit=4,show=false,font=30,disp=STPval("color"), code=function(v)if sceneTemp.state~=1 then sceneTemp.color=v end end,hide=STPeq("state",1)}),
|
||||
newSwitch({name="blind", x=240,y=330,w=60, font=40,disp=STPval("blind"), code=pressKey("w"), hide=STPeq("state",1)}),
|
||||
newSwitch({name="slide", x=240,y=420,w=60, font=40,disp=STPval("slide"), code=pressKey("e"), hide=STPeq("state",1)}),
|
||||
newSwitch({name="pathVis", x=240,y=510,w=60, font=40,disp=STPval("pathVis"), code=pressKey("r"), hide=function()return sceneTemp.state==1 or not sceneTemp.slide end}),
|
||||
newSwitch({name="revKB", x=240,y=600,w=60, font=40,disp=STPval("revKB"), code=pressKey("t"), hide=STPeq("state",1)}),
|
||||
newButton({name="back", x=1140,y=640,w=170,h=80, font=40,code=BACK}),
|
||||
},
|
||||
schulte_G={
|
||||
newButton({name="reset", x=160,y=100,w=180,h=100,color="lGreen", font=40,code=pressKey("space"),hide=function()return sceneTemp.state==0 end}),
|
||||
newSlider({name="rank", x=130,y=250,w=150,unit=3,show=false, font=40,disp=function()return sceneTemp.rank-3 end, code=function(v)sceneTemp.rank=v+3 end,hide=function()return sceneTemp.state>0 end}),
|
||||
newSwitch({name="blind", x=240,y=330,w=60, font=40,disp=STPval("blind"), code=pressKey("q"),hide=STPeq("state",1)}),
|
||||
newSwitch({name="disappear",x=240,y=420,w=60, font=40,disp=STPval("disappear"), code=pressKey("w"),hide=STPeq("state",1)}),
|
||||
newSwitch({name="tapFX", x=240,y=510,w=60, font=40,disp=STPval("tapFX"), code=pressKey("e"),hide=STPeq("state",1)}),
|
||||
newButton({name="back", x=1140,y=640,w=170,h=80, font=40,code=BACK}),
|
||||
newButton({name="reset", x=160,y=100,w=180,h=100,color="lGreen",font=40,code=pressKey("space"),hide=function()return sceneTemp.state==0 end}),
|
||||
newSlider({name="rank", x=130,y=250,w=150,unit=3,show=false,font=40,disp=function()return sceneTemp.rank-3 end,code=function(v)sceneTemp.rank=v+3 end,hide=function()return sceneTemp.state>0 end}),
|
||||
newSwitch({name="blind", x=240,y=330,w=60, font=40,disp=STPval("blind"), code=pressKey("q"),hide=STPeq("state",1)}),
|
||||
newSwitch({name="disappear",x=240,y=420,w=60, font=40,disp=STPval("disappear"),code=pressKey("w"),hide=STPeq("state",1)}),
|
||||
newSwitch({name="tapFX", x=240,y=510,w=60, font=40,disp=STPval("tapFX"), code=pressKey("e"),hide=STPeq("state",1)}),
|
||||
newButton({name="back", x=1140,y=640,w=170,h=80, font=40,code=BACK}),
|
||||
},
|
||||
pong={
|
||||
newKey({name="reset", x=640,y=45,w=150,h=50, font=35,code=pressKey("r")}),
|
||||
|
||||
Reference in New Issue
Block a user