联网游戏房间内支持打字聊天(有较大体验问题,请不要使用)
This commit is contained in:
@@ -247,7 +247,7 @@ function NET.signal_quit()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
function NET.sendMessage(mes)
|
function NET.sendMessage(mes)
|
||||||
WS.send('play','{"action":4,"data":{"message":'..mes..'}}')
|
WS.send('play','{"action":4,"data":'..JSON.encode{message=mes}..'}')
|
||||||
end
|
end
|
||||||
function NET.changeConfig()
|
function NET.changeConfig()
|
||||||
WS.send('play','{"action":5,"data":'..JSON.encode({config=dumpBasicConfig()})..'}')
|
WS.send('play','{"action":5,"data":'..JSON.encode({config=dumpBasicConfig()})..'}')
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ local ins=table.insert
|
|||||||
local SCR,VK,NET,netPLY=SCR,VK,NET,netPLY
|
local SCR,VK,NET,netPLY=SCR,VK,NET,netPLY
|
||||||
local PLAYERS,GAME=PLAYERS,GAME
|
local PLAYERS,GAME=PLAYERS,GAME
|
||||||
|
|
||||||
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=560,hide=false}
|
||||||
|
local inputBox=WIDGET.newInputBox{name="input",x=340,y=660,w=600,h=50,hide=false}
|
||||||
|
|
||||||
local playing
|
local playing
|
||||||
local lastUpstreamTime
|
local lastUpstreamTime
|
||||||
@@ -14,13 +15,10 @@ local touchMoveLastFrame=false
|
|||||||
|
|
||||||
local scene={}
|
local scene={}
|
||||||
|
|
||||||
function scene.sceneBack()
|
|
||||||
love.keyboard.setKeyRepeat(true)
|
|
||||||
end
|
|
||||||
function scene.sceneInit(org)
|
function scene.sceneInit(org)
|
||||||
love.keyboard.setKeyRepeat(false)
|
|
||||||
textBox.hide=true
|
textBox.hide=true
|
||||||
textBox:clear()
|
textBox:clear()
|
||||||
|
inputBox.hide=true
|
||||||
|
|
||||||
noTouch=not SETTING.VKSwitch
|
noTouch=not SETTING.VKSwitch
|
||||||
playing=false
|
playing=false
|
||||||
@@ -31,6 +29,9 @@ function scene.sceneInit(org)
|
|||||||
NET.changeConfig()
|
NET.changeConfig()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
function scene.sceneBack()
|
||||||
|
love.keyboard.setKeyRepeat(true)
|
||||||
|
end
|
||||||
|
|
||||||
scene.mouseDown=NULL
|
scene.mouseDown=NULL
|
||||||
function scene.mouseMove(x,y)netPLY.mouseMove(x,y)end
|
function scene.mouseMove(x,y)netPLY.mouseMove(x,y)end
|
||||||
@@ -86,6 +87,23 @@ function scene.keyDown(key)
|
|||||||
end
|
end
|
||||||
elseif key=="\\"then
|
elseif key=="\\"then
|
||||||
textBox.hide=not textBox.hide
|
textBox.hide=not textBox.hide
|
||||||
|
inputBox.hide=not inputBox.hide
|
||||||
|
if textBox.hide then
|
||||||
|
WIDGET.sel=nil
|
||||||
|
else
|
||||||
|
TASK.new(function()YIELD()WIDGET.sel=inputBox end)
|
||||||
|
end
|
||||||
|
elseif not inputBox.hide then
|
||||||
|
if key=="return"then
|
||||||
|
print(EDITING)
|
||||||
|
if inputBox:hasText()then
|
||||||
|
NET.sendMessage(inputBox:getText())
|
||||||
|
inputBox:clear()
|
||||||
|
end
|
||||||
|
else
|
||||||
|
WIDGET.sel=inputBox
|
||||||
|
WIDGET.keyPressed(key)
|
||||||
|
end
|
||||||
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]
|
||||||
@@ -158,6 +176,7 @@ function scene.socketRead(cmd,d)
|
|||||||
elseif cmd=='go'then
|
elseif cmd=='go'then
|
||||||
if not playing then
|
if not playing then
|
||||||
playing=true
|
playing=true
|
||||||
|
love.keyboard.setKeyRepeat(false)
|
||||||
netPLY.resetReady()
|
netPLY.resetReady()
|
||||||
netPLY.mouseMove(0,0)
|
netPLY.mouseMove(0,0)
|
||||||
lastUpstreamTime=0
|
lastUpstreamTime=0
|
||||||
@@ -168,6 +187,7 @@ function scene.socketRead(cmd,d)
|
|||||||
end
|
end
|
||||||
elseif cmd=='finish'then
|
elseif cmd=='finish'then
|
||||||
playing=false
|
playing=false
|
||||||
|
love.keyboard.setKeyRepeat(true)
|
||||||
local winnerUID
|
local winnerUID
|
||||||
for _,p in next,d.result do
|
for _,p in next,d.result do
|
||||||
if p.place==1 then
|
if p.place==1 then
|
||||||
@@ -280,6 +300,7 @@ function scene.draw()
|
|||||||
end
|
end
|
||||||
scene.widgetList={
|
scene.widgetList={
|
||||||
textBox,
|
textBox,
|
||||||
|
inputBox,
|
||||||
WIDGET.newKey{name="setting",fText=TEXTURE.setting,x=1200,y=160,w=90,h=90,code=pressKey"s",hide=function()return playing or netPLY.getSelfReady()or NET.getlock('ready')end},
|
WIDGET.newKey{name="setting",fText=TEXTURE.setting,x=1200,y=160,w=90,h=90,code=pressKey"s",hide=function()return playing or netPLY.getSelfReady()or NET.getlock('ready')end},
|
||||||
WIDGET.newKey{name="ready",x=1060,y=630,w=300,h=80,color='lB',font=40,code=pressKey"space",
|
WIDGET.newKey{name="ready",x=1060,y=630,w=300,h=80,color='lB',font=40,code=pressKey"space",
|
||||||
hide=function()
|
hide=function()
|
||||||
|
|||||||
Reference in New Issue
Block a user