实现新api的进房和准备/观战

修复不会刷新在线人数
This commit is contained in:
MrZ_26
2022-10-19 23:29:45 +08:00
parent ccb05230f2
commit dc1973e049
7 changed files with 131 additions and 114 deletions

View File

@@ -157,12 +157,6 @@ function scene.draw()
-- Player
PLAYERS[1]:draw()
-- Profile
drawSelfProfile()
-- Player count
drawOnlinePlayerCount()
end
scene.widgetList={

View File

@@ -27,14 +27,15 @@ local function _hideReadyUI()
end
local function _setCancel()
NET.player_setPlaying(true)
NET.player_setReady(true)
NET.player_setPlayMode('Gamer')
NET.player_setReadyMode(false)
end
local function _setReady()
NET.player_setReady(true)
NET.player_setPlayMode('Gamer')
NET.player_setReadyMode(true)
end
local function _setSpectate()
NET.player_setPlaying(false)
NET.player_setPlayMode('Spectator')
end
local function _gotoSetting()
@@ -153,7 +154,7 @@ function scene.keyDown(key,isRep)
end
elseif not _hideReadyUI() then
if key=='space' then
if NETPLY.getSelfJoinMode()==0 then
if NETPLY.getSelfPlayMode()~='Gamer' then
(kb.isDown('lctrl','rctrl','lalt','ralt') and _setSpectate or _setReady)()
else
_setCancel()
@@ -323,8 +324,8 @@ function scene.draw()
gc_print("M",430,10)
end
end
local function _hideF_ingame() return _hideReadyUI() or NETPLY.getSelfReady() end
local function _hideF_ingame2() return _hideReadyUI() or not NETPLY.getSelfReady() end
local function _hideF_ingame() return _hideReadyUI() or NETPLY.getSelfReadyMode()=='Spectator' end
local function _hideF_ingame2() return _hideReadyUI() or NETPLY.getSelfReadyMode()=='Gamer' end
scene.widgetList={
textBox,
inputBox,

View File

@@ -36,14 +36,17 @@ local function _createRoom()
if #roomname==0 then
roomname=(USERS.getUsername(USER.uid) or "Anonymous").."'s room"
end
NET.room_create(
roomname,
descriptionBox.value,
ROOMENV.capacity,
"normal",
ROOMENV,
pw
)
NET.room_create{
capacity=ROOMENV.capacity,
info={
name=roomname,
type="normal",
version=VERSION.room,
description=descriptionBox.value,
},
data=ROOMENV,
password=pw,
}
end
end