2012-01-06 09:48:59 +01:00
|
|
|
Settings = {}
|
|
|
|
|
|
|
|
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.exists(key)
|
|
|
|
return g_configs.exists(key)
|
|
|
|
end
|
|
|
|
|
|
|
|
function Settings.remove(key)
|
|
|
|
g_configs.remove(key)
|
|
|
|
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
|
|
|
|
|
2012-01-15 16:13:22 +01:00
|
|
|
function Settings.setList(key, list)
|
|
|
|
g_configs.setList(key, list)
|
|
|
|
end
|
|
|
|
|
2012-01-06 09:48:59 +01:00
|
|
|
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
|
|
|
|
|
2012-01-15 16:13:22 +01:00
|
|
|
function Settings.getList(key)
|
|
|
|
return g_configs.getList(key)
|
|
|
|
end
|
|
|
|
|
2012-01-06 09:48:59 +01:00
|
|
|
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
|