Update virtual control stuff

This commit is contained in:
SweetSea-ButImNotSweet
2024-04-19 12:53:13 +07:00
parent aefc660dd4
commit cedc6e888e
6 changed files with 96 additions and 81 deletions

View File

@@ -2,7 +2,7 @@ local bitser = require 'libs.bitser'
local fs = love.filesystem
function loadSave()
config = loadFromFile(CONFIG_FILE)
-- config = loadFromFile(CONFIG_FILE)
end
function loadFromFile(filename)
@@ -13,16 +13,53 @@ function loadFromFile(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
-- 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)
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
}
)