房间内显示房间信息
This commit is contained in:
@@ -5,13 +5,20 @@ local WS,TIME=WS,TIME
|
|||||||
local NET={
|
local NET={
|
||||||
connected=false,
|
connected=false,
|
||||||
allow_online=false,
|
allow_online=false,
|
||||||
allReady=false,
|
|
||||||
serverGaming=false,
|
|
||||||
connectingStream=false,
|
|
||||||
roomList={},
|
|
||||||
accessToken=false,
|
accessToken=false,
|
||||||
rid=false,
|
roomList={},
|
||||||
rsid=false,
|
roomInfo={
|
||||||
|
-- rid=false,
|
||||||
|
name=false,
|
||||||
|
-- type=false,
|
||||||
|
private=false,
|
||||||
|
-- count=false,
|
||||||
|
capacity=false,
|
||||||
|
},
|
||||||
|
allReady=false,
|
||||||
|
streamRoomID=false,
|
||||||
|
connectingStream=false,
|
||||||
|
serverGaming=false,
|
||||||
}
|
}
|
||||||
|
|
||||||
local mesType={
|
local mesType={
|
||||||
@@ -109,7 +116,7 @@ function NET.wsconn_stream()
|
|||||||
WS.connect('stream','/stream',JSON.encode{
|
WS.connect('stream','/stream',JSON.encode{
|
||||||
uid=USER.uid,
|
uid=USER.uid,
|
||||||
accessToken=NET.accessToken,
|
accessToken=NET.accessToken,
|
||||||
rid=NET.rsid,
|
rid=NET.streamRoomID,
|
||||||
})
|
})
|
||||||
TASK.new(NET.updateWS_stream)
|
TASK.new(NET.updateWS_stream)
|
||||||
end
|
end
|
||||||
@@ -169,27 +176,34 @@ function NET.fetchRoom()
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function NET.createRoom(roomType,name)
|
function NET.createRoom(roomType,roomName)
|
||||||
if NET.lock('enterRoom',1.26)then
|
if NET.lock('enterRoom',1.26)then
|
||||||
|
NET.roomInfo.name=roomName or"?"
|
||||||
|
NET.roomInfo.type=roomType or"?"
|
||||||
|
NET.roomInfo.private=false
|
||||||
|
NET.roomInfo.capacity="?"
|
||||||
WS.send('play',JSON.encode{
|
WS.send('play',JSON.encode{
|
||||||
action=1,
|
action=1,
|
||||||
data={
|
data={
|
||||||
type=roomType,
|
type=roomType,
|
||||||
name=name,
|
name=roomName,
|
||||||
password=nil,
|
password=nil,
|
||||||
config=dumpBasicConfig(),
|
config=dumpBasicConfig(),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function NET.enterRoom(roomID,password)
|
function NET.enterRoom(room,password)
|
||||||
if NET.lock('enterRoom',1.26)then
|
if NET.lock('enterRoom',1.26)then
|
||||||
SFX.play('reach',.6)
|
SFX.play('reach',.6)
|
||||||
NET.rid=roomID
|
NET.roomInfo.name=room.name or"?"
|
||||||
|
NET.roomInfo.type=room.type or"?"
|
||||||
|
NET.roomInfo.private=not not password
|
||||||
|
NET.roomInfo.capacity=room.capacity or"?"
|
||||||
WS.send('play',JSON.encode{
|
WS.send('play',JSON.encode{
|
||||||
action=2,
|
action=2,
|
||||||
data={
|
data={
|
||||||
rid=roomID,
|
rid=room.rid,
|
||||||
config=dumpBasicConfig(),
|
config=dumpBasicConfig(),
|
||||||
password=password,
|
password=password,
|
||||||
}
|
}
|
||||||
@@ -410,7 +424,7 @@ function NET.updateWS_play()
|
|||||||
SFX.play('reach',.6)
|
SFX.play('reach',.6)
|
||||||
NET.allReady=true
|
NET.allReady=true
|
||||||
elseif res.action==8 then--Set
|
elseif res.action==8 then--Set
|
||||||
NET.rsid=d.rid
|
NET.streamRoomID=d.rid
|
||||||
NET.connectingStream=true
|
NET.connectingStream=true
|
||||||
NET.wsconn_stream()
|
NET.wsconn_stream()
|
||||||
elseif res.action==9 then--Game finished
|
elseif res.action==9 then--Game finished
|
||||||
|
|||||||
@@ -258,6 +258,14 @@ function scene.draw()
|
|||||||
mStr(text.ready,640,10)
|
mStr(text.ready,640,10)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--Room info.
|
||||||
|
gc.setColor(1,1,1)
|
||||||
|
setFont(25)
|
||||||
|
mStr(NET.roomInfo.name,640,685)
|
||||||
|
setFont(40)
|
||||||
|
gc.print(netPLY.getCount().."/"..NET.roomInfo.capacity,70,655)
|
||||||
|
if NET.roomInfo.private then gc.draw(IMG.lock,30,668)end
|
||||||
|
|
||||||
--Profile
|
--Profile
|
||||||
drawSelfProfile()
|
drawSelfProfile()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -16,7 +16,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="ffa", x=640, y=200,w=350,h=120,font=40,code=function()NET.enterRoom("ffa")end},
|
WIDGET.newButton{name="ffa", x=640, y=200,w=350,h=120,font=40,code=function()NET.enterRoom({name="ffa"})end},
|
||||||
WIDGET.newButton{name="rooms", x=640, y=360,w=350,h=120,font=40,code=goScene"net_rooms"},
|
WIDGET.newButton{name="rooms", x=640, y=360,w=350,h=120,font=40,code=goScene"net_rooms"},
|
||||||
WIDGET.newButton{name="chat", x=640, y=540,w=350,h=120,color='D',font=40,code=NULL},
|
WIDGET.newButton{name="chat", x=640, y=540,w=350,h=120,color='D',font=40,code=NULL},
|
||||||
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',
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ function scene.keyDown(k)
|
|||||||
LOG.print("Can't enter private room now")
|
LOG.print("Can't enter private room now")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
NET.enterRoom(NET.roomList[selected].rid)--,password
|
NET.enterRoom(NET.roomList[selected])--,password
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user