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

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() gc.pop()
end end
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() do--function drawWarning()
local SETTING,GAME,shader_warning,SCR=SETTING,GAME,SHADER.warning,SCR local SETTING,GAME,shader_warning,SCR=SETTING,GAME,SHADER.warning,SCR
function drawWarning() function drawWarning()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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