adds version checking for cave story, to ensure folders are valid

This commit is contained in:
duncathan 2020-03-06 06:28:38 -06:00
parent e52e63f8e8
commit 67adcb6639
3 changed files with 28 additions and 12 deletions

View file

@ -0,0 +1 @@
1

View file

@ -1,6 +1,7 @@
require 'lib.strict'
VERSION = '0.8C'
CSVERSION = 1
Class = require 'lib.classic'
_ = require 'lib.moses'
@ -26,8 +27,8 @@ function love.load()
Settings:init()
Screen:setup()
if Settings.settings.csdirectory ~= "" then
Screen:setStatus("Cave Story folder found!")
if Settings.settings.csdirectory == "csdata" then
Screen:setStatus("Cave story folder found!")
Randomizer:setPath(Settings.settings.csdirectory)
else
Screen:setStatus("Drag and drop your Cave Story folder here.")
@ -62,15 +63,23 @@ local function recursivelyDelete( item )
end
function love.directorydropped(path)
local success = Randomizer:_mountDirectory(path)
local success, dirStage = Randomizer:_mountDirectory(path)
local csversion = lf.read(dirStage .. '/_version.txt') or "0"
csversion = tonumber(csversion)
--Randomizer:_unmountDirectory(path)
if success then
recursivelyDelete('csdata') -- completely clear the folder, in case of user error :)
recursiveWrite('mounted-data', 'csdata')
Settings.settings.csdirectory = 'csdata'
Settings:update()
Randomizer:setPath('csdata')
Screen:setStatus("Cave Story folder updated!")
if csversion >= CSVERSION then
recursivelyDelete('csdata') -- completely clear the folder, in case of user error :)
recursiveWrite('mounted-data', 'csdata')
Settings.settings.csdirectory = 'csdata'
Settings.settings.csversion = csversion
Settings:update()
Randomizer:setPath('csdata')
Screen:setStatus("Cave Story folder updated!")
else
Screen:setStatus("Invalid Cave Story folder!\n\nMake sure you're using an up to date version of the randomizer's included Cave Story folder.")
end
else
Screen:setStatus("Could not find \"data\" subfolder.\n\nMaybe try dropping your Cave Story \"data\" folder in directly?")
end

View file

@ -11,6 +11,10 @@ function C:init()
self.settings[k] = self.settings[k] or v
end
end
-- check for out of date CS folder
if self.settings.csversion < CSVERSION then
self.settings.csdirectory = nil
end
self:update()
end
@ -34,7 +38,8 @@ function C:getDefaults()
},
musicShuffle = false,
musicBeta = false,
musicFlavor = "Shuffle"
musicFlavor = "Shuffle",
csversion = 0
}
end
@ -53,7 +58,7 @@ function C:serialize()
local line = "return {\r\n"
local tab = " "
line = line .. tab .. ("csdirectory = [[%s]],\r\n"):format(self.settings.csdirectory or "")
line = line .. tab .. ("csdirectory = %q,\r\n"):format(self.settings.csdirectory or "")
line = line .. tab .. ("puppy = %s,\r\n"):format(self.settings.puppy)
line = line .. tab .. ("obj = %q,\r\n"):format(self.settings.obj or "")
line = line .. tab .. ("mychar = %q,\r\n"):format(self.settings.mychar or "")
@ -63,7 +68,8 @@ function C:serialize()
line = line .. tab .. ("dboosts = %s,\r\n"):format(dboost)
line = line .. tab .. ("musicShuffle = %s,\r\n"):format(self.settings.musicShuffle)
line = line .. tab .. ("musicBeta = %s,\r\n"):format(self.settings.musicBeta)
line = line .. tab .. ("musicFlavor = %q\r\n"):format(self.settings.musicFlavor)
line = line .. tab .. ("musicFlavor = %q,\r\n"):format(self.settings.musicFlavor)
line = line .. tab .. ("csversion = %s,\r\n"):format(self.settings.csversion)
return line .. "}"
end