整理代码习惯,常量字符串改用单引号,可能有遗漏
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
local printf=love.graphics.printf
|
||||
local draw=love.graphics.draw
|
||||
local aDraw={}
|
||||
function aDraw.str(obj,x,y)printf(obj,x-626,y,1252,"center")end
|
||||
function aDraw.str(obj,x,y)printf(obj,x-626,y,1252,'center')end
|
||||
function aDraw.simpX(obj,x,y)draw(obj,x-obj:getWidth()*.5,y)end
|
||||
function aDraw.simpY(obj,x,y)draw(obj,x,y-obj:getHeight()*.5)end
|
||||
function aDraw.X(obj,x,y,a,k)draw(obj,x,y,a,k,nil,obj:getWidth()*.5,0)end
|
||||
|
||||
@@ -46,7 +46,7 @@ function BGM.init(list)
|
||||
for i=1,count do
|
||||
local file="media/BGM/"..list[i]..".ogg"
|
||||
if love.filesystem.getInfo(file)then
|
||||
Sources[list[i]]=love.audio.newSource(file,"stream")
|
||||
Sources[list[i]]=love.audio.newSource(file,'stream')
|
||||
Sources[list[i]]:setLooping(true)
|
||||
Sources[list[i]]:setVolume(0)
|
||||
else
|
||||
|
||||
@@ -19,19 +19,19 @@ local cmds={
|
||||
|
||||
draw="draw",
|
||||
dLine="line",
|
||||
fRect=function(...)gc.rectangle("fill",...)end,
|
||||
dRect=function(...)gc.rectangle("line",...)end,
|
||||
fCirc=function(...)gc.circle("fill",...)end,
|
||||
dCirc=function(...)gc.circle("line",...)end,
|
||||
fPoly=function(...)gc.polygon("fill",...)end,
|
||||
dPoly=function(...)gc.polygon("line",...)end,
|
||||
fRect=function(...)gc.rectangle('fill',...)end,
|
||||
dRect=function(...)gc.rectangle('line',...)end,
|
||||
fCirc=function(...)gc.circle('fill',...)end,
|
||||
dCirc=function(...)gc.circle('line',...)end,
|
||||
fPoly=function(...)gc.polygon('fill',...)end,
|
||||
dPoly=function(...)gc.polygon('line',...)end,
|
||||
|
||||
dPie=function(...)gc.arc("line",...)end,
|
||||
dArc=function(...)gc.arc("line","open",...)end,
|
||||
dBow=function(...)gc.arc("line","closed",...)end,
|
||||
fPie=function(...)gc.arc("fill",...)end,
|
||||
fArc=function(...)gc.arc("fill","open",...)end,
|
||||
fBow=function(...)gc.arc("fill","closed",...)end,
|
||||
dPie=function(...)gc.arc('line',...)end,
|
||||
dArc=function(...)gc.arc('line','open',...)end,
|
||||
dBow=function(...)gc.arc('line','closed',...)end,
|
||||
fPie=function(...)gc.arc('fill',...)end,
|
||||
fArc=function(...)gc.arc('fill','open',...)end,
|
||||
fBow=function(...)gc.arc('fill','closed',...)end,
|
||||
}
|
||||
return function(L)
|
||||
gc.push()
|
||||
@@ -42,13 +42,13 @@ return function(L)
|
||||
gc.setLineWidth(1)
|
||||
for i=3,#L do
|
||||
local cmd=L[i][1]
|
||||
if type(cmd)=="boolean"and cmd then
|
||||
if type(cmd)=='boolean'and cmd then
|
||||
table.remove(L[i],1)
|
||||
cmd=L[i][1]
|
||||
end
|
||||
if type(cmd)=="string"then
|
||||
if type(cmd)=='string'then
|
||||
local func=cmds[cmd]
|
||||
if type(func)=="string"then func=gc[func]end
|
||||
if type(func)=='string'then func=gc[func]end
|
||||
if func then
|
||||
func(unpack(L[i],2))
|
||||
else
|
||||
|
||||
@@ -14,34 +14,34 @@ return function(L,t)
|
||||
else
|
||||
s="return{\n"
|
||||
t=1
|
||||
if type(L)~="table"then
|
||||
if type(L)~='table'then
|
||||
return
|
||||
end
|
||||
end
|
||||
local count=1
|
||||
for k,v in next,L do
|
||||
local T=type(k)
|
||||
if T=="number"then
|
||||
if T=='number'then
|
||||
if k==count then
|
||||
k=""
|
||||
count=count+1
|
||||
else
|
||||
k="["..k.."]="
|
||||
end
|
||||
elseif T=="string"then
|
||||
elseif T=='string'then
|
||||
if find(k,"[^0-9a-zA-Z_]")then
|
||||
k="[\""..k.."\"]="
|
||||
else
|
||||
k=k.."="
|
||||
end
|
||||
elseif T=="boolean"then k="["..k.."]="
|
||||
elseif T=='boolean'then k="["..k.."]="
|
||||
else error("Error key type!")
|
||||
end
|
||||
T=type(v)
|
||||
if T=="number"then v=tostring(v)
|
||||
elseif T=="string"then v="\""..v.."\""
|
||||
elseif T=="table"then v=TABLE.dump(v,t+1)
|
||||
elseif T=="boolean"then v=tostring(v)
|
||||
if T=='number'then v=tostring(v)
|
||||
elseif T=='string'then v="\""..v.."\""
|
||||
elseif T=='table'then v=TABLE.dump(v,t+1)
|
||||
elseif T=='boolean'then v=tostring(v)
|
||||
else error("Error data type!")
|
||||
end
|
||||
s=s..tabs[t]..k..v..",\n"
|
||||
|
||||
@@ -3,7 +3,7 @@ local FILE={}
|
||||
function FILE.load(name)
|
||||
if fs.getInfo(name)then
|
||||
local F=fs.newFile(name)
|
||||
if F:open("r")then
|
||||
if F:open'r'then
|
||||
local s=F:read()
|
||||
F:close()
|
||||
if s:sub(1,6)=="return"then
|
||||
@@ -26,17 +26,17 @@ function FILE.load(name)
|
||||
end
|
||||
function FILE.save(data,name,mode)
|
||||
if not mode then mode=""end
|
||||
if type(data)=="table"then
|
||||
if mode:find("l")then
|
||||
if type(data)=='table'then
|
||||
if mode:find'l'then
|
||||
data=TABLE.dump(data)
|
||||
if not data then
|
||||
LOG.print(name.." "..text.saveError.."dump error","error")
|
||||
LOG.print(name.." "..text.saveError.."dump error",'error')
|
||||
return
|
||||
end
|
||||
else
|
||||
data=JSON.encode(data)
|
||||
if not data then
|
||||
LOG.print(name.." "..text.saveError.."json error","error")
|
||||
LOG.print(name.." "..text.saveError.."json error",'error')
|
||||
return
|
||||
end
|
||||
end
|
||||
@@ -45,16 +45,16 @@ function FILE.save(data,name,mode)
|
||||
end
|
||||
|
||||
local F=fs.newFile(name)
|
||||
F:open("w")
|
||||
F:open'w'
|
||||
local success,mes=F:write(data)
|
||||
F:flush()F:close()
|
||||
if success then
|
||||
if not mode:find("q")then
|
||||
if not mode:find'q'then
|
||||
LOG.print(text.saveDone,COLOR.G)
|
||||
end
|
||||
else
|
||||
LOG.print(text.saveError..(mes or"unknown error"),"error")
|
||||
LOG.print(debug.traceback(),"error")
|
||||
LOG.print(text.saveError..(mes or"unknown error"),'error')
|
||||
LOG.print(debug.traceback(),'error')
|
||||
end
|
||||
end
|
||||
return FILE
|
||||
@@ -12,7 +12,7 @@ function IMG.init(list)
|
||||
local function load(skip)
|
||||
local loaded=0
|
||||
for k,v in next,list do
|
||||
if type(v)=="string"then
|
||||
if type(v)=='string'then
|
||||
IMG[k]=love.graphics.newImage("media/image/"..v)
|
||||
else
|
||||
for i=1,#v do
|
||||
|
||||
@@ -66,12 +66,12 @@ local devMode
|
||||
local infoCanvas=gc.newCanvas(108,27)
|
||||
local function updatePowerInfo()
|
||||
local state,pow=love.system.getPowerInfo()
|
||||
gc.setCanvas(infoCanvas)gc_push("transform")gc.origin()
|
||||
gc.setCanvas(infoCanvas)gc_push('transform')gc.origin()
|
||||
gc.clear(0,0,0,.25)
|
||||
if state~="unknown"then
|
||||
if state~='unknown'then
|
||||
gc.setLineWidth(4)
|
||||
local charging=state=="charging"
|
||||
if state=="nobattery"then
|
||||
local charging=state=='charging'
|
||||
if state=='nobattery'then
|
||||
gc_setColor(1,1,1)
|
||||
gc.setLineWidth(2)
|
||||
gc.line(74,SCR.safeX+5,100,22)
|
||||
@@ -82,7 +82,7 @@ local function updatePowerInfo()
|
||||
elseif pow<26 then gc_setColor(1,0,0)
|
||||
else gc_setColor(.5,0,1)
|
||||
end
|
||||
gc_rectangle("fill",76,6,pow*.22,14)
|
||||
gc_rectangle('fill',76,6,pow*.22,14)
|
||||
if pow<100 then
|
||||
setFont(15)
|
||||
gc_setColor(0,0,0)
|
||||
@@ -281,12 +281,12 @@ function love.joystickremoved(JS)
|
||||
end
|
||||
end
|
||||
local keyMirror={
|
||||
dpup="up",
|
||||
dpdown="down",
|
||||
dpleft="left",
|
||||
dpright="right",
|
||||
start="return",
|
||||
back="escape",
|
||||
dpup='up',
|
||||
dpdown='down',
|
||||
dpleft='left',
|
||||
dpright='right',
|
||||
start='return',
|
||||
back='escape',
|
||||
}
|
||||
function love.gamepadpressed(_,i)
|
||||
mouseShow=false
|
||||
@@ -330,7 +330,7 @@ function love.lowmemory()
|
||||
if TIME()-lastGCtime>6.26 then
|
||||
collectgarbage()
|
||||
lastGCtime=TIME()
|
||||
LOG.print("[auto GC] low MEM 设备内存过低","warn")
|
||||
LOG.print("[auto GC] low MEM 设备内存过低",'warn')
|
||||
end
|
||||
end
|
||||
function love.resize(w,h)
|
||||
@@ -343,7 +343,7 @@ end
|
||||
function love.focus(f)
|
||||
if f then
|
||||
love.timer.step()
|
||||
elseif SCN.cur=="game"and SETTING.autoPause then
|
||||
elseif SCN.cur=='game'and SETTING.autoPause then
|
||||
pauseGame()
|
||||
end
|
||||
end
|
||||
@@ -377,7 +377,7 @@ function love.errorhandler(msg)
|
||||
gc.reset()
|
||||
|
||||
if LOADED and #ERRDATA<3 then
|
||||
BG.set("none")
|
||||
BG.set('none')
|
||||
local scn=SCN and SCN.cur or"NULL"
|
||||
ERRDATA[#ERRDATA+1]={mes=err,scene=scn}
|
||||
|
||||
@@ -398,7 +398,7 @@ function love.errorhandler(msg)
|
||||
local res,threadErr
|
||||
repeat
|
||||
res,threadErr=resume(loopThread)
|
||||
until status(loopThread)=="dead"
|
||||
until status(loopThread)=='dead'
|
||||
if not res then
|
||||
love.errorhandler(threadErr)
|
||||
return
|
||||
@@ -413,15 +413,15 @@ function love.errorhandler(msg)
|
||||
while true do
|
||||
love.event.pump()
|
||||
for E,a,b in love.event.poll()do
|
||||
if E=="quit"or a=="escape"then
|
||||
if E=='quit'or a=='escape'then
|
||||
destroyPlayers()
|
||||
return true
|
||||
elseif E=="resize"then
|
||||
elseif E=='resize'then
|
||||
SCR.resize(a,b)
|
||||
end
|
||||
end
|
||||
gc.clear(.3,.5,.9)
|
||||
gc_push("transform")
|
||||
gc_push('transform')
|
||||
gc.replaceTransform(xOy)
|
||||
setFont(100)gc_print(":(",100,0,0,1.2)
|
||||
setFont(40)gc.printf(errorMsg,100,160,SCR.w0-100)
|
||||
@@ -439,7 +439,7 @@ function love.errorhandler(msg)
|
||||
end
|
||||
end
|
||||
local WS=WS
|
||||
local WSnames={"app","user","play","stream","chat"}
|
||||
local WSnames={'app','user','play','stream','chat'}
|
||||
local WScolor={
|
||||
{1,.5,.5,.7},
|
||||
{1,.8,.3,.7},
|
||||
@@ -479,8 +479,8 @@ function love.run()
|
||||
|
||||
--Scene Launch
|
||||
while #SCN.stack>0 do SCN.pop()end
|
||||
SCN.push("quit","slowFade")
|
||||
SCN.init(#ERRDATA==0 and"load"or"error")
|
||||
SCN.push('quit','slowFade')
|
||||
SCN.init(#ERRDATA==0 and'load'or'error')
|
||||
|
||||
return function()
|
||||
local _
|
||||
@@ -494,7 +494,7 @@ function love.run()
|
||||
for N,a,b,c,d,e in POLL()do
|
||||
if love[N]then
|
||||
love[N](a,b,c,d,e)
|
||||
elseif N=="quit"then
|
||||
elseif N=='quit'then
|
||||
destroyPlayers()
|
||||
return a or true
|
||||
end
|
||||
@@ -522,7 +522,7 @@ function love.run()
|
||||
--Draw background
|
||||
BG.draw()
|
||||
|
||||
gc_push("transform")
|
||||
gc_push('transform')
|
||||
gc.replaceTransform(xOy)
|
||||
|
||||
--Draw scene contents
|
||||
@@ -539,7 +539,7 @@ function love.run()
|
||||
_=SCS[R][0]
|
||||
gc_draw(TEXTURE.miniBlock[R],mx,my,t%3.14159265359*4,16,16,_[2]+.5,#BLOCKS[R][0]-_[1]-.5)
|
||||
gc_setColor(1,1,1)
|
||||
gc_draw(TEXTURE[ms.isDown(1)and"cursor_hold"or"cursor"],mx,my,nil,nil,nil,8,8)
|
||||
gc_draw(TEXTURE[ms.isDown(1)and'cursor_hold'or'cursor'],mx,my,nil,nil,nil,8,8)
|
||||
end
|
||||
SYSFX.draw()
|
||||
TEXT.draw()
|
||||
@@ -577,31 +577,31 @@ function love.run()
|
||||
ins(frameTimeList,1,dt)rem(frameTimeList,126)
|
||||
gc_setColor(1,1,1,.3)
|
||||
for i=1,#frameTimeList do
|
||||
gc_rectangle("fill",150+2*i,_-20,2,-frameTimeList[i]*4000)
|
||||
gc_rectangle('fill',150+2*i,_-20,2,-frameTimeList[i]*4000)
|
||||
end
|
||||
|
||||
--Websocket status
|
||||
gc_push("transform")
|
||||
gc_push('transform')
|
||||
gc.translate(SCR.w,SCR.h-100)
|
||||
gc.scale(SCR.k)
|
||||
for i=1,5 do
|
||||
local status=WS.status(WSnames[i])
|
||||
gc_setColor(WScolor[i])
|
||||
gc_rectangle("fill",0,20*i,-80,-20)
|
||||
if status=="dead"then
|
||||
gc_rectangle('fill',0,20*i,-80,-20)
|
||||
if status=='dead'then
|
||||
gc_setColor(1,1,1)
|
||||
gc_draw(TEXTURE.ws_dead,-20,20*i-20)
|
||||
elseif status=="connecting"then
|
||||
elseif status=='connecting'then
|
||||
gc_setColor(1,1,1,.5+.3*sin(t*6.26))
|
||||
gc_draw(TEXTURE.ws_connecting,-20,20*i-20)
|
||||
elseif status=="running"then
|
||||
elseif status=='running'then
|
||||
gc_setColor(1,1,1)
|
||||
gc_draw(TEXTURE.ws_running,-20,20*i-20)
|
||||
end
|
||||
local t1,t2,t3=WS.getTimers(WSnames[i])
|
||||
gc_setColor(1,1,1,t1)gc_rectangle("fill",-60,20*i,-20,-20)
|
||||
gc_setColor(0,1,0,t2)gc_rectangle("fill",-40,20*i,-20,-20)
|
||||
gc_setColor(1,0,0,t3)gc_rectangle("fill",-20,20*i,-20,-20)
|
||||
gc_setColor(1,1,1,t1)gc_rectangle('fill',-60,20*i,-20,-20)
|
||||
gc_setColor(0,1,0,t2)gc_rectangle('fill',-40,20*i,-20,-20)
|
||||
gc_setColor(1,0,0,t3)gc_rectangle('fill',-20,20*i,-20,-20)
|
||||
end
|
||||
gc_pop()
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ local function encode_table(val, stack)
|
||||
-- Treat as array -- check keys are valid and it is not sparse
|
||||
local n = 0
|
||||
for k in pairs(val) do
|
||||
if type(k) ~= "number" then
|
||||
if type(k) ~= 'number' then
|
||||
error("invalid table: mixed or invalid key types")
|
||||
end
|
||||
n = n + 1
|
||||
@@ -77,7 +77,7 @@ local function encode_table(val, stack)
|
||||
else
|
||||
-- Treat as an object
|
||||
for k, v in pairs(val) do
|
||||
if type(k) ~= "string" then
|
||||
if type(k) ~= 'string' then
|
||||
error("invalid table: mixed or invalid key types")
|
||||
end
|
||||
ins(res, encode(k, stack) .. ":" .. encode(v, stack))
|
||||
@@ -100,11 +100,11 @@ local function encode_number(val)
|
||||
end
|
||||
|
||||
local type_func_map = {
|
||||
["nil"] = encode_nil,
|
||||
["table"] = encode_table,
|
||||
["string"] = encode_string,
|
||||
["number"] = encode_number,
|
||||
["boolean"] = tostring
|
||||
['nil'] = encode_nil,
|
||||
['table'] = encode_table,
|
||||
['string'] = encode_string,
|
||||
['number'] = encode_number,
|
||||
['boolean'] = tostring
|
||||
}
|
||||
|
||||
encode = function(val, stack)
|
||||
@@ -119,7 +119,7 @@ function json.encode(val)
|
||||
if a then
|
||||
return b
|
||||
elseif LOG then
|
||||
LOG.print(text.jsonError..": "..(b or"uknErr"),"warn")
|
||||
LOG.print(text.jsonError..": "..(b or"uknErr"),'warn')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -336,7 +336,7 @@ function parse(str, idx)
|
||||
end
|
||||
|
||||
local function decode(str)
|
||||
if type(str) ~= "string" then
|
||||
if type(str) ~= 'string' then
|
||||
error("expected argument of type string, got " .. type(str))
|
||||
end
|
||||
local res, idx = parse(str, next_char(str, 1, space_chars, true))
|
||||
@@ -349,7 +349,7 @@ function json.decode(str)
|
||||
if a then
|
||||
return b
|
||||
elseif LOG then
|
||||
LOG.print(text.jsonError..": "..(b or"uknErr"),"warn")
|
||||
LOG.print(text.jsonError..": "..(b or"uknErr"),'warn')
|
||||
end
|
||||
end
|
||||
return json
|
||||
@@ -2,9 +2,9 @@ local LANG={}
|
||||
function LANG.init(langList,publicText)--Attention, calling this will destory all initializing methods, create a LANG.set()!
|
||||
local function langFallback(T0,T)
|
||||
for k,v in next,T0 do
|
||||
if type(v)=="table"and not v.refuseCopy then--refuseCopy: just copy pointer, not contents
|
||||
if type(v)=='table'and not v.refuseCopy then--refuseCopy: just copy pointer, not contents
|
||||
if not T[k]then T[k]={}end
|
||||
if type(T[k])=="table"then langFallback(v,T[k])end
|
||||
if type(T[k])=='table'then langFallback(v,T[k])end
|
||||
elseif not T[k]then
|
||||
T[k]=v
|
||||
end
|
||||
@@ -26,7 +26,7 @@ function LANG.init(langList,publicText)--Attention, calling this will destory al
|
||||
end
|
||||
|
||||
--Metatable:__call for table:getTip
|
||||
if type(rawget(L,"getTip"))=="table"then
|
||||
if type(rawget(L,"getTip"))=='table'then
|
||||
setmetatable(L.getTip,tipMeta)
|
||||
end
|
||||
|
||||
|
||||
@@ -49,14 +49,14 @@ local function draw(L)
|
||||
render(L.shadowCanvas,0,0,0,1,L.size)
|
||||
|
||||
--Ready to final render
|
||||
setShader()setCanvas()gc.setBlendMode("add")
|
||||
setShader()setCanvas()gc.setBlendMode('add')
|
||||
|
||||
--Render to screes
|
||||
gc.setColor(r,g,b,a)
|
||||
render(L.renderCanvas,X,Y+L.size,0,1,-1)
|
||||
|
||||
--Reset
|
||||
gc.setBlendMode("alpha")
|
||||
gc.setBlendMode('alpha')
|
||||
end
|
||||
|
||||
local LIGHT={}
|
||||
|
||||
@@ -4,7 +4,7 @@ return function(name,libName)
|
||||
if r1 and r2 then
|
||||
return r2
|
||||
else
|
||||
LOG.print("Cannot load "..name..": "..(r2 or r3),"warn",COLOR.R)
|
||||
LOG.print("Cannot load "..name..": "..(r2 or r3),'warn',COLOR.R)
|
||||
end
|
||||
elseif SYSTEM=="Android"then
|
||||
local fs=love.filesystem
|
||||
@@ -12,35 +12,35 @@ return function(name,libName)
|
||||
|
||||
local libFunc=package.loadlib(SAVEDIR.."/lib/"..libName.Android,libName.libFunc)
|
||||
if libFunc then
|
||||
LOG.print(name.." lib loaded","warn",COLOR.G)
|
||||
LOG.print(name.." lib loaded",'warn',COLOR.G)
|
||||
else
|
||||
for i=1,#platform do
|
||||
local soFile=fs.read("data","libAndroid/"..platform[i].."/"..libName.Android)
|
||||
local soFile=fs.read('data',"libAndroid/"..platform[i].."/"..libName.Android)
|
||||
if soFile then
|
||||
local success,message=fs.write("lib/"..libName.Android,soFile)
|
||||
if success then
|
||||
libFunc,message=package.loadlib(SAVEDIR.."/lib/"..libName.Android,libName.libFunc)
|
||||
if libFunc then
|
||||
LOG.print(name.." lib loaded","warn",COLOR.G)
|
||||
LOG.print(name.." lib loaded",'warn',COLOR.G)
|
||||
break
|
||||
else
|
||||
LOG.print("Cannot load "..name..": "..message,"warn",COLOR.R)
|
||||
LOG.print("Cannot load "..name..": "..message,'warn',COLOR.R)
|
||||
end
|
||||
else
|
||||
LOG.print("Write "..name.."-"..platform[i].." to saving failed: "..message,"warn",COLOR.R)
|
||||
LOG.print("Write "..name.."-"..platform[i].." to saving failed: "..message,'warn',COLOR.R)
|
||||
end
|
||||
else
|
||||
LOG.print("Read "..name.."-"..platform[i].." failed","warn",COLOR.R)
|
||||
LOG.print("Read "..name.."-"..platform[i].." failed",'warn',COLOR.R)
|
||||
end
|
||||
end
|
||||
if not libFunc then
|
||||
LOG.print("Cannot load "..name,"warn",COLOR.R)
|
||||
LOG.print("Cannot load "..name,'warn',COLOR.R)
|
||||
return
|
||||
end
|
||||
end
|
||||
return libFunc()
|
||||
else
|
||||
LOG.print("No "..name.." for "..SYSTEM,"warn",COLOR.R)
|
||||
LOG.print("No "..name.." for "..SYSTEM,'warn',COLOR.R)
|
||||
return
|
||||
end
|
||||
return true
|
||||
|
||||
@@ -38,21 +38,21 @@ end
|
||||
function LOG.print(text,T,C)--text,type/time,color
|
||||
local time
|
||||
local his
|
||||
if T=="warn"then
|
||||
if T=='warn'then
|
||||
C=C or COLOR.Y
|
||||
his=true
|
||||
time=180
|
||||
elseif T=="error"then
|
||||
elseif T=='error'then
|
||||
C=C or COLOR.R
|
||||
his=true
|
||||
time=210
|
||||
elseif T=="message"then
|
||||
elseif T=='message'then
|
||||
C=C or COLOR.N
|
||||
his=true
|
||||
elseif type(T)=="number"then
|
||||
elseif type(T)=='number'then
|
||||
C=C or COLOR.Z
|
||||
time=T
|
||||
elseif type(T)=="table"then
|
||||
elseif type(T)=='table'then
|
||||
C=T
|
||||
elseif not C then
|
||||
C=COLOR.Z
|
||||
|
||||
@@ -11,7 +11,7 @@ local _internal={}-- list of internal profiler functions
|
||||
|
||||
local getInfo=debug.getinfo
|
||||
function profile.hooker(event,line,info)
|
||||
info=info or getInfo(2,"fnS")
|
||||
info=info or getInfo(2,'fnS')
|
||||
local f=info.func
|
||||
if _internal[f]then return end-- ignore the profiler itself
|
||||
if info.name then _labeled[f]=info.name end-- get the function name if available
|
||||
@@ -27,10 +27,10 @@ function profile.hooker(event,line,info)
|
||||
_tcalled[f]=nil
|
||||
end
|
||||
if event=="tail call"then
|
||||
local prev=getInfo(3,"fnS")
|
||||
profile.hooker("return",line,prev)
|
||||
profile.hooker("call",line,info)
|
||||
elseif event=="call"then
|
||||
local prev=getInfo(3,'fnS')
|
||||
profile.hooker('return',line,prev)
|
||||
profile.hooker('call',line,info)
|
||||
elseif event=='call'then
|
||||
_tcalled[f]=clock()
|
||||
else
|
||||
_ncalls[f]=_ncalls[f]+1
|
||||
@@ -43,7 +43,7 @@ function profile.start()
|
||||
jit.off()
|
||||
jit.flush()
|
||||
end
|
||||
debug.sethook(profile.hooker,"cr")
|
||||
debug.sethook(profile.hooker,'cr')
|
||||
end
|
||||
|
||||
--- Stops collecting data.
|
||||
@@ -68,7 +68,7 @@ function profile.stop()
|
||||
lookup[id]=f
|
||||
end
|
||||
end
|
||||
collectgarbage("collect")
|
||||
collectgarbage()
|
||||
end
|
||||
|
||||
--- Resets all collected data.
|
||||
@@ -78,7 +78,7 @@ function profile.reset()
|
||||
_telapsed[f]=0
|
||||
_tcalled[f]=nil
|
||||
end
|
||||
collectgarbage("collect")
|
||||
collectgarbage()
|
||||
end
|
||||
|
||||
local function _comp(a,b)
|
||||
@@ -151,7 +151,7 @@ end
|
||||
|
||||
-- store all internal profiler functions
|
||||
for _,v in next,profile do
|
||||
_internal[v]=type(v)=="function"
|
||||
_internal[v]=type(v)=='function'
|
||||
end
|
||||
|
||||
return profile
|
||||
|
||||
@@ -85,7 +85,7 @@ function SCN.push(tar,style)
|
||||
if not SCN.swapping then
|
||||
local m=#SCN.stack
|
||||
SCN.stack[m+1]=tar or SCN.cur
|
||||
SCN.stack[m+2]=style or"fade"
|
||||
SCN.stack[m+2]=style or'fade'
|
||||
end
|
||||
end
|
||||
function SCN.pop()
|
||||
@@ -94,46 +94,46 @@ function SCN.pop()
|
||||
end
|
||||
|
||||
local swap={
|
||||
none={1,0,NULL},--swapTime, changeTime, drawFunction
|
||||
none={1,0,function()end},--swapTime, changeTime, drawFunction
|
||||
flash={8,1,function()gc.clear(1,1,1)end},
|
||||
fade={30,15,function(t)
|
||||
t=t>15 and 2-t/15 or t/15
|
||||
gc.setColor(0,0,0,t)
|
||||
gc.rectangle("fill",0,0,SCR.w,SCR.h)
|
||||
gc.rectangle('fill',0,0,SCR.w,SCR.h)
|
||||
end},
|
||||
fade_togame={120,20,function(t)
|
||||
t=t>20 and(120-t)/100 or t/20
|
||||
gc.setColor(0,0,0,t)
|
||||
gc.rectangle("fill",0,0,SCR.w,SCR.h)
|
||||
gc.rectangle('fill',0,0,SCR.w,SCR.h)
|
||||
end},
|
||||
slowFade={180,90,function(t)
|
||||
t=t>90 and 2-t/90 or t/90
|
||||
gc.setColor(0,0,0,t)
|
||||
gc.rectangle("fill",0,0,SCR.w,SCR.h)
|
||||
gc.rectangle('fill',0,0,SCR.w,SCR.h)
|
||||
end},
|
||||
swipeL={30,15,function(t)
|
||||
t=t/30
|
||||
gc.setColor(.1,.1,.1,1-abs(t-.5))
|
||||
t=t*t*(3-2*t)*2-1
|
||||
gc.rectangle("fill",t*SCR.w,0,SCR.w,SCR.h)
|
||||
gc.rectangle('fill',t*SCR.w,0,SCR.w,SCR.h)
|
||||
end},
|
||||
swipeR={30,15,function(t)
|
||||
t=t/30
|
||||
gc.setColor(.1,.1,.1,1-abs(t-.5))
|
||||
t=t*t*(2*t-3)*2+1
|
||||
gc.rectangle("fill",t*SCR.w,0,SCR.w,SCR.h)
|
||||
gc.rectangle('fill',t*SCR.w,0,SCR.w,SCR.h)
|
||||
end},
|
||||
swipeD={30,15,function(t)
|
||||
t=t/30
|
||||
gc.setColor(.1,.1,.1,1-abs(t-.5))
|
||||
t=t*t*(2*t-3)*2+1
|
||||
gc.rectangle("fill",0,t*SCR.h,SCR.w,SCR.h)
|
||||
gc.rectangle('fill',0,t*SCR.h,SCR.w,SCR.h)
|
||||
end},
|
||||
}--Scene swapping animations
|
||||
function SCN.swapTo(tar,style)--Parallel scene swapping, cannot back
|
||||
if scenes[tar]then
|
||||
if not SCN.swapping and tar~=SCN.cur then
|
||||
if not style then style="fade"end
|
||||
if not style then style='fade'end
|
||||
SCN.swapping=true
|
||||
local S=SCN.stat
|
||||
S.tar,S.style=tar,style
|
||||
@@ -141,7 +141,7 @@ function SCN.swapTo(tar,style)--Parallel scene swapping, cannot back
|
||||
S.time,S.mid,S.draw=s[1],s[2],s[3]
|
||||
end
|
||||
else
|
||||
LOG.print("No Scene: "..tar,"warn")
|
||||
LOG.print("No Scene: "..tar,'warn')
|
||||
end
|
||||
end
|
||||
function SCN.go(tar,style)--Normal scene swapping, can back
|
||||
@@ -149,7 +149,7 @@ function SCN.go(tar,style)--Normal scene swapping, can back
|
||||
SCN.push()
|
||||
SCN.swapTo(tar,style)
|
||||
else
|
||||
LOG.print("No Scene: "..tar,"warn")
|
||||
LOG.print("No Scene: "..tar,'warn')
|
||||
end
|
||||
end
|
||||
function SCN.back()
|
||||
|
||||
@@ -15,7 +15,7 @@ function SFX.init(list)
|
||||
for i=1,count do
|
||||
local N="media/SFX/"..list[i]..".ogg"
|
||||
if love.filesystem.getInfo(N)then
|
||||
Sources[list[i]]={love.audio.newSource(N,"static")}
|
||||
Sources[list[i]]={love.audio.newSource(N,'static')}
|
||||
else
|
||||
LOG.print("No SFX file: "..N,5,COLOR.O)
|
||||
end
|
||||
@@ -76,7 +76,7 @@ function SFX.init(list)
|
||||
end
|
||||
function SFX.reset()
|
||||
for _,L in next,Sources do
|
||||
if type(L)=="table"then
|
||||
if type(L)=='table'then
|
||||
for i=#L,1,-1 do
|
||||
if not L[i]:isPlaying()then
|
||||
rem(L,i)
|
||||
|
||||
@@ -75,32 +75,32 @@ function FXdraw.tap(S)
|
||||
local t=S.t
|
||||
setWidth(2)
|
||||
setColor(1,1,1,1-t)
|
||||
gc.circle("line",S.x,S.y,t*(2-t)*30)
|
||||
gc.circle('line',S.x,S.y,t*(2-t)*30)
|
||||
setColor(1,1,1,(1-t)*.5)
|
||||
gc.circle("fill",S.x,S.y,t*30)
|
||||
gc.circle('fill',S.x,S.y,t*30)
|
||||
|
||||
setColor(1,1,1,1-t)
|
||||
for i=1,10 do
|
||||
local p=S.ptc[i]
|
||||
local T=t^.5
|
||||
gc.rectangle("fill",p[1]*(1-T)+p[3]*T-5,p[2]*(1-T)+p[4]*T-5,11,11)
|
||||
gc.rectangle('fill',p[1]*(1-T)+p[3]*T-5,p[2]*(1-T)+p[4]*T-5,11,11)
|
||||
end
|
||||
end
|
||||
function FXdraw.ripple(S)
|
||||
local t=S.t
|
||||
setWidth(2)
|
||||
setColor(1,1,1,1-t)
|
||||
gc.circle("line",S.x,S.y,t*(2-t)*S.r)
|
||||
gc.circle('line',S.x,S.y,t*(2-t)*S.r)
|
||||
end
|
||||
function FXdraw.rectRipple(S)
|
||||
setWidth(6)
|
||||
setColor(1,1,1,1-S.t)
|
||||
local r=(10*S.t)^1.2
|
||||
gc.rectangle("line",S.x-r,S.y-r,S.w+2*r,S.h+2*r)
|
||||
gc.rectangle('line',S.x-r,S.y-r,S.w+2*r,S.h+2*r)
|
||||
end
|
||||
function FXdraw.shade(S)
|
||||
setColor(S.r,S.g,S.b,1-S.t)
|
||||
gc.rectangle("fill",S.x,S.y,S.w,S.h,2)
|
||||
gc.rectangle('fill',S.x,S.y,S.w,S.h,2)
|
||||
end
|
||||
function FXdraw.cell(S)
|
||||
setColor(1,1,1,1-S.t)
|
||||
|
||||
@@ -5,7 +5,7 @@ local TABLE={}
|
||||
function TABLE.shift(org)
|
||||
local L={}
|
||||
for i=1,#org do
|
||||
if type(org[i])~="table"then
|
||||
if type(org[i])~='table'then
|
||||
L[i]=org[i]
|
||||
else
|
||||
L[i]=TABLE.shift(org[i])
|
||||
@@ -18,7 +18,7 @@ end
|
||||
function TABLE.copy(org)
|
||||
local L={}
|
||||
for k,v in next,org do
|
||||
if type(v)~="table"then
|
||||
if type(v)~='table'then
|
||||
L[k]=v
|
||||
else
|
||||
L[k]=TABLE.copy(v)
|
||||
@@ -31,7 +31,7 @@ end
|
||||
function TABLE.update(new,old)
|
||||
for k,v in next,new do
|
||||
if type(v)==type(old[k])then
|
||||
if type(v)=="table"then
|
||||
if type(v)=='table'then
|
||||
TABLE.update(v,old[k])
|
||||
else
|
||||
old[k]=v
|
||||
@@ -45,7 +45,7 @@ function TABLE.complete(new,old)
|
||||
for k,v in next,new do
|
||||
if old[k]==nil then
|
||||
old[k]=v
|
||||
elseif type(v)=="table"and type(old[k])=="table"then
|
||||
elseif type(v)=='table'and type(old[k])=='table'then
|
||||
TABLE.complete(v,old[k])
|
||||
end
|
||||
end
|
||||
@@ -68,7 +68,7 @@ end
|
||||
--Re-index string value of a table
|
||||
function TABLE.reIndex(org)
|
||||
for k,v in next,org do
|
||||
if type(v)=="string"then
|
||||
if type(v)=='string'then
|
||||
org[k]=org[v]
|
||||
end
|
||||
end
|
||||
@@ -92,34 +92,34 @@ do--function TABLE.dump(L,t)
|
||||
else
|
||||
s="return{\n"
|
||||
t=1
|
||||
if type(L)~="table"then
|
||||
if type(L)~='table'then
|
||||
return
|
||||
end
|
||||
end
|
||||
local count=1
|
||||
for k,v in next,L do
|
||||
local T=type(k)
|
||||
if T=="number"then
|
||||
if T=='number'then
|
||||
if k==count then
|
||||
k=""
|
||||
count=count+1
|
||||
else
|
||||
k="["..k.."]="
|
||||
end
|
||||
elseif T=="string"then
|
||||
elseif T=='string'then
|
||||
if find(k,"[^0-9a-zA-Z_]")then
|
||||
k="[\""..k.."\"]="
|
||||
else
|
||||
k=k.."="
|
||||
end
|
||||
elseif T=="boolean"then k="["..k.."]="
|
||||
elseif T=='boolean'then k="["..k.."]="
|
||||
else error("Error key type!")
|
||||
end
|
||||
T=type(v)
|
||||
if T=="number"then v=tostring(v)
|
||||
elseif T=="string"then v="\""..v.."\""
|
||||
elseif T=="table"then v=dump(v,t+1)
|
||||
elseif T=="boolean"then v=tostring(v)
|
||||
if T=='number'then v=tostring(v)
|
||||
elseif T=='string'then v="\""..v.."\""
|
||||
elseif T=='table'then v=dump(v,t+1)
|
||||
elseif T=='boolean'then v=tostring(v)
|
||||
else error("Error data type!")
|
||||
end
|
||||
s=s..tabs[t]..k..v..",\n"
|
||||
|
||||
@@ -9,7 +9,7 @@ end
|
||||
function TASK.update()
|
||||
for i=#tasks,1,-1 do
|
||||
local T=tasks[i]
|
||||
if status(T.thread)=="dead"then
|
||||
if status(T.thread)=='dead'then
|
||||
rem(tasks,i)
|
||||
else
|
||||
assert(resume(T.thread))
|
||||
@@ -19,7 +19,7 @@ end
|
||||
function TASK.new(code,...)
|
||||
local thread=coroutine.create(code)
|
||||
resume(thread,...)
|
||||
if status(thread)~="dead"then
|
||||
if status(thread)~='dead'then
|
||||
tasks[#tasks+1]={
|
||||
thread=thread,
|
||||
code=code,
|
||||
|
||||
@@ -19,21 +19,21 @@ function textFX.fly(t)
|
||||
mStr(t.text,t.x+(t.c-.5)^3*300,t.y-t.font*.7)
|
||||
end
|
||||
function textFX.stretch(t)
|
||||
gc_push("transform")
|
||||
gc_push('transform')
|
||||
gc_translate(t.x,t.y)
|
||||
if t.c<.3 then gc_scale((.3-t.c)*1.6+1,1)end
|
||||
mStr(t.text,0,-t.font*.7)
|
||||
gc_pop()
|
||||
end
|
||||
function textFX.drive(t)
|
||||
gc_push("transform")
|
||||
gc_push('transform')
|
||||
gc_translate(t.x,t.y)
|
||||
if t.c<.3 then gc_shear((.3-t.c)*2,0)end
|
||||
mStr(t.text,0,-t.font*.7)
|
||||
gc_pop()
|
||||
end
|
||||
function textFX.spin(t)
|
||||
gc_push("transform")
|
||||
gc_push('transform')
|
||||
gc_translate(t.x,t.y)
|
||||
if t.c<.3 then
|
||||
gc_rotate((.3-t.c)^2*4)
|
||||
@@ -49,7 +49,7 @@ function textFX.flicker(t)
|
||||
mStr(t.text,t.x,t.y-t.font*.7)
|
||||
end
|
||||
function textFX.zoomout(t)
|
||||
gc_push("transform")
|
||||
gc_push('transform')
|
||||
local k=t.c^.5*.1+1
|
||||
gc_translate(t.x,t.y)
|
||||
gc_scale(k,k)
|
||||
@@ -57,7 +57,7 @@ function textFX.zoomout(t)
|
||||
gc_pop()
|
||||
end
|
||||
function textFX.beat(t)
|
||||
gc_push("transform")
|
||||
gc_push('transform')
|
||||
gc_translate(t.x,t.y)
|
||||
if t.c<.3 then
|
||||
local k=1.3-t.c^2/.3
|
||||
@@ -85,7 +85,7 @@ function TEXT.show(text,x,y,font,style,spd,stop)
|
||||
font=int(font/5)*5 or 40, --Font
|
||||
spd=(spd or 1)/60, --Timing speed(1=last 1 sec)
|
||||
stop=stop, --Stop time(sustained text)
|
||||
draw=textFX[style or"appear"]or error("unavailable type:"..style), --Draw method
|
||||
draw=textFX[style or'appear']or error("unavailable type:"..style), --Draw method
|
||||
}
|
||||
end
|
||||
function TEXT.getText(text,x,y,font,style,spd,stop)--Another version of TEXT.show(), but only return text object, need manual management
|
||||
@@ -97,7 +97,7 @@ function TEXT.getText(text,x,y,font,style,spd,stop)--Another version of TEXT.sho
|
||||
font=int(font/5)*5 or 40,
|
||||
spd=(spd or 1)/60,
|
||||
stop=stop,
|
||||
draw=textFX[style or"appear"]or error("unavailable type:"..style),
|
||||
draw=textFX[style or'appear']or error("unavailable type:"..style),
|
||||
}
|
||||
end
|
||||
function TEXT.update(list)
|
||||
|
||||
@@ -12,7 +12,7 @@ function THEME.calculate(Y,M,D)
|
||||
return
|
||||
--Christmas
|
||||
M=="12"and math.abs(D-25)<4 and
|
||||
"xmas"or
|
||||
'xmas'or
|
||||
|
||||
--Spring festival
|
||||
M<"03"and math.abs((({
|
||||
@@ -25,49 +25,49 @@ function THEME.calculate(Y,M,D)
|
||||
42,32,50,39,28,46,35,24,43,33,
|
||||
21,40,
|
||||
})[Y-2000]or -26)-((M-1)*31+D))<6 and
|
||||
"sprfes"or
|
||||
'sprfes'or
|
||||
|
||||
--April fool's day
|
||||
M=="04"and D=="01"and
|
||||
"fool"or
|
||||
'fool'or
|
||||
|
||||
--Z day (Feb./Mar./Apr./May./June. 26)
|
||||
D=="26"and(
|
||||
M=="01"or M=="02"and"zday1"or
|
||||
M=="03"or M=="04"and"zday2"or
|
||||
M=="05"or M=="06"and"zday3"
|
||||
M=="01"or M=="02"and'zday1'or
|
||||
M=="03"or M=="04"and'zday2'or
|
||||
M=="05"or M=="06"and'zday3'
|
||||
)or
|
||||
|
||||
"classic"
|
||||
'classic'
|
||||
end
|
||||
|
||||
function THEME.set(theme)
|
||||
if theme=="classic"then
|
||||
BG.setDefault("space")
|
||||
if theme=='classic'then
|
||||
BG.setDefault('space')
|
||||
BGM.setDefault("blank")
|
||||
elseif theme=="xmas"then
|
||||
BG.setDefault("snow")
|
||||
BGM.setDefault("xmas")
|
||||
elseif theme=='xmas'then
|
||||
BG.setDefault('snow')
|
||||
BGM.setDefault('xmas')
|
||||
LOG.print("==============",COLOR.R)
|
||||
LOG.print("Merry Christmas!",COLOR.Z)
|
||||
LOG.print("==============",COLOR.R)
|
||||
elseif theme=="sprfes"then
|
||||
BG.setDefault("firework")
|
||||
elseif theme=='sprfes'then
|
||||
BG.setDefault('firework')
|
||||
BGM.setDefault("spring festival")
|
||||
LOG.print(" ★☆☆★",COLOR.R)
|
||||
LOG.print("新年快乐!",COLOR.Z)
|
||||
LOG.print(" ★☆☆★",COLOR.R)
|
||||
elseif theme=="zday1"then
|
||||
BG.setDefault("lanterns")
|
||||
elseif theme=='zday1'then
|
||||
BG.setDefault('lanterns')
|
||||
BGM.setDefault("empty")
|
||||
elseif theme=="zday2"then
|
||||
BG.setDefault("lanterns")
|
||||
elseif theme=='zday2'then
|
||||
BG.setDefault('lanterns')
|
||||
BGM.setDefault("overzero")
|
||||
elseif theme=="zday3"then
|
||||
BG.setDefault("lanterns")
|
||||
elseif theme=='zday3'then
|
||||
BG.setDefault('lanterns')
|
||||
BGM.setDefault("vacuum")
|
||||
elseif theme=="fool"then
|
||||
BG.setDefault("blockrain")
|
||||
elseif theme=='fool'then
|
||||
BG.setDefault('blockrain')
|
||||
BGM.setDefault("how feeling")
|
||||
else
|
||||
return
|
||||
|
||||
@@ -54,7 +54,7 @@ do--Connect
|
||||
repeat
|
||||
res,err=SOCK:receive("*l")
|
||||
if not res then readCHN:push(err)return end
|
||||
if not ctLen and res:find"length"then
|
||||
if not ctLen and res:find("length")then
|
||||
ctLen=tonumber(res:match"%d+")
|
||||
end
|
||||
until res==""
|
||||
@@ -87,7 +87,7 @@ local _send do
|
||||
local mask_str=char(unpack(mask_key))
|
||||
|
||||
function _send(op,message)
|
||||
]]..(debug:find"S"and""or"--")..[[print((">> %s[%d]:%s"):format(threadName,#message,message))
|
||||
]]..(debug:find'S'and""or"--")..[[print((">> %s[%d]:%s"):format(threadName,#message,message))
|
||||
--Message type
|
||||
SOCK:send(char(bor(0x80,op)))
|
||||
|
||||
@@ -154,7 +154,7 @@ while true do--Running
|
||||
if s then
|
||||
res=s
|
||||
elseif p then--UNF head
|
||||
]]..(debug:find"R"and""or"--")..[[print(("<< %s[%d/%d]:%s"):format(threadName,#p,length,#p<50 and p or p:sub(1,50)))
|
||||
]]..(debug:find'R'and""or"--")..[[print(("<< %s[%d/%d]:%s"):format(threadName,#p,length,#p<50 and p or p:sub(1,50)))
|
||||
UFF=true
|
||||
sBuffer=sBuffer..p
|
||||
length=length-#p
|
||||
@@ -166,11 +166,11 @@ while true do--Running
|
||||
else
|
||||
local s,e,p=SOCK:receive(length)
|
||||
if s then
|
||||
]]..(debug:find"R"and""or"--")..[[print(("<< %s(%d):%s"):format(threadName,length,#s<50 and s or s:sub(1,50)))
|
||||
]]..(debug:find'R'and""or"--")..[[print(("<< %s(%d):%s"):format(threadName,length,#s<50 and s or s:sub(1,50)))
|
||||
sBuffer=sBuffer..s
|
||||
length=length-#s
|
||||
elseif p then
|
||||
]]..(debug:find"R"and""or"--")..[[print(("<< %s(%d):%s"):format(threadName,length,#p<50 and p or p:sub(1,50)))
|
||||
]]..(debug:find'R'and""or"--")..[[print(("<< %s(%d):%s"):format(threadName,length,#p<50 and p or p:sub(1,50)))
|
||||
sBuffer=sBuffer..p
|
||||
length=length-#p
|
||||
end
|
||||
@@ -181,13 +181,13 @@ while true do--Running
|
||||
break
|
||||
end
|
||||
end
|
||||
]]..(debug:find"R"and""or"--")..[[print(("<< %s[(%d)]:%s"):format(threadName,#res,#res<800 and res or res:sub(1,150).."\n...\n"..res:sub(-150)))
|
||||
]]..(debug:find'R'and""or"--")..[[print(("<< %s[(%d)]:%s"):format(threadName,#res,#res<800 and res or res:sub(1,150).."\n...\n"..res:sub(-150)))
|
||||
|
||||
--React
|
||||
if op==8 then--8=close
|
||||
readCHN:push(op)
|
||||
SOCK:close()
|
||||
if type(res)=="string"then
|
||||
if type(res)=='string'then
|
||||
res=JSON.decode(res)
|
||||
readCHN:push(res and res.reason or"WS Error")
|
||||
else
|
||||
@@ -196,21 +196,21 @@ while true do--Running
|
||||
elseif op==0 then--0=continue
|
||||
lBuffer=lBuffer..res
|
||||
if fin then
|
||||
]]..(debug:find"M"and""or"--")..[[print("FIN=1 (c")
|
||||
]]..(debug:find'M'and""or"--")..[[print("FIN=1 (c")
|
||||
readCHN:push(lBuffer)
|
||||
lBuffer=""
|
||||
else
|
||||
]]..(debug:find"M"and""or"--")..[[print("FIN=0 (c")
|
||||
]]..(debug:find'M'and""or"--")..[[print("FIN=0 (c")
|
||||
end
|
||||
else
|
||||
readCHN:push(op)
|
||||
if fin then
|
||||
]]..(debug:find"M"and""or"--")..[[print("OP: "..op.."\tFIN=1")
|
||||
]]..(debug:find'M'and""or"--")..[[print("OP: "..op.."\tFIN=1")
|
||||
readCHN:push(res)
|
||||
else
|
||||
]]..(debug:find"M"and""or"--")..[[print("OP: "..op.."\tFIN=0")
|
||||
]]..(debug:find'M'and""or"--")..[[print("OP: "..op.."\tFIN=0")
|
||||
sBuffer=res
|
||||
]]..(debug:find"M"and""or"--")..[[print("START pack: "..res)
|
||||
]]..(debug:find'M'and""or"--")..[[print("START pack: "..res)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -223,7 +223,7 @@ local wsList=setmetatable({},{
|
||||
__index=function(l,k)
|
||||
local ws={
|
||||
real=false,
|
||||
status="dead",
|
||||
status='dead',
|
||||
lastPongTime=timer(),
|
||||
sendTimer=0,
|
||||
alertTimer=0,
|
||||
@@ -244,7 +244,7 @@ function WS.connect(name,subPath,body)
|
||||
lastPingTime=0,
|
||||
lastPongTime=timer(),
|
||||
pingInterval=26,
|
||||
status="connecting",--connecting, running, dead
|
||||
status='connecting',--connecting, running, dead
|
||||
sendTimer=0,
|
||||
alertTimer=0,
|
||||
pongTimer=0,
|
||||
@@ -259,7 +259,7 @@ end
|
||||
|
||||
function WS.status(name)
|
||||
local ws=wsList[name]
|
||||
return ws.status or"dead"
|
||||
return ws.status or'dead'
|
||||
end
|
||||
|
||||
function WS.getTimers(name)
|
||||
@@ -286,12 +286,12 @@ local OPcode={
|
||||
pong=10,
|
||||
}
|
||||
local OPname={
|
||||
[0]="continue",
|
||||
[1]="text",
|
||||
[2]="binary",
|
||||
[8]="close",
|
||||
[9]="ping",
|
||||
[10]="pong",
|
||||
[0]='continue',
|
||||
[1]='text',
|
||||
[2]='binary',
|
||||
[8]='close',
|
||||
[9]='ping',
|
||||
[10]='pong',
|
||||
}
|
||||
function WS.send(name,message,op)
|
||||
local ws=wsList[name]
|
||||
@@ -308,7 +308,7 @@ function WS.read(name)
|
||||
if ws.real and ws.readCHN:getCount()>=2 then
|
||||
local op=ws.readCHN:pop()
|
||||
local message=ws.readCHN:pop()
|
||||
if op==8 then ws.status="dead"end--8=close
|
||||
if op==8 then ws.status='dead'end--8=close
|
||||
ws.lastPongTime=timer()
|
||||
ws.pongTimer=1
|
||||
return message,OPname[op]or op
|
||||
@@ -320,7 +320,7 @@ function WS.close(name)
|
||||
if ws.real then
|
||||
ws.sendCHN:push(8)--close
|
||||
ws.sendCHN:push("")
|
||||
ws.status="dead"
|
||||
ws.status='dead'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -329,20 +329,20 @@ function WS.update(dt)
|
||||
for name,ws in next,wsList do
|
||||
if ws.real then
|
||||
ws.triggerCHN:push(0)
|
||||
if ws.status=="connecting"then
|
||||
if ws.status=='connecting'then
|
||||
local mes=ws.readCHN:pop()
|
||||
if mes then
|
||||
if mes=="success"then
|
||||
ws.status="running"
|
||||
ws.status='running'
|
||||
ws.lastPingTime=time
|
||||
ws.lastPongTime=time
|
||||
ws.pongTimer=1
|
||||
else
|
||||
ws.status="dead"
|
||||
LOG.print(text.wsFailed..": "..(mes=="timeout"and text.netTimeout or mes),"warn")
|
||||
ws.status='dead'
|
||||
LOG.print(text.wsFailed..": "..(mes=="timeout"and text.netTimeout or mes),'warn')
|
||||
end
|
||||
end
|
||||
elseif ws.status=="running"then
|
||||
elseif ws.status=='running'then
|
||||
if time-ws.lastPingTime>ws.pingInterval then
|
||||
ws.sendCHN:push(9)
|
||||
ws.sendCHN:push("")--ping
|
||||
|
||||
@@ -16,7 +16,7 @@ local widgetMetatable={
|
||||
}
|
||||
|
||||
local text={
|
||||
type="text",
|
||||
type='text',
|
||||
mustHaveText=true,
|
||||
alpha=0,
|
||||
}
|
||||
@@ -34,16 +34,16 @@ function text:draw()
|
||||
if self.alpha>0 then
|
||||
local c=self.color
|
||||
gc.setColor(c[1],c[2],c[3],self.alpha)
|
||||
if self.align=="M"then
|
||||
if self.align=='M'then
|
||||
mDraw_X(self.obj,self.x,self.y)
|
||||
elseif self.align=="L"then
|
||||
elseif self.align=='L'then
|
||||
gc.draw(self.obj,self.x,self.y)
|
||||
elseif self.align=="R"then
|
||||
elseif self.align=='R'then
|
||||
gc.draw(self.obj,self.x-self.obj:getWidth(),self.y)
|
||||
end
|
||||
end
|
||||
end
|
||||
function WIDGET.newText(D)--name,x,y[,fText][,color][,font=30][,align="M"][,hide]
|
||||
function WIDGET.newText(D)--name,x,y[,fText][,color][,font=30][,align='M'][,hide]
|
||||
local _={
|
||||
name= D.name,
|
||||
x= D.x,
|
||||
@@ -52,7 +52,7 @@ function WIDGET.newText(D)--name,x,y[,fText][,color][,font=30][,align="M"][,hide
|
||||
fText= D.fText,
|
||||
color= D.color and(COLOR[D.color]or D.color)or COLOR.Z,
|
||||
font= D.font or 30,
|
||||
align= D.align or"M",
|
||||
align= D.align or'M',
|
||||
hideCon=D.hide,
|
||||
}
|
||||
for k,v in next,text do _[k]=v end
|
||||
@@ -62,10 +62,10 @@ function WIDGET.newText(D)--name,x,y[,fText][,color][,font=30][,align="M"][,hide
|
||||
end
|
||||
|
||||
local image={
|
||||
type="image",
|
||||
type='image',
|
||||
}
|
||||
function image:reset()
|
||||
if type(self.img)=="string"then
|
||||
if type(self.img)=='string'then
|
||||
self.img=IMG[self.img]
|
||||
end
|
||||
end
|
||||
@@ -90,7 +90,7 @@ function WIDGET.newImage(D)--name[,img(name)],x,y[,ang][,k][,hide]
|
||||
end
|
||||
|
||||
local button={
|
||||
type="button",
|
||||
type='button',
|
||||
mustHaveText=true,
|
||||
ATV=0,--Activating time(0~8)
|
||||
}
|
||||
@@ -98,7 +98,7 @@ function button:reset()
|
||||
self.ATV=0
|
||||
end
|
||||
function button:setObject(obj)
|
||||
if type(obj)=="string"or type(obj)=="number"then
|
||||
if type(obj)=='string'or type(obj)=='number'then
|
||||
self.obj=gc.newText(getFont(self.font),obj)
|
||||
elseif obj then
|
||||
self.obj=obj
|
||||
@@ -139,16 +139,16 @@ function button:draw()
|
||||
local c=self.color
|
||||
local r,g,b=c[1],c[2],c[3]
|
||||
gc.setColor(.2+r*.8,.2+g*.8,.2+b*.8,.7)
|
||||
gc.rectangle("fill",x-ATV,y-ATV,w+2*ATV,h+2*ATV)
|
||||
gc.rectangle('fill',x-ATV,y-ATV,w+2*ATV,h+2*ATV)
|
||||
if ATV>0 then
|
||||
gc.setLineWidth(4)
|
||||
gc.setColor(1,1,1,ATV*.125)
|
||||
gc.rectangle("line",x-ATV+2,y-ATV+2,w+2*ATV-4,h+2*ATV-4)
|
||||
gc.rectangle('line',x-ATV+2,y-ATV+2,w+2*ATV-4,h+2*ATV-4)
|
||||
end
|
||||
local obj=self.obj
|
||||
local y0=y+h*.5-ATV*.5
|
||||
gc.setColor(1,1,1,.2+ATV*.05)
|
||||
if self.align=="M"then
|
||||
if self.align=='M'then
|
||||
local x0=x+w*.5
|
||||
mDraw(obj,x0-2,y0-2)
|
||||
mDraw(obj,x0-2,y0+2)
|
||||
@@ -156,7 +156,7 @@ function button:draw()
|
||||
mDraw(obj,x0+2,y0+2)
|
||||
gc.setColor(r*.5,g*.5,b*.5)
|
||||
mDraw(obj,x0,y0)
|
||||
elseif self.align=="L"then
|
||||
elseif self.align=='L'then
|
||||
local edge=self.edge
|
||||
mDraw_Y(obj,x+edge-2,y0-2)
|
||||
mDraw_Y(obj,x+edge-2,y0+2)
|
||||
@@ -164,7 +164,7 @@ function button:draw()
|
||||
mDraw_Y(obj,x+edge+2,y0+2)
|
||||
gc.setColor(r*.5,g*.5,b*.5)
|
||||
mDraw_Y(obj,x+edge,y0)
|
||||
elseif self.align=="R"then
|
||||
elseif self.align=='R'then
|
||||
local x0=x+w-self.edge-obj:getWidth()
|
||||
mDraw_Y(obj,x0-2,y0-2)
|
||||
mDraw_Y(obj,x0-2,y0+2)
|
||||
@@ -180,9 +180,9 @@ end
|
||||
function button:press(_,_,k)
|
||||
self.code(k)
|
||||
self:FX()
|
||||
if self.sound then SFX.play("button")end
|
||||
if self.sound then SFX.play('button')end
|
||||
end
|
||||
function WIDGET.newButton(D)--name,x,y,w[,h][,fText][,color][,font=30][,sound=true][,align="M"][,edge=0],code[,hide]
|
||||
function WIDGET.newButton(D)--name,x,y,w[,h][,fText][,color][,font=30][,sound=true][,align='M'][,edge=0],code[,hide]
|
||||
if not D.h then D.h=D.w end
|
||||
local _={
|
||||
name= D.name,
|
||||
@@ -203,7 +203,7 @@ function WIDGET.newButton(D)--name,x,y,w[,h][,fText][,color][,font=30][,sound=tr
|
||||
fText= D.fText,
|
||||
color= D.color and(COLOR[D.color]or D.color)or COLOR.Z,
|
||||
font= D.font or 30,
|
||||
align= D.align or"M",
|
||||
align= D.align or'M',
|
||||
edge= D.edge or 0,
|
||||
sound= D.sound~=false,
|
||||
code= D.code,
|
||||
@@ -215,7 +215,7 @@ function WIDGET.newButton(D)--name,x,y,w[,h][,fText][,color][,font=30][,sound=tr
|
||||
end
|
||||
|
||||
local key={
|
||||
type="key",
|
||||
type='key',
|
||||
mustHaveText=true,
|
||||
ATV=0,--Activating time(0~4)
|
||||
}
|
||||
@@ -223,7 +223,7 @@ function key:reset()
|
||||
self.ATV=0
|
||||
end
|
||||
function key:setObject(obj)
|
||||
if type(obj)=="string"or type(obj)=="number"then
|
||||
if type(obj)=='string'or type(obj)=='number'then
|
||||
self.obj=gc.newText(getFont(self.font),obj)
|
||||
elseif obj then
|
||||
self.obj=obj
|
||||
@@ -254,18 +254,18 @@ function key:draw()
|
||||
local r,g,b=c[1],c[2],c[3]
|
||||
|
||||
gc.setColor(1,1,1,ATV*.125)
|
||||
gc.rectangle("fill",x,y,w,h)
|
||||
gc.rectangle('fill',x,y,w,h)
|
||||
|
||||
gc.setColor(.2+r*.8,.2+g*.8,.2+b*.8,.7)
|
||||
gc.setLineWidth(4)
|
||||
gc.rectangle("line",x,y,w,h)
|
||||
gc.rectangle('line',x,y,w,h)
|
||||
|
||||
gc.setColor(r,g,b,1.2)
|
||||
if self.align=="M"then
|
||||
if self.align=='M'then
|
||||
mDraw(self.obj,x+w*.5,y+h*.5)
|
||||
elseif self.align=="L"then
|
||||
elseif self.align=='L'then
|
||||
mDraw_Y(self.obj,x+self.edge,y+h*.5)
|
||||
elseif self.align=="R"then
|
||||
elseif self.align=='R'then
|
||||
mDraw_Y(self.obj,x+w-self.edge-self.obj:getWidth(),y+h*.5)
|
||||
end
|
||||
end
|
||||
@@ -274,9 +274,9 @@ function key:getInfo()
|
||||
end
|
||||
function key:press(_,_,k)
|
||||
self.code(k)
|
||||
if self.sound then SFX.play("key")end
|
||||
if self.sound then SFX.play('key')end
|
||||
end
|
||||
function WIDGET.newKey(D)--name,x,y,w[,h][,fText][,color][,font=30][,sound=true][,align="M"][,edge=0],code[,hide]
|
||||
function WIDGET.newKey(D)--name,x,y,w[,h][,fText][,color][,font=30][,sound=true][,align='M'][,edge=0],code[,hide]
|
||||
if not D.h then D.h=D.w end
|
||||
local _={
|
||||
name= D.name,
|
||||
@@ -298,7 +298,7 @@ function WIDGET.newKey(D)--name,x,y,w[,h][,fText][,color][,font=30][,sound=true]
|
||||
color= D.color and(COLOR[D.color]or D.color)or COLOR.Z,
|
||||
font= D.font or 30,
|
||||
sound= D.sound~=false,
|
||||
align= D.align or"M",
|
||||
align= D.align or'M',
|
||||
edge= D.edge or 0,
|
||||
code= D.code,
|
||||
hide= D.hide,
|
||||
@@ -309,7 +309,7 @@ function WIDGET.newKey(D)--name,x,y,w[,h][,fText][,color][,font=30][,sound=true]
|
||||
end
|
||||
|
||||
local switch={
|
||||
type="switch",
|
||||
type='switch',
|
||||
mustHaveText=true,
|
||||
ATV=0,--Activating time(0~8)
|
||||
CHK=0,--Check alpha(0~6)
|
||||
@@ -341,7 +341,7 @@ function switch:draw()
|
||||
--Checked
|
||||
if ATV>0 then
|
||||
gc.setColor(1,1,1,ATV*.08)
|
||||
gc.rectangle("fill",x,y,50,50)
|
||||
gc.rectangle('fill',x,y,50,50)
|
||||
end
|
||||
if self.CHK>0 then
|
||||
gc.setColor(.9,1,.9,self.CHK/6)
|
||||
@@ -352,7 +352,7 @@ function switch:draw()
|
||||
--Frame
|
||||
gc.setLineWidth(4)
|
||||
gc.setColor(1,1,1,.6+ATV*.05)
|
||||
gc.rectangle("line",x,y,50,50)
|
||||
gc.rectangle('line',x,y,50,50)
|
||||
|
||||
--Drawable
|
||||
gc.setColor(self.color)
|
||||
@@ -363,7 +363,7 @@ function switch:getInfo()
|
||||
end
|
||||
function switch:press()
|
||||
self.code()
|
||||
if self.sound then SFX.play("move")end
|
||||
if self.sound then SFX.play('move')end
|
||||
end
|
||||
function WIDGET.newSwitch(D)--name,x,y[,fText][,color][,font=30][,sound=true][,disp],code,hide
|
||||
local _={
|
||||
@@ -390,7 +390,7 @@ function WIDGET.newSwitch(D)--name,x,y[,fText][,color][,font=30][,sound=true][,d
|
||||
end
|
||||
|
||||
local slider={
|
||||
type="slider",
|
||||
type='slider',
|
||||
ATV=0,--Activating time(0~8)
|
||||
TAT=0,--Text activating time(0~180)
|
||||
pos=0,--Position shown
|
||||
@@ -463,12 +463,12 @@ function slider:draw()
|
||||
local cx=x+(x2-x)*self.pos/self.unit
|
||||
local bx,by,bw,bh=cx-10-ATV*.5,y-16-ATV,20+ATV,32+2*ATV
|
||||
gc.setColor(.8,.8,.8)
|
||||
gc.rectangle("fill",bx,by,bw,bh)
|
||||
gc.rectangle('fill',bx,by,bw,bh)
|
||||
|
||||
if ATV>0 then
|
||||
gc.setLineWidth(2)
|
||||
gc.setColor(1,1,1,ATV*.16)
|
||||
gc.rectangle("line",bx+1,by+1,bw-2,bh-2)
|
||||
gc.rectangle('line',bx+1,by+1,bw-2,bh-2)
|
||||
end
|
||||
if self.TAT>0 and self.show then
|
||||
setFont(25)
|
||||
@@ -552,7 +552,7 @@ function WIDGET.newSlider(D)--name,x,y,w[,fText][,color][,unit][,smooth][,font=3
|
||||
_.smooth=_.unit<=1
|
||||
end
|
||||
if D.show then
|
||||
if type(D.show)=="function"then
|
||||
if type(D.show)=='function'then
|
||||
_.show=D.show
|
||||
else
|
||||
_.show=sliderShowFunc[D.show]
|
||||
@@ -570,7 +570,7 @@ function WIDGET.newSlider(D)--name,x,y,w[,fText][,color][,unit][,smooth][,font=3
|
||||
end
|
||||
|
||||
local selector={
|
||||
type="selector",
|
||||
type='selector',
|
||||
mustHaveText=true,
|
||||
ATV=8,--Activating time(0~4)
|
||||
select=0,--Selected item ID
|
||||
@@ -588,7 +588,7 @@ function selector:reset()
|
||||
end
|
||||
end
|
||||
self.hide=true
|
||||
LOG.print("Selector "..self.name.." dead, disp= "..tostring(V),"warn")
|
||||
LOG.print("Selector "..self.name.." dead, disp= "..tostring(V),'warn')
|
||||
end
|
||||
function selector:isAbove(x,y)
|
||||
return
|
||||
@@ -619,7 +619,7 @@ function selector:draw()
|
||||
|
||||
gc.setColor(1,1,1,.6+ATV*.1)
|
||||
gc.setLineWidth(3)
|
||||
gc.rectangle("line",x,y,w,60)
|
||||
gc.rectangle('line',x,y,w,60)
|
||||
|
||||
gc.setColor(1,1,1,.2+ATV*.1)
|
||||
local t=(TIME()%.5)^.5
|
||||
@@ -667,7 +667,7 @@ function selector:press(x)
|
||||
self.code(self.list[s])
|
||||
self.select=s
|
||||
self.selText=self.list[s]
|
||||
if self.sound then SFX.play("prerotate")end
|
||||
if self.sound then SFX.play('prerotate')end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -684,7 +684,7 @@ function selector:arrowKey(isLeft)
|
||||
self.code(self.list[s])
|
||||
self.select=s
|
||||
self.selText=self.list[s]
|
||||
if self.sound then SFX.play("prerotate")end
|
||||
if self.sound then SFX.play('prerotate')end
|
||||
end
|
||||
function WIDGET.newSelector(D)--name,x,y,w[,fText][,color][,sound=true],list,disp,code,hide
|
||||
local _={
|
||||
@@ -717,7 +717,7 @@ function WIDGET.newSelector(D)--name,x,y,w[,fText][,color][,sound=true],list,dis
|
||||
end
|
||||
|
||||
local inputBox={
|
||||
type="inputBox",
|
||||
type='inputBox',
|
||||
keepFocus=true,
|
||||
ATV=0,--Activating time(0~4)
|
||||
value="",--Text contained
|
||||
@@ -754,11 +754,11 @@ function inputBox:draw()
|
||||
local ATV=self.ATV
|
||||
|
||||
gc.setColor(1,1,1,ATV*.1)
|
||||
gc.rectangle("fill",x,y,w,h)
|
||||
gc.rectangle('fill',x,y,w,h)
|
||||
|
||||
gc.setColor(1,1,1)
|
||||
gc.setLineWidth(4)
|
||||
gc.rectangle("line",x,y,w,h)
|
||||
gc.rectangle('line',x,y,w,h)
|
||||
|
||||
--Drawable
|
||||
setFont(self.font)
|
||||
@@ -770,7 +770,7 @@ function inputBox:draw()
|
||||
gc.print("*",x-5+self.font*.5*i,y+h*.5-self.font*.7)
|
||||
end
|
||||
else
|
||||
gc.printf(self.value,x+10,y,self.w,"left")
|
||||
gc.printf(self.value,x+10,y,self.w)
|
||||
setFont(self.font-10)
|
||||
if WIDGET.sel==self then
|
||||
gc.print(EDITING,x+10,y+12-self.font*1.4)
|
||||
@@ -795,10 +795,10 @@ function inputBox:keypress(k)
|
||||
p=p-1
|
||||
end
|
||||
t=sub(t,1,p-1)
|
||||
SFX.play("lock")
|
||||
SFX.play('lock')
|
||||
elseif k=="delete"then
|
||||
t=""
|
||||
SFX.play("hold")
|
||||
SFX.play('hold')
|
||||
end
|
||||
self.value=t
|
||||
end
|
||||
@@ -829,7 +829,7 @@ function WIDGET.newInputBox(D)--name,x,y,w[,h][,font=30][,secret][,regex],hide
|
||||
end
|
||||
|
||||
local textBox={
|
||||
type="textBox",
|
||||
type='textBox',
|
||||
scrollPos=0,--Which line display at bottom
|
||||
scrollPix=0,--Hidden wheel move value
|
||||
sure=0,--Sure-timer for clear history
|
||||
@@ -899,7 +899,7 @@ end
|
||||
function textBox:clear()
|
||||
self.texts={}
|
||||
self.scrollPos=0
|
||||
SFX.play("fall")
|
||||
SFX.play('fall')
|
||||
end
|
||||
function textBox:draw()
|
||||
local x,y,w,h=self.x,self.y,self.w,self.h
|
||||
@@ -910,19 +910,19 @@ function textBox:draw()
|
||||
|
||||
--Background
|
||||
gc.setColor(0,0,0,.3)
|
||||
gc.rectangle("fill",x,y,w,h)
|
||||
gc.rectangle('fill',x,y,w,h)
|
||||
|
||||
--Frame
|
||||
gc.setLineWidth(4)
|
||||
gc.setColor(1,1,WIDGET.sel==self and 0 or 1)
|
||||
gc.rectangle("line",x,y,w,h)
|
||||
gc.rectangle('line',x,y,w,h)
|
||||
|
||||
--Slider
|
||||
if #texts>cap then
|
||||
gc.setLineWidth(2)
|
||||
gc.rectangle("line",x-25,y,20,h)
|
||||
gc.rectangle('line',x-25,y,20,h)
|
||||
local len=max(h*cap/#texts,26)
|
||||
gc.rectangle("fill",x-22,y+(h-len-6)*(scroll-cap)/(#texts-cap)+3,14,len)
|
||||
gc.rectangle('fill',x-22,y+(h-len-6)*(scroll-cap)/(#texts-cap)+3,14,len)
|
||||
end
|
||||
|
||||
gc.setColor(1,1,1)
|
||||
@@ -930,7 +930,7 @@ function textBox:draw()
|
||||
--Clear button
|
||||
if not self.fix then
|
||||
mStr(self.sure>0 and"?"or"X",x+w-20,y-1)
|
||||
gc.rectangle("line",x+w-40,y,40,40)
|
||||
gc.rectangle('line',x+w-40,y,40,40)
|
||||
end
|
||||
|
||||
--Texts
|
||||
@@ -1004,7 +1004,7 @@ function WIDGET.set(list)
|
||||
for i=1,#list do
|
||||
list[i]:reset()
|
||||
end
|
||||
if SCN.cur~="custom_field"then
|
||||
if SCN.cur~='custom_field'then
|
||||
local colorList=THEME.getThemeColor()
|
||||
if not colorList then return end
|
||||
local rnd=math.random
|
||||
@@ -1025,7 +1025,7 @@ function WIDGET.setLang(widgetText)
|
||||
t=W.name or"##"
|
||||
W.color=COLOR.dV
|
||||
end
|
||||
if type(t)=="string"and W.font then
|
||||
if type(t)=='string'and W.font then
|
||||
t=gc.newText(getFont(W.font),t)
|
||||
end
|
||||
W.obj=t
|
||||
@@ -1054,7 +1054,7 @@ end
|
||||
function WIDGET.drag(x,y,dx,dy)
|
||||
local W=WIDGET.sel
|
||||
if not W then return end
|
||||
if W.type=="slider"or W.type=="textBox"then
|
||||
if W.type=='slider'or W.type=='textBox'then
|
||||
W:drag(x,y,dx,dy)
|
||||
elseif not W:isAbove(x,y)then
|
||||
WIDGET.sel=false
|
||||
@@ -1063,7 +1063,7 @@ end
|
||||
function WIDGET.release(x,y)
|
||||
local W=WIDGET.sel
|
||||
if not W then return end
|
||||
if W.type=="slider"then
|
||||
if W.type=='slider'then
|
||||
W:release(x,y)
|
||||
end
|
||||
end
|
||||
@@ -1073,7 +1073,7 @@ function WIDGET.keyPressed(k)
|
||||
elseif kb.isDown("lshift","lalt","lctrl")and(k=="left"or k=="right")then
|
||||
--When hold [↑], control slider with left/right
|
||||
local W=WIDGET.sel
|
||||
if W and W.type=="slider"or W.type=="selector"then
|
||||
if W and W.type=='slider'or W.type=='selector'then
|
||||
W:arrowKey(k=="left")
|
||||
end
|
||||
elseif k=="up"or k=="down"or k=="left"or k=="right"then
|
||||
@@ -1116,19 +1116,19 @@ function WIDGET.keyPressed(k)
|
||||
end
|
||||
else
|
||||
local W=WIDGET.sel
|
||||
if W and W.type=="inputBox"then
|
||||
if W and W.type=='inputBox'then
|
||||
W:keypress(k)
|
||||
end
|
||||
end
|
||||
end
|
||||
function WIDGET.textinput(texts)
|
||||
local W=WIDGET.sel
|
||||
if W and W.type=="inputBox"then
|
||||
if W and W.type=='inputBox'then
|
||||
if not W.regex or texts:match(W.regex)then
|
||||
WIDGET.sel.value=WIDGET.sel.value..texts
|
||||
SFX.play("move")
|
||||
SFX.play('move')
|
||||
else
|
||||
SFX.play("finesseError",.3)
|
||||
SFX.play('finesseError',.3)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1146,9 +1146,9 @@ function WIDGET.gamepadPressed(i)
|
||||
elseif i=="a"or i=="b"then
|
||||
local W=WIDGET.sel
|
||||
if W then
|
||||
if W.type=="button"or W.type=="key"then
|
||||
if W.type=='button'or W.type=='key'then
|
||||
WIDGET.press()
|
||||
elseif W.type=="slider"then
|
||||
elseif W.type=='slider'then
|
||||
local p=W.disp()
|
||||
local P=i=="left"and(p>0 and p-1)or p<W.unit and p+1
|
||||
if p==P or not P then return end
|
||||
|
||||
Reference in New Issue
Block a user