diff --git a/Zframework/bgm.lua b/Zframework/bgm.lua index aebab767..3b238766 100644 --- a/Zframework/bgm.lua +++ b/Zframework/bgm.lua @@ -50,7 +50,7 @@ function BGM.init(list) Sources[list[i]]:setLooping(true) Sources[list[i]]:setVolume(0) else - LOG.print("No BGM file: "..list[i],5,COLOR.O) + LOG.print("No BGM file: "..list[i],5,'warn') end if not skip and i~=count then coroutine.yield() diff --git a/Zframework/file.lua b/Zframework/file.lua index b11106b0..b756701f 100644 --- a/Zframework/file.lua +++ b/Zframework/file.lua @@ -21,7 +21,7 @@ function FILE.load(name) return s end end - LOG.print(name.." "..text.loadError,COLOR.R) + LOG.print(name.." "..text.loadError,'error') end end function FILE.save(data,name,mode) @@ -50,7 +50,7 @@ function FILE.save(data,name,mode) F:flush()F:close() if success then if not mode:find'q'then - LOG.print(text.saveDone,COLOR.G) + LOG.print(text.saveDone,'message') end else LOG.print(text.saveError..(mes or"unknown error"),'error') diff --git a/Zframework/init.lua b/Zframework/init.lua index c8b007ed..fc998e91 100644 --- a/Zframework/init.lua +++ b/Zframework/init.lua @@ -204,7 +204,7 @@ local function noDevkeyPressed(key) if key=="f1"then PROFILE.switch() 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)) + LOG.print(("System:%s[%s]\nluaVer:%s\njitVer:%s\njitVerNum:%s"):format(SYSTEM,jit.arch,_VERSION,jit.version,jit.version_num),'message') elseif key=="f3"then for _=1,8 do local P=PLY_ALIVE[rnd(#PLY_ALIVE)] @@ -217,11 +217,11 @@ local function noDevkeyPressed(key) elseif key=="f5"then if WIDGET.sel then print(WIDGET.sel)end elseif key=="f6"then for k,v in next,_G do print(k,v)end elseif key=="f7"then if love._openConsole then love._openConsole()end - elseif key=="f8"then devMode=nil LOG.print("DEBUG OFF",COLOR.Y) - elseif key=="f9"then devMode=1 LOG.print("DEBUG 1",COLOR.Y) - elseif key=="f10"then devMode=2 LOG.print("DEBUG 2",COLOR.Y) - elseif key=="f11"then devMode=3 LOG.print("DEBUG 3",COLOR.Y) - elseif key=="f12"then devMode=4 LOG.print("DEBUG 4",COLOR.Y) + elseif key=="f8"then devMode=nil LOG.print("DEBUG OFF") + elseif key=="f9"then devMode=1 LOG.print("DEBUG 1") + elseif key=="f10"then devMode=2 LOG.print("DEBUG 2") + elseif key=="f11"then devMode=3 LOG.print("DEBUG 3") + elseif key=="f12"then devMode=4 LOG.print("DEBUG 4") elseif key=="\\"then _G["\100\114\97\119\70\87\77"]=NULL elseif devMode==2 then if WIDGET.sel then @@ -251,7 +251,7 @@ function love.keypressed(key) return elseif key=="f8"then devMode=1 - LOG.print("DEBUG ON",COLOR.Y) + LOG.print("DEBUG ON") elseif key=="f11"then switchFullscreen() elseif not SCN.swapping then @@ -278,12 +278,13 @@ end function love.joystickadded(JS) ins(joysticks,JS) + LOG.print("Joystick added",'message') end function love.joystickremoved(JS) local i=TABLE.find(joysticks,JS) if i then rem(joysticks,i) - LOG.print("Joystick removed",COLOR.Y) + LOG.print("Joystick removed",'message') end end local keyMirror={ diff --git a/Zframework/loadLib.lua b/Zframework/loadLib.lua index be380368..a992cd8b 100644 --- a/Zframework/loadLib.lua +++ b/Zframework/loadLib.lua @@ -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') 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",'message') else for i=1,#platform do - local soFile=fs.read('data',"libAndroid/"..platform[i].."/"..libName.Android) + local soFile,_,_,mes1=fs.read('data',"libAndroid/"..platform[i].."/"..libName.Android) if soFile then - local success,message=fs.write("lib/"..libName.Android,soFile) + local success,mes2=fs.write("lib/"..libName.Android,soFile) if success then - libFunc,message=package.loadlib(SAVEDIR.."/lib/"..libName.Android,libName.libFunc) + libFunc,mes2=package.loadlib(SAVEDIR.."/lib/"..libName.Android,libName.libFunc) if libFunc then - LOG.print(name.." lib loaded",'warn',COLOR.G) + LOG.print(name.." lib loaded",'message') break else - LOG.print("Cannot load "..name..": "..message,'warn',COLOR.R) + LOG.print("Cannot load "..name..": "..mes2,'error') end else - LOG.print("Write "..name.."-"..platform[i].." to saving failed: "..message,'warn',COLOR.R) + LOG.print(("Write %s-%s to saving failed: %s"):format(name,platform[i],mes2),'error') end else - LOG.print("Read "..name.."-"..platform[i].." failed",'warn',COLOR.R) + LOG.print(("Read %s-%s to saving failed: %s"):format(name,platform[i],mes1),'error') end end if not libFunc then - LOG.print("Cannot load "..name,'warn',COLOR.R) + LOG.print("Cannot load "..name,'error') return end end return libFunc() else - LOG.print("No "..name.." for "..SYSTEM,'warn',COLOR.R) + LOG.print("No "..name.." for "..SYSTEM,'error') return end return true diff --git a/Zframework/log.lua b/Zframework/log.lua index f6214d1b..377a0a31 100644 --- a/Zframework/log.lua +++ b/Zframework/log.lua @@ -35,36 +35,26 @@ function LOG.draw() end end end -function LOG.print(text,T,C)--text,type/time/color,color - local time - local his - if T=='warn'then - C=C or COLOR.Y - his=true - time=180 +function LOG.print(text,T)--text,type/time/color,color + local color=COLOR.Z + local time,his + if T=='message'then + color=COLOR.N + his,time=true,180 + elseif T=='warn'then + color=COLOR.Y + his,time=true,180 elseif T=='error'then - C=C or COLOR.R - his=true - time=210 - elseif T=='message'then - C=C or COLOR.N - his=true + color=COLOR.R + his,time=true,210 elseif type(T)=='number'then - C=C or COLOR.Z time=T - elseif type(T)=='table'then - C=T - elseif not C then - C=COLOR.Z end - if his then - ins(debugMesHistory,SCN.cur..": "..tostring(text)) - end - ins(debugMesList,{text=tostring(text),r=C[1],g=C[2],b=C[3],blink=30,time=time or 120}) + if his then ins(debugMesHistory,SCN.cur..": "..tostring(text))end + ins(debugMesList,{text=tostring(text),r=color[1],g=color[2],b=color[3],blink=30,time=time or 120}) end function LOG.copy() - local str=table.concat(debugMesHistory,"\n") - love.system.setClipboardText(str) - LOG.print("Log copied",COLOR.B) + love.system.setClipboardText(table.concat(debugMesHistory,"\n")) + LOG.print("Log copied",'message') end return LOG \ No newline at end of file diff --git a/Zframework/profile.lua b/Zframework/profile.lua index d9d5a3ca..df443f2f 100644 --- a/Zframework/profile.lua +++ b/Zframework/profile.lua @@ -141,10 +141,10 @@ function profile.switch() profile.stop() love.system.setClipboardText(PROFILE.report()) PROFILE.reset() - LOG.print("profile report copied!") + LOG.print("profile report copied!",'message') else PROFILE.start() - LOG.print("profile start!") + LOG.print("profile start!",'message') end switch=not switch end diff --git a/Zframework/sfx.lua b/Zframework/sfx.lua index 986f1312..730487b3 100644 --- a/Zframework/sfx.lua +++ b/Zframework/sfx.lua @@ -17,7 +17,7 @@ function SFX.init(list) if love.filesystem.getInfo(N)then Sources[list[i]]={love.audio.newSource(N,'static')} else - LOG.print("No SFX file: "..N,5,COLOR.O) + LOG.print("No SFX file: "..N,5) end if not skip and i~=count then coroutine.yield() diff --git a/Zframework/theme.lua b/Zframework/theme.lua index 8d35e28b..c297c8d1 100644 --- a/Zframework/theme.lua +++ b/Zframework/theme.lua @@ -48,15 +48,15 @@ function THEME.set(theme) elseif theme=='xmas'then BG.setDefault('snow') BGM.setDefault('xmas') - LOG.print("==============",COLOR.R) - LOG.print("Merry Christmas!",COLOR.Z) - LOG.print("==============",COLOR.R) + LOG.print("==============") + LOG.print("Merry Christmas!") + LOG.print("==============") elseif theme=='sprfes'then BG.setDefault('firework') BGM.setDefault("spring festival") - LOG.print(" ★☆☆★",COLOR.R) - LOG.print("新年快乐!",COLOR.Z) - LOG.print(" ★☆☆★",COLOR.R) + LOG.print(" ★☆☆★") + LOG.print("新年快乐!") + LOG.print(" ★☆☆★") elseif theme=='zday1'then BG.setDefault('lanterns') BGM.setDefault("empty") diff --git a/Zframework/voice.lua b/Zframework/voice.lua index 3c15118d..ce1cae27 100644 --- a/Zframework/voice.lua +++ b/Zframework/voice.lua @@ -45,7 +45,7 @@ function VOC.init(list) if n==1 then if not loadVoiceFile(list[i],list[i])then - LOG.print("No VOICE file: "..list[i],5,COLOR.O) + LOG.print("No VOICE file: "..list[i],5) end end if not Source[list[i]][1]then Source[list[i]]=nil end diff --git a/main.lua b/main.lua index 5f146d9c..db9ff3d6 100644 --- a/main.lua +++ b/main.lua @@ -167,7 +167,7 @@ SFX.init((function() if fs.getRealDirectory("media/SFX/"..v)~=SAVEDIR then table.insert(L,v:sub(1,-5)) else - LOG.print("Dangerous file : %SAVE%/media/SFX/"..v) + LOG.print("Dangerous file : %SAVE%/media/SFX/"..v,'warn') end end return L @@ -178,7 +178,7 @@ BGM.init((function() if fs.getRealDirectory("media/BGM/"..v)~=SAVEDIR then table.insert(L,v:sub(1,-5)) else - LOG.print("Dangerous file : %SAVE%/media/BGM/"..v) + LOG.print("Dangerous file : %SAVE%/media/BGM/"..v,'warn') end end return L diff --git a/parts/data.lua b/parts/data.lua index 1a3e1ef4..8cc00831 100644 --- a/parts/data.lua +++ b/parts/data.lua @@ -4,6 +4,8 @@ local int=math.floor local char,byte=string.char,string.byte local ins=table.insert +local BAG,FIELD,MISSION,CUSTOMENV,GAME=BAG,FIELD,MISSION,CUSTOMENV,GAME + local DATA={} --Sep symbol: 33 (!) --Safe char: 34~126 @@ -14,7 +16,6 @@ local DATA={} Example: "abcdefg" is [SZJLTOI], "a^aDb)" is [Z*63,Z*37,S*10] ]] function DATA.copySequence() - local BAG=BAG local str="" local count=1 @@ -111,22 +112,22 @@ function DATA.pasteBoard(str,page)--Paste [str] data to [page] board if not page then page=1 end if not FIELD[page]then FIELD[page]=DATA.newBoard()end local F=FIELD[page] - local _,__ --Decode + local res str=STRING.trim(str) - _,str=pcall(data.decode,'string','base64',str) - if not _ then return end - _,str=pcall(data.decompress,'string','zlib',str) - if not _ then return end + res,str=pcall(data.decode,'string','base64',str) + if not res then return end + res,str=pcall(data.decompress,'string','zlib',str) + if not res then return end local fX,fY=1,1--*ptr for Field(r*10+(c-1)) local p=1 while true do - _=byte(str,p)--1byte + local b=byte(str,p)--1byte --Str end - if not _ then + if not b then if fX~=1 then return else @@ -134,11 +135,11 @@ function DATA.pasteBoard(str,page)--Paste [str] data to [page] board end end - __=_%32-1--Block id - if __>26 then return end--Illegal blockid - _=int(_/32)--Mode id + local id=b%32-1--Block id + if id>26 then return end--Illegal blockid + b=int(b/32)--Mode id - F[fY][fX]=__ + F[fY][fX]=id if fX<10 then fX=fX+1 else @@ -176,7 +177,6 @@ end ]] function DATA.copyMission() local _ - local MISSION=MISSION local str="" local count=1 @@ -362,7 +362,7 @@ do--function DATA.saveRecording() --Filtering modes that cannot be saved for _,v in next,noRecList do if GAME.curModeName:find(v)then - LOG.print("Cannot save recording of this mode now!",COLOR.N) + LOG.print("Cannot save recording of this mode now!",'warn') return end end @@ -386,7 +386,7 @@ do--function DATA.saveRecording() FILE.save(REPLAY,'conf/replay') return true else - LOG.print("Save failed: File already exists") + LOG.print("Save failed: File already exists",'error') end end end diff --git a/parts/modes/blind_wtf.lua b/parts/modes/blind_wtf.lua index 70f0baa5..0d4a01a6 100644 --- a/parts/modes/blind_wtf.lua +++ b/parts/modes/blind_wtf.lua @@ -16,7 +16,7 @@ return{ load=function() PLY.newPlayer(1) if SETTING.sfx_spawn==0 then - LOG.print(text.switchSpawnSFX,COLOR.Y) + LOG.print(text.switchSpawnSFX,'warn') end end, mesDisp=function(P) diff --git a/parts/net.lua b/parts/net.lua index bceacfe0..b537ac94 100644 --- a/parts/net.lua +++ b/parts/net.lua @@ -298,21 +298,21 @@ function NET.updateWS_app() end end if VERSION.code0 then str=str..DATA.copyMission()end sys.setClipboardText(str.."!"..DATA.copyBoards().."!") - LOG.print(text.exportSuccess,COLOR.G) + LOG.print(text.exportSuccess,'message') elseif key=="v"and kb.isDown("lctrl","rctrl")or key=="cV"then local str=sys.getClipboardText() local args=STRING.split(str:sub((str:find(":")or 0)+1),"!") @@ -98,9 +98,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 end freshMiniFieldVisible() - LOG.print(text.importSuccess,COLOR.G) + LOG.print(text.importSuccess,'message') do return end - ::THROW_fail::LOG.print(text.dataCorrupted,COLOR.R) + ::THROW_fail::LOG.print(text.dataCorrupted,'error') elseif key=="escape"then FILE.save(CUSTOMENV,'conf/customEnv','q') SCN.back() diff --git a/parts/scenes/custom_field.lua b/parts/scenes/custom_field.lua index 7da89397..fb876d89 100644 --- a/parts/scenes/custom_field.lua +++ b/parts/scenes/custom_field.lua @@ -216,21 +216,21 @@ function scene.keyDown(key) SFX.play('fall',.8) elseif key=="c"and kb.isDown("lctrl","rctrl")or key=="cC"then sys.setClipboardText("Techmino Field:"..DATA.copyBoard(page)) - LOG.print(text.exportSuccess,COLOR.G) + LOG.print(text.exportSuccess,'message') elseif key=="v"and kb.isDown("lctrl","rctrl")or key=="cV"then local str=sys.getClipboardText() local p=str:find(":")--ptr* if p then if not str:sub(1,p-1):find("Field")then - LOG.print(text.pasteWrongPlace) + LOG.print(text.pasteWrongPlace,'warn') end str=str:sub(p+1) end if DATA.pasteBoard(str,page)then - LOG.print(text.importSuccess,COLOR.G) + LOG.print(text.importSuccess,'message') else print(text.dataCorrupted) - LOG.print(text.dataCorrupted,COLOR.R) + LOG.print(text.dataCorrupted,'error') end elseif key=="pageup"then page=max(page-1,1) diff --git a/parts/scenes/custom_mission.lua b/parts/scenes/custom_mission.lua index 095d4e16..baef2dcb 100644 --- a/parts/scenes/custom_mission.lua +++ b/parts/scenes/custom_mission.lua @@ -71,22 +71,22 @@ function scene.keyDown(key) elseif key=="c"and kb.isDown("lctrl","rctrl")or key=="cC"then if #MISSION>0 then sys.setClipboardText("Techmino Target:"..DATA.copyMission()) - LOG.print(text.exportSuccess,COLOR.G) + LOG.print(text.exportSuccess,'message') end elseif key=="v"and kb.isDown("lctrl","rctrl")or key=="cV"then local str=sys.getClipboardText() local p=str:find(":")--ptr* if p then if not str:sub(1,p-1):find("Target")then - LOG.print(text.pasteWrongPlace) + LOG.print(text.pasteWrongPlace,'warn') end str=str:sub(p+1) end if DATA.pasteMission(str)then - LOG.print(text.importSuccess,COLOR.G) + LOG.print(text.importSuccess,'message') cur=#MISSION else - LOG.print(text.dataCorrupted,COLOR.R) + LOG.print(text.dataCorrupted,'error') end elseif key=="escape"then SCN.back() diff --git a/parts/scenes/custom_sequence.lua b/parts/scenes/custom_sequence.lua index 25ecce78..8e5fd09a 100644 --- a/parts/scenes/custom_sequence.lua +++ b/parts/scenes/custom_sequence.lua @@ -85,22 +85,22 @@ function scene.keyDown(key) elseif key=="c"and kb.isDown("lctrl","rctrl")or key=="cC"then if #BAG>0 then sys.setClipboardText("Techmino SEQ:"..DATA.copySequence()) - LOG.print(text.exportSuccess,COLOR.G) + LOG.print(text.exportSuccess,'message') end elseif key=="v"and kb.isDown("lctrl","rctrl")or key=="cV"then local str=sys.getClipboardText() local p=str:find(":")--ptr* if p then if not str:sub(1,p-1):find("SEQ")then - LOG.print(text.pasteWrongPlace) + LOG.print(text.pasteWrongPlace,'warn') end str=str:sub(p+1) end if DATA.pasteSequence(str)then - LOG.print(text.importSuccess,COLOR.G) + LOG.print(text.importSuccess,'message') cur=#BAG else - LOG.print(text.dataCorrupted,COLOR.R) + LOG.print(text.dataCorrupted,'error') end elseif key=="escape"then SCN.back() diff --git a/parts/scenes/login.lua b/parts/scenes/login.lua index 758ec997..8027b378 100644 --- a/parts/scenes/login.lua +++ b/parts/scenes/login.lua @@ -6,9 +6,9 @@ local savePW=false local function login() local email,password=emailBox:getText(),passwordBox:getText() if not STRING.simpEmailCheck(email)then - LOG.print(text.wrongEmail)return + LOG.print(text.wrongEmail,'warn')return elseif #password==0 then - LOG.print(text.noPassword)return + LOG.print(text.noPassword,'warn')return end NET.wsconn_user_pswd(email,password) if savePW then diff --git a/parts/scenes/net_game.lua b/parts/scenes/net_game.lua index 97efbaf9..21f4eec3 100644 --- a/parts/scenes/net_game.lua +++ b/parts/scenes/net_game.lua @@ -83,7 +83,7 @@ function scene.keyDown(key) NET.signal_quit() else lastBackTime=TIME() - LOG.print(text.sureQuit,COLOR.O) + LOG.print(text.sureQuit,'warn') end elseif key=="return"then if inputBox.hide then @@ -180,7 +180,7 @@ function scene.socketRead(cmd,d) upstreamProgress=1 resetGameData('n',d.seed) else - LOG.print("Redundant [Go]",30,COLOR.G) + LOG.print("Redundant [Go]",'warn') end elseif cmd=='finish'then playing=false @@ -203,7 +203,7 @@ function scene.socketRead(cmd,d) if res then DATA.pumpRecording(stream,P.stream) else - LOG.print("Bad stream from "..P.username.."#"..P.uid) + LOG.print("Bad stream from "..P.username.."#"..P.uid,30) end end end diff --git a/parts/scenes/net_menu.lua b/parts/scenes/net_menu.lua index 46093434..893f98e5 100644 --- a/parts/scenes/net_menu.lua +++ b/parts/scenes/net_menu.lua @@ -31,7 +31,7 @@ scene.widgetList={ SCN.back() end else - LOG.print(text.sureQuit,COLOR.O) + LOG.print(text.sureQuit,'warn') lastLogoutTime=TIME() end end}, diff --git a/parts/scenes/net_rooms.lua b/parts/scenes/net_rooms.lua index c3f12c64..cb306baf 100644 --- a/parts/scenes/net_rooms.lua +++ b/parts/scenes/net_rooms.lua @@ -74,7 +74,7 @@ function scene.keyDown(k) elseif k=="return"then if NET.getlock('fetchRoom')or not NET.roomList[selected]then return end if NET.roomList[selected].private then - LOG.print("Can't enter private room now") + LOG.print("Can't enter private room now",'message') return end NET.enterRoom(NET.roomList[selected])--,password diff --git a/parts/scenes/register.lua b/parts/scenes/register.lua index 39f5b28d..ed515e44 100644 --- a/parts/scenes/register.lua +++ b/parts/scenes/register.lua @@ -6,13 +6,13 @@ local function register() local password= WIDGET.active.password:getText() local password2=WIDGET.active.password2:getText() if #username==0 then - LOG.print(text.noUsername)return + LOG.print(text.noUsername,'warn')return elseif not STRING.simpEmailCheck(email)then - LOG.print(text.wrongEmail)return + LOG.print(text.wrongEmail,'warn')return elseif #password==0 or #password2==0 then - LOG.print(text.noPassword)return + LOG.print(text.noPassword,'warn')return elseif password~=password2 then - LOG.print(text.diffPassword)return + LOG.print(text.diffPassword,'warn')return end NET.register(username,email,password) end diff --git a/parts/scenes/savedata.lua b/parts/scenes/savedata.lua index 4ba9bed8..6217fad1 100644 --- a/parts/scenes/savedata.lua +++ b/parts/scenes/savedata.lua @@ -10,7 +10,7 @@ local function dumpCB(T) ) ) ) - LOG.print(text.exportSuccess) + LOG.print(text.exportSuccess,'message') end local function parseCB() local _ @@ -18,9 +18,9 @@ local function parseCB() --Decode _,s=pcall(love.data.decode,'string','base64',s) - if not _ then LOG.print(text.dataCorrupted,COLOR.R)return end + if not _ then LOG.print(text.dataCorrupted,'error')return end _,s=pcall(love.data.decompress,'string','zlib',s) - if not _ then LOG.print(text.dataCorrupted,COLOR.R)return end + if not _ then LOG.print(text.dataCorrupted,'error')return end s=loadstring(s) if s then diff --git a/parts/scenes/setting_touch.lua b/parts/scenes/setting_touch.lua index 05e6169e..b3ecc5d7 100644 --- a/parts/scenes/setting_touch.lua +++ b/parts/scenes/setting_touch.lua @@ -188,7 +188,7 @@ scene.widgetList={ B.x,B.y,B.r=T[2],T[3],T[4] end end - LOG.print(("[ %d ]"):format(defaultSetSelect)) + LOG.print(("==[ %d ]=="):format(defaultSetSelect)) defaultSetSelect=defaultSetSelect%5+1 selected=false end},