makes settings persist between instances

This commit is contained in:
duncathan 2020-02-27 23:54:37 -06:00
parent 6ceb103b15
commit cb2edb55fb
4 changed files with 39 additions and 1 deletions

View file

@ -22,8 +22,9 @@ Settings = settings()
local csdirectory
function love.load()
Screen:setup()
Settings:init()
Screen:setup()
if Settings.settings.csdirectory ~= "" then
Screen:setStatus("Cave Story folder found!")
Randomizer:setPath(Settings.settings.csdirectory)

View file

@ -61,6 +61,9 @@ function C:randomize()
self:_writePlaintext(tscFiles)
self:_writeLog()
self:_unmountDirectory(csdirectory)
self:_updateSettings()
return self:_getStatusMessage(seed)
end
@ -254,6 +257,12 @@ function C:_unmountDirectory(path)
assert(lf.unmount(path))
end
function C:_updateSettings()
Settings.settings.puppy = self.puppy
Settings.settings.obj = self.obj
Settings:update()
end
function C:_getStatusMessage(seed)
local warnings, errors = countLogWarningsAndErrors()
local line1

View file

@ -10,6 +10,8 @@ end
function C:setDefaults()
self.settings.csdirectory = nil
self.settings.puppy = false
self.settings.obj = ""
self:update()
end
@ -21,6 +23,8 @@ function C:serialize()
local line = "return {"
line = line .. ("csdirectory = [[%s]],\r\n"):format(self.settings.csdirectory or "")
line = line .. ("puppy = %s,\r\n"):format(self.settings.puppy)
line = line .. ("obj = \"%s\",\r\n"):format(self.settings.obj)
line = line .. "}"
return line

View file

@ -12,6 +12,30 @@ layout:setTheme(require 'lib.luigi.theme.dark')
settings:setTheme(require 'lib.luigi.theme.dark')
function C:setup()
settings.puppy.value = Settings.settings.puppy
local obj = Settings.settings.obj
if obj == "objBadEnd" then
settings.bad.value = true
settings.norm.value = false
settings.boss.value = false
settings.best.value = false
elseif obj == "objNormalEnd" then
settings.bad.value = false
settings.norm.value = true
settings.boss.value = false
settings.best.value = false
elseif obj == "objAllBosses" then
settings.bad.value = false
settings.norm.value = false
settings.boss.value = true
settings.best.value = false
else
settings.bad.value = false
settings.norm.value = false
settings.boss.value = false
settings.best.value = true
end
background = lg.newImage('assets/background.png')
self:draw()
layout:show()