代码规范:把所有的tab换成空格
This commit is contained in:
@@ -9,58 +9,58 @@ local ins,rem=table.insert,table.remove
|
||||
local setFont=setFont
|
||||
|
||||
local posLists={
|
||||
--1~5
|
||||
(function()
|
||||
local L={}
|
||||
for i=1,5 do
|
||||
L[i]={x=70,y=20+90*i,w=790,h=80}
|
||||
end
|
||||
return L
|
||||
end)(),
|
||||
--6~17
|
||||
(function()
|
||||
local L={}
|
||||
for i=1,10 do
|
||||
L[i]={x=40,y=60+55*i,w=520,h=50}
|
||||
end
|
||||
for i=1,7 do
|
||||
L[10+i]={x=600,y=60+55*i,w=520,h=50}
|
||||
end
|
||||
return L
|
||||
end)(),
|
||||
--18~31
|
||||
(function()
|
||||
local L={}
|
||||
for i=1,11 do L[i]= {x=40,y=65+50*i,w=330,h=45}end
|
||||
for i=1,11 do L[11+i]= {x=400,y=65+50*i,w=330,h=45}end
|
||||
for i=1,9 do L[22+i]= {x=760,y=65+50*i,w=330,h=45}end
|
||||
return L
|
||||
end)(),
|
||||
--32~49
|
||||
(function()
|
||||
local L={}
|
||||
for i=1,10 do L[i]= {x=30,y=60+50*i,w=200,h=45}end
|
||||
for i=1,10 do L[10+i]= {x=240,y=60+50*i,w=200,h=45}end
|
||||
for i=1,10 do L[20+i]= {x=450,y=60+50*i,w=200,h=45}end
|
||||
for i=1,10 do L[30+i]= {x=660,y=60+50*i,w=200,h=45}end
|
||||
for i=1,9 do L[40+i]= {x=870,y=60+50*i,w=200,h=45}end
|
||||
return L
|
||||
end)(),
|
||||
--50~99
|
||||
(function()
|
||||
local L={}
|
||||
for i=1,11 do L[i]= {x=30,y=60+50*i,w=100,h=45}end
|
||||
for i=1,11 do L[i+11]= {x=135,y=60+50*i,w=100,h=45}end
|
||||
for i=1,11 do L[i+22]= {x=240,y=60+50*i,w=100,h=45}end
|
||||
for i=1,11 do L[i+33]= {x=345,y=60+50*i,w=100,h=45}end
|
||||
for i=1,11 do L[i+44]= {x=450,y=60+50*i,w=100,h=45}end
|
||||
for i=1,11 do L[i+55]= {x=555,y=60+50*i,w=100,h=45}end
|
||||
for i=1,11 do L[i+66]= {x=660,y=60+50*i,w=100,h=45}end
|
||||
for i=1,11 do L[i+77]= {x=765,y=60+50*i,w=100,h=45}end
|
||||
for i=1,7 do L[i+88]= {x=870,y=60+50*i,w=100,h=45}end
|
||||
for i=1,4 do L[i+95]= {x=975,y=60+50*i,w=100,h=45}end
|
||||
return L
|
||||
end)(),
|
||||
--1~5
|
||||
(function()
|
||||
local L={}
|
||||
for i=1,5 do
|
||||
L[i]={x=70,y=20+90*i,w=790,h=80}
|
||||
end
|
||||
return L
|
||||
end)(),
|
||||
--6~17
|
||||
(function()
|
||||
local L={}
|
||||
for i=1,10 do
|
||||
L[i]={x=40,y=60+55*i,w=520,h=50}
|
||||
end
|
||||
for i=1,7 do
|
||||
L[10+i]={x=600,y=60+55*i,w=520,h=50}
|
||||
end
|
||||
return L
|
||||
end)(),
|
||||
--18~31
|
||||
(function()
|
||||
local L={}
|
||||
for i=1,11 do L[i]= {x=40,y=65+50*i,w=330,h=45}end
|
||||
for i=1,11 do L[11+i]={x=400,y=65+50*i,w=330,h=45}end
|
||||
for i=1,9 do L[22+i]= {x=760,y=65+50*i,w=330,h=45}end
|
||||
return L
|
||||
end)(),
|
||||
--32~49
|
||||
(function()
|
||||
local L={}
|
||||
for i=1,10 do L[i]= {x=30,y=60+50*i,w=200,h=45}end
|
||||
for i=1,10 do L[10+i]={x=240,y=60+50*i,w=200,h=45}end
|
||||
for i=1,10 do L[20+i]={x=450,y=60+50*i,w=200,h=45}end
|
||||
for i=1,10 do L[30+i]={x=660,y=60+50*i,w=200,h=45}end
|
||||
for i=1,9 do L[40+i]= {x=870,y=60+50*i,w=200,h=45}end
|
||||
return L
|
||||
end)(),
|
||||
--50~99
|
||||
(function()
|
||||
local L={}
|
||||
for i=1,11 do L[i]= {x=30,y=60+50*i,w=100,h=45}end
|
||||
for i=1,11 do L[i+11]={x=135,y=60+50*i,w=100,h=45}end
|
||||
for i=1,11 do L[i+22]={x=240,y=60+50*i,w=100,h=45}end
|
||||
for i=1,11 do L[i+33]={x=345,y=60+50*i,w=100,h=45}end
|
||||
for i=1,11 do L[i+44]={x=450,y=60+50*i,w=100,h=45}end
|
||||
for i=1,11 do L[i+55]={x=555,y=60+50*i,w=100,h=45}end
|
||||
for i=1,11 do L[i+66]={x=660,y=60+50*i,w=100,h=45}end
|
||||
for i=1,11 do L[i+77]={x=765,y=60+50*i,w=100,h=45}end
|
||||
for i=1,7 do L[i+88]= {x=870,y=60+50*i,w=100,h=45}end
|
||||
for i=1,4 do L[i+95]= {x=975,y=60+50*i,w=100,h=45}end
|
||||
return L
|
||||
end)(),
|
||||
}
|
||||
local posList
|
||||
local function _placeSort(a,b)return a.place<b.place end
|
||||
@@ -68,71 +68,71 @@ local function _placeSort(a,b)return a.place<b.place end
|
||||
local netPLY
|
||||
|
||||
local nullIndex={
|
||||
__index=function(self,k)
|
||||
MES.traceback()
|
||||
MES.new('error',"User not loaded: "..k)
|
||||
netPLY.add{
|
||||
uid=k,
|
||||
username="Stacker",
|
||||
sid=-1,
|
||||
mode=0,
|
||||
config="",
|
||||
}
|
||||
return self[k]
|
||||
end
|
||||
__index=function(self,k)
|
||||
MES.traceback()
|
||||
MES.new('error',"User not loaded: "..k)
|
||||
netPLY.add{
|
||||
uid=k,
|
||||
username="Stacker",
|
||||
sid=-1,
|
||||
mode=0,
|
||||
config="",
|
||||
}
|
||||
return self[k]
|
||||
end
|
||||
}
|
||||
local PLYlist,PLYmap=setmetatable({},nullIndex),setmetatable({},nullIndex)
|
||||
local function _freshPos()
|
||||
table.sort(PLYlist,_placeSort)
|
||||
if #PLYlist<=5 then
|
||||
posList=posLists[1]
|
||||
elseif #PLYlist<=17 then
|
||||
posList=posLists[2]
|
||||
elseif #PLYlist<=31 then
|
||||
posList=posLists[3]
|
||||
elseif #PLYlist<=49 then
|
||||
posList=posLists[4]
|
||||
else--if #PLY<=99 then
|
||||
posList=posLists[5]
|
||||
end
|
||||
table.sort(PLYlist,_placeSort)
|
||||
if #PLYlist<=5 then
|
||||
posList=posLists[1]
|
||||
elseif #PLYlist<=17 then
|
||||
posList=posLists[2]
|
||||
elseif #PLYlist<=31 then
|
||||
posList=posLists[3]
|
||||
elseif #PLYlist<=49 then
|
||||
posList=posLists[4]
|
||||
else--if #PLY<=99 then
|
||||
posList=posLists[5]
|
||||
end
|
||||
end
|
||||
netPLY={
|
||||
list=PLYlist,
|
||||
map=PLYmap,
|
||||
freshPos=_freshPos,
|
||||
list=PLYlist,
|
||||
map=PLYmap,
|
||||
freshPos=_freshPos,
|
||||
}
|
||||
|
||||
function netPLY.clear()
|
||||
TABLE.cut(PLYlist)
|
||||
TABLE.clear(PLYmap)
|
||||
TABLE.cut(PLYlist)
|
||||
TABLE.clear(PLYmap)
|
||||
end
|
||||
function netPLY.add(d)
|
||||
local p={
|
||||
uid=d.uid,
|
||||
username=d.username,
|
||||
sid=d.sid,
|
||||
mode=d.mode,
|
||||
config=d.config,
|
||||
connected=false,
|
||||
place=1e99,
|
||||
stat=false,
|
||||
}
|
||||
local a=rnd()*6.2832
|
||||
p.x,p.y,p.w,p.h=640+2600*cos(a),360+2600*sin(a),47,47
|
||||
local p={
|
||||
uid=d.uid,
|
||||
username=d.username,
|
||||
sid=d.sid,
|
||||
mode=d.mode,
|
||||
config=d.config,
|
||||
connected=false,
|
||||
place=1e99,
|
||||
stat=false,
|
||||
}
|
||||
local a=rnd()*6.2832
|
||||
p.x,p.y,p.w,p.h=640+2600*cos(a),360+2600*sin(a),47,47
|
||||
|
||||
ins(PLYlist,p)
|
||||
PLYmap[p.uid]=p
|
||||
_freshPos()
|
||||
ins(PLYlist,p)
|
||||
PLYmap[p.uid]=p
|
||||
_freshPos()
|
||||
end
|
||||
function netPLY.remove(sid)
|
||||
for i=1,#PLYlist do
|
||||
if PLYlist[i].sid==sid then
|
||||
PLYmap[PLYlist[i].uid]=nil
|
||||
rem(PLYlist,i)
|
||||
_freshPos()
|
||||
break
|
||||
end
|
||||
end
|
||||
for i=1,#PLYlist do
|
||||
if PLYlist[i].sid==sid then
|
||||
PLYmap[PLYlist[i].uid]=nil
|
||||
rem(PLYlist,i)
|
||||
_freshPos()
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function netPLY.getCount()return #PLYlist end
|
||||
@@ -143,151 +143,151 @@ function netPLY.getSelfReady()return PLYmap[USER.uid].mode>0 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
|
||||
NET.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('blip_2',.5)
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
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
|
||||
NET.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('blip_2',.5)
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
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={
|
||||
lpm=("%.1f %s"):format(S.row/S.time*60,text.radarData[5]),
|
||||
apm=("%.1f %s"):format(S.atk/S.time*60,text.radarData[3]),
|
||||
adpm=("%.1f %s"):format((S.atk+S.dig)/S.time*60,text.radarData[2]),
|
||||
}
|
||||
PLYmap[uid].stat={
|
||||
lpm=("%.1f %s"):format(S.row/S.time*60,text.radarData[5]),
|
||||
apm=("%.1f %s"):format(S.atk/S.time*60,text.radarData[3]),
|
||||
adpm=("%.1f %s"):format((S.atk+S.dig)/S.time*60,text.radarData[2]),
|
||||
}
|
||||
end
|
||||
function netPLY.resetState()
|
||||
for i=1,#PLYlist do
|
||||
PLYlist[i].mode=0
|
||||
PLYlist[i].connected=false
|
||||
end
|
||||
for i=1,#PLYlist do
|
||||
PLYlist[i].mode=0
|
||||
PLYlist[i].connected=false
|
||||
end
|
||||
end
|
||||
|
||||
local selP,mouseX,mouseY
|
||||
function netPLY.mouseMove(x,y)
|
||||
selP=nil
|
||||
for i=1,#PLYlist do
|
||||
local p=PLYlist[i]
|
||||
if x>p.x and y>p.y and x<p.x+p.w and y<p.y+p.h then
|
||||
mouseX,mouseY=x,y
|
||||
selP=p
|
||||
break
|
||||
end
|
||||
end
|
||||
selP=nil
|
||||
for i=1,#PLYlist do
|
||||
local p=PLYlist[i]
|
||||
if x>p.x and y>p.y and x<p.x+p.w and y<p.y+p.h then
|
||||
mouseX,mouseY=x,y
|
||||
selP=p
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function netPLY.update()
|
||||
for i=1,#PLYlist do
|
||||
local p=PLYlist[i]
|
||||
local t=posList[i]
|
||||
p.x=p.x*.9+t.x*.1
|
||||
p.y=p.y*.9+t.y*.1
|
||||
p.w=p.w*.9+t.w*.1
|
||||
p.h=p.h*.9+t.h*.1
|
||||
end
|
||||
for i=1,#PLYlist do
|
||||
local p=PLYlist[i]
|
||||
local t=posList[i]
|
||||
p.x=p.x*.9+t.x*.1
|
||||
p.y=p.y*.9+t.y*.1
|
||||
p.w=p.w*.9+t.w*.1
|
||||
p.h=p.h*.9+t.h*.1
|
||||
end
|
||||
end
|
||||
|
||||
local stencilW,stencilH
|
||||
local function _playerFrameStencil()
|
||||
gc_rectangle('fill',0,0,stencilW,stencilH)
|
||||
gc_rectangle('fill',0,0,stencilW,stencilH)
|
||||
end
|
||||
function netPLY.draw()
|
||||
for i=1,#PLYlist do
|
||||
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'
|
||||
])
|
||||
gc_setLineWidth(2)
|
||||
gc_rectangle('line',0,0,p.w,p.h)
|
||||
if p.connected then
|
||||
local c=COLOR[p.mode==1 and'N'or'F']
|
||||
gc_setColor(c[1],c[2],c[3],.26)
|
||||
gc_rectangle('fill',0,0,p.w,p.h)
|
||||
end
|
||||
for i=1,#PLYlist do
|
||||
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'
|
||||
])
|
||||
gc_setLineWidth(2)
|
||||
gc_rectangle('line',0,0,p.w,p.h)
|
||||
if p.connected then
|
||||
local c=COLOR[p.mode==1 and'N'or'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
|
||||
gc_setStencilTest('equal',1)
|
||||
gc_stencil(_playerFrameStencil)
|
||||
gc_setColor(1,1,1)
|
||||
--Stencil
|
||||
stencilW,stencilH=p.w,p.h
|
||||
gc_setStencilTest('equal',1)
|
||||
gc_stencil(_playerFrameStencil)
|
||||
gc_setColor(1,1,1)
|
||||
|
||||
--Avatar
|
||||
local avatarSize=min(p.h,50)/128*.9
|
||||
gc_draw(USERS.getAvatar(p.uid),2,2,nil,avatarSize)
|
||||
--Avatar
|
||||
local avatarSize=min(p.h,50)/128*.9
|
||||
gc_draw(USERS.getAvatar(p.uid),2,2,nil,avatarSize)
|
||||
|
||||
--UID & Username
|
||||
if p.h>=47 then
|
||||
setFont(40)
|
||||
gc_print("#"..p.uid,50,-5)
|
||||
gc_print(p.username,210,-5)
|
||||
else
|
||||
setFont(15)
|
||||
gc_print("#"..p.uid,46,-1)
|
||||
setFont(30)
|
||||
gc_print(p.username,p.h,8)
|
||||
end
|
||||
--UID & Username
|
||||
if p.h>=47 then
|
||||
setFont(40)
|
||||
gc_print("#"..p.uid,50,-5)
|
||||
gc_print(p.username,210,-5)
|
||||
else
|
||||
setFont(15)
|
||||
gc_print("#"..p.uid,46,-1)
|
||||
setFont(30)
|
||||
gc_print(p.username,p.h,8)
|
||||
end
|
||||
|
||||
--Stat
|
||||
local S=p.stat
|
||||
if S and(p.h>=55 or p.w>=180)then
|
||||
setFont(20)
|
||||
local x=p.w-155
|
||||
if p.h>=55 then
|
||||
gc_printf(S.adpm,x,2,150,'right')
|
||||
gc_printf(S.apm,x,24,150,'right')
|
||||
gc_printf(S.lpm,x,46,150,'right')
|
||||
else
|
||||
gc_printf(S.adpm,x,0,150,'right')
|
||||
gc_printf(S.lpm,x,19,150,'right')
|
||||
end
|
||||
end
|
||||
gc_setStencilTest()
|
||||
gc_translate(-p.x,-p.y)
|
||||
end
|
||||
if selP then
|
||||
gc_translate(min(mouseX,880),min(mouseY,460))
|
||||
gc_setColor(.2,.2,.2,.7)
|
||||
gc_rectangle('fill',0,0,400,260)
|
||||
gc_setColor(1,1,1)
|
||||
gc_setLineWidth(2)
|
||||
gc_rectangle('line',0,0,400,260)
|
||||
--Stat
|
||||
local S=p.stat
|
||||
if S and(p.h>=55 or p.w>=180)then
|
||||
setFont(20)
|
||||
local x=p.w-155
|
||||
if p.h>=55 then
|
||||
gc_printf(S.adpm,x,2,150,'right')
|
||||
gc_printf(S.apm,x,24,150,'right')
|
||||
gc_printf(S.lpm,x,46,150,'right')
|
||||
else
|
||||
gc_printf(S.adpm,x,0,150,'right')
|
||||
gc_printf(S.lpm,x,19,150,'right')
|
||||
end
|
||||
end
|
||||
gc_setStencilTest()
|
||||
gc_translate(-p.x,-p.y)
|
||||
end
|
||||
if selP then
|
||||
gc_translate(min(mouseX,880),min(mouseY,460))
|
||||
gc_setColor(.2,.2,.2,.7)
|
||||
gc_rectangle('fill',0,0,400,260)
|
||||
gc_setColor(1,1,1)
|
||||
gc_setLineWidth(2)
|
||||
gc_rectangle('line',0,0,400,260)
|
||||
|
||||
gc_draw(USERS.getAvatar(selP.uid),5,5,nil,.5)
|
||||
setFont(30)
|
||||
gc_print("#"..selP.uid,75,0)
|
||||
setFont(35)
|
||||
gc_print(selP.username,75,25)
|
||||
setFont(20)
|
||||
gc_printf(USERS.getMotto(selP.uid),5,70,390)
|
||||
if selP.stat then
|
||||
local S=selP.stat
|
||||
gc_print(S.lpm,5,193)
|
||||
gc_print(S.apm,5,213)
|
||||
gc_print(S.adpm,5,233)
|
||||
end
|
||||
gc_translate(-min(mouseX,880),-min(mouseY,460))
|
||||
end
|
||||
gc_draw(USERS.getAvatar(selP.uid),5,5,nil,.5)
|
||||
setFont(30)
|
||||
gc_print("#"..selP.uid,75,0)
|
||||
setFont(35)
|
||||
gc_print(selP.username,75,25)
|
||||
setFont(20)
|
||||
gc_printf(USERS.getMotto(selP.uid),5,70,390)
|
||||
if selP.stat then
|
||||
local S=selP.stat
|
||||
gc_print(S.lpm,5,193)
|
||||
gc_print(S.apm,5,213)
|
||||
gc_print(S.adpm,5,233)
|
||||
end
|
||||
gc_translate(-min(mouseX,880),-min(mouseY,460))
|
||||
end
|
||||
end
|
||||
|
||||
return netPLY
|
||||
Reference in New Issue
Block a user