修正玩家进出房间相关问题

修正获取玩家信息相关问题
实现操作录像传输
修改一些语言文本
This commit is contained in:
MrZ_26
2022-10-23 23:24:14 +08:00
parent 3ae0e80ce5
commit 6ecc80ac0f
13 changed files with 62 additions and 36 deletions

View File

@@ -137,8 +137,8 @@ return{
createRoomSuccessed="Room created",
playerKicked="[$1] removed [$2] from room",
started="Playing",
joinRoom="has entered the room.",
leaveRoom="has left the room.",
joinRoom="$1 has entered the room.",
leaveRoom="$1 has left the room.",
ready="Ready",
connStream="Connecting",
waitStream="Waiting",

View File

@@ -136,8 +136,8 @@ return{
createRoomSuccessed="¡Sala creada con éxito!",
-- playerKicked="[$1] removed [$2] from room",
started="En juego",
joinRoom="entró a la sala.",
leaveRoom="salió de la sala.",
joinRoom="$1 entró a la sala.",
leaveRoom="$1 salió de la sala.",
ready="LISTO",
connStream="CONECTANDO",
waitStream="ESPERANDO",

View File

@@ -127,8 +127,8 @@ return{
createRoomSuccessed="Salon créé avec succès !",
-- playerKicked="[$1] removed [$2] from room",
-- started="Playing",
joinRoom="a rejoint le salon.",
leaveRoom="a quitté le salon.",
joinRoom="$1 a rejoint le salon.",
leaveRoom="$1 a quitté le salon.",
-- ready="READY",
-- connStream="CONNECTING",
-- waitStream="WAITING",

View File

@@ -138,8 +138,8 @@ return{
createRoomSuccessed="Ruang terbuat",
-- playerKicked="[$1] removed [$2] from room",
started="Bermain",
joinRoom="telah memasuki ruangan.",
leaveRoom="telah keluar dari ruangan.",
joinRoom="$1 telah memasuki ruangan.",
leaveRoom="$1 telah keluar dari ruangan.",
ready="Siap",
connStream="Memuat",
waitStream="Menunggu",

View File

@@ -138,8 +138,8 @@ return{
createRoomSuccessed="部屋を建てました",
-- playerKicked="[$1] removed [$2] from room",
started="プレイ中",
joinRoom="が入室しました",
leaveRoom="が退出しました",
joinRoom="$1 が入室しました",
leaveRoom="$1 が退出しました",
ready="準備OK",
connStream="接続中……",
waitStream="待機中……",

View File

@@ -125,8 +125,8 @@ return{
-- createRoomSuccessed="Room successfully created!",
-- playerKicked="[$1] removed [$2] from room",
-- started="Playing",
joinRoom="Entrou a sala.",
leaveRoom="Saiu da sala.",
joinRoom="$1 Entrou a sala.",
leaveRoom="$1 Saiu da sala.",
-- ready="READY",
-- connStream="CONNECTING",
-- waitStream="WAITING",

View File

@@ -137,8 +137,8 @@ return{
createRoomSuccessed="创建房间成功!",
playerKicked="<$1>把<$2>移出了房间",
started="游戏中",
joinRoom="进入房间",
leaveRoom="离开房间",
joinRoom="$1 进入房间",
leaveRoom="$1 离开房间",
ready="各就各位!",
connStream="正在连接",
waitStream="等待其他人连接",

View File

@@ -137,8 +137,8 @@ return{
createRoomSuccessed="CreateRoom.Successs=true",
playerKicked="[$1]: roomKick([$2])",
started="Room.Playing();",
joinRoom="Room.Join();",
leaveRoom="Room.Leave();",
joinRoom="Room.Join($1);",
leaveRoom="Room.Leave($1);",
ready="Ready();",
connStream="Stream.Connecting();",
waitStream="Stream.Waiting();",

View File

@@ -137,8 +137,8 @@ return{
createRoomSuccessed="房間已創建!",
playerKicked="<$1>把<$2>移出了房間",
started="遊戲中",
joinRoom="進入房間",
leaveRoom="離開房間",
joinRoom="$1 進入房間",
leaveRoom="$1 離開房間",
ready="準備!",
connStream="正在連接……",
waitStream="等待其他用戶連接……",

View File

@@ -441,6 +441,22 @@ local function _playerLeaveRoom(uid)
end
end
--Push stream data to players
local function _pumpStream(d)
if d.playerId==USER.uid then return end
for _,P in next,PLAYERS do
if P.uid==d.playerId then
local res,stream=pcall(love.data.decode,'string','base64',d.data)
if res then
DATA.pumpRecording(stream,P.stream)
else
MES.new('error',"Bad stream from "..P.username.."#"..P.uid,.1)
end
return
end
end
end
-- Global
function NET.global_getOnlineCount()
wsSend(actMap.global_getOnlineCount)
@@ -546,7 +562,7 @@ function NET.player_setState(state)-- not used
wsSend(actMap.player_setState,state)
end
function NET.player_stream(stream)
wsSend(actMap.player_stream,stream)
wsSend(actMap.player_stream,love.data.encode('string','base64',stream))
end
function NET.player_setPlayMode(mode)
wsSend(actMap.player_setPlayMode,mode)
@@ -588,14 +604,16 @@ function NET.wsCallBack.room_setInfo(body)
end
function NET.wsCallBack.room_enter(body)
TASK.unlock('enterRoom')
NET.textBox.hide=true
NET.inputBox.hide=true
NET.textBox:clear()
NET.inputBox:clear()
NET.roomState=body.data
NETPLY.clear()
if body.data.players then
NET.textBox.hide=true
NET.inputBox.hide=true
NET.textBox:clear()
NET.inputBox:clear()
NET.roomState=body.data
NETPLY.clear()
loadGame('netBattle',true,true)
for _,p in next,body.data.players do
NETPLY.add{
uid=p.playerId,
@@ -604,9 +622,16 @@ function NET.wsCallBack.room_enter(body)
config=p.config,
}
end
else
local p=body.data
NETPLY.add{
uid=p.playerId,
playMode=p.type,
readyMode=p.state,
config=p.config,
}
end
loadGame('netBattle',true,true)
WAIT.interrupt()
end
function NET.wsCallBack.room_kick(body)
@@ -641,7 +666,8 @@ function NET.wsCallBack.player_setHost(body)-- TODO
end
function NET.wsCallBack.player_setState(body)-- TODO (not used)
end
function NET.wsCallBack.player_stream(body)-- TODO
function NET.wsCallBack.player_stream(body)
_pumpStream(body.data)
end
function NET.wsCallBack.player_setPlayMode(body)
NETPLY.setPlayMode(body.data.playerId,body.data.type)

View File

@@ -399,19 +399,19 @@ function PLY.newDemoPlayer(id)
}
P:popNext()
end
function PLY.newRemotePlayer(id,mini,ply)
function PLY.newRemotePlayer(id,mini,p)
local P=_newEmptyPlayer(id,mini)
P.type='remote'
P.draw=ply_draw.norm
P:startStreaming()
NETPLY.setPlayerObj(ply,P)
P.uid=ply.uid
P.username=ply.username
P.sid=NET.uid_sid[ply.uid]
NETPLY.setPlayerObj(p,P)
P.uid=p.uid
P.username=USERS.getUsername(p.uid)
P.sid=NET.uid_sid[p.uid]
_loadRemoteEnv(P,ply.config)
_loadRemoteEnv(P,p.config)
_applyGameEnv(P)
end
function PLY.newAIPlayer(id,AIdata,mini)

View File

@@ -17,7 +17,7 @@ scene.widgetList={
WIDGET.newButton{name='league',x=640, y=180,w=350,h=120,font=40,color='D',code=goScene'net_league'},
WIDGET.newButton{name='ffa', x=640, y=360,w=350,h=120,font=40,color='D',code=function() MES.new('warn',text.notFinished)--[[NET.enterRoom({name='ffa'})]] end},
WIDGET.newButton{name='rooms', x=640, y=540,w=350,h=120,font=40,code=goScene'net_rooms'},
WIDGET.newButton{name='resetPW',x=680, y=40,w=180,h=60,color='dG',code=function() SCN.go('reset_password','none') end},
WIDGET.newButton{name='resetPW',x=680,y=40,w=180,h=60,color='dG',code=goScene'reset_password'},
WIDGET.newButton{name='logout',x=880, y=40,w=180, h=60,color='dR',
code=function()
if tryBack() then

View File

@@ -81,8 +81,8 @@ function USERS.updateAvatar(uid,imgData)
db_img[uid]=_loadAvatar("cache/"..hash)
end
function USERS.getUsername(uid) return db[uid].username end
function USERS.getMotto(uid) return db[uid].motto end
function USERS.getUsername(uid) return db[uid].username or "" end
function USERS.getMotto(uid) return db[uid].motto or "" end
function USERS.getAvatar(uid)
if uid then
if not db[uid].new then