暂时使用未完成的MES模块替换LOG模块

This commit is contained in:
MrZ626
2021-06-13 02:06:38 +08:00
parent 17e67c674b
commit 7075d7d5b2
38 changed files with 211 additions and 206 deletions

View File

@@ -50,7 +50,7 @@ function BGM.init(list)
Sources[list[i]]:setLooping(true) Sources[list[i]]:setLooping(true)
Sources[list[i]]:setVolume(0) Sources[list[i]]:setVolume(0)
else else
LOG.print("No BGM file: "..list[i],5,'warn') MES.new("No BGM file: "..list[i],5)
end end
if not skip and i~=count then if not skip and i~=count then
coroutine.yield() coroutine.yield()

View File

@@ -21,7 +21,7 @@ function FILE.load(name)
return s return s
end end
end end
LOG.print(name.." "..text.loadError,'error') MES.new(name.." "..text.loadError)
end end
end end
function FILE.save(data,name,mode) function FILE.save(data,name,mode)
@@ -30,13 +30,13 @@ function FILE.save(data,name,mode)
if mode:find'l'then if mode:find'l'then
data=TABLE.dump(data) data=TABLE.dump(data)
if not data then if not data then
LOG.print(name.." "..text.saveError.."dump error",'error') MES.new(name.." "..text.saveError.."dump error")
return return
end end
else else
data=JSON.encode(data) data=JSON.encode(data)
if not data then if not data then
LOG.print(name.." "..text.saveError.."json error",'error') MES.new(name.." "..text.saveError.."json error")
return return
end end
end end
@@ -50,11 +50,11 @@ function FILE.save(data,name,mode)
F:flush()F:close() F:flush()F:close()
if success then if success then
if not mode:find'q'then if not mode:find'q'then
LOG.print(text.saveDone,'message') MES.new(text.saveDone)
end end
else else
LOG.print(text.saveError..(mes or"unknown error"),'error') MES.new(text.saveError..(mes or"unknown error"))
LOG.print(debug.traceback(),'error') MES.new(debug.traceback())
end end
end end
function FILE.clear(path) function FILE.clear(path)

View File

@@ -11,7 +11,6 @@ ADRAW=require"Zframework.aDraw"
SCR= require"Zframework.screen" SCR= require"Zframework.screen"
COLOR= require"Zframework.color" COLOR= require"Zframework.color"
LOG= require"Zframework.log"
SCN= require"Zframework.scene" SCN= require"Zframework.scene"
WS= require"Zframework.websocket" WS= require"Zframework.websocket"
@@ -31,6 +30,7 @@ BG= require"Zframework.background"
WIDGET= require"Zframework.widget" WIDGET= require"Zframework.widget"
TEXT= require"Zframework.text" TEXT= require"Zframework.text"
SYSFX= require"Zframework.sysFX" SYSFX= require"Zframework.sysFX"
MES= require"Zframework.message"
IMG= require"Zframework.image" IMG= require"Zframework.image"
BGM= require"Zframework.bgm" BGM= require"Zframework.bgm"
@@ -208,7 +208,7 @@ local function noDevkeyPressed(key)
if key=="f1"then if key=="f1"then
PROFILE.switch() PROFILE.switch()
elseif key=="f2"then elseif key=="f2"then
LOG.print(("System:%s[%s]\nluaVer:%s\njitVer:%s\njitVerNum:%s"):format(SYSTEM,jit.arch,_VERSION,jit.version,jit.version_num),'message') MES.new(("System:%s[%s]\nluaVer:%s\njitVer:%s\njitVerNum:%s"):format(SYSTEM,jit.arch,_VERSION,jit.version,jit.version_num))
elseif key=="f3"then elseif key=="f3"then
for _=1,8 do for _=1,8 do
local P=PLY_ALIVE[rnd(#PLY_ALIVE)] local P=PLY_ALIVE[rnd(#PLY_ALIVE)]
@@ -218,7 +218,7 @@ local function noDevkeyPressed(key)
end end
end end
elseif key=="f4"and not kb.isDown("lalt","ralt")then elseif key=="f4"and not kb.isDown("lalt","ralt")then
LOG.copy() MES.new.copy()
elseif key=="f5"then elseif key=="f5"then
print(WIDGET.isFocus()or"no widget selected") print(WIDGET.isFocus()or"no widget selected")
elseif key=="f6"then elseif key=="f6"then
@@ -226,15 +226,15 @@ local function noDevkeyPressed(key)
elseif key=="f7"and love._openConsole then elseif key=="f7"and love._openConsole then
love._openConsole() love._openConsole()
elseif key=="f8"then elseif key=="f8"then
devMode=nil LOG.print("DEBUG OFF",.2) devMode=nil MES.new("DEBUG OFF",.2)
elseif key=="f9"then elseif key=="f9"then
devMode=1 LOG.print("DEBUG 1") devMode=1 MES.new("DEBUG 1")
elseif key=="f10"then elseif key=="f10"then
devMode=2 LOG.print("DEBUG 2") devMode=2 MES.new("DEBUG 2")
elseif key=="f11"then elseif key=="f11"then
devMode=3 LOG.print("DEBUG 3") devMode=3 MES.new("DEBUG 3")
elseif key=="f12"then elseif key=="f12"then
devMode=4 LOG.print("DEBUG 4") devMode=4 MES.new("DEBUG 4")
elseif devMode==2 then elseif devMode==2 then
local W=WIDGET.sel local W=WIDGET.sel
if W then if W then
@@ -263,7 +263,7 @@ function love.keypressed(key)
return return
elseif key=="f8"then elseif key=="f8"then
devMode=1 devMode=1
LOG.print("DEBUG ON",.2) MES.new("DEBUG ON",.2)
elseif key=="f11"then elseif key=="f11"then
if kb.isDown("lctrl","rctrl")then if kb.isDown("lctrl","rctrl")then
_G["\100\114\97\119\70\87\77"]=NULL _G["\100\114\97\119\70\87\77"]=NULL
@@ -294,13 +294,13 @@ end
function love.joystickadded(JS) function love.joystickadded(JS)
ins(joysticks,JS) ins(joysticks,JS)
LOG.print("Joystick added",'message') MES.new("Joystick added")
end end
function love.joystickremoved(JS) function love.joystickremoved(JS)
local i=TABLE.find(joysticks,JS) local i=TABLE.find(joysticks,JS)
if i then if i then
rem(joysticks,i) rem(joysticks,i)
LOG.print("Joystick removed",'message') MES.new("Joystick removed")
end end
end end
local keyMirror={ local keyMirror={
@@ -359,7 +359,7 @@ function love.lowmemory()
if TIME()-lastGCtime>6.26 then if TIME()-lastGCtime>6.26 then
collectgarbage() collectgarbage()
lastGCtime=TIME() lastGCtime=TIME()
LOG.print("[auto GC] low MEM 设备内存过低",'warn') MES.new("[auto GC] low MEM 设备内存过低")
end end
end end
function love.resize(w,h) function love.resize(w,h)
@@ -519,7 +519,7 @@ function love.run()
local love=love local love=love
local VOC,BG,SYSFX=VOC,BG,SYSFX local VOC,BG,SYSFX=VOC,BG,SYSFX
local TASK,LOG,TEXT=TASK,LOG,TEXT local TASK,TEXT=TASK,TEXT
local TEXTURE,TIME=TEXTURE,TIME local TEXTURE,TIME=TEXTURE,TIME
local SETTING,VERSION=SETTING,VERSION local SETTING,VERSION=SETTING,VERSION
@@ -570,7 +570,7 @@ function love.run()
if SCN.update then SCN.update(dt)end if SCN.update then SCN.update(dt)end
if SCN.swapping then SCN.swapUpdate()end if SCN.swapping then SCN.swapUpdate()end
TEXT.update() TEXT.update()
LOG.update(dt) MES.update(dt)
--DRAW --DRAW
if not MINI()then if not MINI()then
@@ -597,9 +597,8 @@ function love.run()
gc_setColor(1,1,1) gc_setColor(1,1,1)
gc_draw(ms.isDown(1)and cursor_holdImg or cursorImg,mx,my,nil,nil,nil,8,8) gc_draw(ms.isDown(1)and cursor_holdImg or cursorImg,mx,my,nil,nil,nil,8,8)
end end
gc_replaceTransform(SCR.xOy_ul)
LOG.draw()
gc_replaceTransform(SCR.origin) gc_replaceTransform(SCR.origin)
MES.draw()
--Draw power info. --Draw power info.
if SETTING.powerInfo then if SETTING.powerInfo then
gc_setColor(1,1,1) gc_setColor(1,1,1)

View File

@@ -118,8 +118,8 @@ function json.encode(val)
local a,b=pcall(encode,val) local a,b=pcall(encode,val)
if a then if a then
return b return b
elseif LOG then elseif MES.new then
LOG.print(text.jsonError..": "..(b or"uknErr"),'warn') MES.new(text.jsonError..": "..(b or"uknErr"))
end end
end end
@@ -348,8 +348,8 @@ function json.decode(str)
local a,b=pcall(decode,str) local a,b=pcall(decode,str)
if a then if a then
return b return b
elseif LOG then elseif MES.new then
LOG.print(text.jsonError..": "..(b or"uknErr"),'warn') MES.new(text.jsonError..": "..(b or"uknErr"))
end end
end end
return json return json

View File

@@ -4,7 +4,7 @@ return function(name,libName)
if r1 and r2 then if r1 and r2 then
return r2 return r2
else else
LOG.print("Cannot load "..name..": "..(r2 or r3),'warn') MES.new("Cannot load "..name..": "..(r2 or r3))
end end
elseif SYSTEM=="Android"then elseif SYSTEM=="Android"then
local fs=love.filesystem local fs=love.filesystem
@@ -17,25 +17,25 @@ return function(name,libName)
if success then if success then
libFunc,mes2=package.loadlib(SAVEDIR.."/lib/"..libName.Android,libName.libFunc) libFunc,mes2=package.loadlib(SAVEDIR.."/lib/"..libName.Android,libName.libFunc)
if libFunc then if libFunc then
LOG.print(name.." lib loaded",'message') MES.new(name.." lib loaded")
break break
else else
LOG.print("Cannot load "..name..": "..mes2,'error') MES.new("Cannot load "..name..": "..mes2)
end end
else else
LOG.print(("Write %s-%s to saving failed: %s"):format(name,platform[i],mes2),'error') MES.new(("Write %s-%s to saving failed: %s"):format(name,platform[i],mes2))
end end
else else
LOG.print(("Read %s-%s to saving failed: %s"):format(name,platform[i],mes1),'error') MES.new(("Read %s-%s to saving failed: %s"):format(name,platform[i],mes1))
end end
end end
if not libFunc then if not libFunc then
LOG.print("Cannot load "..name,'error') MES.new("Cannot load "..name)
return return
end end
return libFunc() return libFunc()
else else
LOG.print("No "..name.." for "..SYSTEM,'error') MES.new("No "..name.." for "..SYSTEM)
return return
end end
return true return true

View File

@@ -1,64 +0,0 @@
local utf8=require"utf8"
local gc=love.graphics
local gc_setColor,gc_print=gc.setColor,gc.print
local int,min=math.floor,math.min
local ins,rem=table.insert,table.remove
local setFont=setFont
local mesList={}
local mesHistory={
"Version: "..VERSION.string,
os.date("Launched at %Y/%m/%d %H:%M"),
}
local LOG={}
function LOG.update(dt)
if mesList[1]then
for i=#mesList,1,-1 do
local M=mesList[i]
if M.blink>0 then
M.blink=M.blink-1
else
M.time=M.time-dt
if M.time<=0 then
rem(mesList,i)
end
end
end
end
end
function LOG.draw()
if mesList[1]then
setFont(20)
for i=1,#mesList do
local M=mesList[i]
M.rgba[4]=M.blink>0 and int(M.blink/3)%2 or min(M.time*60/26,1)
gc_setColor(M.rgba)
gc_print(M.text,10+(20-min(M.time*60,20))^1.5/4,25*i)
end
end
end
function LOG.print(text,T)--text,type/time
local color=COLOR.Z
local his,time
if T=='message'then
color=COLOR.N
his,time=true,4
elseif T=='warn'then
color=COLOR.Y
his,time=true,4
elseif T=='error'then
color=COLOR.R
his,time=true,5
elseif type(T)=='number'then
time=T
end
text=tostring(text)
assert(utf8.len(text),"Error UTF-8 coding")
if his then ins(mesHistory,SCN.cur..": "..text)end
ins(mesList,{text=text,rgba={color[1],color[2],color[3],nil},blink=30,time=time or 3})
end
function LOG.copy()
love.system.setClipboardText(table.concat(mesHistory,"\n"))
LOG.print("Log copied",'message')
end
return LOG

70
Zframework/message.lua Normal file
View File

@@ -0,0 +1,70 @@
local gc=love.graphics
local gc_push,gc_pop=gc.push,gc.pop
local gc_replaceTransform=gc.replaceTransform
local gc_translate,gc_setColor,gc_draw=gc.translate,gc.setColor,gc.draw
local ins,rem=table.insert,table.remove
local mesList={}
local MES={}
function MES.new(...)
local icon,str,time=...
if type(icon)~='userdata'then
icon,str,time=false,icon,str
else
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,
{'setCL',.5,.5,.5,.7},
{'fRect',0,0,w+20,48},
{'setCL',.9,.9,.9},
{'setLW',2},
{'dRect',1,1,w+18,46},
{'setCL',1,1,1},
}
if icon then
ins(L,{'draw',icon,4,4,nil,40/icon:getWidth(),40/icon:getHeight()})
end
ins(L,{'draw',t,icon and 50 or 10,2})
ins(mesList,{
startTime=.5,
endTime=.5,
time=time or 3,
canvas=DOGC(L),
})
end
function MES.update(dt)
for i=#mesList,1,-1 do
local m=mesList[i]
if m.startTime>0 then
m.startTime=m.startTime-dt
elseif m.time>0 then
m.time=m.time-dt
elseif m.endTime>0 then
m.endTime=m.endTime-dt
else
rem(mesList,i)
end
end
end
function MES.draw()
gc_push('transform')
if #mesList>0 then
gc_translate(0,25)
for i=1,#mesList do
local m=mesList[i]
gc_setColor(1,1,1,2*(m.endTime-m.startTime))
gc_draw(m.canvas,40-80*(m.endTime+m.startTime))
gc_translate(0,52)
end
gc_replaceTransform(SCR.xOy)
end
gc_pop()
end
return MES

View File

@@ -141,10 +141,10 @@ function profile.switch()
profile.stop() profile.stop()
love.system.setClipboardText(PROFILE.report()) love.system.setClipboardText(PROFILE.report())
PROFILE.reset() PROFILE.reset()
LOG.print("profile report copied!",'message') MES.new("profile report copied!")
else else
PROFILE.start() PROFILE.start()
LOG.print("profile start!",'message') MES.new("profile start!")
end end
switch=not switch switch=not switch
end end

View File

@@ -150,7 +150,7 @@ function SCN.swapTo(tar,style)--Parallel scene swapping, cannot back
S.time,S.mid,S.draw=s[1],s[2],s[3] S.time,S.mid,S.draw=s[1],s[2],s[3]
end end
else else
LOG.print("No Scene: "..tar,'warn') MES.new("No Scene: "..tar)
end end
end end
function SCN.go(tar,style)--Normal scene swapping, can back function SCN.go(tar,style)--Normal scene swapping, can back
@@ -158,7 +158,7 @@ function SCN.go(tar,style)--Normal scene swapping, can back
SCN.push() SCN.push()
SCN.swapTo(tar,style) SCN.swapTo(tar,style)
else else
LOG.print("No Scene: "..tar,'warn') MES.new("No Scene: "..tar)
end end
end end
function SCN.back() function SCN.back()

View File

@@ -17,7 +17,7 @@ function SFX.init(list)
if love.filesystem.getInfo(N)then if love.filesystem.getInfo(N)then
Sources[list[i]]={love.audio.newSource(N,'static')} Sources[list[i]]={love.audio.newSource(N,'static')}
else else
LOG.print("No SFX file: "..N,.1) MES.new("No SFX file: "..N,.1)
end end
if not skip and i~=count then if not skip and i~=count then
coroutine.yield() coroutine.yield()

View File

@@ -52,18 +52,18 @@ function THEME.set(theme)
elseif theme=='xmas'then elseif theme=='xmas'then
BG.setDefault('snow') BG.setDefault('snow')
BGM.setDefault('xmas') BGM.setDefault('xmas')
LOG.print("==============") MES.new("==============")
LOG.print("Merry Christmas!") MES.new("Merry Christmas!")
LOG.print("==============") MES.new("==============")
elseif theme=='birth'then elseif theme=='birth'then
BG.setDefault('firework') BG.setDefault('firework')
BGM.setDefault('magicblock') BGM.setDefault('magicblock')
elseif theme=='sprfes'then elseif theme=='sprfes'then
BG.setDefault('firework') BG.setDefault('firework')
BGM.setDefault("spring festival") BGM.setDefault("spring festival")
LOG.print(" ★☆☆★") MES.new(" ★☆☆★")
LOG.print("新年快乐!") MES.new("新年快乐!")
LOG.print(" ★☆☆★") MES.new(" ★☆☆★")
elseif theme=='zday1'then elseif theme=='zday1'then
BG.setDefault('lanterns') BG.setDefault('lanterns')
BGM.setDefault("empty") BGM.setDefault("empty")

View File

@@ -45,7 +45,7 @@ function VOC.init(list)
if n==1 then if n==1 then
if not loadVoiceFile(list[i],list[i])then if not loadVoiceFile(list[i],list[i])then
LOG.print("No VOICE file: "..list[i],.1) MES.new("No VOICE file: "..list[i],.1)
end end
end end
if not Source[list[i]][1]then Source[list[i]]=nil end if not Source[list[i]][1]then Source[list[i]]=nil end

View File

@@ -349,7 +349,7 @@ function WS.update(dt)
ws.pongTimer=1 ws.pongTimer=1
else else
ws.status='dead' ws.status='dead'
LOG.print(text.wsFailed..": "..(mes=="timeout"and text.netTimeout or mes),'warn') MES.new(text.wsFailed..": "..(mes=="timeout"and text.netTimeout or mes))
end end
end end
elseif ws.status=='running'then elseif ws.status=='running'then

View File

@@ -617,7 +617,7 @@ function selector:reset()
self.selText=self.list[i] self.selText=self.list[i]
else else
self.hide=true self.hide=true
LOG.print("Selector "..self.name.." dead, disp= "..tostring(V),'warn') MES.new("Selector "..self.name.." dead, disp= "..tostring(V))
end end
end end
function selector:isAbove(x,y) function selector:isAbove(x,y)
@@ -771,7 +771,7 @@ function inputBox:addText(str)
if type(str)=='string'then if type(str)=='string'then
self.value=self.value..str self.value=self.value..str
else else
LOG.print("inputBox "..self.name.." dead, addText("..type(str)..")",'warn') MES.new("inputBox "..self.name.." dead, addText("..type(str)..")")
end end
end end
function inputBox:clear() function inputBox:clear()

View File

@@ -161,7 +161,7 @@ SFX.init((function()
if fs.getRealDirectory("media/SFX/"..v)~=SAVEDIR then if fs.getRealDirectory("media/SFX/"..v)~=SAVEDIR then
table.insert(L,v:sub(1,-5)) table.insert(L,v:sub(1,-5))
else else
LOG.print("Dangerous file : %SAVE%/media/SFX/"..v,'warn') MES.new("Dangerous file : %SAVE%/media/SFX/"..v)
end end
end end
return L return L
@@ -172,7 +172,7 @@ BGM.init((function()
if fs.getRealDirectory("media/BGM/"..v)~=SAVEDIR then if fs.getRealDirectory("media/BGM/"..v)~=SAVEDIR then
table.insert(L,v:sub(1,-5)) table.insert(L,v:sub(1,-5))
else else
LOG.print("Dangerous file : %SAVE%/media/BGM/"..v,'warn') MES.new("Dangerous file : %SAVE%/media/BGM/"..v)
end end
end end
return L return L

View File

@@ -352,7 +352,7 @@ do--function DATA.saveRecording()
--Filtering modes that cannot be saved --Filtering modes that cannot be saved
for _,v in next,noRecList do for _,v in next,noRecList do
if GAME.curModeName:find(v)then if GAME.curModeName:find(v)then
LOG.print("Cannot save recording of this mode now!",'warn') MES.new("Cannot save recording of this mode now!")
return return
end end
end end
@@ -376,7 +376,7 @@ do--function DATA.saveRecording()
FILE.save(REPLAY,'conf/replay') FILE.save(REPLAY,'conf/replay')
return true return true
else else
LOG.print("Save failed: File already exists",'error') MES.new("Save failed: File already exists")
end end
end end
end end

View File

@@ -127,7 +127,7 @@ function freshDate(mode)
STAT.date=date STAT.date=date
STAT.todayTime=0 STAT.todayTime=0
if not mode:find'q'then if not mode:find'q'then
LOG.print(text.newDay,'message') MES.new(text.newDay)
end end
return true return true
end end
@@ -141,10 +141,10 @@ function legalGameTime()--Check if today's playtime is legal
if STAT.todayTime<14400 then if STAT.todayTime<14400 then
return true return true
elseif STAT.todayTime<21600 then elseif STAT.todayTime<21600 then
LOG.print(text.playedLong,'warn') MES.new(text.playedLong)
return true return true
else else
LOG.print(text.playedTooMuch,'warn') MES.new(text.playedTooMuch)
return false return false
end end
end end
@@ -484,7 +484,7 @@ do--function resetGameData(args)
end end
end end
else else
LOG.print("Wrong task type",'warn') MES.new("Wrong task type")
end end
end end
BG.set(GAME.modeEnv.bg) BG.set(GAME.modeEnv.bg)
@@ -574,8 +574,8 @@ do--function drawSelfProfile()
--Draw avatar --Draw avatar
gc_setLineWidth(2) gc_setLineWidth(2)
gc_setColor(.3,.3,.3,.8)gc_rectangle('fill',-300,0,300,80) gc_setColor(.3,.3,.3,.8)gc_rectangle('fill',0,0,-300,80)
gc_setColor(1,1,1)gc_rectangle('line',-300,0,300,80) gc_setColor(1,1,1)gc_rectangle('line',0,0,-300,80)
gc_rectangle('line',-73,7,66,66,2) gc_rectangle('line',-73,7,66,66,2)
gc_draw(selfAvatar,-72,8,nil,.5) gc_draw(selfAvatar,-72,8,nil,.5)

View File

@@ -16,7 +16,7 @@ return{
load=function() load=function()
PLY.newPlayer(1) PLY.newPlayer(1)
if SETTING.sfx_spawn==0 then if SETTING.sfx_spawn==0 then
LOG.print(text.switchSpawnSFX,'warn') MES.new(text.switchSpawnSFX)
end end
end, end,
mesDisp=function(P) mesDisp=function(P)

View File

@@ -78,7 +78,7 @@ local function _parse(res)
if mesType[res.type]then if mesType[res.type]then
return res return res
else else
LOG.print( MES.new(
"Error ws-mes type:"..( "Error ws-mes type:"..(
res.type and( res.type and(
res.reason and res.reason and
@@ -97,9 +97,9 @@ end
local function _closeMessage(message) local function _closeMessage(message)
local mes=JSON.decode(message:sub(3)) local mes=JSON.decode(message:sub(3))
if mes then if mes then
LOG.print(("%s [%s] %s"):format(text.wsClose,mes.type or"unknown type",mes.reason or""),'error') MES.new(("%s [%s] %s"):format(text.wsClose,mes.type or"unknown type",mes.reason or""))
else else
LOG.print(text.wsClose,'error') MES.new(text.wsClose)
end end
end end
@@ -122,7 +122,7 @@ local function pumpStream(d)
if res then if res then
DATA.pumpRecording(stream,P.stream) DATA.pumpRecording(stream,P.stream)
else else
LOG.print("Bad stream from "..P.username.."#"..P.uid,.2) MES.new("Bad stream from "..P.username.."#"..P.uid,.2)
end end
break break
end end
@@ -249,13 +249,13 @@ function NET.uploadSave()
{section=6,data=STRING.packTable(FILE.load('conf/vkSave1'))}, {section=6,data=STRING.packTable(FILE.load('conf/vkSave1'))},
{section=7,data=STRING.packTable(FILE.load('conf/vkSave2'))}, {section=7,data=STRING.packTable(FILE.load('conf/vkSave2'))},
}..'}}') }..'}}')
LOG.print("Uploading") MES.new("Uploading")
end end
end end
function NET.downloadSave() function NET.downloadSave()
if NET.lock('downloadSave',10)then if NET.lock('downloadSave',10)then
WS.send('user','{"action":3,"data":{"sections":[1,2,3,4,5,6,7]}}') WS.send('user','{"action":3,"data":{"sections":[1,2,3,4,5,6,7]}}')
LOG.print("Downloading") MES.new("Downloading")
end end
end end
function NET.loadSavedData(sections) function NET.loadSavedData(sections)
@@ -295,7 +295,7 @@ function NET.loadSavedData(sections)
FILE.save(NET.cloudData.vkSave1,'conf/vkSave1','q') FILE.save(NET.cloudData.vkSave1,'conf/vkSave1','q')
FILE.save(NET.cloudData.vkSave2,'conf/vkSave2','q') FILE.save(NET.cloudData.vkSave2,'conf/vkSave2','q')
else else
LOG.print(text.versionNotMatch,1) MES.new(text.versionNotMatch,1)
end end
end end
@@ -414,22 +414,22 @@ function NET.updateWS_app()
end end
end end
if VERSION.code<res.newestCode then if VERSION.code<res.newestCode then
LOG.print(text.oldVersion:gsub("$1",res.newestName),3) MES.new(text.oldVersion:gsub("$1",res.newestName),3)
end end
LOG.print(res.notice,5) MES.new(res.notice,5)
NET.tryLogin(true) NET.tryLogin(true)
elseif res.action==0 then--Broadcast elseif res.action==0 then--Broadcast
LOG.print(res.data.message,5) MES.new(res.data.message,5)
elseif res.action==1 then--Get notice elseif res.action==1 then--Get notice
--? --?
elseif res.action==2 then--Register elseif res.action==2 then--Register
if res.type=='Self'or res.type=='Server'then if res.type=='Self'or res.type=='Server'then
LOG.print(res.data.message,5) MES.new(res.data.message,5)
if SCN.cur=='register'then if SCN.cur=='register'then
SCN.back() SCN.back()
end end
else else
LOG.print(res.reason or"Registration failed",5) MES.new(res.reason or"Registration failed",5)
end end
NET.unlock('register') NET.unlock('register')
elseif res.action==3 then--Get player counts elseif res.action==3 then--Get player counts
@@ -466,24 +466,24 @@ function NET.updateWS_user()
FILE.save(USER,'conf/user','q') FILE.save(USER,'conf/user','q')
if SCN.cur=='login'then SCN.back()end if SCN.cur=='login'then SCN.back()end
end end
LOG.print(text.loginSuccessed,'message') MES.new(text.loginSuccessed)
--Get self infos --Get self infos
NET.getUserInfo(USER.uid) NET.getUserInfo(USER.uid)
NET.unlock('wsc_user') NET.unlock('wsc_user')
elseif res.action==0 then--Get accessToken elseif res.action==0 then--Get accessToken
NET.accessToken=res.accessToken NET.accessToken=res.accessToken
LOG.print(text.accessSuccessed,'message') MES.new(text.accessSuccessed)
NET.wsconn_play() NET.wsconn_play()
elseif res.action==1 then--Get userInfo elseif res.action==1 then--Get userInfo
USERS.updateUserData(res.data) USERS.updateUserData(res.data)
elseif res.action==2 then--Upload successed elseif res.action==2 then--Upload successed
NET.unlock('uploadSave') NET.unlock('uploadSave')
LOG.print(text.exportSuccess) MES.new(text.exportSuccess)
elseif res.action==3 then--Download successed elseif res.action==3 then--Download successed
NET.unlock('downloadSave') NET.unlock('downloadSave')
NET.loadSavedData(res.data.sections) NET.loadSavedData(res.data.sections)
LOG.print(text.importSuccess) MES.new(text.importSuccess)
end end
else else
WS.alert('user') WS.alert('user')
@@ -724,17 +724,17 @@ function NET.updateWS_manage()
local res=_parse(message) local res=_parse(message)
if res then if res then
if res.type=='Connect'then if res.type=='Connect'then
LOG.print("Manage connected",'warn') MES.new("Manage connected")
elseif res.action==0 then elseif res.action==0 then
LOG.print("success",'message') MES.new("success")
elseif res.action==9 then elseif res.action==9 then
LOG.print("success",'message') MES.new("success")
elseif res.action==10 then elseif res.action==10 then
LOG.print(TABLE.dump(res.data)) MES.new(TABLE.dump(res.data))
elseif res.action==11 then elseif res.action==11 then
LOG.print(TABLE.dump(res.data)) MES.new(TABLE.dump(res.data))
elseif res.action==12 then elseif res.action==12 then
LOG.print(TABLE.dump(res.data)) MES.new(TABLE.dump(res.data))
end end
else else
WS.alert('manage') WS.alert('manage')

View File

@@ -244,7 +244,7 @@ local function loadRemoteEnv(P,confStr)--Load gameEnv
confStr=JSON.decode(confStr) confStr=JSON.decode(confStr)
if not confStr then if not confStr then
confStr={} confStr={}
LOG.print("Bad conf from "..P.username.."#"..P.uid) MES.new("Bad conf from "..P.username.."#"..P.uid)
end end
P.gameEnv={}--Current game setting environment P.gameEnv={}--Current game setting environment

View File

@@ -222,7 +222,7 @@ return function(P)--Return a piece-generating funtion for player P
elseif type(s)=='string'and seqGenerators[s]then elseif type(s)=='string'and seqGenerators[s]then
return seqGenerators[s] return seqGenerators[s]
else else
LOG.print( MES.new(
type(s)=='string'and type(s)=='string'and
"No sequence mode called "..s or "No sequence mode called "..s or
"Wrong sequence generator", "Wrong sequence generator",

View File

@@ -116,16 +116,16 @@ local function tapBoard(x,y,key)
if checkBoard(b)then if checkBoard(b)then
state=2 state=2
time=TIME()-startTime time=TIME()-startTime
if time<1 then LOG.print("不是人") if time<1 then MES.new("不是人")
elseif time<2 then LOG.print("还是人") elseif time<2 then MES.new("还是人")
elseif time<3 then LOG.print("神仙") elseif time<3 then MES.new("神仙")
elseif time<5 then LOG.print("太强了") elseif time<5 then MES.new("太强了")
elseif time<7.5 then LOG.print("很强") elseif time<7.5 then MES.new("很强")
elseif time<10 then LOG.print("可以的") elseif time<10 then MES.new("可以的")
elseif time<20 then LOG.print("马上入门了") elseif time<20 then MES.new("马上入门了")
elseif time<30 then LOG.print("入门不远了") elseif time<30 then MES.new("入门不远了")
elseif time<60 then LOG.print("多加练习") elseif time<60 then MES.new("多加练习")
else LOG.print("第一次玩?加油") else MES.new("第一次玩?加油")
end end
SFX.play('win') SFX.play('win')
return return

View File

@@ -51,13 +51,13 @@ function scene.keyDown(key)
if key=="return"or key=="return2"then if key=="return"or key=="return2"then
if CUSTOMENV.opponent~="X"then if CUSTOMENV.opponent~="X"then
if CUSTOMENV.opponent:sub(1,2)=='CC'and CUSTOMENV.sequence=="fixed"then if CUSTOMENV.opponent:sub(1,2)=='CC'and CUSTOMENV.sequence=="fixed"then
LOG.print(text.ai_fixed,'warn') MES.new(text.ai_fixed)
return return
elseif #BAG>0 then elseif #BAG>0 then
LOG.print(text.ai_prebag,'warn') MES.new(text.ai_prebag)
return return
elseif #MISSION>0 then elseif #MISSION>0 then
LOG.print(text.ai_mission,'warn') MES.new(text.ai_mission)
return return
end end
end end
@@ -95,7 +95,7 @@ function scene.keyDown(key)
str=str.."!" str=str.."!"
if #MISSION>0 then str=str..DATA.copyMission()end if #MISSION>0 then str=str..DATA.copyMission()end
sys.setClipboardText(str.."!"..DATA.copyBoards().."!") sys.setClipboardText(str.."!"..DATA.copyBoards().."!")
LOG.print(text.exportSuccess,'message') MES.new(text.exportSuccess)
elseif key=="v"and kb.isDown("lctrl","rctrl")or key=="cV"then elseif key=="v"and kb.isDown("lctrl","rctrl")or key=="cV"then
local str=sys.getClipboardText() local str=sys.getClipboardText()
local args=STRING.split(str:sub((str:find(":")or 0)+1),"!") local args=STRING.split(str:sub((str:find(":")or 0)+1),"!")
@@ -111,9 +111,9 @@ function scene.keyDown(key)
if args[i]:find("%S")and not DATA.pasteBoard(args[i],i-3)and i<#args then goto THROW_fail end if args[i]:find("%S")and not DATA.pasteBoard(args[i],i-3)and i<#args then goto THROW_fail end
end end
freshMiniFieldVisible() freshMiniFieldVisible()
LOG.print(text.importSuccess,'message') MES.new(text.importSuccess)
do return end do return end
::THROW_fail::LOG.print(text.dataCorrupted,'error') ::THROW_fail::MES.new(text.dataCorrupted)
elseif key=="escape"then elseif key=="escape"then
FILE.save(CUSTOMENV,'conf/customEnv','q') FILE.save(CUSTOMENV,'conf/customEnv','q')
SCN.back() SCN.back()

View File

@@ -216,20 +216,20 @@ function scene.keyDown(key)
SFX.play('fall',.8) SFX.play('fall',.8)
elseif key=="c"and kb.isDown("lctrl","rctrl")or key=="cC"then elseif key=="c"and kb.isDown("lctrl","rctrl")or key=="cC"then
sys.setClipboardText("Techmino Field:"..DATA.copyBoard(page)) sys.setClipboardText("Techmino Field:"..DATA.copyBoard(page))
LOG.print(text.exportSuccess,'message') MES.new(text.exportSuccess)
elseif key=="v"and kb.isDown("lctrl","rctrl")or key=="cV"then elseif key=="v"and kb.isDown("lctrl","rctrl")or key=="cV"then
local str=sys.getClipboardText() local str=sys.getClipboardText()
local p=str:find(":")--ptr* local p=str:find(":")--ptr*
if p then if p then
if not str:sub(1,p-1):find("Field")then if not str:sub(1,p-1):find("Field")then
LOG.print(text.pasteWrongPlace,'warn') MES.new(text.pasteWrongPlace)
end end
str=str:sub(p+1) str=str:sub(p+1)
end end
if DATA.pasteBoard(str,page)then if DATA.pasteBoard(str,page)then
LOG.print(text.importSuccess,'message') MES.new(text.importSuccess)
else else
LOG.print(text.dataCorrupted,'error') MES.new(text.dataCorrupted)
end end
elseif key=="pageup"then elseif key=="pageup"then
page=max(page-1,1) page=max(page-1,1)

View File

@@ -71,22 +71,22 @@ function scene.keyDown(key)
elseif key=="c"and kb.isDown("lctrl","rctrl")or key=="cC"then elseif key=="c"and kb.isDown("lctrl","rctrl")or key=="cC"then
if #MISSION>0 then if #MISSION>0 then
sys.setClipboardText("Techmino Target:"..DATA.copyMission()) sys.setClipboardText("Techmino Target:"..DATA.copyMission())
LOG.print(text.exportSuccess,'message') MES.new(text.exportSuccess)
end end
elseif key=="v"and kb.isDown("lctrl","rctrl")or key=="cV"then elseif key=="v"and kb.isDown("lctrl","rctrl")or key=="cV"then
local str=sys.getClipboardText() local str=sys.getClipboardText()
local p=str:find(":")--ptr* local p=str:find(":")--ptr*
if p then if p then
if not str:sub(1,p-1):find("Target")then if not str:sub(1,p-1):find("Target")then
LOG.print(text.pasteWrongPlace,'warn') MES.new(text.pasteWrongPlace)
end end
str=str:sub(p+1) str=str:sub(p+1)
end end
if DATA.pasteMission(str)then if DATA.pasteMission(str)then
LOG.print(text.importSuccess,'message') MES.new(text.importSuccess)
cur=#MISSION cur=#MISSION
else else
LOG.print(text.dataCorrupted,'error') MES.new(text.dataCorrupted)
end end
elseif key=="escape"then elseif key=="escape"then
SCN.back() SCN.back()

View File

@@ -85,22 +85,22 @@ function scene.keyDown(key)
elseif key=="c"and kb.isDown("lctrl","rctrl")or key=="cC"then elseif key=="c"and kb.isDown("lctrl","rctrl")or key=="cC"then
if #BAG>0 then if #BAG>0 then
sys.setClipboardText("Techmino SEQ:"..DATA.copySequence()) sys.setClipboardText("Techmino SEQ:"..DATA.copySequence())
LOG.print(text.exportSuccess,'message') MES.new(text.exportSuccess)
end end
elseif key=="v"and kb.isDown("lctrl","rctrl")or key=="cV"then elseif key=="v"and kb.isDown("lctrl","rctrl")or key=="cV"then
local str=sys.getClipboardText() local str=sys.getClipboardText()
local p=str:find(":")--ptr* local p=str:find(":")--ptr*
if p then if p then
if not str:sub(1,p-1):find("SEQ")then if not str:sub(1,p-1):find("SEQ")then
LOG.print(text.pasteWrongPlace,'warn') MES.new(text.pasteWrongPlace)
end end
str=str:sub(p+1) str=str:sub(p+1)
end end
if DATA.pasteSequence(str)then if DATA.pasteSequence(str)then
LOG.print(text.importSuccess,'message') MES.new(text.importSuccess)
cur=#BAG cur=#BAG
else else
LOG.print(text.dataCorrupted,'error') MES.new(text.dataCorrupted)
end end
elseif key=="escape"then elseif key=="escape"then
SCN.back() SCN.back()

View File

@@ -6,9 +6,9 @@ local savePW=false
local function login() local function login()
local email,password=emailBox:getText(),passwordBox:getText() local email,password=emailBox:getText(),passwordBox:getText()
if not STRING.simpEmailCheck(email)then if not STRING.simpEmailCheck(email)then
LOG.print(text.wrongEmail,'warn')return MES.new(text.wrongEmail)return
elseif #password==0 then elseif #password==0 then
LOG.print(text.noPassword,'warn')return MES.new(text.noPassword)return
end end
NET.wsconn_user_pswd(email,password) NET.wsconn_user_pswd(email,password)
if savePW then if savePW then

View File

@@ -67,7 +67,7 @@ function scene.keyDown(key)
NET.tryLogin(false) NET.tryLogin(false)
else else
NET.wsconn_app() NET.wsconn_app()
LOG.print(text.wsConnecting,'message') MES.new(text.wsConnecting)
SFX.play('connect') SFX.play('connect')
end end
end end

View File

@@ -35,7 +35,7 @@ local function _quit()
NET.signal_quit() NET.signal_quit()
else else
lastBackTime=TIME() lastBackTime=TIME()
LOG.print(text.sureQuit,'warn') MES.new(text.sureQuit)
end end
end end
local function _switchChat() local function _switchChat()
@@ -220,7 +220,7 @@ function scene.socketRead(cmd,d)
resetGameData('n',NET.seed) resetGameData('n',NET.seed)
netPLY.mouseMove(0,0) netPLY.mouseMove(0,0)
else else
LOG.print("Redundant [Go]",'warn') MES.new("Redundant [Go]")
end end
elseif cmd=='finish'then elseif cmd=='finish'then
playing=false playing=false

View File

@@ -16,7 +16,7 @@ function scene.draw()
end end
scene.widgetList={ scene.widgetList={
WIDGET.newKey{name="setting",fText=TEXTURE.setting,x=1200,y=160,w=90,h=90,code=goScene'setting_game'}, WIDGET.newKey{name="setting",fText=TEXTURE.setting,x=1200,y=160,w=90,h=90,code=goScene'setting_game'},
WIDGET.newKey{name="match",x=640,y=500,w=760,h=140,font=60,code=function()LOG.print("Coming soon 开发中,敬请期待")end}, WIDGET.newKey{name="match",x=640,y=500,w=760,h=140,font=60,code=function()MES.new("Coming soon 开发中,敬请期待")end},
WIDGET.newButton{name="back",x=1140,y=640,w=170,h=80,fText=TEXTURE.back,code=backScene}, WIDGET.newButton{name="back",x=1140,y=640,w=170,h=80,fText=TEXTURE.back,code=backScene},
} }

View File

@@ -18,7 +18,7 @@ end
scene.widgetList={ scene.widgetList={
WIDGET.newKey{name="setting",fText=TEXTURE.setting,x=1200,y=160,w=90,h=90,code=goScene'setting_game'}, WIDGET.newKey{name="setting",fText=TEXTURE.setting,x=1200,y=160,w=90,h=90,code=goScene'setting_game'},
WIDGET.newButton{name="league", x=640, y=180,w=350,h=120,font=40,color='D',code=goScene'net_league'}, WIDGET.newButton{name="league", x=640, y=180,w=350,h=120,font=40,color='D',code=goScene'net_league'},
WIDGET.newButton{name="ffa", x=640, y=360,w=350,h=120,font=40,color='D',code=function()LOG.print("Coming soon 开发中,敬请期待")--[[NET.enterRoom({name="ffa"})]]end}, WIDGET.newButton{name="ffa", x=640, y=360,w=350,h=120,font=40,color='D',code=function()MES.new("Coming soon 开发中,敬请期待")--[[NET.enterRoom({name="ffa"})]]end},
WIDGET.newButton{name="rooms", x=640, y=540,w=350,h=120,font=40,code=goScene'net_rooms'}, WIDGET.newButton{name="rooms", x=640, y=540,w=350,h=120,font=40,code=goScene'net_rooms'},
WIDGET.newButton{name="logout", x=880, y=40,w=180,h=60,color='dR', WIDGET.newButton{name="logout", x=880, y=40,w=180,h=60,color='dR',
code=function() code=function()
@@ -32,7 +32,7 @@ scene.widgetList={
SCN.back() SCN.back()
end end
else else
LOG.print(text.sureQuit,'warn') MES.new(text.sureQuit)
lastLogoutTime=TIME() lastLogoutTime=TIME()
end end
end}, end},

View File

@@ -85,7 +85,7 @@ scene.widgetList={
ROOMENV.capacity=i ROOMENV.capacity=i
WIDGET.active.capacity.color=COLOR.lY WIDGET.active.capacity.color=COLOR.lY
else else
LOG.print("没有权限 Permission Denied",'warn') MES.new("没有权限 Permission Denied")
WIDGET.active.capacity.color=COLOR.R WIDGET.active.capacity.color=COLOR.R
end end
end}, end},

View File

@@ -61,8 +61,8 @@ function scene.keyDown(k)
elseif k=="return"then elseif k=="return"then
if NET.getlock('fetchRoom')or not NET.roomList[selected]then return end if NET.getlock('fetchRoom')or not NET.roomList[selected]then return end
local R=NET.roomList[selected] local R=NET.roomList[selected]
if R.roomInfo.version~=VERSION.short then LOG.print("Version doesn't match",'message')return end if R.roomInfo.version~=VERSION.short then MES.new("Version doesn't match")return end
if R.private then LOG.print("Can't enter private room now",'message')return end if R.private then MES.new("Can't enter private room now")return end
NET.enterRoom(R)--,password NET.enterRoom(R)--,password
end end
end end

View File

@@ -6,13 +6,13 @@ local function register()
local password= WIDGET.active.password:getText() local password= WIDGET.active.password:getText()
local password2=WIDGET.active.password2:getText() local password2=WIDGET.active.password2:getText()
if #username==0 then if #username==0 then
LOG.print(text.noUsername,'warn')return MES.new(text.noUsername)return
elseif not STRING.simpEmailCheck(email)then elseif not STRING.simpEmailCheck(email)then
LOG.print(text.wrongEmail,'warn')return MES.new(text.wrongEmail)return
elseif #password==0 or #password2==0 then elseif #password==0 or #password2==0 then
LOG.print(text.noPassword,'warn')return MES.new(text.noPassword)return
elseif password~=password2 then elseif password~=password2 then
LOG.print(text.diffPassword,'warn')return MES.new(text.diffPassword)return
end end
NET.register(username,email,password) NET.register(username,email,password)
end end

View File

@@ -2,7 +2,7 @@ local scene={}
local function dumpCB(T) local function dumpCB(T)
love.system.setClipboardText(STRING.packText(TABLE.dump(T))) love.system.setClipboardText(STRING.packText(TABLE.dump(T)))
LOG.print(text.exportSuccess,'message') MES.new(text.exportSuccess)
end end
local function parseCB() local function parseCB()
local _ local _
@@ -10,7 +10,7 @@ local function parseCB()
--Decode --Decode
s=STRING.unpackText(s) s=STRING.unpackText(s)
if not s then LOG.print(text.dataCorrupted,'error')return end if not s then MES.new(text.dataCorrupted)return end
s=loadstring(s) s=loadstring(s)
if s then if s then
@@ -32,9 +32,9 @@ scene.widgetList={
if D then if D then
TABLE.update(D,RANKS) TABLE.update(D,RANKS)
FILE.save(RANKS,'conf/unlock') FILE.save(RANKS,'conf/unlock')
LOG.print(text.importSuccess,'message') MES.new(text.importSuccess)
else else
LOG.print(text.dataCorrupted,'warn') MES.new(text.dataCorrupted)
end end
end}, end},
WIDGET.newButton{name="data", x=490,y=390,w=280,h=100,color='lR', WIDGET.newButton{name="data", x=490,y=390,w=280,h=100,color='lR',
@@ -43,9 +43,9 @@ scene.widgetList={
if D and D.version==STAT.version then if D and D.version==STAT.version then
TABLE.update(D,STAT) TABLE.update(D,STAT)
FILE.save(STAT,'conf/data') FILE.save(STAT,'conf/data')
LOG.print(text.importSuccess,'message') MES.new(text.importSuccess)
else else
LOG.print(text.dataCorrupted,'warn') MES.new(text.dataCorrupted)
end end
end}, end},
WIDGET.newButton{name="setting", x=790,y=390,w=280,h=100,color='lR', WIDGET.newButton{name="setting", x=790,y=390,w=280,h=100,color='lR',
@@ -54,9 +54,9 @@ scene.widgetList={
if D then if D then
TABLE.update(D,SETTING) TABLE.update(D,SETTING)
FILE.save(SETTING,'conf/settings') FILE.save(SETTING,'conf/settings')
LOG.print(text.importSuccess,'message') MES.new(text.importSuccess)
else else
LOG.print(text.dataCorrupted,'warn') MES.new(text.dataCorrupted)
end end
end}, end},
WIDGET.newButton{name="vk", x=1090,y=390,w=280,h=100,color='lR', WIDGET.newButton{name="vk", x=1090,y=390,w=280,h=100,color='lR',
@@ -65,9 +65,9 @@ scene.widgetList={
if D then if D then
TABLE.update(D,VK_org) TABLE.update(D,VK_org)
FILE.save(VK_org,'conf/virtualkey') FILE.save(VK_org,'conf/virtualkey')
LOG.print(text.importSuccess,'message') MES.new(text.importSuccess)
else else
LOG.print(text.dataCorrupted,'warn') MES.new(text.dataCorrupted)
end end
end}, end},

View File

@@ -16,7 +16,7 @@ local function load1()
if D then if D then
TABLE.update(D,VK_org) TABLE.update(D,VK_org)
else else
LOG.print(text.noFile,'message') MES.new(text.noFile)
end end
end end
local function save2() local function save2()
@@ -27,7 +27,7 @@ local function load2()
if D then if D then
TABLE.update(D,VK_org) TABLE.update(D,VK_org)
else else
LOG.print(text.noFile,'message') MES.new(text.noFile)
end end
end end
@@ -188,7 +188,7 @@ scene.widgetList={
B.x,B.y,B.r=T[2],T[3],T[4] B.x,B.y,B.r=T[2],T[3],T[4]
end end
end end
LOG.print(("==[ %d ]=="):format(defaultSetSelect)) MES.new(("==[ %d ]=="):format(defaultSetSelect))
defaultSetSelect=defaultSetSelect%5+1 defaultSetSelect=defaultSetSelect%5+1
selected=false selected=false
end}, end},

View File

@@ -35,7 +35,7 @@ function scene.keyDown(key)
if backCounter==0 then if backCounter==0 then
SCN.back() SCN.back()
else else
LOG.print(backCounter) MES.new(backCounter)
end end
end end
end end

View File

@@ -32,7 +32,7 @@ function SKIN.init(list)
I=gc.newImage(N) I=gc.newImage(N)
else else
I=gc.newImage("media/image/skin/"..list[1]..".png") I=gc.newImage("media/image/skin/"..list[1]..".png")
LOG.print("No skin file: "..list[i],'warn') MES.new("No skin file: "..list[i])
end end
gc.setDefaultFilter('linear','linear') gc.setDefaultFilter('linear','linear')
for y=0,2 do for y=0,2 do