MES模块支持带内部图标(目前只有warn)

This commit is contained in:
MrZ626
2021-06-13 20:48:39 +08:00
parent e77f415f38
commit 0ee460b679
18 changed files with 41 additions and 26 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
MES.new("No BGM file: "..list[i],5) MES.new('warn',"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

@@ -4,7 +4,7 @@ return function(name,libName)
if r1 and r2 then if r1 and r2 then
return r2 return r2
else else
MES.new("Cannot load "..name..": "..(r2 or r3)) MES.new('warn',"Cannot load "..name..": "..(r2 or r3))
end end
elseif SYSTEM=="Android"then elseif SYSTEM=="Android"then
local fs=love.filesystem local fs=love.filesystem
@@ -20,7 +20,7 @@ return function(name,libName)
MES.new(name.." lib loaded") MES.new(name.." lib loaded")
break break
else else
MES.new("Cannot load "..name..": "..mes2) MES.new('warn',"Cannot load "..name..": "..mes2)
end end
else else
MES.new(("Write %s-%s to saving failed: %s"):format(name,platform[i],mes2)) MES.new(("Write %s-%s to saving failed: %s"):format(name,platform[i],mes2))
@@ -30,12 +30,12 @@ return function(name,libName)
end end
end end
if not libFunc then if not libFunc then
MES.new("Cannot load "..name) MES.new('warn',"Cannot load "..name)
return return
end end
return libFunc() return libFunc()
else else
MES.new("No "..name.." for "..SYSTEM) MES.new('warn',"No "..name.." for "..SYSTEM)
return return
end end
return true return true

View File

@@ -5,12 +5,27 @@ local gc_translate,gc_setColor,gc_draw=gc.translate,gc.setColor,gc.draw
local ins,rem=table.insert,table.remove local ins,rem=table.insert,table.remove
local mesList={} local mesList={}
local mesIcon={
warn=DOGC{40,40,
{'setCL',.95,.83,.4},
{'fPoly',20.5,1,0,38,40,38},
{'setCL',0,0,0},
{'dPoly',20.5,1,0,38,40,38},
{'fRect',17,10,7,18},
{'fRect',17,29,7,7},
{'setCL',1,1,1},
{'fRect',18,11,5,16},
{'fRect',18,30,5,5},
},
}
local MES={} local MES={}
function MES.new(...) function MES.new(...)
local icon,str,time=... local icon,str,time=...
if type(icon)~='userdata'then if type(icon)=='string'and mesIcon[icon]then
icon=mesIcon[icon]
elseif type(icon)~='userdata'then
icon,str,time=false,icon,str icon,str,time=false,icon,str
else else
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
MES.new("No Scene: "..tar) MES.new('warn',"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
MES.new("No Scene: "..tar) MES.new('warn',"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
MES.new("No SFX file: "..N,.1) MES.new('warn',"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

@@ -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
MES.new("No VOICE file: "..list[i],.1) MES.new('warn',"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

@@ -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
MES.new("Selector "..self.name.." dead, disp= "..tostring(V)) MES.new('warn',"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
MES.new("inputBox "..self.name.." dead, addText("..type(str)..")") MES.new('warn',"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
MES.new("Dangerous file : %SAVE%/media/SFX/"..v) MES.new('warn',"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
MES.new("Dangerous file : %SAVE%/media/BGM/"..v) MES.new('warn',"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
MES.new("Cannot save recording of this mode now!") MES.new('warn',"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
MES.new("Save failed: File already exists") MES.new('warn',"Save failed: File already exists")
end end
end end
end end

View File

@@ -484,7 +484,7 @@ do--function resetGameData(args)
end end
end end
else else
MES.new("Wrong task type") MES.new('warn',"Wrong task type")
end end
end end
BG.set(GAME.modeEnv.bg) BG.set(GAME.modeEnv.bg)

View File

@@ -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
MES.new("Bad stream from "..P.username.."#"..P.uid,.2) MES.new('warn',"Bad stream from "..P.username.."#"..P.uid,.2)
end end
break break
end end

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={}
MES.new("Bad conf from "..P.username.."#"..P.uid) MES.new('warn',"Bad conf from "..P.username.."#"..P.uid)
end end
P.gameEnv={}--Current game setting environment P.gameEnv={}--Current game setting environment

View File

@@ -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
MES.new("Redundant [Go]") MES.new('warn',"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()MES.new("Coming soon 开发中,敬请期待")end}, WIDGET.newKey{name="match",x=640,y=500,w=760,h=140,font=60,code=function()MES.new('warn',"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()MES.new("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('warn',"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()

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
MES.new("没有权限 Permission Denied") MES.new('warn',"没有权限 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 MES.new("Version doesn't match")return end if R.roomInfo.version~=VERSION.short then MES.new('warn',"Version doesn't match")return end
if R.private then MES.new("Can't enter private room now")return end if R.private then MES.new('warn',"Can't enter private room now")return end
NET.enterRoom(R)--,password NET.enterRoom(R)--,password
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")
MES.new("No skin file: "..list[i]) MES.new('warn',"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