文件保存时一般不再弹出保存成功的消息

This commit is contained in:
MrZ626
2021-06-19 14:05:59 +08:00
parent 98715e4579
commit 4c95f6bfbc
10 changed files with 51 additions and 34 deletions

View File

@@ -48,14 +48,11 @@ function FILE.save(data,name,mode)
F:open'w' F:open'w'
local success,mes=F:write(data) local success,mes=F:write(data)
F:flush()F:close() F:flush()F:close()
if success then if not success then
if not mode:find'q'then
MES.new('check',text.saveDone)
end
else
MES.new('error',text.saveError..(mes or"unknown error")) MES.new('error',text.saveError..(mes or"unknown error"))
MES.new(false,debug.traceback()) MES.new(false,debug.traceback())
end end
return success
end end
function FILE.clear(path) function FILE.clear(path)
if fs.getRealDirectory(path)~=SAVEDIR or fs.getInfo(path).type~='directory'then return end if fs.getRealDirectory(path)~=SAVEDIR or fs.getInfo(path).type~='directory'then return end

View File

@@ -289,9 +289,9 @@ do
end end
if needSave then if needSave then
FILE.save(SETTING,'conf/settings','q') FILE.save(SETTING,'conf/settings')
FILE.save(RANKS,'conf/unlock','q') FILE.save(RANKS,'conf/unlock')
FILE.save(STAT,'conf/data','q') FILE.save(STAT,'conf/data')
end end
if autoRestart then if autoRestart then
love.event.quit('restart') love.event.quit('restart')

View File

@@ -275,7 +275,9 @@ function gameOver()--Save record
end end
end end
if needSave then if needSave then
FILE.save(RANKS,'conf/unlock','q') if FILE.save(RANKS,'conf/unlock')then
MES.new('check',text.saveDone)
end
end end
end end
local D=M.score(P) local D=M.score(P)
@@ -294,7 +296,7 @@ function gameOver()--Save record
D.date=os.date("%Y/%m/%d %H:%M") D.date=os.date("%Y/%m/%d %H:%M")
ins(L,p+1,D) ins(L,p+1,D)
if L[11]then L[11]=nil end 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 end
end end

View File

@@ -268,23 +268,28 @@ function NET.loadSavedData(sections)
end end
end end
if STAT.version==NET.cloudData.STAT.version then if STAT.version==NET.cloudData.STAT.version then
local success=true
TABLE.update(NET.cloudData.STAT,STAT) 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) 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) 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) 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) 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') success=success and FILE.save(NET.cloudData.vkSave1,'conf/vkSave1')
FILE.save(NET.cloudData.vkSave2,'conf/vkSave2','q') 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 else
MES.new('error',text.versionNotMatch,1) MES.new('error',text.versionNotMatch,1)
end end
@@ -454,7 +459,7 @@ function NET.updateWS_user()
if res.uid then if res.uid then
USER.uid=res.uid USER.uid=res.uid
USER.authToken=res.authToken USER.authToken=res.authToken
FILE.save(USER,'conf/user','q') FILE.save(USER,'conf/user')
if SCN.cur=='login'then SCN.back()end if SCN.cur=='login'then SCN.back()end
end end
MES.new('check',text.loginSuccessed) MES.new('check',text.loginSuccessed)

View File

@@ -611,8 +611,9 @@ local commands={}do
if #key>0 then if #key>0 then
if SETTING[key]~=nil then if SETTING[key]~=nil then
SETTING[key]=nil SETTING[key]=nil
FILE.save(SETTING,'conf/settings','q') if FILE.save(SETTING,'conf/settings')then
log{C.Y,("Succesfully erased key '%s'"):format(key)} log{C.Y,("Succesfully erased key '%s'"):format(key)}
end
else else
log{C.R,"No key called "..key} log{C.R,"No key called "..key}
end end

View File

@@ -64,11 +64,11 @@ function scene.keyDown(key,isRep)
end end
if key=="return2"or kb.isDown("lalt","lctrl","lshift")then if key=="return2"or kb.isDown("lalt","lctrl","lshift")then
if initField then if initField then
FILE.save(CUSTOMENV,'conf/customEnv','q') FILE.save(CUSTOMENV,'conf/customEnv')
loadGame('custom_puzzle',true) loadGame('custom_puzzle',true)
end end
else else
FILE.save(CUSTOMENV,'conf/customEnv','q') FILE.save(CUSTOMENV,'conf/customEnv')
loadGame('custom_clear',true) loadGame('custom_clear',true)
end end
elseif key=="f"then elseif key=="f"then
@@ -118,7 +118,7 @@ function scene.keyDown(key,isRep)
do return end do return end
::THROW_fail::MES.new('error',text.dataCorrupted) ::THROW_fail::MES.new('error',text.dataCorrupted)
elseif key=="escape"then elseif key=="escape"then
FILE.save(CUSTOMENV,'conf/customEnv','q') FILE.save(CUSTOMENV,'conf/customEnv')
SCN.back() SCN.back()
else else
WIDGET.keyPressed(key) WIDGET.keyPressed(key)

View File

@@ -153,22 +153,28 @@ local loadingThread=coroutine.wrap(function()
upFloor() upFloor()
SKIN.change(SETTING.skinSet) SKIN.change(SETTING.skinSet)
local editFlag
for name,rank in next,RANKS do for name,rank in next,RANKS do
local M=MODES[name] local M=MODES[name]
if type(rank)~='number'then if type(rank)~='number'then
RANKS[name]=nil RANKS[name]=nil
editFlag=true
elseif M and M.unlock and rank>0 then elseif M and M.unlock and rank>0 then
for _,unlockName in next,M.unlock do for _,unlockName in next,M.unlock do
if not RANKS[unlockName]then if not RANKS[unlockName]then
RANKS[unlockName]=0 RANKS[unlockName]=0
editFlag=true
end end
end end
end end
if not(M and M.score)then if not(M and M.score)then
RANKS[name]=nil RANKS[name]=nil
editFlag=true
end end
end end
FILE.save(RANKS,'conf/unlock','q') if editFlag then
FILE.save(RANKS,'conf/unlock')
end
YIELD() YIELD()
upFloor() upFloor()

View File

@@ -12,7 +12,9 @@ local function login()
end end
NET.wsconn_user_pswd(email,password) NET.wsconn_user_pswd(email,password)
if savePW then 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 else
if love.filesystem.getInfo('conf/account')then if love.filesystem.getInfo('conf/account')then
love.filesystem.remove('conf/account') love.filesystem.remove('conf/account')

View File

@@ -28,7 +28,7 @@ scene.widgetList={
NET.wsclose_user() NET.wsclose_user()
USER.uid=false USER.uid=false
USER.authToken=false USER.authToken=false
FILE.save(USER,'conf/user','q') FILE.save(USER,'conf/user')
SCN.back() SCN.back()
end end
else else

View File

@@ -31,8 +31,9 @@ scene.widgetList={
local D=parseCB() local D=parseCB()
if D then if D then
TABLE.update(D,RANKS) TABLE.update(D,RANKS)
FILE.save(RANKS,'conf/unlock') if FILE.save(RANKS,'conf/unlock')then
MES.new('check',text.importSuccess) MES.new('check',text.importSuccess)
end
else else
MES.new('error',text.dataCorrupted) MES.new('error',text.dataCorrupted)
end end
@@ -42,8 +43,9 @@ scene.widgetList={
local D=parseCB() local D=parseCB()
if D and D.version==STAT.version then if D and D.version==STAT.version then
TABLE.update(D,STAT) TABLE.update(D,STAT)
FILE.save(STAT,'conf/data') if FILE.save(STAT,'conf/data')then
MES.new('check',text.importSuccess) MES.new('check',text.importSuccess)
end
else else
MES.new('error',text.dataCorrupted) MES.new('error',text.dataCorrupted)
end end
@@ -53,8 +55,9 @@ scene.widgetList={
local D=parseCB() local D=parseCB()
if D then if D then
TABLE.update(D,SETTING) TABLE.update(D,SETTING)
FILE.save(SETTING,'conf/settings') if FILE.save(SETTING,'conf/settings')then
MES.new('check',text.importSuccess) MES.new('check',text.importSuccess)
end
else else
MES.new('error',text.dataCorrupted) MES.new('error',text.dataCorrupted)
end end
@@ -64,8 +67,9 @@ scene.widgetList={
local D=parseCB() local D=parseCB()
if D then if D then
TABLE.update(D,VK_org) TABLE.update(D,VK_org)
FILE.save(VK_org,'conf/virtualkey') if FILE.save(VK_org,'conf/virtualkey')then
MES.new('check',text.importSuccess) MES.new('check',text.importSuccess)
end
else else
MES.new('error',text.dataCorrupted) MES.new('error',text.dataCorrupted)
end end