继续实现一堆联网消息
语言文件加一条 框架跟进
This commit is contained in:
Submodule Zframework updated: 1a44ad2ea1...98f0fff6b0
@@ -111,6 +111,7 @@ return{
|
||||
},
|
||||
|
||||
tooFrequently="Request too frequently",
|
||||
roomPasswordChanged="Room password changed",
|
||||
getNoticeFail="Failed to fetch announcements",
|
||||
oldVersion="Version $1 is now available",
|
||||
needUpdate="Newer version required!",
|
||||
|
||||
@@ -110,6 +110,7 @@ return{
|
||||
},
|
||||
|
||||
-- tooFrequently="Request too frequently",
|
||||
-- roomPasswordChanged="Room password changed",
|
||||
getNoticeFail="Error al buscar novedades.",
|
||||
oldVersion="¡Está disponible la nueva versión $1!",
|
||||
needUpdate="¡Nueva versión requerida!",
|
||||
|
||||
@@ -101,6 +101,7 @@ return{
|
||||
},
|
||||
|
||||
-- tooFrequently="Request too frequently",
|
||||
-- roomPasswordChanged="Room password changed",
|
||||
getNoticeFail="Echec de l'obtention de la notice",
|
||||
oldVersion="La version $1 est disponible !",
|
||||
-- versionNotMatch="Version do not match!",
|
||||
|
||||
@@ -112,6 +112,7 @@ return{
|
||||
},
|
||||
|
||||
-- tooFrequently="Request too frequently",
|
||||
-- roomPasswordChanged="Room password changed",
|
||||
getNoticeFail="Gagal mengambil pengumuman-pengumuman",
|
||||
oldVersion="Versi $1 sekarang tersedia",
|
||||
needUpdate="Butuh versi lebih baru!",
|
||||
|
||||
@@ -112,6 +112,7 @@ return{
|
||||
},
|
||||
|
||||
-- tooFrequently="Request too frequently",
|
||||
-- roomPasswordChanged="Room password changed",
|
||||
getNoticeFail="お知らせ情報を取得できませんでした",
|
||||
oldVersion="バージョン$1のダウンロードが可能になりました",
|
||||
needUpdate="最新バージョンに更新してください",
|
||||
|
||||
@@ -99,6 +99,7 @@ return{
|
||||
},
|
||||
|
||||
-- tooFrequently="Request too frequently",
|
||||
-- roomPasswordChanged="Room password changed",
|
||||
getNoticeFail="Não conseguiu ter anúncios",
|
||||
oldVersion="Versão $1 esta disponível agora!",
|
||||
-- versionNotMatch="Version do not match!",
|
||||
|
||||
@@ -111,6 +111,7 @@ return{
|
||||
},
|
||||
|
||||
tooFrequently="操作太频繁",
|
||||
roomPasswordChanged="房间密码已更改",
|
||||
getNoticeFail="拉取公告失败",
|
||||
oldVersion="最新版本$1可以下载了!",
|
||||
needUpdate="请更新游戏!",
|
||||
|
||||
@@ -111,6 +111,7 @@ return{
|
||||
},
|
||||
|
||||
tooFrequently="Error.requestTooFrequently();",
|
||||
roomPasswordChanged="Info.roomPwChanged();",
|
||||
getNoticeFail="Error.FetchAnnouncement();",
|
||||
oldVersion="Version.New($1);",
|
||||
needUpdate="Version.NeedUpdate();",
|
||||
|
||||
@@ -111,6 +111,7 @@ return{
|
||||
},
|
||||
|
||||
tooFrequently="操作太頻繁",
|
||||
roomPasswordChanged="房間密碼已更改",
|
||||
getNoticeFail="無法獲取公告",
|
||||
oldVersion="版本 $1 現已推出",
|
||||
needUpdate="請更新遊戲!",
|
||||
|
||||
@@ -24,6 +24,9 @@ local NET={
|
||||
roomReadyState=false,
|
||||
|
||||
onlineCount="_",
|
||||
|
||||
textBox=WIDGET.newTextBox{name='texts',x=340,y=80,w=600,h=560},
|
||||
inputBox=WIDGET.newInputBox{name='input',x=340,y=660,w=600,h=50,limit=256},
|
||||
}
|
||||
|
||||
|
||||
@@ -309,6 +312,15 @@ function NET.pwLogin(email,pw)
|
||||
end)
|
||||
end
|
||||
|
||||
--Remove player when leave
|
||||
local function _removePlayer(L,sid)
|
||||
for i=1,#L do
|
||||
if L[i].sid==sid then
|
||||
return table.remove(L,i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------<NEW WS API>
|
||||
local actMap={
|
||||
global_getOnlineCount= 1000,
|
||||
@@ -473,39 +485,77 @@ NET.wsCallBack={}
|
||||
function NET.wsCallBack.global_getOnlineCount(body)
|
||||
NET.onlineCount=tonumber(body.data) or "_"
|
||||
end
|
||||
function NET.wsCallBack.room_chat(body)-- TODO
|
||||
function NET.wsCallBack.room_chat(body)
|
||||
if SCN.cur=='net_game' then
|
||||
TASK.unlock('receiveMessage')
|
||||
TASK.lock('receiveMessage',1)
|
||||
NET.textBox:push{
|
||||
COLOR.L,"[?]",-- TODO
|
||||
COLOR.Y,"#"..body.playerId.." ",
|
||||
COLOR.I,body.message,
|
||||
}
|
||||
end
|
||||
end
|
||||
function NET.wsCallBack.room_create(body)
|
||||
TASK.unlock('createRoom')
|
||||
-- NET.roomState=...
|
||||
-- SCN.go('net_game')
|
||||
WAIT.interrupt()
|
||||
NET.wsCallBack.room_enter(body)
|
||||
end
|
||||
function NET.wsCallBack.room_getData(body)-- TODO
|
||||
function NET.wsCallBack.room_getData(body)
|
||||
NET.roomState.roomData=body.data
|
||||
end
|
||||
function NET.wsCallBack.room_setData(body)-- TODO
|
||||
function NET.wsCallBack.room_setData(body)
|
||||
NET.wsCallBack.room_getData(body)
|
||||
end
|
||||
function NET.wsCallBack.room_getInfo(body)-- TODO
|
||||
function NET.wsCallBack.room_getInfo(body)
|
||||
NET.roomState.roomInfo=body.info
|
||||
end
|
||||
function NET.wsCallBack.room_setInfo(body)-- TODO
|
||||
function NET.wsCallBack.room_setInfo(body)
|
||||
NET.wsCallBack.room_getInfo(body)
|
||||
end
|
||||
function NET.wsCallBack.room_enter(body)
|
||||
function NET.wsCallBack.room_enter(body)-- TODO
|
||||
TASK.unlock('enterRoom')
|
||||
-- NET.roomState=...
|
||||
-- SCN.go('net_game')
|
||||
NET.textBox.hide=true
|
||||
NET.inputBox.hide=true
|
||||
NET.textBox:clear()
|
||||
NET.inputBox:clear()
|
||||
loadGame('netBattle',true,true)
|
||||
WAIT.interrupt()
|
||||
end
|
||||
function NET.wsCallBack.room_kick(body)-- TODO
|
||||
function NET.wsCallBack.room_kick(body)
|
||||
if body.data then
|
||||
-- local eid=body.data.executorId
|
||||
local uid=body.data.targetId
|
||||
NETPLY.remove(uid)
|
||||
_removePlayer(PLAYERS,uid)
|
||||
_removePlayer(PLY_ALIVE,uid)
|
||||
end
|
||||
end
|
||||
function NET.wsCallBack.room_leave(body)-- TODO
|
||||
function NET.wsCallBack.room_leave(body)
|
||||
if body.data then
|
||||
if body.type=='Server' then
|
||||
if SCN.cur=='net_game' then
|
||||
if SCN.stack[#SCN.stack-1]=='net_newRoom' then
|
||||
SCN.pop()
|
||||
end
|
||||
SCN.back()
|
||||
end
|
||||
elseif body.type=='Client' then
|
||||
local uid=body.data.playerId
|
||||
NETPLY.remove(uid)
|
||||
_removePlayer(PLAYERS,uid)
|
||||
_removePlayer(PLY_ALIVE,uid)
|
||||
end
|
||||
end
|
||||
end
|
||||
function NET.wsCallBack.room_fetch(body)
|
||||
TASK.unlock('fetchRoom')
|
||||
if body.data then SCN.scenes.net_rooms.widgetList.roomList:setList(body.data) end
|
||||
end
|
||||
function NET.wsCallBack.room_setPW(body)-- TODO
|
||||
function NET.wsCallBack.room_setPW()
|
||||
MES.new(text.roomPasswordChanged)
|
||||
end
|
||||
function NET.wsCallBack.room_remove(body)-- TODO
|
||||
function NET.wsCallBack.room_remove(body)
|
||||
NET.wsCallBack.room_leave(body)
|
||||
end
|
||||
function NET.wsCallBack.player_updateConf(body)-- TODO
|
||||
end
|
||||
@@ -559,7 +609,7 @@ function NET.ws_update()
|
||||
local body=JSON.decode(msg)
|
||||
if body then
|
||||
-- print(("Recv: <-- $1 ($2)"):repD(body.action,body.type))
|
||||
-- print(("Recv: <-- $1 ($2)"):repD(body.action,body.type)) print(TABLE.dump(body),"\n")
|
||||
print(("Recv: <-- $1 ($2)"):repD(body.action,body.type)) print(TABLE.dump(body),"\n")
|
||||
if body.type=='Failed' then
|
||||
parseError(body.message~=nil and body.message or msg)
|
||||
else
|
||||
|
||||
@@ -10,15 +10,14 @@ local ins=table.insert
|
||||
local SCR,VK,NET,NETPLY=SCR,VK,NET,NETPLY
|
||||
local PLAYERS,GAME=PLAYERS,GAME
|
||||
|
||||
local textBox=WIDGET.newTextBox{name='texts',x=340,y=80,w=600,h=560}
|
||||
local inputBox=WIDGET.newInputBox{name='input',x=340,y=660,w=600,h=50,limit=256}
|
||||
local textBox=NET.textBox
|
||||
local inputBox=NET.inputBox
|
||||
|
||||
local playing
|
||||
local lastUpstreamTime
|
||||
local upstreamProgress
|
||||
local noTouch,noKey=false,false
|
||||
local touchMoveLastFrame=false
|
||||
local newMessageTimer
|
||||
|
||||
local function _hideReadyUI()
|
||||
return
|
||||
@@ -66,15 +65,10 @@ end
|
||||
local scene={}
|
||||
|
||||
function scene.sceneInit()
|
||||
textBox.hide=true
|
||||
textBox:clear()
|
||||
inputBox.hide=true
|
||||
|
||||
noTouch=not SETTING.VKSwitch
|
||||
playing=false
|
||||
lastUpstreamTime=0
|
||||
upstreamProgress=1
|
||||
newMessageTimer=0
|
||||
|
||||
if SCN.prev=='setting_game' then
|
||||
NET.player_updateConf()
|
||||
@@ -216,7 +210,6 @@ function scene.socketRead(cmd,d)
|
||||
COLOR.Y,text.leaveRoom,
|
||||
}
|
||||
elseif cmd=='talk' then
|
||||
newMessageTimer=80
|
||||
textBox:push{
|
||||
COLOR.Z,d.username,
|
||||
COLOR.dY,"#"..d.uid.." ",
|
||||
@@ -275,9 +268,6 @@ function scene.update(dt)
|
||||
else
|
||||
NETPLY.update(dt)
|
||||
end
|
||||
if newMessageTimer>0 then
|
||||
newMessageTimer=newMessageTimer-1
|
||||
end
|
||||
end
|
||||
|
||||
function scene.draw()
|
||||
@@ -336,9 +326,10 @@ function scene.draw()
|
||||
end
|
||||
|
||||
-- New message
|
||||
if newMessageTimer>0 then
|
||||
local a=TASK.getLock('receiveMessage')
|
||||
if a then
|
||||
setFont(40)
|
||||
gc_setColor(.3,.7,1,(newMessageTimer/60)^2)
|
||||
gc_setColor(.3,.7,1,a^2)
|
||||
gc_print("M",430,10)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user