From 4c95f6bfbcb328b21d4a8b10c66fb14ca7cc14df Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sat, 19 Jun 2021 14:05:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=BF=9D=E5=AD=98=E6=97=B6?= =?UTF-8?q?=E4=B8=80=E8=88=AC=E4=B8=8D=E5=86=8D=E5=BC=B9=E5=87=BA=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E6=88=90=E5=8A=9F=E7=9A=84=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/file.lua | 7 ++----- main.lua | 6 +++--- parts/gametoolfunc.lua | 6 ++++-- parts/net.lua | 21 +++++++++++++-------- parts/scenes/app_console.lua | 5 +++-- parts/scenes/customGame.lua | 6 +++--- parts/scenes/load.lua | 8 +++++++- parts/scenes/login.lua | 4 +++- parts/scenes/net_menu.lua | 2 +- parts/scenes/savedata.lua | 20 ++++++++++++-------- 10 files changed, 51 insertions(+), 34 deletions(-) diff --git a/Zframework/file.lua b/Zframework/file.lua index 1f3b4b67..33f4f255 100644 --- a/Zframework/file.lua +++ b/Zframework/file.lua @@ -48,14 +48,11 @@ function FILE.save(data,name,mode) F:open'w' local success,mes=F:write(data) F:flush()F:close() - if success then - if not mode:find'q'then - MES.new('check',text.saveDone) - end - else + if not success then MES.new('error',text.saveError..(mes or"unknown error")) MES.new(false,debug.traceback()) end + return success end function FILE.clear(path) if fs.getRealDirectory(path)~=SAVEDIR or fs.getInfo(path).type~='directory'then return end diff --git a/main.lua b/main.lua index 966c758f..a82e2209 100644 --- a/main.lua +++ b/main.lua @@ -289,9 +289,9 @@ do end if needSave then - FILE.save(SETTING,'conf/settings','q') - FILE.save(RANKS,'conf/unlock','q') - FILE.save(STAT,'conf/data','q') + FILE.save(SETTING,'conf/settings') + FILE.save(RANKS,'conf/unlock') + FILE.save(STAT,'conf/data') end if autoRestart then love.event.quit('restart') diff --git a/parts/gametoolfunc.lua b/parts/gametoolfunc.lua index 358ba6b5..37e1c73a 100644 --- a/parts/gametoolfunc.lua +++ b/parts/gametoolfunc.lua @@ -275,7 +275,9 @@ function gameOver()--Save record end end if needSave then - FILE.save(RANKS,'conf/unlock','q') + if FILE.save(RANKS,'conf/unlock')then + MES.new('check',text.saveDone) + end end end local D=M.score(P) @@ -294,7 +296,7 @@ function gameOver()--Save record D.date=os.date("%Y/%m/%d %H:%M") ins(L,p+1,D) if L[11]then L[11]=nil end - FILE.save(L,('record/%s.rec'):format(M.name),'lq') + FILE.save(L,('record/%s.rec'):format(M.name),'l') end end end diff --git a/parts/net.lua b/parts/net.lua index cab58f69..75a68590 100644 --- a/parts/net.lua +++ b/parts/net.lua @@ -268,23 +268,28 @@ function NET.loadSavedData(sections) end end if STAT.version==NET.cloudData.STAT.version then + local success=true TABLE.update(NET.cloudData.STAT,STAT) - FILE.save(STAT,'conf/data') + success=success and FILE.save(STAT,'conf/data') TABLE.update(NET.cloudData.RANKS,RANKS) - FILE.save(RANKS,'conf/unlock') + success=success and FILE.save(RANKS,'conf/unlock') TABLE.update(NET.cloudData.SETTING,SETTING) - FILE.save(SETTING,'conf/settings') + success=success and FILE.save(SETTING,'conf/settings') TABLE.update(NET.cloudData.keyMap,keyMap) - FILE.save(keyMap,'conf/key') + success=success and FILE.save(keyMap,'conf/key') TABLE.update(NET.cloudData.VK_org,VK_org) - FILE.save(VK_org,'conf/virtualkey') + success=success and FILE.save(VK_org,'conf/virtualkey') - FILE.save(NET.cloudData.vkSave1,'conf/vkSave1','q') - FILE.save(NET.cloudData.vkSave2,'conf/vkSave2','q') + success=success and FILE.save(NET.cloudData.vkSave1,'conf/vkSave1') + success=success and FILE.save(NET.cloudData.vkSave2,'conf/vkSave2') + if success then + MES.new('check',text.saveDone) + end + MES.new('check',text.saveDone) else MES.new('error',text.versionNotMatch,1) end @@ -454,7 +459,7 @@ function NET.updateWS_user() if res.uid then USER.uid=res.uid USER.authToken=res.authToken - FILE.save(USER,'conf/user','q') + FILE.save(USER,'conf/user') if SCN.cur=='login'then SCN.back()end end MES.new('check',text.loginSuccessed) diff --git a/parts/scenes/app_console.lua b/parts/scenes/app_console.lua index 98fad4cf..3f7cf8b3 100644 --- a/parts/scenes/app_console.lua +++ b/parts/scenes/app_console.lua @@ -611,8 +611,9 @@ local commands={}do if #key>0 then if SETTING[key]~=nil then SETTING[key]=nil - FILE.save(SETTING,'conf/settings','q') - log{C.Y,("Succesfully erased key '%s'"):format(key)} + if FILE.save(SETTING,'conf/settings')then + log{C.Y,("Succesfully erased key '%s'"):format(key)} + end else log{C.R,"No key called "..key} end diff --git a/parts/scenes/customGame.lua b/parts/scenes/customGame.lua index 458a6282..99417709 100644 --- a/parts/scenes/customGame.lua +++ b/parts/scenes/customGame.lua @@ -64,11 +64,11 @@ function scene.keyDown(key,isRep) end if key=="return2"or kb.isDown("lalt","lctrl","lshift")then if initField then - FILE.save(CUSTOMENV,'conf/customEnv','q') + FILE.save(CUSTOMENV,'conf/customEnv') loadGame('custom_puzzle',true) end else - FILE.save(CUSTOMENV,'conf/customEnv','q') + FILE.save(CUSTOMENV,'conf/customEnv') loadGame('custom_clear',true) end elseif key=="f"then @@ -118,7 +118,7 @@ function scene.keyDown(key,isRep) do return end ::THROW_fail::MES.new('error',text.dataCorrupted) elseif key=="escape"then - FILE.save(CUSTOMENV,'conf/customEnv','q') + FILE.save(CUSTOMENV,'conf/customEnv') SCN.back() else WIDGET.keyPressed(key) diff --git a/parts/scenes/load.lua b/parts/scenes/load.lua index 3e5f3bb4..f71d43a5 100644 --- a/parts/scenes/load.lua +++ b/parts/scenes/load.lua @@ -153,22 +153,28 @@ local loadingThread=coroutine.wrap(function() upFloor() SKIN.change(SETTING.skinSet) + local editFlag for name,rank in next,RANKS do local M=MODES[name] if type(rank)~='number'then RANKS[name]=nil + editFlag=true elseif M and M.unlock and rank>0 then for _,unlockName in next,M.unlock do if not RANKS[unlockName]then RANKS[unlockName]=0 + editFlag=true end end end if not(M and M.score)then RANKS[name]=nil + editFlag=true end end - FILE.save(RANKS,'conf/unlock','q') + if editFlag then + FILE.save(RANKS,'conf/unlock') + end YIELD() upFloor() diff --git a/parts/scenes/login.lua b/parts/scenes/login.lua index 1ae7bd3d..9f88e5b5 100644 --- a/parts/scenes/login.lua +++ b/parts/scenes/login.lua @@ -12,7 +12,9 @@ local function login() end NET.wsconn_user_pswd(email,password) if savePW then - FILE.save({email,password},'conf/account','q') + if FILE.save({email,password},'conf/account')then + MES.new('check',text.saveDone) + end else if love.filesystem.getInfo('conf/account')then love.filesystem.remove('conf/account') diff --git a/parts/scenes/net_menu.lua b/parts/scenes/net_menu.lua index 31147565..8b18d519 100644 --- a/parts/scenes/net_menu.lua +++ b/parts/scenes/net_menu.lua @@ -28,7 +28,7 @@ scene.widgetList={ NET.wsclose_user() USER.uid=false USER.authToken=false - FILE.save(USER,'conf/user','q') + FILE.save(USER,'conf/user') SCN.back() end else diff --git a/parts/scenes/savedata.lua b/parts/scenes/savedata.lua index 031f0673..f2e5c37c 100644 --- a/parts/scenes/savedata.lua +++ b/parts/scenes/savedata.lua @@ -31,8 +31,9 @@ scene.widgetList={ local D=parseCB() if D then TABLE.update(D,RANKS) - FILE.save(RANKS,'conf/unlock') - MES.new('check',text.importSuccess) + if FILE.save(RANKS,'conf/unlock')then + MES.new('check',text.importSuccess) + end else MES.new('error',text.dataCorrupted) end @@ -42,8 +43,9 @@ scene.widgetList={ local D=parseCB() if D and D.version==STAT.version then TABLE.update(D,STAT) - FILE.save(STAT,'conf/data') - MES.new('check',text.importSuccess) + if FILE.save(STAT,'conf/data')then + MES.new('check',text.importSuccess) + end else MES.new('error',text.dataCorrupted) end @@ -53,8 +55,9 @@ scene.widgetList={ local D=parseCB() if D then TABLE.update(D,SETTING) - FILE.save(SETTING,'conf/settings') - MES.new('check',text.importSuccess) + if FILE.save(SETTING,'conf/settings')then + MES.new('check',text.importSuccess) + end else MES.new('error',text.dataCorrupted) end @@ -64,8 +67,9 @@ scene.widgetList={ local D=parseCB() if D then TABLE.update(D,VK_org) - FILE.save(VK_org,'conf/virtualkey') - MES.new('check',text.importSuccess) + if FILE.save(VK_org,'conf/virtualkey')then + MES.new('check',text.importSuccess) + end else MES.new('error',text.dataCorrupted) end