优化LOG库,LOG.print功能更多
This commit is contained in:
@@ -55,7 +55,7 @@ function BGM.play(s)
|
|||||||
elseif not s then
|
elseif not s then
|
||||||
return
|
return
|
||||||
elseif not BGM.list[s]then
|
elseif not BGM.list[s]then
|
||||||
LOG.print("Cannot find BGM: "..s,color.lRed)
|
LOG.print("Cannot find BGM: "..s,color.red)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if BGM.nowPlay~=s then
|
if BGM.nowPlay~=s then
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ xOy=love.math.newTransform()
|
|||||||
joysticks={}
|
joysticks={}
|
||||||
|
|
||||||
local devMode
|
local devMode
|
||||||
debugMesHistory={}
|
|
||||||
|
|
||||||
local infoCanvas=gc.newCanvas(108,27)
|
local infoCanvas=gc.newCanvas(108,27)
|
||||||
local function updatePowerInfo()
|
local function updatePowerInfo()
|
||||||
@@ -191,8 +190,8 @@ function love.keypressed(i)
|
|||||||
if devMode then
|
if devMode then
|
||||||
if i=="f5"then
|
if i=="f5"then
|
||||||
DBP("DEBUG:")
|
DBP("DEBUG:")
|
||||||
elseif i=="f3"then
|
elseif i=="f3"then LOG.print("挂了.gif")
|
||||||
LOG.print("挂了.gif")
|
elseif i=="f4"then LOG.copy()
|
||||||
elseif i=="f8"then devMode=nil LOG.print("DEBUG OFF",color.yellow)
|
elseif i=="f8"then devMode=nil LOG.print("DEBUG OFF",color.yellow)
|
||||||
elseif i=="f9"then devMode=1 LOG.print("DEBUG 1",color.yellow)
|
elseif i=="f9"then devMode=1 LOG.print("DEBUG 1",color.yellow)
|
||||||
elseif i=="f10"then devMode=2 LOG.print("DEBUG 2",color.yellow)
|
elseif i=="f10"then devMode=2 LOG.print("DEBUG 2",color.yellow)
|
||||||
@@ -210,8 +209,6 @@ function love.keypressed(i)
|
|||||||
elseif i=="q"then
|
elseif i=="q"then
|
||||||
local W=WIDGET.sel
|
local W=WIDGET.sel
|
||||||
if W then W:printInfo()end
|
if W then W:printInfo()end
|
||||||
elseif i=="f3"then
|
|
||||||
assert(false,"Techmino:挂了")
|
|
||||||
elseif i=="e"then
|
elseif i=="e"then
|
||||||
for k,v in next,_G do
|
for k,v in next,_G do
|
||||||
DBP(k,v)
|
DBP(k,v)
|
||||||
@@ -263,7 +260,7 @@ function love.joystickremoved(JS)
|
|||||||
for i=1,#joysticks do
|
for i=1,#joysticks do
|
||||||
if joysticks[i]==JS then
|
if joysticks[i]==JS then
|
||||||
rem(joysticks,i)
|
rem(joysticks,i)
|
||||||
LOG.print("Joystick removed")
|
LOG.print("Joystick removed",color.yellow)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,29 +3,32 @@ local int,min=math.floor,math.min
|
|||||||
local ins,rem=table.insert,table.remove
|
local ins,rem=table.insert,table.remove
|
||||||
|
|
||||||
local debugMesList={}
|
local debugMesList={}
|
||||||
|
local debugMesHistory={
|
||||||
|
"Version: "..gameVersion,
|
||||||
|
os.date("Launched at %Y/%m/%d %H:%M"),
|
||||||
|
}
|
||||||
local debugMesFloat=0
|
local debugMesFloat=0
|
||||||
local LOG={}
|
local LOG={}
|
||||||
function LOG.print(text,clr)--use this for print for debug in-game
|
|
||||||
if not clr then clr=color.white end
|
|
||||||
ins(debugMesList,{text=text,r=clr[1],g=clr[2],b=clr[3],time=240})
|
|
||||||
ins(debugMesHistory,SCN.cur..": "..tostring(text))
|
|
||||||
end
|
|
||||||
function LOG.update()
|
function LOG.update()
|
||||||
if debugMesList[1]then
|
if debugMesList[1]then
|
||||||
for i=#debugMesList,1,-1 do
|
for i=#debugMesList,1,-1 do
|
||||||
local M=debugMesList[i]
|
local M=debugMesList[i]
|
||||||
M.time=M.time-1
|
if M.blink>0 then
|
||||||
if i==1 and M.time==0 then
|
M.blink=M.blink-1
|
||||||
rem(debugMesList,i)
|
else
|
||||||
if not debugMesList[1]then
|
M.time=M.time-1
|
||||||
debugMesFloat=0
|
if i==1 and M.time==0 then
|
||||||
else
|
rem(debugMesList,i)
|
||||||
debugMesFloat=debugMesFloat+25
|
if not debugMesList[1]then
|
||||||
|
debugMesFloat=0
|
||||||
|
else
|
||||||
|
debugMesFloat=debugMesFloat+25
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if debugMesFloat>0 then
|
end
|
||||||
debugMesFloat=int(debugMesFloat*.9)
|
if debugMesFloat>0 then
|
||||||
end
|
debugMesFloat=int(debugMesFloat*.9)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -35,9 +38,38 @@ function LOG.draw()
|
|||||||
for i=1,#debugMesList do
|
for i=1,#debugMesList do
|
||||||
local M=debugMesList[i]
|
local M=debugMesList[i]
|
||||||
local t=M.time
|
local t=M.time
|
||||||
gc.setColor(M.r,M.g,M.b,t>200 and int(t/3)%2 or min(t/26,1))
|
gc.setColor(M.r,M.g,M.b,M.blink>0 and int(M.blink/3)%2 or min(t/26,1))
|
||||||
gc.print(M.text,10+(20-min(t,20))^1.5/4,25*i+debugMesFloat)
|
gc.print(M.text,10+(20-min(t,20))^1.5/4,25*i+debugMesFloat)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
function LOG.print(text,type,clr)
|
||||||
|
local time
|
||||||
|
local his
|
||||||
|
if _G.type(type)=="table"then
|
||||||
|
clr,type=type or color.white
|
||||||
|
elseif type=="warn"then
|
||||||
|
clr=clr or color.yellow
|
||||||
|
his=true
|
||||||
|
time=180
|
||||||
|
elseif type=="error"then
|
||||||
|
clr=clr or color.red
|
||||||
|
his=true
|
||||||
|
time=210
|
||||||
|
elseif type=="message"then
|
||||||
|
clr=clr or color.green
|
||||||
|
his=true
|
||||||
|
elseif not clr then
|
||||||
|
clr=color.white
|
||||||
|
end
|
||||||
|
if his then
|
||||||
|
ins(debugMesHistory,SCN.cur..": "..tostring(text))
|
||||||
|
end
|
||||||
|
ins(debugMesList,{text=text,r=clr[1],g=clr[2],b=clr[3],blink=30,time=time or 150})
|
||||||
|
end
|
||||||
|
function LOG.copy()
|
||||||
|
local str=table.concat(debugMesHistory,"\n")
|
||||||
|
love.system.setClipboardText(str)
|
||||||
|
LOG.print("Log copied",color.blue)
|
||||||
|
end
|
||||||
return LOG
|
return LOG
|
||||||
@@ -39,10 +39,10 @@ local function loadCC()
|
|||||||
end
|
end
|
||||||
if not f then
|
if not f then
|
||||||
CCloader_filename[system]=nil
|
CCloader_filename[system]=nil
|
||||||
LOG.print("failed to load CC")
|
LOG.print("failed to load CC","warn",color.red)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
LOG.print("CC load successfully")
|
LOG.print("CC load successfully","warn",color.green)
|
||||||
f()
|
f()
|
||||||
BOT={
|
BOT={
|
||||||
getConf= cc.get_default_config ,--()options,weights
|
getConf= cc.get_default_config ,--()options,weights
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ do--calculator
|
|||||||
elseif S.val==196000+022 then
|
elseif S.val==196000+022 then
|
||||||
S.pass=true
|
S.pass=true
|
||||||
marking=nil
|
marking=nil
|
||||||
LOG.print("\68\69\86\58\87\97\116\101\114\109\97\114\107\32\82\101\109\111\118\101\100")
|
LOG.print("\68\69\86\58\87\97\116\101\114\109\97\114\107\32\82\101\109\111\118\101\100","warn",color.lBlue)
|
||||||
SFX.play("clear")
|
SFX.play("clear")
|
||||||
elseif S.val==72943816 then
|
elseif S.val==72943816 then
|
||||||
S.pass=true
|
S.pass=true
|
||||||
@@ -102,7 +102,7 @@ do--calculator
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
FILE.saveUnlock()
|
FILE.saveUnlock()
|
||||||
LOG.print("\68\69\86\58\85\78\76\79\67\75\65\76\76",640,360,60)
|
LOG.print("\68\69\86\58\85\78\76\79\67\75\65\76\76","warn",color.lBlue)
|
||||||
SFX.play("clear_2")
|
SFX.play("clear_2")
|
||||||
elseif S.val==1379e8+2626e4+1379 then
|
elseif S.val==1379e8+2626e4+1379 then
|
||||||
S.pass=true
|
S.pass=true
|
||||||
@@ -253,14 +253,14 @@ do--p15
|
|||||||
if checkBoard(b)then
|
if checkBoard(b)then
|
||||||
S.state=2
|
S.state=2
|
||||||
S.time=Timer()-S.startTime
|
S.time=Timer()-S.startTime
|
||||||
if S.time<1 then LOG.print("不是人")
|
if S.time<1 then LOG.print("不是人",color.lBlue)
|
||||||
elseif S.time<2 then LOG.print("还是人")
|
elseif S.time<2 then LOG.print("还是人",color.lBlue)
|
||||||
elseif S.time<3 then LOG.print("神仙")
|
elseif S.time<3 then LOG.print("神仙",color.lBlue)
|
||||||
elseif S.time<5 then LOG.print("太强了")
|
elseif S.time<5 then LOG.print("太强了",color.lBlue)
|
||||||
elseif S.time<7.5 then LOG.print("很强")
|
elseif S.time<7.5 then LOG.print("很强",color.lBlue)
|
||||||
elseif S.time<10 then LOG.print("可以的")
|
elseif S.time<10 then LOG.print("可以的",color.lBlue)
|
||||||
elseif S.time<20 then LOG.print("再接再厉")
|
elseif S.time<20 then LOG.print("再接再厉",color.lBlue)
|
||||||
elseif S.time<30 then LOG.print("多加练习")
|
elseif S.time<30 then LOG.print("多加练习",color.lBlue)
|
||||||
end
|
end
|
||||||
SFX.play("win")
|
SFX.play("win")
|
||||||
end
|
end
|
||||||
@@ -575,7 +575,7 @@ do--intro
|
|||||||
elseif newVersionLaunch then
|
elseif newVersionLaunch then
|
||||||
SCN.push("main","fade")
|
SCN.push("main","fade")
|
||||||
SCN.swapTo("history","fade")
|
SCN.swapTo("history","fade")
|
||||||
LOG.print(text.newVersion,color.lBlue)
|
LOG.print(text.newVersion,"warn",color.lBlue)
|
||||||
else
|
else
|
||||||
SCN.go("main")
|
SCN.go("main")
|
||||||
end
|
end
|
||||||
@@ -785,10 +785,10 @@ do--mode
|
|||||||
if mapCam.sel=="custom_clear"or mapCam.sel=="custom_puzzle"then
|
if mapCam.sel=="custom_clear"or mapCam.sel=="custom_puzzle"then
|
||||||
if customSel[11]>1 then
|
if customSel[11]>1 then
|
||||||
if customSel[7]==5 then
|
if customSel[7]==5 then
|
||||||
LOG.print(text.ai_fixed,color.red)
|
LOG.print(text.ai_fixed,"warn",color.red)
|
||||||
return
|
return
|
||||||
elseif #preBag>0 then
|
elseif #preBag>0 then
|
||||||
LOG.print(text.ai_prebag,color.red)
|
LOG.print(text.ai_prebag,"warn",color.red)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user