实现拉取房间列表
框架跟进
This commit is contained in:
Submodule Zframework updated: 4e40322930...b48282a5f4
@@ -7,7 +7,7 @@ local NET={
|
|||||||
cloudData={},
|
cloudData={},
|
||||||
|
|
||||||
roomState={--A copy of room structure on server
|
roomState={--A copy of room structure on server
|
||||||
roomInfo={
|
info={
|
||||||
name=false,
|
name=false,
|
||||||
type=false,
|
type=false,
|
||||||
version=false,
|
version=false,
|
||||||
@@ -347,7 +347,7 @@ function NET.room.enter(rid,password)
|
|||||||
SFX.play('reach',.6)
|
SFX.play('reach',.6)
|
||||||
wsSend(1306,{
|
wsSend(1306,{
|
||||||
data={
|
data={
|
||||||
rid=rid,
|
roomId=rid,
|
||||||
password=password,
|
password=password,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -467,7 +467,9 @@ function NET.updateWS()
|
|||||||
elseif res.action==1306 then-- TODO
|
elseif res.action==1306 then-- TODO
|
||||||
elseif res.action==1307 then-- TODO
|
elseif res.action==1307 then-- TODO
|
||||||
elseif res.action==1308 then-- TODO
|
elseif res.action==1308 then-- TODO
|
||||||
elseif res.action==1309 then-- TODO
|
elseif res.action==1309 then--Fetch rooms
|
||||||
|
TASK.unlock('fetchRoom')
|
||||||
|
if res.data then SCN.scenes.net_rooms.widgetList.roomList:setList(res.data) end
|
||||||
elseif res.action==1310 then-- TODO
|
elseif res.action==1310 then-- TODO
|
||||||
elseif res.action==1311 then-- TODO
|
elseif res.action==1311 then-- TODO
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ function scene.sceneInit()
|
|||||||
showEmail=false
|
showEmail=false
|
||||||
emailBox.secret=true
|
emailBox.secret=true
|
||||||
emailBox:setText(USER.email)
|
emailBox:setText(USER.email)
|
||||||
passwordBox:setText(USER.password)
|
passwordBox:setText("")
|
||||||
end
|
end
|
||||||
|
|
||||||
function scene.keyDown(key,rep)
|
function scene.keyDown(key,rep)
|
||||||
|
|||||||
@@ -317,7 +317,7 @@ function scene.draw()
|
|||||||
--Room info.
|
--Room info.
|
||||||
gc_setColor(1,1,1)
|
gc_setColor(1,1,1)
|
||||||
setFont(25)
|
setFont(25)
|
||||||
gc_printf(NET.roomState.roomInfo.name,0,685,1270,'right')
|
gc_printf(NET.roomState.info.name,0,685,1270,'right')
|
||||||
setFont(40)
|
setFont(40)
|
||||||
gc_print(NETPLY.getCount().."/"..NET.roomState.capacity,70,655)
|
gc_print(NETPLY.getCount().."/"..NET.roomState.capacity,70,655)
|
||||||
if NET.roomState.private then
|
if NET.roomState.private then
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ scene.widgetList={
|
|||||||
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()
|
||||||
if tryBack()then
|
if tryBack()then
|
||||||
if USER.uid then
|
USER.__data.email=false
|
||||||
NET.closeWS()
|
USER.__data.password=false
|
||||||
USER.uid=false
|
USER.__data.rToken=false
|
||||||
USER.authToken=false
|
USER.__data.aToken=false
|
||||||
SCN.back()
|
NET.closeWS()
|
||||||
end
|
SCN.back()
|
||||||
end
|
end
|
||||||
end},
|
end},
|
||||||
WIDGET.newButton{name='back', x=1140,y=640,w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=backScene},
|
WIDGET.newButton{name='back', x=1140,y=640,w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=backScene},
|
||||||
|
|||||||
@@ -19,17 +19,19 @@ local roomList=WIDGET.newListBox{name='roomList',x=50,y=50,w=800,h=440,lineH=40,
|
|||||||
if item.private then
|
if item.private then
|
||||||
gc_draw(IMG.lock,10,5)
|
gc_draw(IMG.lock,10,5)
|
||||||
end
|
end
|
||||||
gc_print(item.count.."/"..item.capacity,670,-4)
|
gc_printf(item.count.Spectator>0 and ("$1(+$2)/$3"):repD(item.count.Gamer,item.count.Spectator,item.capacity) or ("$1/$2"):repD(item.count.Gamer,item.capacity),600,-4,180,'right')
|
||||||
|
|
||||||
gc_setColor(.9,.9,1)
|
gc_setColor(.9,.9,1)
|
||||||
gc_print(id,45,-4)
|
gc_print(id,45,-4)
|
||||||
|
|
||||||
if item.start then
|
if item.state=='Standby' then
|
||||||
gc_setColor(.1,.5,.2)
|
gc_setColor(COLOR.Z)
|
||||||
else
|
elseif item.state=='Ready' then
|
||||||
gc_setColor(1,1,.7)
|
gc_setColor(COLOR.lG)
|
||||||
|
elseif item.state=='Playing' then
|
||||||
|
gc_setColor(COLOR.G)
|
||||||
end
|
end
|
||||||
gc_print(item.roomInfo.name,200,-4)
|
gc_print(item.info.name,200,-4)
|
||||||
end}
|
end}
|
||||||
local function _hidePW()
|
local function _hidePW()
|
||||||
local R=roomList:getSel()
|
local R=roomList:getSel()
|
||||||
@@ -38,15 +40,18 @@ end
|
|||||||
local passwordBox=WIDGET.newInputBox{name='password',x=350,y=505,w=500,h=50,secret=true,hideF=_hidePW,limit=64}
|
local passwordBox=WIDGET.newInputBox{name='password',x=350,y=505,w=500,h=50,secret=true,hideF=_hidePW,limit=64}
|
||||||
|
|
||||||
--[[roomList[n]={
|
--[[roomList[n]={
|
||||||
rid="qwerty",
|
state='Standby',
|
||||||
roomInfo={
|
roomId="qwerty"
|
||||||
|
count={
|
||||||
|
Gamer=0,
|
||||||
|
Spectator=1,
|
||||||
|
}
|
||||||
|
info={
|
||||||
name="MrZ's room",
|
name="MrZ's room",
|
||||||
type="classic",
|
description="123123123",
|
||||||
version=1409,
|
type="normal",
|
||||||
|
version='ver A-7',
|
||||||
},
|
},
|
||||||
private=false,
|
|
||||||
start=false,
|
|
||||||
count=4,
|
|
||||||
capacity=5,
|
capacity=5,
|
||||||
}]]
|
}]]
|
||||||
local function _fetchRoom()
|
local function _fetchRoom()
|
||||||
@@ -69,8 +74,8 @@ function scene.keyDown(key)
|
|||||||
elseif roomList:getLen()>0 and(key=='join'or key=='return'and love.keyboard.isDown('lctrl','rctrl'))then
|
elseif roomList:getLen()>0 and(key=='join'or key=='return'and love.keyboard.isDown('lctrl','rctrl'))then
|
||||||
local R=roomList:getSel()
|
local R=roomList:getSel()
|
||||||
if TASK.getLock('fetchRoom')or not R then return end
|
if TASK.getLock('fetchRoom')or not R then return end
|
||||||
if R.roomInfo.version==VERSION.room then
|
if R.info.version==VERSION.room then
|
||||||
NET.room.enter(R,passwordBox.value)
|
NET.room.enter(R.roomId,passwordBox.value)
|
||||||
else
|
else
|
||||||
MES.new('error',text.versionNotMatch)
|
MES.new('error',text.versionNotMatch)
|
||||||
end
|
end
|
||||||
@@ -109,18 +114,18 @@ function scene.draw()
|
|||||||
gc_setLineWidth(3)
|
gc_setLineWidth(3)
|
||||||
gc_rectangle('line',0,0,385,335)
|
gc_rectangle('line',0,0,385,335)
|
||||||
setFont(25)
|
setFont(25)
|
||||||
gc_print(R.roomInfo.type,10,25)
|
gc_print(R.info.type,10,25)
|
||||||
gc_setColor(1,1,.7)
|
gc_setColor(1,1,.7)
|
||||||
gc_printf(R.roomInfo.name,10,0,365)
|
gc_printf(R.info.name,10,0,365)
|
||||||
setFont(20)
|
setFont(20)
|
||||||
gc_setColor(COLOR.lH)
|
gc_setColor(COLOR.lH)
|
||||||
gc_printf(R.roomInfo.description or"[No description]",10,55,365)
|
gc_printf(R.info.description or"[No description]",10,55,365)
|
||||||
if R.start then
|
if R.start then
|
||||||
gc_setColor(COLOR.lA)
|
gc_setColor(COLOR.lA)
|
||||||
gc_print(text.started,10,300)
|
gc_print(text.started,10,300)
|
||||||
end
|
end
|
||||||
gc_setColor(COLOR.lN)
|
gc_setColor(COLOR.lN)
|
||||||
gc_printf(R.roomInfo.version,10,300,365,'right')
|
gc_printf(R.info.version,10,300,365,'right')
|
||||||
gc_translate(-870,-220)
|
gc_translate(-870,-220)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user