实现新api的进房和准备/观战
修复不会刷新在线人数
This commit is contained in:
@@ -71,8 +71,8 @@ local nullIndex={
|
||||
MES.new('error',"User not loaded: "..k)
|
||||
NETPLY.add{
|
||||
uid=k,
|
||||
username="Stacker",
|
||||
mode=0,
|
||||
playMode='Spectator',
|
||||
readyMode='Standby',
|
||||
config="",
|
||||
}
|
||||
return self[k]
|
||||
@@ -106,10 +106,10 @@ end
|
||||
function NETPLY.add(d)
|
||||
local p={
|
||||
uid=d.uid,
|
||||
username=d.username,
|
||||
mode=d.mode,
|
||||
config=d.config,
|
||||
connected=false,
|
||||
playMode=d.playMode,-- 'Gamer'|'Spectator'
|
||||
readyMode=d.readyMode,-- 'Standby'|'Ready'|'Playing'|'Finished'
|
||||
config=d.config,-- A long string generated by dumpBasicConfig()
|
||||
|
||||
place=1e99,
|
||||
stat=false,
|
||||
}
|
||||
@@ -132,34 +132,26 @@ function NETPLY.remove(uid)
|
||||
end
|
||||
|
||||
function NETPLY.getCount() return #PLYlist end
|
||||
function NETPLY.getSelfJoinMode() return PLYmap[USER.uid].mode end
|
||||
function NETPLY.getSelfReady() return PLYmap[USER.uid].mode>0 end
|
||||
function NETPLY.getSelfPlayMode() return PLYmap[USER.uid].playMode end
|
||||
function NETPLY.getSelfReadyMode() return PLYmap[USER.uid].playMode end
|
||||
function NETPLY.getSelfReady() return PLYmap[USER.uid].readyMode end
|
||||
|
||||
function NETPLY.setPlayerObj(ply,p) ply.p=p end
|
||||
function NETPLY.setConf(uid,config) PLYmap[uid].config=config end
|
||||
function NETPLY.setJoinMode(uid,ready)
|
||||
for _,p in next,PLYlist do
|
||||
if p.uid==uid then
|
||||
if p.mode~=ready then
|
||||
p.mode=ready
|
||||
if ready==0 then NET.roomReadyState=false end
|
||||
SFX.play('spin_0',.6)
|
||||
if p.uid==USER.uid then
|
||||
TASK.unlock('ready')
|
||||
elseif PLYmap[USER.uid].mode==0 then
|
||||
for j=1,#PLYlist do
|
||||
if not p.uid==USER.uid and PLYlist[j].mode==0 then
|
||||
return
|
||||
end
|
||||
end
|
||||
SFX.play('warn_2',.5)
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
function NETPLY.setPlayMode(uid,mode)
|
||||
local p=PLYmap[uid]
|
||||
if p and p.playMode~=mode then
|
||||
p.playMode=mode
|
||||
NET.freshRoomState()
|
||||
end
|
||||
end
|
||||
function NETPLY.setReadyMode(uid,mode)
|
||||
local p=PLYmap[uid]
|
||||
if p and p.ReadyMode~=mode then
|
||||
p.ReadyMode=mode
|
||||
NET.freshRoomState()
|
||||
end
|
||||
end
|
||||
function NETPLY.setConnect(uid) PLYmap[uid].connected=true end
|
||||
function NETPLY.setPlace(uid,place) PLYmap[uid].place=place end
|
||||
function NETPLY.setStat(uid,S)
|
||||
PLYmap[uid].stat={
|
||||
@@ -170,8 +162,7 @@ function NETPLY.setStat(uid,S)
|
||||
end
|
||||
function NETPLY.resetState()
|
||||
for i=1,#PLYlist do
|
||||
PLYlist[i].mode=0
|
||||
PLYlist[i].connected=false
|
||||
PLYlist[i].playMode=0
|
||||
end
|
||||
end
|
||||
|
||||
@@ -209,18 +200,19 @@ function NETPLY.draw()
|
||||
local p=PLYlist[i]
|
||||
gc_translate(p.x,p.y)
|
||||
-- Rectangle
|
||||
gc_setColor(COLOR[
|
||||
p.mode==0 and 'lH' or
|
||||
p.mode==1 and 'N' or
|
||||
p.mode==2 and 'F'
|
||||
])
|
||||
if p.playMode=='Gamer' then
|
||||
gc_setColor(COLOR[
|
||||
p.playMode=='Spectator' and 'lH' or
|
||||
p.playMode=='Gamer' and (
|
||||
p.readyMode=='Standby' and 'Z' or
|
||||
'N'
|
||||
) or 'dH'
|
||||
])
|
||||
else
|
||||
gc_setColor(COLOR.lH)
|
||||
end
|
||||
gc_setLineWidth(2)
|
||||
gc_rectangle('line',0,0,p.w,p.h)
|
||||
if p.connected then
|
||||
local c=p.mode==1 and COLOR.N or COLOR.F
|
||||
gc_setColor(c[1],c[2],c[3],.26)
|
||||
gc_rectangle('fill',0,0,p.w,p.h)
|
||||
end
|
||||
|
||||
-- Stencil
|
||||
stencilW,stencilH=p.w,p.h
|
||||
@@ -236,12 +228,12 @@ function NETPLY.draw()
|
||||
if p.h>=47 then
|
||||
setFont(40)
|
||||
gc_print("#"..p.uid,50,-5)
|
||||
gc_print(p.username,210,-5)
|
||||
gc_print(USERS.getUsername(p.uid),210,-5)
|
||||
else
|
||||
setFont(15)
|
||||
gc_print("#"..p.uid,46,-1)
|
||||
setFont(30)
|
||||
gc_print(p.username,p.h,8)
|
||||
gc_print(USERS.getUsername(p.uid),p.h,8)
|
||||
end
|
||||
|
||||
-- Stat
|
||||
@@ -273,7 +265,7 @@ function NETPLY.draw()
|
||||
setFont(30)
|
||||
gc_print("#"..selP.uid,75,0)
|
||||
setFont(35)
|
||||
gc_print(selP.username,75,25)
|
||||
gc_print(USERS.getUsername(selP.uid),75,25)
|
||||
setFont(20)
|
||||
gc_printf(USERS.getMotto(selP.uid),5,70,390)
|
||||
if selP.stat then
|
||||
|
||||
Reference in New Issue
Block a user