From 754545cc401d3e9d96cd2da395455856565740a3 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Tue, 24 Aug 2021 18:29:45 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8D=95=E5=B0=81=E8=A3=85=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E7=BB=9F=E8=AE=A1=E3=80=81=E8=BF=9B=E5=BA=A6=E3=80=81?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E7=9A=84=E4=B8=89=E4=B8=AA=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E6=96=B9=E4=BE=BF=E9=98=85=E8=AF=BB=E4=BB=A3=E7=A0=81=20f11?= =?UTF-8?q?=E5=BC=80=E5=85=B3=E5=85=A8=E5=B1=8F=E6=97=B6=E4=BC=9A=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E4=BF=9D=E5=AD=98=E8=AE=BE=E7=BD=AE=20close=20#230?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/init.lua | 7 ++----- main.lua | 6 +++--- parts/gametoolfunc.lua | 13 +++++++++++-- parts/net.lua | 6 +++--- parts/scenes/app_console.lua | 9 ++++----- parts/scenes/lang.lua | 2 +- parts/scenes/load.lua | 2 +- parts/scenes/savedata.lua | 20 ++++++++------------ parts/scenes/setting_game.lua | 2 +- parts/scenes/setting_sound.lua | 2 +- parts/scenes/setting_video.lua | 2 +- 11 files changed, 36 insertions(+), 35 deletions(-) diff --git a/Zframework/init.lua b/Zframework/init.lua index d507ffce..7a153ba5 100644 --- a/Zframework/init.lua +++ b/Zframework/init.lua @@ -287,11 +287,8 @@ function love.keypressed(key,_,isRep) devMode=1 MES.new('info',"DEBUG ON",.2) elseif key=="f11"then - if kb.isDown("lctrl","rctrl")then - _G['\100\114\97\119\70\87\77']=NULL - else - switchFullscreen() - end + switchFullscreen() + saveSettings() elseif not SCN.swapping then if SCN.keyDown then if EDITING==""then diff --git a/main.lua b/main.lua index 8f888856..aefea100 100644 --- a/main.lua +++ b/main.lua @@ -354,9 +354,9 @@ do end if needSave then - FILE.save(SETTING,'conf/settings') - FILE.save(RANKS,'conf/unlock') - FILE.save(STAT,'conf/data') + saveStats() + saveProgress() + saveSettings() end end diff --git a/parts/gametoolfunc.lua b/parts/gametoolfunc.lua index 98fb9c46..f0925d67 100644 --- a/parts/gametoolfunc.lua +++ b/parts/gametoolfunc.lua @@ -12,6 +12,15 @@ local SETTING,GAME,SCR=SETTING,GAME,SCR --System +function saveStats() + FILE.save(STAT,'conf/data') +end +function saveProgress() + FILE.save(RANKS,'conf/unlock') +end +function saveSettings() + FILE.save(SETTING,'conf/settings') +end function applySettings() love.window.setFullscreen(SETTING.fullscreen) LANG.set(SETTING.lang) @@ -304,7 +313,7 @@ function gameOver()--Save record end end if needSave then - FILE.save(RANKS,'conf/unlock') + saveProgress() end end local D=M.score(P) @@ -340,7 +349,7 @@ function trySave() STAT.game=STAT.game+1 mergeStat(STAT,PLAYERS[1].stat) STAT.todayTime=STAT.todayTime+PLAYERS[1].stat.time - FILE.save(STAT,'conf/data') + saveStats() end end do--function freshPlayerPosition(sudden) diff --git a/parts/net.lua b/parts/net.lua index 2d5a832d..576b31eb 100644 --- a/parts/net.lua +++ b/parts/net.lua @@ -262,14 +262,14 @@ function NET.loadSavedData(sections) if STAT.version==NET.cloudData.STAT.version then local success=true TABLE.update(NET.cloudData.STAT,STAT) - success=success and FILE.save(STAT,'conf/data') + success=success and saveStats() TABLE.update(NET.cloudData.RANKS,RANKS) - success=success and FILE.save(RANKS,'conf/unlock') + success=success and saveProgress() TABLE.update(NET.cloudData.SETTING,SETTING) applySettings() - success=success and FILE.save(SETTING,'conf/settings') + success=success and saveSettings() TABLE.update(NET.cloudData.keyMap,keyMap) success=success and FILE.save(keyMap,'conf/key') diff --git a/parts/scenes/app_console.lua b/parts/scenes/app_console.lua index ec8e7202..98c8a86e 100644 --- a/parts/scenes/app_console.lua +++ b/parts/scenes/app_console.lua @@ -656,9 +656,8 @@ local commands={}do if #key>0 then if SETTING[key]~=nil then SETTING[key]=nil - if FILE.save(SETTING,'conf/settings')then - log{C.Y,("Succesfully erased key '%s'"):format(key)} - end + saveSettings() + log{C.Y,("Succesfully erased key '%s'"):format(key)} else log{C.R,"No key called "..key} end @@ -683,7 +682,7 @@ local commands={}do if M.x then RANKS[name]=0 end end end - FILE.save(RANKS,'conf/unlock') + saveProgress() log{C.lC,"\85\78\76\79\67\75\65\76\76"} SFX.play('clear_2') else @@ -719,7 +718,7 @@ local commands={}do code=function(bool) if bool=="on"or bool=="off"then SETTING.allowTAS=bool=="on" - FILE.save(SETTING,'conf/settings') + saveSettings() log("Allow TAS: "..bool) if bool then log("Hot keys: f1=play/pause f2=slowdown f3=speedup/nextframe") diff --git a/parts/scenes/lang.lua b/parts/scenes/lang.lua index 5286df29..7c324f25 100644 --- a/parts/scenes/lang.lua +++ b/parts/scenes/lang.lua @@ -12,7 +12,7 @@ local langList={ local scene={} function scene.sceneBack() - FILE.save(SETTING,'conf/settings') + saveSettings() end local function _setLang(n) diff --git a/parts/scenes/load.lua b/parts/scenes/load.lua index d85a3748..ddd4f40c 100644 --- a/parts/scenes/load.lua +++ b/parts/scenes/load.lua @@ -116,7 +116,7 @@ local loadingThread=coroutine.wrap(function() end end if editFlag then - FILE.save(RANKS,'conf/unlock') + saveProgress() end YIELD('loadOther') diff --git a/parts/scenes/savedata.lua b/parts/scenes/savedata.lua index c0bafbbc..5dffc8b7 100644 --- a/parts/scenes/savedata.lua +++ b/parts/scenes/savedata.lua @@ -37,9 +37,8 @@ scene.widgetList={ RANKS[k]=nil end end - if FILE.save(RANKS,'conf/unlock')then - MES.new('check',text.importSuccess) - end + saveProgress() + MES.new('check',text.importSuccess) else MES.new('error',text.dataCorrupted) end @@ -49,9 +48,8 @@ scene.widgetList={ local D=parseCB() if D and D.version==STAT.version then TABLE.update(D,STAT) - if FILE.save(STAT,'conf/data')then - MES.new('check',text.importSuccess) - end + saveStats() + MES.new('check',text.importSuccess) else MES.new('error',text.dataCorrupted) end @@ -62,9 +60,8 @@ scene.widgetList={ if D then TABLE.update(D,SETTING) applySettings() - if FILE.save(SETTING,'conf/settings')then - MES.new('check',text.importSuccess) - end + saveSettings() + MES.new('check',text.importSuccess) else MES.new('error',text.dataCorrupted) end @@ -74,9 +71,8 @@ scene.widgetList={ local D=parseCB() if D then TABLE.update(D,VK_org) - if FILE.save(VK_org,'conf/virtualkey')then - MES.new('check',text.importSuccess) - end + FILE.save(VK_org,'conf/virtualkey') + MES.new('check',text.importSuccess) else MES.new('error',text.dataCorrupted) end diff --git a/parts/scenes/setting_game.lua b/parts/scenes/setting_game.lua index 422bf5a2..3bba10ed 100644 --- a/parts/scenes/setting_game.lua +++ b/parts/scenes/setting_game.lua @@ -6,7 +6,7 @@ function scene.sceneInit() BG.set() end function scene.sceneBack() - FILE.save(SETTING,'conf/settings') + saveSettings() end function scene.draw() diff --git a/parts/scenes/setting_sound.lua b/parts/scenes/setting_sound.lua index d6a5d628..38c2c61b 100644 --- a/parts/scenes/setting_sound.lua +++ b/parts/scenes/setting_sound.lua @@ -17,7 +17,7 @@ function scene.sceneInit() BG.set() end function scene.sceneBack() - FILE.save(SETTING,'conf/settings') + saveSettings() end function scene.mouseDown(x,y) diff --git a/parts/scenes/setting_video.lua b/parts/scenes/setting_video.lua index a4e8c917..56a48fe7 100644 --- a/parts/scenes/setting_video.lua +++ b/parts/scenes/setting_video.lua @@ -3,7 +3,7 @@ local gc=love.graphics local scene={} function scene.sceneBack() - FILE.save(SETTING,'conf/settings') + saveSettings() end local fakeBlock={{true}}