Finished stable implementation (as far as tested), still requires more testing.

This commit is contained in:
BenDol 2014-04-01 16:27:33 +13:00
parent 61059e66ec
commit b295053662
22 changed files with 180 additions and 177 deletions

View File

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

View File

@ -37,8 +37,8 @@ local function tryLogin(charInfo, tries)
end }) end })
-- save last used character -- save last used character
g_settings.set('last-used-character', charInfo.characterName) g_settings:set('last-used-character', charInfo.characterName)
g_settings.set('last-used-world', charInfo.worldName) g_settings:set('last-used-world', charInfo.worldName)
end end
local function updateWait(timeStart, timeEnd) local function updateWait(timeStart, timeEnd)
@ -225,7 +225,7 @@ function CharacterList.create(characters, account, otui)
connect(widget, { onDoubleClick = function () CharacterList.doLogin() return true end } ) connect(widget, { onDoubleClick = function () CharacterList.doLogin() return true end } )
if i == 1 or (g_settings.get('last-used-character') == widget.characterName and g_settings.get('last-used-world') == widget.worldName) then if i == 1 or (g_settings:get('last-used-character') == widget.characterName and g_settings:get('last-used-world') == widget.worldName) then
focusLabel = widget focusLabel = widget
end end
end end

View File

@ -41,13 +41,13 @@ local function onCharacterList(protocol, characters, account, otui)
local account = g_crypt.encrypt(G.account) local account = g_crypt.encrypt(G.account)
local password = g_crypt.encrypt(G.password) local password = g_crypt.encrypt(G.password)
g_settings.set('account', account) g_settings:set('account', account)
g_settings.set('password', password) g_settings:set('password', password)
ServerList.setServerAccount(G.host, account) ServerList.setServerAccount(G.host, account)
ServerList.setServerPassword(G.host, password) ServerList.setServerPassword(G.host, password)
g_settings.set('autologin', enterGame:getChildById('autoLoginBox'):isChecked()) g_settings:set('autologin', enterGame:getChildById('autoLoginBox'):isChecked())
else else
-- reset server list account/password -- reset server list account/password
ServerList.setServerAccount(G.host, '') ServerList.setServerAccount(G.host, '')
@ -63,9 +63,9 @@ local function onCharacterList(protocol, characters, account, otui)
CharacterList.show() CharacterList.show()
if motdEnabled then if motdEnabled then
local lastMotdNumber = g_settings.getNumber("motd") local lastMotdNumber = g_settings:getNumber("motd")
if G.motdNumber and G.motdNumber ~= lastMotdNumber then if G.motdNumber and G.motdNumber ~= lastMotdNumber then
g_settings.set("motd", motdNumber) g_settings:set("motd", motdNumber)
motdWindow = displayInfoBox(tr('Message of the day'), G.motdMessage) motdWindow = displayInfoBox(tr('Message of the day'), G.motdMessage)
connect(motdWindow, { onOk = function() CharacterList.show() motdWindow = nil end }) connect(motdWindow, { onOk = function() CharacterList.show() motdWindow = nil end })
CharacterList.hide() CharacterList.hide()
@ -99,12 +99,12 @@ function EnterGame.init()
motdButton:show() motdButton:show()
end end
local account = g_settings.get('account') local account = g_settings:get('account')
local password = g_settings.get('password') local password = g_settings:get('password')
local host = g_settings.get('host') local host = g_settings:get('host')
local port = g_settings.get('port') local port = g_settings:get('port')
local autologin = g_settings.getBoolean('autologin') local autologin = g_settings:getBoolean('autologin')
local clientVersion = g_settings.getInteger('client-version') local clientVersion = g_settings:getInteger('client-version')
if clientVersion == 0 then clientVersion = 860 end if clientVersion == 0 then clientVersion = 860 end
if port == nil or port == 0 then port = 7171 end if port == nil or port == 0 then port = 7171 end
@ -132,13 +132,13 @@ end
function EnterGame.firstShow() function EnterGame.firstShow()
EnterGame.show() EnterGame.show()
local account = g_crypt.decrypt(g_settings.get('account')) local account = g_crypt.decrypt(g_settings:get('account'))
local password = g_crypt.decrypt(g_settings.get('password')) local password = g_crypt.decrypt(g_settings:get('password'))
local host = g_settings.get('host') local host = g_settings:get('host')
local autologin = g_settings.getBoolean('autologin') local autologin = g_settings:getBoolean('autologin')
if #host > 0 and #password > 0 and #account > 0 and autologin then if #host > 0 and #password > 0 and #account > 0 and autologin then
addEvent(function() addEvent(function()
if not g_settings.getBoolean('autologin') then return end if not g_settings:getBoolean('autologin') then return end
EnterGame.doLogin() EnterGame.doLogin()
end) end)
end end
@ -205,8 +205,8 @@ function EnterGame.clearAccountFields()
enterGame:getChildById('accountNameTextEdit'):clearText() enterGame:getChildById('accountNameTextEdit'):clearText()
enterGame:getChildById('accountPasswordTextEdit'):clearText() enterGame:getChildById('accountPasswordTextEdit'):clearText()
enterGame:getChildById('accountNameTextEdit'):focus() enterGame:getChildById('accountNameTextEdit'):focus()
g_settings.remove('account') g_settings:remove('account')
g_settings.remove('password') g_settings:remove('password')
end end
function EnterGame.doLogin() function EnterGame.doLogin()
@ -223,9 +223,9 @@ function EnterGame.doLogin()
return return
end end
g_settings.set('host', G.host) g_settings:set('host', G.host)
g_settings.set('port', G.port) g_settings:set('port', G.port)
g_settings.set('client-version', clientVersion) g_settings:set('client-version', clientVersion)
protocolLogin = ProtocolLogin.create() protocolLogin = ProtocolLogin.create()
protocolLogin.onLoginError = onError protocolLogin.onLoginError = onError

View File

@ -64,7 +64,7 @@ function init()
installLocales('/locales') installLocales('/locales')
local userLocaleName = g_settings.get('locale', 'false') local userLocaleName = g_settings:get('locale', 'false')
if userLocaleName ~= 'false' and setLocale(userLocaleName) then if userLocaleName ~= 'false' and setLocale(userLocaleName) then
pdebug('Using configured locale: ' .. userLocaleName) pdebug('Using configured locale: ' .. userLocaleName)
else else
@ -150,7 +150,7 @@ function setLocale(name)
sendLocale(locale.name) sendLocale(locale.name)
end end
currentLocale = locale currentLocale = locale
g_settings.set('locale', name) g_settings:set('locale', name)
if onLocaleChanged then onLocaleChanged(name) end if onLocaleChanged then onLocaleChanged(name) end
return true return true
end end

View File

@ -84,7 +84,7 @@ end
function init() function init()
for k,v in pairs(defaultOptions) do for k,v in pairs(defaultOptions) do
g_settings.setDefault(k, v) g_settings:setDefault(k, v)
options[k] = v options[k] = v
end end
@ -129,9 +129,9 @@ function setup()
-- load options -- load options
for k,v in pairs(defaultOptions) do for k,v in pairs(defaultOptions) do
if type(v) == 'boolean' then if type(v) == 'boolean' then
setOption(k, g_settings.getBoolean(k), true) setOption(k, g_settings:getBoolean(k), true)
elseif type(v) == 'number' then elseif type(v) == 'number' then
setOption(k, g_settings.getNumber(k), true) setOption(k, g_settings:getNumber(k), true)
end end
end end
end end
@ -243,7 +243,7 @@ function setOption(key, value, force)
end end
end end
g_settings.set(key, value) g_settings:set(key, value)
options[key] = value options[key] = value
end end

View File

@ -11,14 +11,14 @@ function ServerList.init()
serverListWindow = g_ui.displayUI('serverlist') serverListWindow = g_ui.displayUI('serverlist')
serverTextList = serverListWindow:getChildById('serverList') serverTextList = serverListWindow:getChildById('serverList')
servers = g_settings.getNode('ServerList') or {} servers = g_settings:getNode('ServerList') or {}
ServerList.load() ServerList.load()
end end
function ServerList.terminate() function ServerList.terminate()
ServerList.destroy() ServerList.destroy()
g_settings.setNode('ServerList', servers) g_settings:setNode('ServerList', servers)
ServerList = nil ServerList = nil
end end

View File

@ -8,10 +8,10 @@ sendReportEvent = nil
firstReportEvent = nil firstReportEvent = nil
function initUUID() function initUUID()
UUID = g_settings.getString('report-uuid') UUID = g_settings:getString('report-uuid')
if not UUID or #UUID ~= 36 then if not UUID or #UUID ~= 36 then
UUID = g_crypt.genUUID() UUID = g_crypt.genUUID()
g_settings.set('report-uuid', UUID) g_settings:set('report-uuid', UUID)
end end
end end

View File

@ -126,7 +126,7 @@ function init()
terminalButton = modules.client_topmenu.addLeftButton('terminalButton', tr('Terminal') .. ' (Ctrl + T)', '/images/topbuttons/terminal', toggle) terminalButton = modules.client_topmenu.addLeftButton('terminalButton', tr('Terminal') .. ' (Ctrl + T)', '/images/topbuttons/terminal', toggle)
g_keyboard.bindKeyDown('Ctrl+T', toggle) g_keyboard.bindKeyDown('Ctrl+T', toggle)
commandHistory = g_settings.getList('terminal-history') commandHistory = g_settings:getList('terminal-history')
commandTextEdit = terminalWindow:getChildById('commandTextEdit') commandTextEdit = terminalWindow:getChildById('commandTextEdit')
g_keyboard.bindKeyPress('Up', function() navigateCommand(1) end, commandTextEdit) g_keyboard.bindKeyPress('Up', function() navigateCommand(1) end, commandTextEdit)
@ -159,7 +159,7 @@ function init()
end end
function terminate() function terminate()
g_settings.setList('terminal-history', commandHistory) g_settings:setList('terminal-history', commandHistory)
removeEvent(flushEvent) removeEvent(flushEvent)
@ -172,7 +172,7 @@ function terminate()
pos = oldPos, pos = oldPos,
poped = poped poped = poped
} }
g_settings.setNode('terminal-window', settings) g_settings:setNode('terminal-window', settings)
g_keyboard.unbindKeyDown('Ctrl+T') g_keyboard.unbindKeyDown('Ctrl+T')
g_logger.setOnLog(nil) g_logger.setOnLog(nil)
@ -222,7 +222,7 @@ function toggle()
hide() hide()
else else
if not firstShown then if not firstShown then
local settings = g_settings.getNode('terminal-window') local settings = g_settings:getNode('terminal-window')
if settings then if settings then
if settings.size then oldSize = size end if settings.size then oldSize = size end
if settings.pos then oldPos = settings.pos end if settings.pos then oldPos = settings.pos end

View File

@ -0,0 +1,76 @@
-- @docclass
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)
else
return value
end
elseif value == nil then
return ''
else
return tostring(value)
end
end
function Config:set(key, value)
self:setValue(key, convertSettingValue(value))
end
function Config:setDefault(key, value)
if self:exists(key) then return false end
self:set(key, value)
return true
end
function Config:get(key, default)
if not self:exists(key) and default ~= nil then
self:set(key, default)
end
return self:getValue(key)
end
function Config:getString(key, default)
return self:get(key, default)
end
function Config:getInteger(key, default)
local v = tonumber(self:get(key, default)) or 0
return v
end
function Config:getNumber(key, default)
local v = tonumber(self:get(key, default)) or 0
return v
end
function Config:getBoolean(key, default)
return toboolean(self:get(key, default))
end
function Config:getPoint(key, default)
return topoint(self:get(key, default))
end
function Config:getRect(key, default)
return torect(self:get(key, default))
end
function Config:getSize(key, default)
return tosize(self:get(key, default))
end
function Config:getColor(key, default)
return tocolor(self:get(key, default))
end
function Config:getColor(key, default)
return tocolor(self:get(key, default))
end

View File

@ -14,6 +14,7 @@ Module
dofile 'const' dofile 'const'
dofile 'util' dofile 'util'
dofile 'globals' dofile 'globals'
dofile 'config'
dofile 'settings' dofile 'settings'
dofile 'keyboard' dofile 'keyboard'
dofile 'mouse' dofile 'mouse'

View File

@ -1,78 +1,4 @@
-- @docclass -- @docclass
g_settings = g_configs.getSettings() g_settings = g_configs.getSettings()
local function convertSettingValue(value) -- Reserved for settings specific functionality
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)
else
return value
end
elseif value == nil then
return ''
else
return tostring(value)
end
end
function g_settings.set(key, value)
g_settings.set(key, convertSettingValue(value))
end
function g_settings.setDefault(key, value)
if g_settings.exists(key) then return false end
g_settings.set(key, value)
return true
end
function g_settings.get(key, default)
print(g_settings.exists)
if not g_settings.exists(key) and default ~= nil then
g_settings.set(key, default)
end
return g_settings.get(key)
end
function g_settings.getString(key, default)
return g_settings.get(key, default)
end
function g_settings.getInteger(key, default)
local v = tonumber(g_settings.get(key, default)) or 0
return v
end
function g_settings.getNumber(key, default)
local v = tonumber(g_settings.get(key, default)) or 0
return v
end
function g_settings.getBoolean(key, default)
return toboolean(g_settings.get(key, default))
end
function g_settings.getPoint(key, default)
return topoint(g_settings.get(key, default))
end
function g_settings.getRect(key, default)
return torect(g_settings.get(key, default))
end
function g_settings.getSize(key, default)
return tosize(g_settings.get(key, default))
end
function g_settings.getColor(key, default)
return tocolor(g_settings.get(key, default))
end
function g_settings.getColor(key, default)
return tocolor(g_settings.get(key, default))
end

View File

@ -93,7 +93,7 @@ function UIMiniWindow:setup()
local oldParent = self:getParent() local oldParent = self:getParent()
local settings = g_settings.getNode('MiniWindows') local settings = g_settings:getNode('MiniWindows')
if settings then if settings then
local selfSettings = settings[self:getId()] local selfSettings = settings[self:getId()]
if selfSettings then if selfSettings then
@ -245,7 +245,7 @@ end
function UIMiniWindow:getSettings(name) function UIMiniWindow:getSettings(name)
if not self.save then return nil end if not self.save then return nil end
local settings = g_settings.getNode('MiniWindows') local settings = g_settings:getNode('MiniWindows')
if settings then if settings then
local selfSettings = settings[self:getId()] local selfSettings = settings[self:getId()]
if selfSettings then if selfSettings then
@ -258,7 +258,7 @@ end
function UIMiniWindow:setSettings(data) function UIMiniWindow:setSettings(data)
if not self.save then return end if not self.save then return end
local settings = g_settings.getNode('MiniWindows') local settings = g_settings:getNode('MiniWindows')
if not settings then if not settings then
settings = {} settings = {}
end end
@ -272,13 +272,13 @@ function UIMiniWindow:setSettings(data)
settings[id][key] = value settings[id][key] = value
end end
g_settings.setNode('MiniWindows', settings) g_settings:setNode('MiniWindows', settings)
end end
function UIMiniWindow:eraseSettings(data) function UIMiniWindow:eraseSettings(data)
if not self.save then return end if not self.save then return end
local settings = g_settings.getNode('MiniWindows') local settings = g_settings:getNode('MiniWindows')
if not settings then if not settings then
settings = {} settings = {}
end end
@ -292,7 +292,7 @@ function UIMiniWindow:eraseSettings(data)
settings[id][key] = nil settings[id][key] = nil
end end
g_settings.setNode('MiniWindows', settings) g_settings:setNode('MiniWindows', settings)
end end
function UIMiniWindow:saveParent(parent) function UIMiniWindow:saveParent(parent)

View File

@ -131,7 +131,7 @@ function onMiniWindowClose()
end end
function getSortType() function getSortType()
local settings = g_settings.getNode('BattleList') local settings = g_settings:getNode('BattleList')
if not settings then if not settings then
return 'name' return 'name'
end end
@ -141,13 +141,13 @@ end
function setSortType(state) function setSortType(state)
settings = {} settings = {}
settings['sortType'] = state settings['sortType'] = state
g_settings.mergeNode('BattleList', settings) g_settings:mergeNode('BattleList', settings)
checkCreatures() checkCreatures()
end end
function getSortOrder() function getSortOrder()
local settings = g_settings.getNode('BattleList') local settings = g_settings:getNode('BattleList')
if not settings then if not settings then
return 'asc' return 'asc'
end end
@ -157,7 +157,7 @@ end
function setSortOrder(state) function setSortOrder(state)
settings = {} settings = {}
settings['sortOrder'] = state settings['sortOrder'] = state
g_settings.mergeNode('BattleList', settings) g_settings:mergeNode('BattleList', settings)
checkCreatures() checkCreatures()
end end
@ -171,7 +171,7 @@ function isSortDesc()
end end
function isHidingFilters() function isHidingFilters()
local settings = g_settings.getNode('BattleList') local settings = g_settings:getNode('BattleList')
if not settings then if not settings then
return false return false
end end
@ -181,7 +181,7 @@ end
function setHidingFilters(state) function setHidingFilters(state)
settings = {} settings = {}
settings['hidingFilters'] = state settings['hidingFilters'] = state
g_settings.mergeNode('BattleList', settings) g_settings:mergeNode('BattleList', settings)
end end
function hideFilterPanel() function hideFilterPanel()

View File

@ -134,7 +134,7 @@ function online()
if player then if player then
local char = g_game.getCharacterName() local char = g_game.getCharacterName()
local lastCombatControls = g_settings.getNode('LastCombatControls') local lastCombatControls = g_settings:getNode('LastCombatControls')
if not table.empty(lastCombatControls) then if not table.empty(lastCombatControls) then
if lastCombatControls[char] then if lastCombatControls[char] then
@ -167,7 +167,7 @@ function online()
end end
function offline() function offline()
local lastCombatControls = g_settings.getNode('LastCombatControls') local lastCombatControls = g_settings:getNode('LastCombatControls')
if not lastCombatControls then if not lastCombatControls then
lastCombatControls = {} lastCombatControls = {}
end end
@ -186,7 +186,7 @@ function offline()
end end
-- save last combat control settings -- save last combat control settings
g_settings.setNode('LastCombatControls', lastCombatControls) g_settings:setNode('LastCombatControls', lastCombatControls)
end end
end end

View File

@ -242,11 +242,11 @@ end
function save() function save()
local settings = {} local settings = {}
settings.messageHistory = messageHistory settings.messageHistory = messageHistory
g_settings.setNode('game_console', settings) g_settings:setNode('game_console', settings)
end end
function load() function load()
local settings = g_settings.getNode('game_console') local settings = g_settings:getNode('game_console')
if settings then if settings then
messageHistory = settings.messageHistory or {} messageHistory = settings.messageHistory or {}
end end
@ -263,7 +263,7 @@ end
function clear() function clear()
-- save last open channels -- save last open channels
local lastChannelsOpen = g_settings.getNode('lastChannelsOpen') or {} local lastChannelsOpen = g_settings:getNode('lastChannelsOpen') or {}
local char = g_game.getCharacterName() local char = g_game.getCharacterName()
local savedChannels = {} local savedChannels = {}
local set = false local set = false
@ -278,7 +278,7 @@ function clear()
else else
lastChannelsOpen[char] = nil lastChannelsOpen[char] = nil
end end
g_settings.setNode('lastChannelsOpen', lastChannelsOpen) g_settings:setNode('lastChannelsOpen', lastChannelsOpen)
-- close channels -- close channels
for _, channelName in pairs(channels) do for _, channelName in pairs(channels) do
@ -1018,25 +1018,25 @@ function loadCommunicationSettings()
communicationSettings.whitelistedPlayers = {} communicationSettings.whitelistedPlayers = {}
communicationSettings.ignoredPlayers = {} communicationSettings.ignoredPlayers = {}
local ignoreNode = g_settings.getNode('IgnorePlayers') local ignoreNode = g_settings:getNode('IgnorePlayers')
if ignoreNode then if ignoreNode then
for i = 1, #ignoreNode do for i = 1, #ignoreNode do
table.insert(communicationSettings.ignoredPlayers, ignoreNode[i]) table.insert(communicationSettings.ignoredPlayers, ignoreNode[i])
end end
end end
local whitelistNode = g_settings.getNode('WhitelistedPlayers') local whitelistNode = g_settings:getNode('WhitelistedPlayers')
if whitelistNode then if whitelistNode then
for i = 1, #whitelistNode do for i = 1, #whitelistNode do
table.insert(communicationSettings.whitelistedPlayers, whitelistNode[i]) table.insert(communicationSettings.whitelistedPlayers, whitelistNode[i])
end end
end end
communicationSettings.useIgnoreList = g_settings.getBoolean('UseIgnoreList') communicationSettings.useIgnoreList = g_settings:getBoolean('UseIgnoreList')
communicationSettings.useWhiteList = g_settings.getBoolean('UseWhiteList') communicationSettings.useWhiteList = g_settings:getBoolean('UseWhiteList')
communicationSettings.privateMessages = g_settings.getBoolean('IgnorePrivateMessages') communicationSettings.privateMessages = g_settings:getBoolean('IgnorePrivateMessages')
communicationSettings.yelling = g_settings.getBoolean('IgnoreYelling') communicationSettings.yelling = g_settings:getBoolean('IgnoreYelling')
communicationSettings.allowVIPs = g_settings.getBoolean('AllowVIPs') communicationSettings.allowVIPs = g_settings:getBoolean('AllowVIPs')
end end
function saveCommunicationSettings() function saveCommunicationSettings()
@ -1052,12 +1052,12 @@ function saveCommunicationSettings()
table.insert(tmpWhiteList, whitelistedPlayers[i]) table.insert(tmpWhiteList, whitelistedPlayers[i])
end end
g_settings.set('UseIgnoreList', communicationSettings.useIgnoreList) g_settings:set('UseIgnoreList', communicationSettings.useIgnoreList)
g_settings.set('UseWhiteList', communicationSettings.useWhiteList) g_settings:set('UseWhiteList', communicationSettings.useWhiteList)
g_settings.set('IgnorePrivateMessages', communicationSettings.privateMessages) g_settings:set('IgnorePrivateMessages', communicationSettings.privateMessages)
g_settings.set('IgnoreYelling', communicationSettings.yelling) g_settings:set('IgnoreYelling', communicationSettings.yelling)
g_settings.setNode('IgnorePlayers', tmpIgnoreList) g_settings:setNode('IgnorePlayers', tmpIgnoreList)
g_settings.setNode('WhitelistedPlayers', tmpWhiteList) g_settings:setNode('WhitelistedPlayers', tmpWhiteList)
end end
function getIgnoredPlayers() function getIgnoredPlayers()
@ -1240,7 +1240,7 @@ function online()
g_keyboard.bindKeyDown('Ctrl+R', openPlayerReportRuleViolationWindow) g_keyboard.bindKeyDown('Ctrl+R', openPlayerReportRuleViolationWindow)
end end
-- open last channels -- open last channels
local lastChannelsOpen = g_settings.getNode('lastChannelsOpen') local lastChannelsOpen = g_settings:getNode('lastChannelsOpen')
if lastChannelsOpen then if lastChannelsOpen then
local savedChannels = lastChannelsOpen[g_game.getCharacterName()] local savedChannels = lastChannelsOpen[g_game.getCharacterName()]
if savedChannels then if savedChannels then

View File

@ -145,7 +145,7 @@ end
function load(forceDefaults) function load(forceDefaults)
hotkeysManagerLoaded = false hotkeysManagerLoaded = false
local hotkeySettings = g_settings.getNode('game_hotkeys') local hotkeySettings = g_settings:getNode('game_hotkeys')
local hotkeys = {} local hotkeys = {}
if not table.empty(hotkeySettings) then hotkeys = hotkeySettings end if not table.empty(hotkeySettings) then hotkeys = hotkeySettings end
@ -192,7 +192,7 @@ function reload()
end end
function save() function save()
local hotkeySettings = g_settings.getNode('game_hotkeys') or {} local hotkeySettings = g_settings:getNode('game_hotkeys') or {}
local hotkeys = hotkeySettings local hotkeys = hotkeySettings
if perServer then if perServer then
@ -223,8 +223,8 @@ function save()
end end
hotkeyList = hotkeys hotkeyList = hotkeys
g_settings.setNode('game_hotkeys', hotkeySettings) g_settings:setNode('game_hotkeys', hotkeySettings)
g_settings.save() g_settings:save()
end end
function loadDefautComboKeys() function loadDefautComboKeys()

View File

@ -178,11 +178,11 @@ end
function save() function save()
local settings = {} local settings = {}
settings.splitterMarginBottom = bottomSplitter:getMarginBottom() settings.splitterMarginBottom = bottomSplitter:getMarginBottom()
g_settings.setNode('game_interface', settings) g_settings:setNode('game_interface', settings)
end end
function load() function load()
local settings = g_settings.getNode('game_interface') local settings = g_settings:getNode('game_interface')
if settings then if settings then
if settings.splitterMarginBottom then if settings.splitterMarginBottom then
bottomSplitter:setMarginBottom(settings.splitterMarginBottom) bottomSplitter:setMarginBottom(settings.splitterMarginBottom)

View File

@ -48,7 +48,7 @@ function terminate()
end end
function loadVipInfo() function loadVipInfo()
local settings = g_settings.getNode('VipList') local settings = g_settings:getNode('VipList')
if not settings then if not settings then
vipInfo = {} vipInfo = {}
return return
@ -59,7 +59,7 @@ end
function saveVipInfo() function saveVipInfo()
settings = {} settings = {}
settings['VipInfo'] = vipInfo settings['VipInfo'] = vipInfo
g_settings.mergeNode('VipList', settings) g_settings:mergeNode('VipList', settings)
end end
@ -212,13 +212,13 @@ end
function hideOffline(state) function hideOffline(state)
settings = {} settings = {}
settings['hideOffline'] = state settings['hideOffline'] = state
g_settings.mergeNode('VipList', settings) g_settings:mergeNode('VipList', settings)
refresh() refresh()
end end
function isHiddingOffline() function isHiddingOffline()
local settings = g_settings.getNode('VipList') local settings = g_settings:getNode('VipList')
if not settings then if not settings then
return false return false
end end
@ -226,7 +226,7 @@ function isHiddingOffline()
end end
function getSortedBy() function getSortedBy()
local settings = g_settings.getNode('VipList') local settings = g_settings:getNode('VipList')
if not settings or not settings['sortedBy'] then if not settings or not settings['sortedBy'] then
return 'status' return 'status'
end end
@ -236,7 +236,7 @@ end
function sortBy(state) function sortBy(state)
settings = {} settings = {}
settings['sortedBy'] = state settings['sortedBy'] = state
g_settings.mergeNode('VipList', settings) g_settings:mergeNode('VipList', settings)
refresh() refresh()
end end

View File

@ -55,7 +55,7 @@ function UIMinimap:disableAutoWalk()
end end
function UIMinimap:load() function UIMinimap:load()
local settings = g_settings.getNode('Minimap') local settings = g_settings:getNode('Minimap')
if settings then if settings then
if settings.flags then if settings.flags then
for _,flag in pairs(settings.flags) do for _,flag in pairs(settings.flags) do
@ -76,7 +76,7 @@ function UIMinimap:save()
}) })
end end
settings.zoom = self:getZoom() settings.zoom = self:getZoom()
g_settings.setNode('Minimap', settings) g_settings:setNode('Minimap', settings)
end end
local function onFlagMouseRelease(widget, pos, button) local function onFlagMouseRelease(widget, pos, button)

View File

@ -70,7 +70,7 @@ void Config::clear()
m_confsDoc->clear(); m_confsDoc->clear();
} }
void Config::set(const std::string& key, const std::string& value) void Config::setValue(const std::string& key, const std::string& value)
{ {
if(key == "") { if(key == "") {
remove(key); remove(key);
@ -94,12 +94,12 @@ void Config::setList(const std::string& key, const std::vector<std::string>& lis
m_confsDoc->addChild(child); m_confsDoc->addChild(child);
} }
bool Config::exists(const std::string key) bool Config::exists(const std::string& key)
{ {
return m_confsDoc->hasChildAt(key); return m_confsDoc->hasChildAt(key);
} }
std::string Config::get(const std::string& key) std::string Config::getValue(const std::string& key)
{ {
OTMLNodePtr child = m_confsDoc->get(key); OTMLNodePtr child = m_confsDoc->get(key);
if(child) if(child)

View File

@ -39,16 +39,16 @@ public:
bool save(); bool save();
void clear(); void clear();
void set(const std::string& key, const std::string& value); void setValue(const std::string& key, const std::string& value);
void setList(const std::string& key, const std::vector<std::string>& list); void setList(const std::string& key, const std::vector<std::string>& list);
std::string get(const std::string& key); std::string getValue(const std::string& key);
std::vector<std::string> getList(const std::string& key); std::vector<std::string> getList(const std::string& key);
void setNode(const std::string& key, const OTMLNodePtr& node); void setNode(const std::string& key, const OTMLNodePtr& node);
void mergeNode(const std::string& key, const OTMLNodePtr& node); void mergeNode(const std::string& key, const OTMLNodePtr& node);
OTMLNodePtr getNode(const std::string& key); OTMLNodePtr getNode(const std::string& key);
bool exists(const std::string key); bool exists(const std::string& key);
void remove(const std::string& key); void remove(const std::string& key);
std::string getFileName(); std::string getFileName();

View File

@ -193,9 +193,9 @@ void Application::registerLuaFunctions()
// Config // Config
g_lua.registerClass<Config>(); g_lua.registerClass<Config>();
g_lua.bindClassMemberFunction<Config>("save", &Config::save); g_lua.bindClassMemberFunction<Config>("save", &Config::save);
g_lua.bindClassMemberFunction<Config>("set", &Config::set); g_lua.bindClassMemberFunction<Config>("setValue", &Config::setValue);
g_lua.bindClassMemberFunction<Config>("setList", &Config::setList); g_lua.bindClassMemberFunction<Config>("setList", &Config::setList);
g_lua.bindClassMemberFunction<Config>("get", &Config::get); g_lua.bindClassMemberFunction<Config>("getValue", &Config::getValue);
g_lua.bindClassMemberFunction<Config>("getList", &Config::getList); g_lua.bindClassMemberFunction<Config>("getList", &Config::getList);
g_lua.bindClassMemberFunction<Config>("exists", &Config::exists); g_lua.bindClassMemberFunction<Config>("exists", &Config::exists);
g_lua.bindClassMemberFunction<Config>("remove", &Config::remove); g_lua.bindClassMemberFunction<Config>("remove", &Config::remove);