游戏内再次封装saveFile和loadFile函数

原本的FILE模块更独立,不基于全局text变量和报错信息而是直接报错
This commit is contained in:
MrZ626
2021-11-25 17:38:09 +08:00
parent 720dc2131f
commit f3a88ef269
23 changed files with 206 additions and 111 deletions

View File

@@ -64,11 +64,11 @@ function scene.keyDown(key,isRep)
end
if key=="return2"or kb.isDown("lalt","lctrl","lshift")then
if #FIELD[1]>0 then
FILE.save(CUSTOMENV,'conf/customEnv')
saveFile(CUSTOMENV,'conf/customEnv')
loadGame('custom_puzzle',true)
end
else
FILE.save(CUSTOMENV,'conf/customEnv')
saveFile(CUSTOMENV,'conf/customEnv')
loadGame('custom_clear',true)
end
elseif key=="f"then
@@ -84,10 +84,10 @@ function scene.keyDown(key,isRep)
TABLE.clear(CUSTOMENV)
TABLE.complete(require"parts.customEnv0",CUSTOMENV)
for _,W in next,scene.widgetList do W:reset()end
FILE.save(DATA.copyMission(),'conf/customMissions')
FILE.save(DATA.copyBoards(),'conf/customBoards')
FILE.save(DATA.copySequence(),'conf/customSequence')
FILE.save(CUSTOMENV,'conf/customEnv')
saveFile(DATA.copyMission(),'conf/customMissions')
saveFile(DATA.copyBoards(),'conf/customBoards')
saveFile(DATA.copySequence(),'conf/customSequence')
saveFile(CUSTOMENV,'conf/customEnv')
sure=0
SFX.play('finesseError',.7)
BG.set(CUSTOMENV.bg)
@@ -123,7 +123,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')
saveFile(CUSTOMENV,'conf/customEnv')
SCN.back()
else
WIDGET.keyPressed(key)

View File

@@ -127,7 +127,7 @@ function scene.sceneInit()
page=1
end
function scene.sceneBack()
FILE.save(DATA.copyBoards(),'conf/customBoards')
saveFile(DATA.copyBoards(),'conf/customBoards')
end
function scene.mouseMove(x,y)

View File

@@ -16,7 +16,7 @@ function scene.sceneInit()
sure=0
end
function scene.sceneBack()
FILE.save(DATA.copyMission(),'conf/customMissions')
saveFile(DATA.copyMission(),'conf/customMissions')
end
local ENUM_MISSION=ENUM_MISSION

View File

@@ -16,7 +16,7 @@ function scene.sceneInit()
sure=0
end
function scene.sceneBack()
FILE.save(DATA.copySequence(),'conf/customSequence')
saveFile(DATA.copySequence(),'conf/customSequence')
end
local minoKey={

View File

@@ -96,7 +96,7 @@ local loadingThread=coroutine.wrap(function()
YIELD('loadMode')
for _,M in next,MODES do
M.records=FILE.load("record/"..M.name..".rec",'luaon')or M.score and{}
M.records=loadFile("record/"..M.name..".rec",'-luaon -canSkip')or M.score and{}
M.icon=M.icon and(modeIcons[M.icon]or gc.newImage("media/image/modeicon/"..M.icon..".png"))
end

View File

@@ -12,7 +12,7 @@ local function _login()
end
NET.wsconn_user_pswd(email,password)
if savePW then
FILE.save({email,password},'conf/account')
saveFile({email,password},'conf/account')
else
love.filesystem.remove('conf/account')
end
@@ -21,7 +21,7 @@ end
local scene={}
function scene.sceneInit()
local data=FILE.load('conf/account')
local data=loadFile('conf/account')
if data then
savePW=true
emailBox:setText(data[1])

View File

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

View File

@@ -90,7 +90,7 @@ function scene.keyDown(key)
local rep=listBox:getSel()
if rep then
if rep.available and rep.fileName then
local repStr=FILE.load(rep.fileName,'string')
local repStr=loadFile(rep.fileName,'-string')
if repStr then
love.system.setClipboardText(love.data.encode('string','base64',repStr))
MES.new('info',text.exportSuccess)
@@ -108,7 +108,7 @@ function scene.keyDown(key)
local fileName=os.date("replay/%Y_%m_%d_%H%M%S_import.rep")
local rep=DATA.parseReplayData(fileName,fileData,false)
if rep.available then
if FILE.save(fileData,fileName,'d')then
if saveFile(fileData,fileName,'-d')then
table.insert(REPLAY,1,rep)
MES.new('info',text.importSuccess)
end

View File

@@ -71,7 +71,7 @@ scene.widgetList={
local D=_parseCB()
if D then
TABLE.update(D,VK_ORG)
FILE.save(VK_ORG,'conf/virtualkey')
saveFile(VK_ORG,'conf/virtualkey')
MES.new('check',text.importSuccess)
else
MES.new('error',text.dataCorrupted)

View File

@@ -23,7 +23,7 @@ function scene.sceneInit()
BG.set('none')
end
function scene.sceneBack()
FILE.save(KEY_MAP,'conf/key')
saveFile(KEY_MAP,'conf/key')
end
local forbbidenKeys={

View File

@@ -9,10 +9,10 @@ local snapUnit=1
local selected--Button selected
local function _save1()
FILE.save(VK_ORG,'conf/vkSave1')
saveFile(VK_ORG,'conf/vkSave1')
end
local function _load1()
local D=FILE.load('conf/vkSave1')
local D=loadFile('conf/vkSave1')
if D then
TABLE.update(D,VK_ORG)
else
@@ -20,10 +20,10 @@ local function _load1()
end
end
local function _save2()
FILE.save(VK_ORG,'conf/vkSave2')
saveFile(VK_ORG,'conf/vkSave2')
end
local function _load2()
local D=FILE.load('conf/vkSave2')
local D=loadFile('conf/vkSave2')
if D then
TABLE.update(D,VK_ORG)
else
@@ -37,7 +37,7 @@ function scene.sceneInit()
selected=false
end
function scene.sceneBack()
FILE.save(VK_ORG,'conf/virtualkey')
saveFile(VK_ORG,'conf/virtualkey')
end
local function _onVK_org(x,y)