MES模块增加更多图标,调整使用方法
This commit is contained in:
@@ -21,7 +21,7 @@ function FILE.load(name)
|
||||
return s
|
||||
end
|
||||
end
|
||||
MES.new(name.." "..text.loadError)
|
||||
MES.new('error',name.." "..text.loadError)
|
||||
end
|
||||
end
|
||||
function FILE.save(data,name,mode)
|
||||
@@ -30,13 +30,13 @@ function FILE.save(data,name,mode)
|
||||
if mode:find'l'then
|
||||
data=TABLE.dump(data)
|
||||
if not data then
|
||||
MES.new(name.." "..text.saveError.."dump error")
|
||||
MES.new('error',name.." "..text.saveError.."dump error")
|
||||
return
|
||||
end
|
||||
else
|
||||
data=JSON.encode(data)
|
||||
if not data then
|
||||
MES.new(name.." "..text.saveError.."json error")
|
||||
MES.new('error',name.." "..text.saveError.."json error")
|
||||
return
|
||||
end
|
||||
end
|
||||
@@ -50,11 +50,11 @@ function FILE.save(data,name,mode)
|
||||
F:flush()F:close()
|
||||
if success then
|
||||
if not mode:find'q'then
|
||||
MES.new(text.saveDone)
|
||||
MES.new('check',text.saveDone)
|
||||
end
|
||||
else
|
||||
MES.new(text.saveError..(mes or"unknown error"))
|
||||
MES.new(debug.traceback())
|
||||
MES.new('error',text.saveError..(mes or"unknown error"))
|
||||
MES.new(false,debug.traceback())
|
||||
end
|
||||
end
|
||||
function FILE.clear(path)
|
||||
|
||||
@@ -208,7 +208,7 @@ local function noDevkeyPressed(key)
|
||||
if key=="f1"then
|
||||
PROFILE.switch()
|
||||
elseif key=="f2"then
|
||||
MES.new(("System:%s[%s]\nluaVer:%s\njitVer:%s\njitVerNum:%s"):format(SYSTEM,jit.arch,_VERSION,jit.version,jit.version_num))
|
||||
MES.new('info',("System:%s[%s]\nluaVer:%s\njitVer:%s\njitVerNum:%s"):format(SYSTEM,jit.arch,_VERSION,jit.version,jit.version_num))
|
||||
elseif key=="f3"then
|
||||
for _=1,8 do
|
||||
local P=PLY_ALIVE[rnd(#PLY_ALIVE)]
|
||||
@@ -226,15 +226,15 @@ local function noDevkeyPressed(key)
|
||||
elseif key=="f7"and love._openConsole then
|
||||
love._openConsole()
|
||||
elseif key=="f8"then
|
||||
devMode=nil MES.new("DEBUG OFF",.2)
|
||||
devMode=nil MES.new('info',"DEBUG OFF",.2)
|
||||
elseif key=="f9"then
|
||||
devMode=1 MES.new("DEBUG 1")
|
||||
devMode=1 MES.new('info',"DEBUG 1")
|
||||
elseif key=="f10"then
|
||||
devMode=2 MES.new("DEBUG 2")
|
||||
devMode=2 MES.new('info',"DEBUG 2")
|
||||
elseif key=="f11"then
|
||||
devMode=3 MES.new("DEBUG 3")
|
||||
devMode=3 MES.new('info',"DEBUG 3")
|
||||
elseif key=="f12"then
|
||||
devMode=4 MES.new("DEBUG 4")
|
||||
devMode=4 MES.new('info',"DEBUG 4")
|
||||
elseif devMode==2 then
|
||||
local W=WIDGET.sel
|
||||
if W then
|
||||
@@ -263,7 +263,7 @@ function love.keypressed(key)
|
||||
return
|
||||
elseif key=="f8"then
|
||||
devMode=1
|
||||
MES.new("DEBUG ON",.2)
|
||||
MES.new('info',"DEBUG ON",.2)
|
||||
elseif key=="f11"then
|
||||
if kb.isDown("lctrl","rctrl")then
|
||||
_G["\100\114\97\119\70\87\77"]=NULL
|
||||
@@ -294,13 +294,13 @@ end
|
||||
|
||||
function love.joystickadded(JS)
|
||||
ins(joysticks,JS)
|
||||
MES.new("Joystick added")
|
||||
MES.new('info',"Joystick added")
|
||||
end
|
||||
function love.joystickremoved(JS)
|
||||
local i=TABLE.find(joysticks,JS)
|
||||
if i then
|
||||
rem(joysticks,i)
|
||||
MES.new("Joystick removed")
|
||||
MES.new('info',"Joystick removed")
|
||||
end
|
||||
end
|
||||
local keyMirror={
|
||||
@@ -359,7 +359,7 @@ function love.lowmemory()
|
||||
if TIME()-lastGCtime>6.26 then
|
||||
collectgarbage()
|
||||
lastGCtime=TIME()
|
||||
MES.new("[auto GC] low MEM 设备内存过低")
|
||||
MES.new('check',"[auto GC] low MEM 设备内存过低")
|
||||
end
|
||||
end
|
||||
function love.resize(w,h)
|
||||
|
||||
@@ -119,7 +119,7 @@ function json.encode(val)
|
||||
if a then
|
||||
return b
|
||||
elseif MES.new then
|
||||
MES.new(text.jsonError..": "..(b or"uknErr"))
|
||||
MES.new('error',text.jsonError..": "..(b or"uknErr"))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -349,7 +349,7 @@ function json.decode(str)
|
||||
if a then
|
||||
return b
|
||||
elseif MES.new then
|
||||
MES.new(text.jsonError..": "..(b or"uknErr"))
|
||||
MES.new('error',text.jsonError..": "..(b or"uknErr"))
|
||||
end
|
||||
end
|
||||
return json
|
||||
@@ -17,16 +17,16 @@ return function(name,libName)
|
||||
if success then
|
||||
libFunc,mes2=package.loadlib(SAVEDIR.."/lib/"..libName.Android,libName.libFunc)
|
||||
if libFunc then
|
||||
MES.new(name.." lib loaded")
|
||||
MES.new('check',name.." lib loaded")
|
||||
break
|
||||
else
|
||||
MES.new('error',"Cannot load "..name..": "..mes2)
|
||||
end
|
||||
else
|
||||
MES.new(("Write %s-%s to saving failed: %s"):format(name,platform[i],mes2))
|
||||
MES.new('error',("Write %s-%s to saving failed: %s"):format(name,platform[i],mes2))
|
||||
end
|
||||
else
|
||||
MES.new(("Read %s-%s to saving failed: %s"):format(name,platform[i],mes1))
|
||||
MES.new('error',("Read %s-%s to saving failed: %s"):format(name,platform[i],mes1))
|
||||
end
|
||||
end
|
||||
if not libFunc then
|
||||
|
||||
@@ -6,6 +6,23 @@ local ins,rem=table.insert,table.remove
|
||||
|
||||
local mesList={}
|
||||
local mesIcon={
|
||||
check=DOGC{40,40,
|
||||
{'setLW',10},
|
||||
{'setCL',0,0,0},
|
||||
{'line',4,19,15,30,36,9},
|
||||
{'setLW',6},
|
||||
{'setCL',.7,1,.6},
|
||||
{'line',5,20,15,30,35,10},
|
||||
},
|
||||
info=DOGC{40,40,
|
||||
{'setCL',.2,.25,.85},
|
||||
{'fCirc',20,20,15},
|
||||
{'setCL',1,1,1},
|
||||
{'setLW',2},
|
||||
{'dCirc',20,20,15},
|
||||
{'fRect',18,11,4,4},
|
||||
{'fRect',18,17,4,12},
|
||||
},
|
||||
warn=DOGC{40,40,
|
||||
{'setCL',.95,.83,.4},
|
||||
{'fPoly',20.5,1,0,38,40,38},
|
||||
@@ -23,25 +40,20 @@ local mesIcon={
|
||||
{'setCL',0,0,0},
|
||||
{'dCirc',20,20,19},
|
||||
{'setLW',6},
|
||||
{'line',20-9.8,20-9.8,20+9.8,20+9.8},
|
||||
{'line',20-9.8,20+9.8,20+9.8,20-9.8},
|
||||
{'line',10.2,10.2,29.8,29.8},
|
||||
{'line',10.2,29.8,29.8,10.2},
|
||||
{'setLW',4},
|
||||
{'setCL',1,1,1},
|
||||
{'line',20-9,20-9,20+9,20+9},
|
||||
{'line',20-9,20+9,20+9,20-9},
|
||||
{'line',11,11,29,29},
|
||||
{'line',11,29,29,11},
|
||||
},
|
||||
}
|
||||
|
||||
local MES={}
|
||||
|
||||
function MES.new(...)
|
||||
local icon,str,time=...
|
||||
if type(icon)=='string'and mesIcon[icon]then
|
||||
icon=mesIcon[icon]
|
||||
elseif type(icon)~='userdata'then
|
||||
icon,str,time=false,icon,str
|
||||
else
|
||||
end
|
||||
function MES.new(icon,str,time)
|
||||
-- icon=mesIcon.info
|
||||
if type(icon)=='string'then icon=mesIcon[icon]end
|
||||
local t=gc.newText(getFont(30),str)
|
||||
local w=math.max(t:getWidth()+(icon and 45 or 5),200)
|
||||
local L={w+20,48,
|
||||
|
||||
@@ -141,10 +141,10 @@ function profile.switch()
|
||||
profile.stop()
|
||||
love.system.setClipboardText(PROFILE.report())
|
||||
PROFILE.reset()
|
||||
MES.new("profile report copied!")
|
||||
MES.new('check',"profile report copied!")
|
||||
else
|
||||
PROFILE.start()
|
||||
MES.new("profile start!")
|
||||
MES.new('check',"profile start!")
|
||||
end
|
||||
switch=not switch
|
||||
end
|
||||
|
||||
@@ -52,18 +52,14 @@ function THEME.set(theme)
|
||||
elseif theme=='xmas'then
|
||||
BG.setDefault('snow')
|
||||
BGM.setDefault('xmas')
|
||||
MES.new("==============")
|
||||
MES.new("Merry Christmas!")
|
||||
MES.new("==============")
|
||||
MES.new('info',"==Merry Christmas==")
|
||||
elseif theme=='birth'then
|
||||
BG.setDefault('firework')
|
||||
BGM.setDefault('magicblock')
|
||||
elseif theme=='sprfes'then
|
||||
BG.setDefault('firework')
|
||||
BGM.setDefault("spring festival")
|
||||
MES.new(" ★☆☆★")
|
||||
MES.new("新年快乐!")
|
||||
MES.new(" ★☆☆★")
|
||||
MES.new('info',"★☆新年快乐☆★")
|
||||
elseif theme=='zday1'then
|
||||
BG.setDefault('lanterns')
|
||||
BGM.setDefault("empty")
|
||||
|
||||
@@ -349,7 +349,7 @@ function WS.update(dt)
|
||||
ws.pongTimer=1
|
||||
else
|
||||
ws.status='dead'
|
||||
MES.new(text.wsFailed..": "..(mes=="timeout"and text.netTimeout or mes))
|
||||
MES.new('warn',text.wsFailed..": "..(mes=="timeout"and text.netTimeout or mes))
|
||||
end
|
||||
end
|
||||
elseif ws.status=='running'then
|
||||
|
||||
Reference in New Issue
Block a user