From e31caaeb65e5dc3cb52907ce2a30a0af17d12281 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Mon, 26 Apr 2021 10:55:58 +0800 Subject: [PATCH] =?UTF-8?q?=E8=81=94=E7=BD=91=E5=AF=B9=E6=88=98=E6=88=BF?= =?UTF-8?q?=E9=97=B4=E5=86=85=E6=96=B0=E5=A2=9E=E8=AE=BE=E7=BD=AE=E6=8C=89?= =?UTF-8?q?=E9=92=AE=EF=BC=8C=E4=B8=8D=E7=A6=BB=E5=BC=80=E6=88=BF=E9=97=B4?= =?UTF-8?q?=E5=B0=B1=E8=83=BD=E4=BF=AE=E6=94=B9=E8=AE=BE=E7=BD=AE=EF=BC=88?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E5=9C=A8=E6=9C=AA=E5=87=86=E5=A4=87=E7=8A=B6?= =?UTF-8?q?=E6=80=81=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/net.lua | 16 +++++++++++----- parts/scenes/net_game.lua | 11 ++++++++++- parts/texture.lua | 15 +++++++++++++++ 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/parts/net.lua b/parts/net.lua index 93c2d252..80d5c7e1 100644 --- a/parts/net.lua +++ b/parts/net.lua @@ -198,16 +198,22 @@ end function NET.checkPlayDisconn() return WS.status("play")~="running" end -function NET.signal_ready(ready) - if NET.lock("ready",3)and not NET.serverGaming then - WS.send("play",'{"action":6,"data":{"ready":'..tostring(ready)..'}}') - end -end function NET.signal_quit() if NET.lock("quit",3)then WS.send("play",'{"action":3}') end end +function NET.sendMessage(mes) + WS.send("play",'{"action":4,"data":{"message":'..mes..'}}') +end +function NET.changeConfig() + WS.send("play",'{"action":5,"data":'..JSON.encode({config=dumpBasicConfig()})..'}') +end +function NET.signal_ready(ready) + if NET.lock("ready",3)and not NET.serverGaming then + WS.send("play",'{"action":6,"data":{"ready":'..tostring(ready)..'}}') + end +end function NET.signal_die() WS.send("stream",'{"action":4,"data":{"score":0,"survivalTime":0}}') end diff --git a/parts/scenes/net_game.lua b/parts/scenes/net_game.lua index 05ab4e75..d0a63765 100644 --- a/parts/scenes/net_game.lua +++ b/parts/scenes/net_game.lua @@ -16,7 +16,7 @@ local scene={} function scene.sceneBack() love.keyboard.setKeyRepeat(true) end -function scene.sceneInit() +function scene.sceneInit(org) love.keyboard.setKeyRepeat(false) textBox.hide=true textBox:clear() @@ -25,6 +25,10 @@ function scene.sceneInit() playing=false lastUpstreamTime=0 upstreamProgress=1 + + if org=="setting_game"then + NET.changeConfig() + end end scene.mouseDown=NULL @@ -88,6 +92,10 @@ function scene.keyDown(key) end elseif key=="space"then NET.signal_ready(not PLY_NET[1].ready) + elseif key=="s"then + if not PLY_NET[1].ready then + SCN.go("setting_game") + end end end function scene.keyUp(key) @@ -274,6 +282,7 @@ function scene.draw() end scene.widgetList={ textBox, + WIDGET.newKey{name="setting",fText=TEXTURE.setting,x=1200,y=160,w=90,h=90,code=pressKey"s",hide=function()return PLY_NET[1].ready end}, WIDGET.newKey{name="ready",x=900,y=560,w=400,h=100,color="lB",font=40,code=pressKey"space", hide=function() return diff --git a/parts/texture.lua b/parts/texture.lua index 52287462..9f71de95 100644 --- a/parts/texture.lua +++ b/parts/texture.lua @@ -79,6 +79,7 @@ TEXTURE.cursor_hold=DOGC{16,16, {"fCirc",8,8,3}, } +--Level icons TEXTURE.lvIcon=setmetatable({},{__index=function(self,lv) local img={25,25} @@ -93,6 +94,20 @@ TEXTURE.lvIcon=setmetatable({},{__index=function(self,lv) return img end}) +--Setting icon +TEXTURE.setting=DOGC{64,64, + {"setLW",8}, + {"dCirc",32,32,18}, + {"setLW",10}, + {"dLine",52,32,64,32}, + {"dLine",32,52,32,64}, + {"dLine",12,32,0,32}, + {"dLine",32,12,32,0}, + {"dLine",45,45,55,55}, + {"dLine",19,45,9,55}, + {"dLine",19,19,9,9}, + {"dLine",45,19,55,9}, +} gc.setDefaultFilter("linear","linear")