整理代码,调整textBox控件机制
This commit is contained in:
@@ -845,7 +845,7 @@ function textBox:update()
|
|||||||
end
|
end
|
||||||
function textBox:push(t)
|
function textBox:push(t)
|
||||||
ins(self.texts,t)
|
ins(self.texts,t)
|
||||||
if self.scrollPos==#self.texts-1 then
|
if self.scrollPos==#self.texts-1 and not(self.hide and self.hide())then
|
||||||
self.scrollPos=#self.texts
|
self.scrollPos=#self.texts
|
||||||
else
|
else
|
||||||
SFX.play("spin_0",.8)
|
SFX.play("spin_0",.8)
|
||||||
|
|||||||
@@ -69,25 +69,8 @@ end
|
|||||||
function NET.wsconn_app()
|
function NET.wsconn_app()
|
||||||
WS.connect("app","/app")
|
WS.connect("app","/app")
|
||||||
end
|
end
|
||||||
function NET.wsconn_play()
|
|
||||||
if _lock("conn_play")then
|
|
||||||
WS.connect("play","/play",JSON.encode{
|
|
||||||
uid=USER.uid,
|
|
||||||
accessToken=NET.accessToken,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
function NET.wsconn_stream()
|
|
||||||
if _lock("connectStream")then
|
|
||||||
WS.connect("stream","/stream",JSON.encode{
|
|
||||||
uid=USER.uid,
|
|
||||||
accessToken=NET.accessToken,
|
|
||||||
rid=NET.rsid,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
function NET.wsconn_user_pswd(email,password)
|
function NET.wsconn_user_pswd(email,password)
|
||||||
if _lock("conn_user")then
|
if _lock("wsc_user")then
|
||||||
WS.connect("user","/user",JSON.encode{
|
WS.connect("user","/user",JSON.encode{
|
||||||
email=email,
|
email=email,
|
||||||
password=password,
|
password=password,
|
||||||
@@ -95,13 +78,30 @@ function NET.wsconn_user_pswd(email,password)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
function NET.wsconn_user_token(uid,authToken)
|
function NET.wsconn_user_token(uid,authToken)
|
||||||
if _lock("conn_user")then
|
if _lock("wsc_user")then
|
||||||
WS.connect("user","/user",JSON.encode{
|
WS.connect("user","/user",JSON.encode{
|
||||||
uid=uid,
|
uid=uid,
|
||||||
authToken=authToken,
|
authToken=authToken,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
function NET.wsconn_play()
|
||||||
|
if _lock("wsc_play")then
|
||||||
|
WS.connect("play","/play",JSON.encode{
|
||||||
|
uid=USER.uid,
|
||||||
|
accessToken=NET.accessToken,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function NET.wsconn_stream()
|
||||||
|
if _lock("wsc_stream")then
|
||||||
|
WS.connect("stream","/stream",JSON.encode{
|
||||||
|
uid=USER.uid,
|
||||||
|
accessToken=NET.accessToken,
|
||||||
|
rid=NET.rsid,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--Disconnect
|
--Disconnect
|
||||||
function NET.wsclose_play()
|
function NET.wsclose_play()
|
||||||
@@ -110,9 +110,6 @@ end
|
|||||||
function NET.wsclose_stream()
|
function NET.wsclose_stream()
|
||||||
WS.close("stream")
|
WS.close("stream")
|
||||||
end
|
end
|
||||||
function NET.wsclose_user()
|
|
||||||
WS.close("user")
|
|
||||||
end
|
|
||||||
|
|
||||||
--Account
|
--Account
|
||||||
function NET.pong(wsName,message)
|
function NET.pong(wsName,message)
|
||||||
@@ -288,7 +285,7 @@ function NET.updateWS_user()
|
|||||||
|
|
||||||
--Get self infos
|
--Get self infos
|
||||||
NET.getUserInfo(USER.uid)
|
NET.getUserInfo(USER.uid)
|
||||||
_unlock("conn_user")
|
_unlock("wsc_user")
|
||||||
elseif res.action==0 then--Get accessToken
|
elseif res.action==0 then--Get accessToken
|
||||||
NET.accessToken=res.accessToken
|
NET.accessToken=res.accessToken
|
||||||
LOG.print(text.accessSuccessed)
|
LOG.print(text.accessSuccessed)
|
||||||
@@ -323,7 +320,7 @@ function NET.updateWS_play()
|
|||||||
if res then
|
if res then
|
||||||
if res.type=="Connect"then
|
if res.type=="Connect"then
|
||||||
SCN.go("net_menu")
|
SCN.go("net_menu")
|
||||||
_unlock("conn_play")
|
_unlock("wsc_play")
|
||||||
elseif res.action==0 then--Fetch rooms
|
elseif res.action==0 then--Fetch rooms
|
||||||
NET.roomList=res.roomList
|
NET.roomList=res.roomList
|
||||||
_unlock("fetchRoom")
|
_unlock("fetchRoom")
|
||||||
@@ -426,7 +423,7 @@ function NET.updateWS_stream()
|
|||||||
local res=_parse(message)
|
local res=_parse(message)
|
||||||
if res then
|
if res then
|
||||||
if res.type=="Connect"then
|
if res.type=="Connect"then
|
||||||
--?
|
_unlock("wsc_stream")
|
||||||
elseif res.action==0 then--Game start
|
elseif res.action==0 then--Game start
|
||||||
SCN.socketRead("Begin",res.data)
|
SCN.socketRead("Begin",res.data)
|
||||||
elseif res.action==1 then--Game finished
|
elseif res.action==1 then--Game finished
|
||||||
|
|||||||
@@ -9,8 +9,7 @@ local onVirtualkey=onVirtualkey
|
|||||||
local pressVirtualkey=pressVirtualkey
|
local pressVirtualkey=pressVirtualkey
|
||||||
local updateVirtualkey=updateVirtualkey
|
local updateVirtualkey=updateVirtualkey
|
||||||
|
|
||||||
local hideChatBox
|
local textBox=WIDGET.newTextBox{name="texts",x=340,y=80,w=600,h=550,hide=false}
|
||||||
local textBox=WIDGET.newTextBox{name="texts",x=340,y=80,w=600,h=550,hide=function()return hideChatBox end}
|
|
||||||
|
|
||||||
local playing
|
local playing
|
||||||
local lastUpstreamTime
|
local lastUpstreamTime
|
||||||
@@ -28,7 +27,7 @@ function scene.sceneBack()
|
|||||||
end
|
end
|
||||||
function scene.sceneInit()
|
function scene.sceneInit()
|
||||||
love.keyboard.setKeyRepeat(false)
|
love.keyboard.setKeyRepeat(false)
|
||||||
hideChatBox=true
|
textBox.hide=true
|
||||||
textBox:clear()
|
textBox:clear()
|
||||||
|
|
||||||
resetGameData("n")
|
resetGameData("n")
|
||||||
@@ -85,7 +84,7 @@ function scene.keyDown(key)
|
|||||||
LOG.print(text.sureQuit,COLOR.orange)
|
LOG.print(text.sureQuit,COLOR.orange)
|
||||||
end
|
end
|
||||||
elseif key=="\\"then
|
elseif key=="\\"then
|
||||||
hideChatBox=not hideChatBox
|
textBox.hide=not textBox.hide
|
||||||
elseif playing then
|
elseif playing then
|
||||||
if noKey then return end
|
if noKey then return end
|
||||||
local k=keyMap.keyboard[key]
|
local k=keyMap.keyboard[key]
|
||||||
@@ -274,7 +273,7 @@ function scene.draw()
|
|||||||
drawFWM()
|
drawFWM()
|
||||||
|
|
||||||
--Players
|
--Players
|
||||||
for p=hideChatBox and 1 or 2,#PLAYERS do
|
for p=textBox.hide and 1 or 2,#PLAYERS do
|
||||||
PLAYERS[p]:draw()
|
PLAYERS[p]:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -285,7 +284,7 @@ function scene.draw()
|
|||||||
drawWarning()
|
drawWarning()
|
||||||
|
|
||||||
--New message
|
--New message
|
||||||
if textBox.new and hideChatBox then
|
if textBox.new and textBox.hide then
|
||||||
setFont(30)
|
setFont(30)
|
||||||
gc.setColor(1,TIME()%.4<.2 and 1 or 0,0)
|
gc.setColor(1,TIME()%.4<.2 and 1 or 0,0)
|
||||||
gc.print("M",460,15)
|
gc.print("M",460,15)
|
||||||
@@ -296,7 +295,7 @@ scene.widgetList={
|
|||||||
WIDGET.newKey{name="ready",x=640,y=440,w=200,h=80,color="yellow",font=40,code=pressKey"space",hide=function()
|
WIDGET.newKey{name="ready",x=640,y=440,w=200,h=80,color="yellow",font=40,code=pressKey"space",hide=function()
|
||||||
return
|
return
|
||||||
playing or
|
playing or
|
||||||
not hideChatBox or
|
not textBox.hide or
|
||||||
NET.getLock("ready")
|
NET.getLock("ready")
|
||||||
end},
|
end},
|
||||||
WIDGET.newKey{name="hideChat",fText="...",x=380,y=35,w=60,font=35,code=pressKey"\\"},
|
WIDGET.newKey{name="hideChat",fText="...",x=380,y=35,w=60,font=35,code=pressKey"\\"},
|
||||||
|
|||||||
Reference in New Issue
Block a user