fixes in Settings

This commit is contained in:
Eduardo Bart 2012-01-06 22:34:40 -02:00
parent 0f3bac595e
commit 3c62ce97db
3 changed files with 11 additions and 4 deletions

View File

@ -56,7 +56,7 @@ function EnterGame.create()
local account = Settings.get('account')
local password = Settings.get('password')
local host = Settings.get('host')
local port = Settings.getNumber('port')
local port = Settings.get('port')
local autologin = Settings.getBoolean('autologin')
enterGame:getChildById('accountNameLineEdit'):setText(account)

View File

@ -11,6 +11,8 @@ local function convertSettingValue(value)
elseif value.r then
return colortostring(value)
end
elseif value == nil then
return ''
else
return tostring(value)
end
@ -25,8 +27,13 @@ function Settings.remove(key)
end
function Settings.set(key, value)
local valuestr = convertSettingValue(value)
if valuestr == '' then
g_configs.remove(key)
else
g_configs.set(key, convertSettingValue(value))
end
end
function Settings.setDefault(key, value)
if Settings.exists(key) then return false end
@ -35,8 +42,7 @@ function Settings.setDefault(key, value)
end
function Settings.get(key, default)
if Settings.exists(key) then
elseif default ~= nil then
if not Settings.exists(key) and default ~= nil then
Settings.set(key, default)
end
return g_configs.get(key)

View File

@ -934,6 +934,7 @@ void LuaInterface::pushBoolean(bool v)
void LuaInterface::pushCString(const char* v)
{
assert(v);
lua_pushstring(L, v);
}