From 42168ddf16c9c527bf532afb7bd37e1c0c5837d8 Mon Sep 17 00:00:00 2001 From: MrZ_26 <1046101471@qq.com> Date: Tue, 25 Oct 2022 02:17:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9B=E8=81=94?= =?UTF-8?q?=E7=BD=91=E7=9B=B8=E5=85=B3=E5=9C=BA=E6=99=AF=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E5=85=B3=E7=B3=BB=E9=97=AE=E9=A2=98=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E9=87=8D=E8=AE=BE=E5=AF=86=E7=A0=81=E5=9C=BA=E6=99=AF=E5=9B=9E?= =?UTF-8?q?=E8=BD=A6=E9=94=AE=E8=87=AA=E5=8A=A8=E8=AF=86=E5=88=AB=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=9D=A1=E4=BB=B6=E9=94=99=E8=AF=AF=20=E6=A1=86?= =?UTF-8?q?=E6=9E=B6=E8=B7=9F=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework | 2 +- main.lua | 8 ++++---- parts/net.lua | 30 ++++++++++++++---------------- parts/player/player.lua | 2 +- parts/scenes/load.lua | 2 +- parts/scenes/main.lua | 2 +- parts/scenes/mode.lua | 2 +- parts/scenes/net_menu.lua | 2 +- parts/scenes/reset_password.lua | 4 ++-- 9 files changed, 26 insertions(+), 28 deletions(-) diff --git a/Zframework b/Zframework index d86dba11..b0b59816 160000 --- a/Zframework +++ b/Zframework @@ -1 +1 @@ -Subproject commit d86dba11eabd3eb0c1cb23f5716ebc389f35e848 +Subproject commit b0b5981698a01dd5188fb1de2f5115a7991f88e7 diff --git a/main.lua b/main.lua index 9e63dff7..bef38b83 100644 --- a/main.lua +++ b/main.lua @@ -60,11 +60,11 @@ BGM.setMaxSources(5) VOC.setDiversion(.62) WIDGET.setOnChange(function() - if SCN.cur~='custom_field' then + if SCN.stack[#SCN.stack-1]~='custom_field' then local colorList=THEME.getThemeColor() if not colorList then return end local rnd=math.random - for _,W in next,SCN.scenes[SCN.cur].widgetList do + for _,W in next,SCN.scenes[SCN.stack[#SCN.stack-1]].widgetList do if W.color then W.color=colorList[rnd(#colorList)] end @@ -218,10 +218,10 @@ do-- Z.setOnFocus TASK.new(task_autoSoundOn) end else - if SCN.cur=='game' and SETTING.autoPause then + if SCN.stack[#SCN.stack-1]=='game' and SETTING.autoPause then pauseGame() end - if SETTING.autoMute and SCN.cur~='music' then + if SETTING.autoMute and SCN.stack[#SCN.stack-1]~='music' then TASK.removeTask_code(task_autoSoundOn) TASK.new(task_autoSoundOff) end diff --git a/parts/net.lua b/parts/net.lua index 9a2da600..f6b65832 100644 --- a/parts/net.lua +++ b/parts/net.lua @@ -32,10 +32,6 @@ local NET={ inputBox=WIDGET.newInputBox{name='input',x=340,y=660,w=600,h=50,limit=256}, } -function NET.connectLost() - while SCN.stack[#SCN.stack-1]~='main' and #SCN.stack>0 do SCN.pop() end - SCN.back() -end function NET.freshRoomAllReady() local playCount,readyCount=0,0 for j=1,#NETPLY.list do @@ -166,13 +162,13 @@ function NET.codeLogin(email,code) USER.aToken=res.data.accessToken saveUser() NET.ws_connect() - SCN.pop()SCN.go('net_menu') + SCN.swapTo('net_menu') elseif res.code==201 then USER.rToken=res.data.refreshToken USER.aToken=res.data.accessToken saveUser() SCN.pop()SCN.push('net_menu') - SCN.swapTo('reset_password') + SCN.go('reset_password') end end @@ -362,7 +358,7 @@ function NET.pwLogin(email,pw) USER.aToken=res.data.accessToken saveUser() NET.ws_connect() - SCN.go('net_menu') + SCN.swapTo('net_menu') end end end @@ -435,10 +431,12 @@ end local function _playerLeaveRoom(uid) for i=1,#PLAYERS do if PLAYERS[i].uid==uid then table.remove(PLAYERS,i) break end end for i=1,#PLY_ALIVE do if PLY_ALIVE[i].uid==uid then table.remove(PLY_ALIVE,i) break end end - if uid==USER.uid and SCN.cur=='net_game' then - SCN.back() - else - NETPLY.remove(uid) + if SCN.stack[#SCN.stack-1]=='net_game' then + if uid==USER.uid then + SCN.backTo('net_menu') + else + NETPLY.remove(uid) + end end end @@ -577,7 +575,7 @@ function NET.wsCallBack.global_getOnlineCount(body) NET.onlineCount=tonumber(body.data) or "_" end function NET.wsCallBack.room_chat(body) - if SCN.cur=='net_game' then + if SCN.stack[#SCN.stack-1]=='net_game' then TASK.unlock('receiveMessage') TASK.lock('receiveMessage',1) NET.textBox:push{ @@ -723,7 +721,7 @@ function NET.ws_update() TEST.yieldT(1/26) if WS.status('game')=='dead' then TEST.yieldUntilNextScene() - NET.connectLost() + SCN.backTo('main') return elseif WS.status('game')=='running' then break @@ -741,7 +739,7 @@ function NET.ws_update() USER.uid=res.data else TEST.yieldUntilNextScene() - NET.connectLost() + SCN.backTo('main') return end end @@ -756,7 +754,7 @@ function NET.ws_update() if WS.status('game')=='dead' then TEST.yieldUntilNextScene() - NET.connectLost() + SCN.backTo('main') return end @@ -774,7 +772,7 @@ function NET.ws_update() if msg and msg.message then LOG(msg.message) end end TEST.yieldUntilNextScene() - NET.connectLost() + SCN.backTo('main') return elseif msg then msg=JSON.decode(msg) diff --git a/parts/player/player.lua b/parts/player/player.lua index 503c6575..1d06a5fc 100644 --- a/parts/player/player.lua +++ b/parts/player/player.lua @@ -2192,7 +2192,7 @@ local function task_autoPause() while true do yield() time=time+1 - if SCN.cur~='game' or PLAYERS[1].frameRun<180 then + if SCN.stack[#SCN.stack-1]~='game' or PLAYERS[1].frameRun<180 then return elseif time==120 then pauseGame() diff --git a/parts/scenes/load.lua b/parts/scenes/load.lua index 24589480..53a5955a 100644 --- a/parts/scenes/load.lua +++ b/parts/scenes/load.lua @@ -127,7 +127,7 @@ function scene.mouseDown() SCN.push('main') SCN.swapTo('lang') else - SCN.swapTo(SETTING.simpMode and 'main_simple' or 'main') + SCN.go(SETTING.simpMode and 'main_simple' or 'main') end end end diff --git a/parts/scenes/main.lua b/parts/scenes/main.lua index 13cc012b..6966c27f 100644 --- a/parts/scenes/main.lua +++ b/parts/scenes/main.lua @@ -108,7 +108,7 @@ function scene.keyDown(key,isRep) elseif key=='escape' then if tryBack() then VOC.play('bye') - SCN.swapTo('quit','slowFade') + SCN.back() end else return true diff --git a/parts/scenes/mode.lua b/parts/scenes/mode.lua index eaaf2b9f..5e44e0fc 100644 --- a/parts/scenes/mode.lua +++ b/parts/scenes/mode.lua @@ -185,7 +185,7 @@ function scene.update() end end - local _=SCN.stat.tar + local _=SCN.state.tar mapCam.zoomMethod=_=="game" and 1 or _=="mode" and 2 if mapCam.zoomMethod==1 then _=mapCam.zoomK diff --git a/parts/scenes/net_menu.lua b/parts/scenes/net_menu.lua index 95e260a0..52cc69cb 100644 --- a/parts/scenes/net_menu.lua +++ b/parts/scenes/net_menu.lua @@ -5,6 +5,7 @@ function scene.sceneInit() end function scene.sceneBack() NET.ws_close() + TASK.removeTask_code(NET.ws_update) end function scene.draw() @@ -27,7 +28,6 @@ scene.widgetList={ USER.__data.rToken=false USER.__data.aToken=false love.filesystem.remove('conf/user') - NET.ws_close() SCN.back() end end}, diff --git a/parts/scenes/reset_password.lua b/parts/scenes/reset_password.lua index 311739b9..4699e0df 100644 --- a/parts/scenes/reset_password.lua +++ b/parts/scenes/reset_password.lua @@ -20,9 +20,9 @@ function scene.keyDown(key,rep) SCN.back() elseif key=='return' then if #scene.widgetList.code:getText()==0 then - _setPW() - else NET.getCode(USER.email) + else + _setPW() end else return true