2012-01-06 09:48:59 +01:00
|
|
|
Settings = {}
|
|
|
|
|
2012-02-02 00:37:40 +01:00
|
|
|
Settings.exists = g_configs.exists
|
|
|
|
Settings.setNode = g_configs.setNode
|
2012-06-22 01:58:18 +02:00
|
|
|
Settings.mergeNode = g_configs.mergeNode
|
2012-02-02 00:37:40 +01:00
|
|
|
Settings.getNode = g_configs.getNode
|
|
|
|
Settings.remove = g_configs.remove
|
|
|
|
Settings.setList = g_configs.setList
|
|
|
|
Settings.getList = g_configs.getList
|
|
|
|
|
2012-01-06 09:48:59 +01:00
|
|
|
local function convertSettingValue(value)
|
|
|
|
if type(value) == 'table' then
|
|
|
|
if value.x and value.width then
|
|
|
|
return recttostring(value)
|
|
|
|
elseif value.x then
|
|
|
|
return pointtostring(value)
|
|
|
|
elseif value.width then
|
|
|
|
return sizetostring(value)
|
|
|
|
elseif value.r then
|
|
|
|
return colortostring(value)
|
2012-01-15 16:13:22 +01:00
|
|
|
else
|
|
|
|
return value
|
2012-01-06 09:48:59 +01:00
|
|
|
end
|
2012-01-07 01:34:40 +01:00
|
|
|
elseif value == nil then
|
|
|
|
return ''
|
2012-01-06 09:48:59 +01:00
|
|
|
else
|
|
|
|
return tostring(value)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function Settings.set(key, value)
|
2012-01-07 01:46:41 +01:00
|
|
|
g_configs.set(key, convertSettingValue(value))
|
2012-01-06 09:48:59 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function Settings.setDefault(key, value)
|
|
|
|
if Settings.exists(key) then return false end
|
|
|
|
Settings.set(key, value)
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
function Settings.get(key, default)
|
2012-01-07 01:34:40 +01:00
|
|
|
if not Settings.exists(key) and default ~= nil then
|
2012-01-06 09:48:59 +01:00
|
|
|
Settings.set(key, default)
|
|
|
|
end
|
|
|
|
return g_configs.get(key)
|
|
|
|
end
|
|
|
|
|
|
|
|
function Settings.getString(key, default)
|
|
|
|
return Settings.get(key, default)
|
|
|
|
end
|
|
|
|
|
|
|
|
function Settings.getInteger(key, default)
|
|
|
|
return tonumber(Settings.get(key, default))
|
|
|
|
end
|
|
|
|
|
|
|
|
function Settings.getNumber(key, default)
|
|
|
|
return tonumber(Settings.get(key, default))
|
|
|
|
end
|
|
|
|
|
|
|
|
function Settings.getBoolean(key, default)
|
|
|
|
return toboolean(Settings.get(key, default))
|
|
|
|
end
|
|
|
|
|
|
|
|
function Settings.getPoint(key, default)
|
|
|
|
return topoint(Settings.get(key, default))
|
|
|
|
end
|
|
|
|
|
|
|
|
function Settings.getRect(key, default)
|
|
|
|
return torect(Settings.get(key, default))
|
|
|
|
end
|
|
|
|
|
|
|
|
function Settings.getSize(key, default)
|
|
|
|
return tosize(Settings.get(key, default))
|
|
|
|
end
|
|
|
|
|
|
|
|
function Settings.getColor(key, default)
|
|
|
|
return tocolor(Settings.get(key, default))
|
|
|
|
end
|
|
|
|
|
|
|
|
function Settings.getColor(key, default)
|
|
|
|
return tocolor(Settings.get(key, default))
|
|
|
|
end
|