修复对战房间内退出设置界面会尝试连接ws-stream的问题,整理代码

This commit is contained in:
MrZ626
2021-05-29 19:56:50 +08:00
parent 4fda9d8ef3
commit 0b43a01976
6 changed files with 21 additions and 20 deletions

View File

@@ -232,8 +232,6 @@ local function noDevkeyPressed(key)
devMode=3 LOG.print("DEBUG 3")
elseif key=="f12"then
devMode=4 LOG.print("DEBUG 4")
elseif key=="backspace"and kb.isDown("lctrl","rctrl")then
_G["\100\114\97\119\70\87\77"]=NULL
elseif devMode==2 then
local W=WIDGET.sel
if W then
@@ -264,7 +262,11 @@ function love.keypressed(key)
devMode=1
LOG.print("DEBUG ON",10)
elseif key=="f11"then
switchFullscreen()
if kb.isDown("lctrl","rctrl")then
_G["\100\114\97\119\70\87\77"]=NULL
else
switchFullscreen()
end
elseif not SCN.swapping then
if SCN.keyDown then
SCN.keyDown(key)

View File

@@ -108,6 +108,7 @@ return{
-- connStream="CONNECTING",
-- waitStream="WAITING",
-- champion="$1 won",
-- spectating="Spectating",
chatRemain="Online",
chatStart="------Começo do log------",
chatHistory="------Novas mensagens abaixo------",

View File

@@ -95,7 +95,7 @@ return{
wsSuccessed="WebSocket: conectado",
wsFailed="WebSocket: conexión fallida",
wsClose="WebSocket cerrado: ",
waitNetTask="Conectando, espera por favor",
-- netTimeout="Network connection timeout",
-- onlinePlayerCount="Online",

View File

@@ -91,11 +91,11 @@ return{
accessSuccessed="身份验证成功",
accessFailed="身份验证失败",
wsConnecting="正在连接WS",
wsSuccessed="WS连接成功",
wsFailed="WS连接失败",
wsClose="WS被断开: ",
netTimeout="网络连接超时",
wsConnecting="正在连接",
wsSuccessed="连接成功",
wsFailed="连接失败",
wsClose="连接被断开: ",
netTimeout="连接超时",
onlinePlayerCount="在线人数",

View File

@@ -22,7 +22,7 @@ local NET={
start=false,
},
spectate=false,--If player is spectating
streamRoomID=false,
specSRID=false,--Cached SRID when enter playing room, for connect WS after scene swapped
seed=false,
allReady=false,
@@ -133,13 +133,13 @@ function NET.wsconn_play()
})
end
end
function NET.wsconn_stream()
function NET.wsconn_stream(srid)
if NET.lock('wsc_stream',5)then
NET.roomState.start=true
WS.connect('stream','/stream',JSON.encode{
uid=USER.uid,
accessToken=NET.accessToken,
srid=NET.streamRoomID,
srid=srid,
})
TASK.new(NET.updateWS_stream)
end
@@ -443,14 +443,13 @@ function NET.updateWS_play()
NET.waitingStream=false
NET.spectate=false
NET.streamRoomID=false
loadGame('netBattle',true,true)
if d.srid then
NET.spectate=true
NET.streamRoomID=d.srid
NET.specSRID=d.srid
NET.connectingStream=true
end
loadGame('netBattle',true,true)
else
--Load other players
netPLY.add{
@@ -485,10 +484,9 @@ function NET.updateWS_play()
SFX.play('reach',.6)
NET.allReady=true
elseif res.action==8 then--Set
NET.streamRoomID=d.srid
NET.allReady=false
NET.connectingStream=true
NET.wsconn_stream()
NET.wsconn_stream(d.srid)
elseif res.action==9 then--Game finished
NET.roomState.start=false
if NET.spectate then NET.signal_setMode(2) end

View File

@@ -59,9 +59,9 @@ function scene.sceneInit(org)
upstreamProgress=1
if org=='setting_game'then NET.changeConfig()end
if NET.streamRoomID then
NET.wsconn_stream()
NET.streamRoomID=false
if NET.specSRID then
NET.wsconn_stream(NET.specSRID)
NET.specSRID=false
end
end
function scene.sceneBack()