Keep g_settings as a 'static' variable rather than a direct object.

This commit is contained in:
BenDol
2014-04-01 16:51:38 +13:00
parent b295053662
commit 79ee0e34ea
18 changed files with 174 additions and 99 deletions

View File

@@ -65,20 +65,20 @@ function init()
else
-- window size
local size = { width = 800, height = 600 }
size = g_settings:getSize('window-size', size)
size = g_settings.getSize('window-size', size)
g_window.resize(size)
-- window position, default is the screen center
local displaySize = g_window.getDisplaySize()
local defaultPos = { x = (displaySize.width - size.width)/2,
y = (displaySize.height - size.height)/2 }
local pos = g_settings:getPoint('window-pos', defaultPos)
local pos = g_settings.getPoint('window-pos', defaultPos)
pos.x = math.max(pos.x, 0)
pos.y = math.max(pos.y, 0)
g_window.move(pos)
-- window maximized?
local maximized = g_settings:getBoolean('window-maximized', false)
local maximized = g_settings.getBoolean('window-maximized', false)
if maximized then g_window.maximize() end
end
@@ -91,9 +91,9 @@ function init()
g_keyboard.bindKeyDown('Ctrl+Shift+R', reloadScripts)
-- generate machine uuid, this is a security measure for storing passwords
if not g_crypt.setMachineUUID(g_settings:get('uuid')) then
g_settings:set('uuid', g_crypt.getMachineUUID())
g_settings:save()
if not g_crypt.setMachineUUID(g_settings.get('uuid')) then
g_settings.set('uuid', g_crypt.getMachineUUID())
g_settings.save()
end
end
@@ -101,9 +101,9 @@ function terminate()
disconnect(g_app, { onRun = startup,
onExit = exit })
-- save window configs
g_settings:set('window-size', g_window.getUnmaximizedSize())
g_settings:set('window-pos', g_window.getUnmaximizedPos())
g_settings:set('window-maximized', g_window.isMaximized())
g_settings.set('window-size', g_window.getUnmaximizedSize())
g_settings.set('window-pos', g_window.getUnmaximizedPos())
g_settings.set('window-maximized', g_window.isMaximized())
end
function exit()