删除测试代码,升级textBox控件,改进listBox控件,整理代码
This commit is contained in:
@@ -508,21 +508,6 @@ function NET.updateWS_play()
|
||||
SFX.play('connected')
|
||||
elseif res.action==0 then--Fetch rooms
|
||||
if SCN.cur=="net_rooms"then
|
||||
for i=1,16 do
|
||||
res.roomList[i]={
|
||||
rid="qwe",
|
||||
roomInfo={
|
||||
name="Test room "..i,
|
||||
type="classic",
|
||||
version=VERSION.short,
|
||||
description="x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x ",
|
||||
},
|
||||
private=i%3==0,
|
||||
start=i%4==0,
|
||||
count=i%5,
|
||||
capacity=5,
|
||||
}
|
||||
end
|
||||
WIDGET.active.roomList:setList(res.roomList)
|
||||
end
|
||||
NET.unlock('fetchRoom')
|
||||
@@ -571,7 +556,7 @@ function NET.updateWS_play()
|
||||
mode=d.mode,
|
||||
config=d.config,
|
||||
}
|
||||
if SCN.socketRead then SCN.socketRead('join',d)end
|
||||
if SCN.cur=='net_game'then SCN.socketRead('join',d)end
|
||||
NET.allReady=false
|
||||
end
|
||||
elseif res.action==3 then--Player leave
|
||||
@@ -584,10 +569,10 @@ function NET.updateWS_play()
|
||||
netPLY.remove(d.sid)
|
||||
removePlayer(PLAYERS,d.sid)
|
||||
removePlayer(PLY_ALIVE,d.sid)
|
||||
if SCN.socketRead then SCN.socketRead('leave',d)end
|
||||
if SCN.cur=='net_game'then SCN.socketRead('leave',d)end
|
||||
end
|
||||
elseif res.action==4 then--Player talk
|
||||
if SCN.socketRead then SCN.socketRead('talk',d)end
|
||||
if SCN.cur=='net_game'then SCN.socketRead('talk',d)end
|
||||
elseif res.action==5 then--Player change settings
|
||||
netPLY.setConf(d.uid,d.config)
|
||||
elseif res.action==6 then--Player change join mode
|
||||
@@ -600,7 +585,7 @@ function NET.updateWS_play()
|
||||
NET.connectingStream=true
|
||||
NET.wsconn_stream(d.srid)
|
||||
elseif res.action==9 then--Game finished
|
||||
if SCN.socketRead then SCN.socketRead('finish',d)end
|
||||
if SCN.cur=='net_game'then SCN.socketRead('finish',d)end
|
||||
|
||||
--d.result: list of {place,survivalTime,uid,score}
|
||||
for _,p in next,d.result do
|
||||
|
||||
@@ -1,26 +1,33 @@
|
||||
local gc=love.graphics
|
||||
local gc_translate=gc.translate
|
||||
local gc_setColor,gc_setLineWidth=gc.setColor,gc.setLineWidth
|
||||
local gc_draw=gc.draw
|
||||
local gc_rectangle,gc_arc=gc.rectangle,gc.arc
|
||||
local gc_print,gc_printf=gc.print,gc.printf
|
||||
|
||||
|
||||
local NET=NET
|
||||
local fetchTimer
|
||||
|
||||
local roomList=WIDGET.newListBox{name="roomList",x=50,y=50,w=800,h=440,lineH=40,drawF=function(ifSel,id,item)
|
||||
setFont(35)
|
||||
if ifSel then
|
||||
gc.setColor(1,1,1,.3)
|
||||
gc.rectangle('fill',0,0,800,40)
|
||||
gc_setColor(1,1,1,.3)
|
||||
gc_rectangle('fill',0,0,800,40)
|
||||
end
|
||||
gc.setColor(1,1,1)
|
||||
if item.private then gc.draw(IMG.lock,10,5)end
|
||||
gc.print(item.count.."/"..item.capacity,670,-4)
|
||||
gc_setColor(1,1,1)
|
||||
if item.private then gc_draw(IMG.lock,10,5)end
|
||||
gc_print(item.count.."/"..item.capacity,670,-4)
|
||||
|
||||
gc.setColor(.9,.9,1)
|
||||
gc.print(id,45,-4)
|
||||
gc_setColor(.9,.9,1)
|
||||
gc_print(id,45,-4)
|
||||
|
||||
if item.start then
|
||||
gc.setColor(0,.4,.1)
|
||||
gc_setColor(0,.4,.1)
|
||||
else
|
||||
gc.setColor(1,1,.7)
|
||||
gc_setColor(1,1,.7)
|
||||
end
|
||||
gc.print(item.roomInfo.name,200,-4)
|
||||
gc_print(item.roomInfo.name,200,-4)
|
||||
end}
|
||||
local function hidePW()
|
||||
local R=roomList:getSel()
|
||||
@@ -86,30 +93,30 @@ end
|
||||
|
||||
function scene.draw()
|
||||
--Fetching timer
|
||||
gc.setColor(1,1,1,.12)
|
||||
gc.arc('fill','pie',250,630,40,-1.5708,-1.5708-.6283*fetchTimer)
|
||||
gc_setColor(1,1,1,.12)
|
||||
gc_arc('fill','pie',250,630,40,-1.5708,-1.5708-.6283*fetchTimer)
|
||||
|
||||
--Room list
|
||||
local R=roomList:getSel()
|
||||
if R then
|
||||
gc.translate(870,220)
|
||||
gc.setColor(1,1,1)
|
||||
gc.setLineWidth(3)
|
||||
gc.rectangle('line',0,0,385,335)
|
||||
gc_translate(870,220)
|
||||
gc_setColor(1,1,1)
|
||||
gc_setLineWidth(3)
|
||||
gc_rectangle('line',0,0,385,335)
|
||||
setFont(25)
|
||||
gc.print(R.roomInfo.type,10,25)
|
||||
gc.setColor(1,1,.7)
|
||||
gc.printf(R.roomInfo.name,10,0,365)
|
||||
gc_print(R.roomInfo.type,10,25)
|
||||
gc_setColor(1,1,.7)
|
||||
gc_printf(R.roomInfo.name,10,0,365)
|
||||
setFont(20)
|
||||
gc.setColor(.8,.8,.8)
|
||||
gc.printf(R.roomInfo.description or"[No description]",10,55,365)
|
||||
gc_setColor(.8,.8,.8)
|
||||
gc_printf(R.roomInfo.description or"[No description]",10,55,365)
|
||||
if R.start then
|
||||
gc.setColor(0,1,.2)
|
||||
gc.print(text.started,10,300)
|
||||
gc_setColor(0,1,.2)
|
||||
gc_print(text.started,10,300)
|
||||
end
|
||||
gc.setColor(1,.2,0)
|
||||
gc.printf(R.roomInfo.version,10,300,365,'right')
|
||||
gc.translate(-870,-220)
|
||||
gc_setColor(1,.2,0)
|
||||
gc_printf(R.roomInfo.version,10,300,365,'right')
|
||||
gc_translate(-870,-220)
|
||||
end
|
||||
|
||||
--Profile
|
||||
|
||||
Reference in New Issue
Block a user