class "Options"

function Options : Options (file)
	self.file = system.projectpath().."/"..file
	local fn,err = loadfile(file)
	self.cfg = fn and fn() or {}
	self:update()
end

function Options : save ()
	local str = UtilFunctions.serialize(self.cfg)
	local fp = io.open(self.file,"w")
	fp:write(str)
	fp:close()
end

function Options : set (key,value)
	self.cfg[key] = value
	self:save()
	self:update()
end

function Options : update ()
	if self.cfg.postfx then
		postfxinit(self.cfg.postfx)
	else
		postfxinit(3)
	end
end

gameoptions = new (Options, "config.cfg")