支持双语公告根据设置语言选择性显示 close #78

This commit is contained in:
MrZ626
2021-08-18 03:33:36 +08:00
parent d9251f16db
commit 04f67d4052

View File

@@ -75,6 +75,12 @@ local function _parse(res)
end end
end end
--Parse notice
local function _parseNotice(str)
str=STRING.split(str,"///")
return str[SETTING.lang<=3 and 1 or 2]or str[1]
end
--WS close message --WS close message
local function _closeMessage(message) local function _closeMessage(message)
local mes=JSON.decode(message) local mes=JSON.decode(message)
@@ -86,7 +92,7 @@ local function _closeMessage(message)
end end
--Remove player when leave --Remove player when leave
local function removePlayer(L,sid) local function _removePlayer(L,sid)
for i=1,#L do for i=1,#L do
if L[i].sid==sid then if L[i].sid==sid then
rem(L,i) rem(L,i)
@@ -96,7 +102,7 @@ local function removePlayer(L,sid)
end end
--Push stream data to players --Push stream data to players
local function pumpStream(d) local function _pumpStream(d)
if d.uid~=USER.uid then if d.uid~=USER.uid then
for _,P in next,PLAYERS do for _,P in next,PLAYERS do
if P.uid==d.uid then if P.uid==d.uid then
@@ -399,7 +405,7 @@ function NET.updateWS_app()
if VERSION.code<res.newestCode then if VERSION.code<res.newestCode then
MES.new('warn',text.oldVersion:gsub("$1",res.newestName),3) MES.new('warn',text.oldVersion:gsub("$1",res.newestName),3)
end end
MES.new('broadcast',res.notice,5) MES.new('broadcast',_parseNotice(res.notice),5)
NET.tryLogin(true) NET.tryLogin(true)
TASK.new(NET.freshPlayerCount) TASK.new(NET.freshPlayerCount)
elseif res.action==0 then--Broadcast elseif res.action==0 then--Broadcast
@@ -556,8 +562,8 @@ function NET.updateWS_play()
SCN.back() SCN.back()
else else
netPLY.remove(d.sid) netPLY.remove(d.sid)
removePlayer(PLAYERS,d.sid) _removePlayer(PLAYERS,d.sid)
removePlayer(PLY_ALIVE,d.sid) _removePlayer(PLY_ALIVE,d.sid)
if SCN.cur=='net_game'then SCN.socketRead('leave',d)end if SCN.cur=='net_game'then SCN.socketRead('leave',d)end
end end
elseif res.action==4 then--Player talk elseif res.action==4 then--Player talk
@@ -637,7 +643,7 @@ function NET.updateWS_stream()
SCN.socketRead('go') SCN.socketRead('go')
if d.history then if d.history then
for _,v in next,d.history do for _,v in next,d.history do
pumpStream(v) _pumpStream(v)
end end
end end
end end
@@ -661,7 +667,7 @@ function NET.updateWS_stream()
end end
end end
elseif res.action==5 then--Receive stream elseif res.action==5 then--Receive stream
pumpStream(d) _pumpStream(d)
end end
else else
WS.alert('stream') WS.alert('stream')