From b2b5c99425757ccd5917206cf51adf413799b82c Mon Sep 17 00:00:00 2001 From: MrZ_26 <1046101471@qq.com> Date: Thu, 3 Nov 2022 15:11:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=8A=82=E6=97=A5=E6=97=A5?= =?UTF-8?q?=E6=9C=9F=E5=86=99=E9=94=99=20=E4=BF=AE=E6=AD=A3=E7=AE=80?= =?UTF-8?q?=E6=B4=81=E6=A8=A1=E5=BC=8F=E5=9C=BA=E6=99=AF=E6=A0=88=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E6=9C=89=E6=9C=AA=E8=A7=A6=E5=8F=91=E6=BC=8F=E6=B4=9E?= =?UTF-8?q?=20=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81=20=E6=A1=86=E6=9E=B6?= =?UTF-8?q?=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 | 16 ++++++++-------- parts/net.lua | 26 +++++++++++++------------- parts/player/player.lua | 2 +- parts/scenes/load.lua | 2 +- parts/scenes/main.lua | 2 +- parts/scenes/setting_game.lua | 8 ++------ parts/theme.lua | 4 ++-- 8 files changed, 29 insertions(+), 33 deletions(-) diff --git a/Zframework b/Zframework index 6581acd9..24864eda 160000 --- a/Zframework +++ b/Zframework @@ -1 +1 @@ -Subproject commit 6581acd9e8c81764b4aeb275264b3f09628c8e46 +Subproject commit 24864eda21356f03acebb8f0da4b74738b54684a diff --git a/main.lua b/main.lua index fec7c8d1..20398c71 100644 --- a/main.lua +++ b/main.lua @@ -60,13 +60,13 @@ BGM.setMaxSources(5) VOC.setDiversion(.62) WIDGET.setOnChange(function() - if SCN.current~='custom_field' then + if SCN.cur~='custom_field' then local colorList=THEME.getThemeColor() - if not colorList then return end - local rnd=math.random - for _,W in next,SCN.scenes[SCN.current].widgetList do - if W.color then - W.color=colorList[rnd(#colorList)] + if colorList then + for _,W in next,SCN.scenes[SCN.cur].widgetList do + if W.color then + W.color=colorList[math.random(#colorList)] + end end end end @@ -218,10 +218,10 @@ do-- Z.setOnFocus TASK.new(task_autoSoundOn) end else - if SCN.current=='game' and SETTING.autoPause then + if SCN.cur=='game' and SETTING.autoPause then pauseGame() end - if SETTING.autoMute and SCN.current~='music' then + if SETTING.autoMute and SCN.cur~='music' then TASK.removeTask_code(task_autoSoundOn) TASK.new(task_autoSoundOff) end diff --git a/parts/net.lua b/parts/net.lua index 17e42dfb..60eff6bd 100644 --- a/parts/net.lua +++ b/parts/net.lua @@ -440,7 +440,7 @@ end --Remove player when leave local function _playerLeaveRoom(uid) - if SCN.current=='net_game' then + if SCN.cur=='net_game' then 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 then @@ -586,7 +586,7 @@ function NET.wsCallBack.global_getOnlineCount(body) NET.onlineCount=tonumber(body.data) or "_" end function NET.wsCallBack.room_chat(body) - if SCN.current=='net_game' then + if SCN.cur=='net_game' then TASK.unlock('receiveMessage') TASK.lock('receiveMessage',1) NET.textBox:push{ @@ -684,22 +684,22 @@ function NET.wsCallBack.room_fetch(body) SCN.scenes.net_rooms.widgetList.roomList:setList(body.data) end function NET.wsCallBack.room_setPW() - if SCN.current~='net_game' then return end + if SCN.cur~='net_game' then return end MES.new(text.roomPasswordChanged) end function NET.wsCallBack.room_remove() - if SCN.current~='net_game' then return end + if SCN.cur~='net_game' then return end MES.new('info',text.roomRemoved) _playerLeaveRoom(USER.uid) end function NET.wsCallBack.player_updateConf(body) - if SCN.current~='net_game' then return end + if SCN.cur~='net_game' then return end if type(body.data)=='table' then NETPLY.map[body.data.playerId].config=body.data.config end end function NET.wsCallBack.player_finish(body) - if SCN.current~='net_game' then return end + if SCN.cur~='net_game' then return end for _,P in next,PLY_ALIVE do if P.uid==body.data.playerId then P.loseTimer=26 @@ -709,11 +709,11 @@ function NET.wsCallBack.player_finish(body) end end function NET.wsCallBack.player_joinGroup(body) - if SCN.current~='net_game' then return end + if SCN.cur~='net_game' then return end NETPLY.map[body.data.playerId].group=body.data.group end function NET.wsCallBack.player_setHost(body) - if SCN.current~='net_game' then return end + if SCN.cur~='net_game' then return end if body.data.role=='Admin' then MES.new('info',text.becomeHost:repD(_getFullName(body.data.playerId))) end @@ -722,21 +722,21 @@ end function NET.wsCallBack.player_setState(body)-- not used end function NET.wsCallBack.player_stream(body) - if SCN.current~='net_game' then return end + if SCN.cur~='net_game' then return end _pumpStream(body.data) end function NET.wsCallBack.player_setPlayMode(body) - if SCN.current~='net_game' then return end + if SCN.cur~='net_game' then return end NETPLY.map[body.data.playerId].playMode=body.data.type NET.freshRoomAllReady() end function NET.wsCallBack.player_setReadyMode(body) - if SCN.current~='net_game' then return end + if SCN.cur~='net_game' then return end NETPLY.map[body.data.playerId].readyMode=body.data.isReady and 'Ready' or 'Standby' NET.freshRoomAllReady() end function NET.wsCallBack.match_finish() - if SCN.current~='net_game' then return end + if SCN.cur~='net_game' then return end for _,P in next,PLAYERS do NETPLY.setStat(P.uid,P.stat) end @@ -748,7 +748,7 @@ end function NET.wsCallBack.match_ready()-- not used end function NET.wsCallBack.match_start(body) - if SCN.current~='net_game' then return end + if SCN.cur~='net_game' then return end TASK.lock('netPlaying') NET.seed=body.data and body.data.seed if not NET.seed then diff --git a/parts/player/player.lua b/parts/player/player.lua index 7b342e6a..c6bcd8d4 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.current~='game' or PLAYERS[1].frameRun<180 then + if SCN.cur~='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 409668fa..755b5fc2 100644 --- a/parts/scenes/load.lua +++ b/parts/scenes/load.lua @@ -103,7 +103,7 @@ local loadingThread=coroutine.wrap(function() SFX.play('enter',.8) SFX.play('welcome') VOC.play('welcome') - THEME.set(THEME.calculate(os.date('%Y'),os.date('%m'),os.date('%d'))) + THEME.set(THEME.calculate()) LOADED=true saveStats() Z.setPowerInfo(SETTING.powerInfo) diff --git a/parts/scenes/main.lua b/parts/scenes/main.lua index 4add469d..d6d59d67 100644 --- a/parts/scenes/main.lua +++ b/parts/scenes/main.lua @@ -22,7 +22,7 @@ function scene.sceneInit() if THEME.cur=='halloween' then TASK.new(function() TEST.yieldT(.26) - while SCN.current=='main' do + while SCN.cur=='main' do flash=.355 SFX.play('clear_'..math.random(4,6),1,math.random()*2-1,-9-math.random()*3) TEST.yieldT(.626+math.random()*6.26) diff --git a/parts/scenes/setting_game.lua b/parts/scenes/setting_game.lua index 308f21e1..dfdc64d2 100644 --- a/parts/scenes/setting_game.lua +++ b/parts/scenes/setting_game.lua @@ -51,12 +51,8 @@ scene.widgetList={ WIDGET.newSwitch{name='simpMode', x=960, y=670, lim=480, disp=SETval('simpMode'), code=function() SETTING.simpMode=not SETTING.simpMode - for i=1,#SCN.stack,2 do - if SCN.stack[i]=='main' or SCN.stack[i]=='main_simple' then - SCN.stack[i]=SETTING.simpMode and 'main_simple' or 'main' - break - end - end + local p=TABLE.find(SCN.stack,'main') or TABLE.find(SCN.stack,'main_simple') + SCN.stack[p]=SETTING.simpMode and 'main_simple' or 'main' end}, WIDGET.newButton{name='back', x=1140, y=640, w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=backScene}, } diff --git a/parts/theme.lua b/parts/theme.lua index 0f25896c..2bbd6997 100644 --- a/parts/theme.lua +++ b/parts/theme.lua @@ -4,7 +4,7 @@ local THEME={ local themeColor={ xmas={COLOR.lR,COLOR.Z,COLOR.lG}, sprfes={COLOR.lR,COLOR.O,COLOR.lY}, - halloween={COLOR.lH,COLOR.O,{COLOR.hsv(0.76, 0.50, 0.42)},{COLOR.hsv(0.33, 0.80, 0.42)}}, + halloween={COLOR.lH,COLOR.O,{COLOR.hsv(.76,.50,.42)},{COLOR.hsv(.33,.80,.42)}}, } function THEME.calculate(Y,M,D) @@ -18,7 +18,7 @@ function THEME.calculate(Y,M,D) 'xmas' or -- Halloween - (M=='11' and D>='28' or M=='12' and D<='04') and + (M=='10' and D>='28' or M=='11' and D<='04') and 'halloween' or -- Birthday