玩家个人信息栏下部显示在线玩家数量

This commit is contained in:
MrZ626
2021-05-12 01:44:06 +08:00
parent 99ba68fce8
commit e3b36c8ad1
13 changed files with 57 additions and 9 deletions

View File

@@ -589,6 +589,11 @@ do--function drawSelfProfile()
gc.pop()
end
end
function drawOnlinePlayerCount()
setFont(20)
gc.setColor(1,1,1)
gc.printf(("%s: %s/%s/%s"):format(text.onlinePlayerCount,NET.UserCount,NET.PlayCount,NET.StreamCount),0,80,1272,'right')
end
do--function drawWarning()
local SETTING,GAME,shader_warning,SCR=SETTING,GAME,SHADER.warning,SCR
function drawWarning()

View File

@@ -97,6 +97,8 @@ return{
wsClose="WebSocket Closed: ",
netTimeout="Network connection timeout",
onlinePlayerCount="Online",
createRoomTooFast="You are creating a room too fast!",
createRoomSuccessed="Room successfully created!",
started="Playing",
@@ -105,7 +107,7 @@ return{
ready="READY",
set="SET",
champion="$1 won",
chatRemain="Online: ",
chatRemain="Online",
chatStart="------Beginning of log------",
chatHistory="------New messages below------",

View File

@@ -97,6 +97,8 @@ return{
-- wsClose="WebSocket Closed: ",
-- netTimeout="Network connection timeout",
-- onlinePlayerCount="Online",
createRoomTooFast="Vous avez créé un salon trop rapidement !",
createRoomSuccessed="Salon créé avec succès !",
-- started="Playing",

View File

@@ -97,6 +97,8 @@ return{
wsClose="WebSocket closed: ",
-- netTimeout="Network connection timeout",
-- onlinePlayerCount="Online",
-- createRoomTooFast="Create room too fast!",
-- createRoomSuccessed="Room successfully created!",
-- started="Playing",
@@ -105,7 +107,7 @@ return{
-- ready="READY",
-- set="SET",
-- champion="$1 won",
chatRemain="Online: ",
chatRemain="Online",
chatStart="------Começo do log------",
chatHistory="------Novas mensagens abaixo------",

View File

@@ -97,6 +97,8 @@ return{
wsClose="WebSocket cerrado: ",
waitNetTask="Conectando, espera por favor",
-- onlinePlayerCount="Online",
createRoomTooFast="¡Creas salas muy rápido, párale we!",
createRoomSuccessed="¡Sala creada con éxito!",
-- started="Playing",

View File

@@ -97,6 +97,8 @@ return{
wsClose="WS被断开: ",
netTimeout="网络连接超时",
onlinePlayerCount="在线人数",
createRoomTooFast="创建房间太快啦,等等吧",
createRoomSuccessed="创建房间成功!",
started="游戏中",

View File

@@ -1,6 +1,8 @@
local data=love.data
local rem=table.remove
local WS,TIME=WS,TIME
local yield=YIELD
local NET={
connected=false,
@@ -19,6 +21,10 @@ local NET={
connectingStream=false,
streamRoomID=false,
serverGaming=false,
UserCount="_",
PlayCount="_",
StreamCount="_",
}
local mesType={
@@ -172,6 +178,14 @@ function NET.getUserInfo(uid)
},
})
end
function NET.freshPlayerCount()
while true do
for _=1,260 do yield()end
if WS.status('app')=='running'then
WS.send('app',JSON.encode{action=3})
end
end
end
--Room
function NET.fetchRoom()
@@ -259,7 +273,7 @@ end
--WS tick funcs
function NET.updateWS_app()
while true do
YIELD()
yield()
if WS.status('app')=='running'then
local message,op=WS.read('app')
if message then
@@ -272,6 +286,7 @@ function NET.updateWS_app()
else
local res=_parse(message)
if res then
for k,v in next,res do print(k,v)end
if res.type=='Connect'then
NET.connected=true
if VERSION.code>=res.lowest then
@@ -298,6 +313,11 @@ function NET.updateWS_app()
LOG.print(res.reason or"Registration failed",300,COLOR.N)
end
NET.unlock('register')
elseif res.action==3 then--Get player counts
NET.UserCount=res.data.User
NET.PlayCount=res.data.Play
NET.StreamCount=res.data.Stream
--res.data.Chat
end
else
WS.alert('app')
@@ -309,7 +329,7 @@ function NET.updateWS_app()
end
function NET.updateWS_user()
while true do
YIELD()
yield()
if WS.status('user')=='running'then
local message,op=WS.read('user')
if message then
@@ -351,7 +371,7 @@ function NET.updateWS_user()
end
function NET.updateWS_play()
while true do
YIELD()
yield()
if WS.status('play')=='running'then
local message,op=WS.read('play')
if message then
@@ -442,7 +462,7 @@ function NET.updateWS_play()
end
function NET.updateWS_stream()
while true do
YIELD()
yield()
if WS.status('stream')=='running'then
local message,op=WS.read('stream')
if message then
@@ -487,7 +507,7 @@ function NET.updateWS_stream()
end
function NET.updateWS_chat()
while true do
YIELD()
yield()
if WS.status('chat')=='running'then
local message,op=WS.read('chat')
if message then

View File

@@ -180,6 +180,7 @@ local loadingThread=coroutine.wrap(function()
TASK.new(NET.updateWS_user)
TASK.new(NET.updateWS_play)
NET.wsconn_app()
TASK.new(NET.freshPlayerCount)
while true do
if math.random()<.126 then

View File

@@ -22,11 +22,12 @@ local consoleEntryThread=coroutine.wrap(function()
end
end)
function scene.sceneInit()
BG.set()
--Set tip
tip:set(text.getTip())
scrollX=tipLength
BG.set()
--Set quick-play-button text
scene.widgetList[2]:setObject(text.WidgetText.main.qplay..": "..text.modes[STAT.lastPlay][1])
@@ -163,6 +164,9 @@ function scene.draw()
--Profile
drawSelfProfile()
--Player count
drawOnlinePlayerCount()
end
scene.widgetList={

View File

@@ -265,6 +265,9 @@ function scene.draw()
--Profile
drawSelfProfile()
--Player count
drawOnlinePlayerCount()
end
--New message

View File

@@ -12,6 +12,7 @@ end
function scene.draw()
drawSelfProfile()
drawOnlinePlayerCount()
end
scene.widgetList={

View File

@@ -164,6 +164,9 @@ function scene.draw()
--Profile
drawSelfProfile()
--Player count
drawOnlinePlayerCount()
end
scene.widgetList={

View File

@@ -33,6 +33,7 @@ return STRING.split([=[
添加模式环境变量bufferLimit,攻击缓冲上限可以调整
添加模式环境变量maxOver,允许超屏最大高度可以调整
添加两个虚拟按键预设槽位
玩家个人信息栏下部显示在线玩家数量
改动:
词典新增两个游戏词条
更换细一点的字体