实现拉取房间列表
框架跟进
This commit is contained in:
Submodule Zframework updated: 4e40322930...b48282a5f4
@@ -7,7 +7,7 @@ local NET={
|
||||
cloudData={},
|
||||
|
||||
roomState={--A copy of room structure on server
|
||||
roomInfo={
|
||||
info={
|
||||
name=false,
|
||||
type=false,
|
||||
version=false,
|
||||
@@ -347,7 +347,7 @@ function NET.room.enter(rid,password)
|
||||
SFX.play('reach',.6)
|
||||
wsSend(1306,{
|
||||
data={
|
||||
rid=rid,
|
||||
roomId=rid,
|
||||
password=password,
|
||||
}
|
||||
})
|
||||
@@ -467,7 +467,9 @@ function NET.updateWS()
|
||||
elseif res.action==1306 then-- TODO
|
||||
elseif res.action==1307 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==1311 then-- TODO
|
||||
end
|
||||
|
||||
@@ -19,7 +19,7 @@ function scene.sceneInit()
|
||||
showEmail=false
|
||||
emailBox.secret=true
|
||||
emailBox:setText(USER.email)
|
||||
passwordBox:setText(USER.password)
|
||||
passwordBox:setText("")
|
||||
end
|
||||
|
||||
function scene.keyDown(key,rep)
|
||||
|
||||
@@ -317,7 +317,7 @@ function scene.draw()
|
||||
--Room info.
|
||||
gc_setColor(1,1,1)
|
||||
setFont(25)
|
||||
gc_printf(NET.roomState.roomInfo.name,0,685,1270,'right')
|
||||
gc_printf(NET.roomState.info.name,0,685,1270,'right')
|
||||
setFont(40)
|
||||
gc_print(NETPLY.getCount().."/"..NET.roomState.capacity,70,655)
|
||||
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',
|
||||
code=function()
|
||||
if tryBack()then
|
||||
if USER.uid then
|
||||
NET.closeWS()
|
||||
USER.uid=false
|
||||
USER.authToken=false
|
||||
SCN.back()
|
||||
end
|
||||
USER.__data.email=false
|
||||
USER.__data.password=false
|
||||
USER.__data.rToken=false
|
||||
USER.__data.aToken=false
|
||||
NET.closeWS()
|
||||
SCN.back()
|
||||
end
|
||||
end},
|
||||
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
|
||||
gc_draw(IMG.lock,10,5)
|
||||
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_print(id,45,-4)
|
||||
|
||||
if item.start then
|
||||
gc_setColor(.1,.5,.2)
|
||||
else
|
||||
gc_setColor(1,1,.7)
|
||||
if item.state=='Standby' then
|
||||
gc_setColor(COLOR.Z)
|
||||
elseif item.state=='Ready' then
|
||||
gc_setColor(COLOR.lG)
|
||||
elseif item.state=='Playing' then
|
||||
gc_setColor(COLOR.G)
|
||||
end
|
||||
gc_print(item.roomInfo.name,200,-4)
|
||||
gc_print(item.info.name,200,-4)
|
||||
end}
|
||||
local function _hidePW()
|
||||
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}
|
||||
|
||||
--[[roomList[n]={
|
||||
rid="qwerty",
|
||||
roomInfo={
|
||||
state='Standby',
|
||||
roomId="qwerty"
|
||||
count={
|
||||
Gamer=0,
|
||||
Spectator=1,
|
||||
}
|
||||
info={
|
||||
name="MrZ's room",
|
||||
type="classic",
|
||||
version=1409,
|
||||
description="123123123",
|
||||
type="normal",
|
||||
version='ver A-7',
|
||||
},
|
||||
private=false,
|
||||
start=false,
|
||||
count=4,
|
||||
capacity=5,
|
||||
}]]
|
||||
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
|
||||
local R=roomList:getSel()
|
||||
if TASK.getLock('fetchRoom')or not R then return end
|
||||
if R.roomInfo.version==VERSION.room then
|
||||
NET.room.enter(R,passwordBox.value)
|
||||
if R.info.version==VERSION.room then
|
||||
NET.room.enter(R.roomId,passwordBox.value)
|
||||
else
|
||||
MES.new('error',text.versionNotMatch)
|
||||
end
|
||||
@@ -109,18 +114,18 @@ function scene.draw()
|
||||
gc_setLineWidth(3)
|
||||
gc_rectangle('line',0,0,385,335)
|
||||
setFont(25)
|
||||
gc_print(R.roomInfo.type,10,25)
|
||||
gc_print(R.info.type,10,25)
|
||||
gc_setColor(1,1,.7)
|
||||
gc_printf(R.roomInfo.name,10,0,365)
|
||||
gc_printf(R.info.name,10,0,365)
|
||||
setFont(20)
|
||||
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
|
||||
gc_setColor(COLOR.lA)
|
||||
gc_print(text.started,10,300)
|
||||
end
|
||||
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)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user