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

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'
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

View File

@@ -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')

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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)

View File

@@ -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()

View File

@@ -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')

View File

@@ -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

View File

@@ -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