Files
tromi_mobile/load/save.lua
SweetSea-ButImNotSweet cedc6e888e Update virtual control stuff
2024-04-19 12:53:13 +07:00

65 lines
1.5 KiB
Lua

local bitser = require 'libs.bitser'
local fs = love.filesystem
function loadSave()
-- config = loadFromFile(CONFIG_FILE)
end
function loadFromFile(filename)
if fs.read(filename) == nil then
return {} -- new object
end
return bitser.loadLoveFile(filename)
end
function initConfig()
-- if config.fullscreen == nil then config.fullscreen = false end
-- if config.music == nil then config.music = true end
-- if not config.input then
-- scene = InputConfigScene(true)
-- else
-- scene = TitleScene()
-- end
end
local _config = loadFromFile(CONFIG_FILE) or {}
local _defaultConfig = {
firstTime = true,
fullscreen = false,
music = true,
input = {
keys = {},
mobile = { -- Should not be changed for any reason, used for mobile only
enter = 'menu_decide',
f13 = 'up',
f14 = 'down',
f15 = 'left',
f16 = 'right',
f17 = 'rotate_left',
f18 = 'rotate_left2',
f19 = 'rotate_right',
f20 = 'rotate_right2',
}
}
}
function saveConfig()
bitser.dumpLoveFile(CONFIG_FILE, _config)
end
config = setmetatable(
{},
{
__index = function(_, k)
if _config[k] == nil then _config[k] = _defaultConfig[k] end
return _config[k]
end,
__newindex = function(_, k, v)
_config[k] = v
saveConfig()
end
}
)