Finished stable implementation (as far as tested), still requires more testing.
This commit is contained in:
parent
61059e66ec
commit
b295053662
|
@ -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()
|
||||
|
|
|
@ -37,8 +37,8 @@ local function tryLogin(charInfo, tries)
|
|||
end })
|
||||
|
||||
-- save last used character
|
||||
g_settings.set('last-used-character', charInfo.characterName)
|
||||
g_settings.set('last-used-world', charInfo.worldName)
|
||||
g_settings:set('last-used-character', charInfo.characterName)
|
||||
g_settings:set('last-used-world', charInfo.worldName)
|
||||
end
|
||||
|
||||
local function updateWait(timeStart, timeEnd)
|
||||
|
@ -225,7 +225,7 @@ function CharacterList.create(characters, account, otui)
|
|||
|
||||
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
|
||||
end
|
||||
end
|
||||
|
|
|
@ -41,13 +41,13 @@ local function onCharacterList(protocol, characters, account, otui)
|
|||
local account = g_crypt.encrypt(G.account)
|
||||
local password = g_crypt.encrypt(G.password)
|
||||
|
||||
g_settings.set('account', account)
|
||||
g_settings.set('password', password)
|
||||
g_settings:set('account', account)
|
||||
g_settings:set('password', password)
|
||||
|
||||
ServerList.setServerAccount(G.host, account)
|
||||
ServerList.setServerPassword(G.host, password)
|
||||
|
||||
g_settings.set('autologin', enterGame:getChildById('autoLoginBox'):isChecked())
|
||||
g_settings:set('autologin', enterGame:getChildById('autoLoginBox'):isChecked())
|
||||
else
|
||||
-- reset server list account/password
|
||||
ServerList.setServerAccount(G.host, '')
|
||||
|
@ -63,9 +63,9 @@ local function onCharacterList(protocol, characters, account, otui)
|
|||
CharacterList.show()
|
||||
|
||||
if motdEnabled then
|
||||
local lastMotdNumber = g_settings.getNumber("motd")
|
||||
local lastMotdNumber = g_settings:getNumber("motd")
|
||||
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)
|
||||
connect(motdWindow, { onOk = function() CharacterList.show() motdWindow = nil end })
|
||||
CharacterList.hide()
|
||||
|
@ -99,12 +99,12 @@ function EnterGame.init()
|
|||
motdButton:show()
|
||||
end
|
||||
|
||||
local account = g_settings.get('account')
|
||||
local password = g_settings.get('password')
|
||||
local host = g_settings.get('host')
|
||||
local port = g_settings.get('port')
|
||||
local autologin = g_settings.getBoolean('autologin')
|
||||
local clientVersion = g_settings.getInteger('client-version')
|
||||
local account = g_settings:get('account')
|
||||
local password = g_settings:get('password')
|
||||
local host = g_settings:get('host')
|
||||
local port = g_settings:get('port')
|
||||
local autologin = g_settings:getBoolean('autologin')
|
||||
local clientVersion = g_settings:getInteger('client-version')
|
||||
if clientVersion == 0 then clientVersion = 860 end
|
||||
|
||||
if port == nil or port == 0 then port = 7171 end
|
||||
|
@ -132,13 +132,13 @@ end
|
|||
function EnterGame.firstShow()
|
||||
EnterGame.show()
|
||||
|
||||
local account = g_crypt.decrypt(g_settings.get('account'))
|
||||
local password = g_crypt.decrypt(g_settings.get('password'))
|
||||
local host = g_settings.get('host')
|
||||
local autologin = g_settings.getBoolean('autologin')
|
||||
local account = g_crypt.decrypt(g_settings:get('account'))
|
||||
local password = g_crypt.decrypt(g_settings:get('password'))
|
||||
local host = g_settings:get('host')
|
||||
local autologin = g_settings:getBoolean('autologin')
|
||||
if #host > 0 and #password > 0 and #account > 0 and autologin then
|
||||
addEvent(function()
|
||||
if not g_settings.getBoolean('autologin') then return end
|
||||
if not g_settings:getBoolean('autologin') then return end
|
||||
EnterGame.doLogin()
|
||||
end)
|
||||
end
|
||||
|
@ -205,8 +205,8 @@ function EnterGame.clearAccountFields()
|
|||
enterGame:getChildById('accountNameTextEdit'):clearText()
|
||||
enterGame:getChildById('accountPasswordTextEdit'):clearText()
|
||||
enterGame:getChildById('accountNameTextEdit'):focus()
|
||||
g_settings.remove('account')
|
||||
g_settings.remove('password')
|
||||
g_settings:remove('account')
|
||||
g_settings:remove('password')
|
||||
end
|
||||
|
||||
function EnterGame.doLogin()
|
||||
|
@ -223,9 +223,9 @@ function EnterGame.doLogin()
|
|||
return
|
||||
end
|
||||
|
||||
g_settings.set('host', G.host)
|
||||
g_settings.set('port', G.port)
|
||||
g_settings.set('client-version', clientVersion)
|
||||
g_settings:set('host', G.host)
|
||||
g_settings:set('port', G.port)
|
||||
g_settings:set('client-version', clientVersion)
|
||||
|
||||
protocolLogin = ProtocolLogin.create()
|
||||
protocolLogin.onLoginError = onError
|
||||
|
|
|
@ -64,7 +64,7 @@ function init()
|
|||
|
||||
installLocales('/locales')
|
||||
|
||||
local userLocaleName = g_settings.get('locale', 'false')
|
||||
local userLocaleName = g_settings:get('locale', 'false')
|
||||
if userLocaleName ~= 'false' and setLocale(userLocaleName) then
|
||||
pdebug('Using configured locale: ' .. userLocaleName)
|
||||
else
|
||||
|
@ -150,7 +150,7 @@ function setLocale(name)
|
|||
sendLocale(locale.name)
|
||||
end
|
||||
currentLocale = locale
|
||||
g_settings.set('locale', name)
|
||||
g_settings:set('locale', name)
|
||||
if onLocaleChanged then onLocaleChanged(name) end
|
||||
return true
|
||||
end
|
||||
|
|
|
@ -84,7 +84,7 @@ end
|
|||
|
||||
function init()
|
||||
for k,v in pairs(defaultOptions) do
|
||||
g_settings.setDefault(k, v)
|
||||
g_settings:setDefault(k, v)
|
||||
options[k] = v
|
||||
end
|
||||
|
||||
|
@ -129,9 +129,9 @@ function setup()
|
|||
-- load options
|
||||
for k,v in pairs(defaultOptions) do
|
||||
if type(v) == 'boolean' then
|
||||
setOption(k, g_settings.getBoolean(k), true)
|
||||
setOption(k, g_settings:getBoolean(k), true)
|
||||
elseif type(v) == 'number' then
|
||||
setOption(k, g_settings.getNumber(k), true)
|
||||
setOption(k, g_settings:getNumber(k), true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -243,7 +243,7 @@ function setOption(key, value, force)
|
|||
end
|
||||
end
|
||||
|
||||
g_settings.set(key, value)
|
||||
g_settings:set(key, value)
|
||||
options[key] = value
|
||||
end
|
||||
|
||||
|
|
|
@ -11,14 +11,14 @@ function ServerList.init()
|
|||
serverListWindow = g_ui.displayUI('serverlist')
|
||||
serverTextList = serverListWindow:getChildById('serverList')
|
||||
|
||||
servers = g_settings.getNode('ServerList') or {}
|
||||
servers = g_settings:getNode('ServerList') or {}
|
||||
ServerList.load()
|
||||
end
|
||||
|
||||
function ServerList.terminate()
|
||||
ServerList.destroy()
|
||||
|
||||
g_settings.setNode('ServerList', servers)
|
||||
g_settings:setNode('ServerList', servers)
|
||||
|
||||
ServerList = nil
|
||||
end
|
||||
|
|
|
@ -8,10 +8,10 @@ sendReportEvent = nil
|
|||
firstReportEvent = nil
|
||||
|
||||
function initUUID()
|
||||
UUID = g_settings.getString('report-uuid')
|
||||
UUID = g_settings:getString('report-uuid')
|
||||
if not UUID or #UUID ~= 36 then
|
||||
UUID = g_crypt.genUUID()
|
||||
g_settings.set('report-uuid', UUID)
|
||||
g_settings:set('report-uuid', UUID)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ function init()
|
|||
terminalButton = modules.client_topmenu.addLeftButton('terminalButton', tr('Terminal') .. ' (Ctrl + T)', '/images/topbuttons/terminal', toggle)
|
||||
g_keyboard.bindKeyDown('Ctrl+T', toggle)
|
||||
|
||||
commandHistory = g_settings.getList('terminal-history')
|
||||
commandHistory = g_settings:getList('terminal-history')
|
||||
|
||||
commandTextEdit = terminalWindow:getChildById('commandTextEdit')
|
||||
g_keyboard.bindKeyPress('Up', function() navigateCommand(1) end, commandTextEdit)
|
||||
|
@ -159,7 +159,7 @@ function init()
|
|||
end
|
||||
|
||||
function terminate()
|
||||
g_settings.setList('terminal-history', commandHistory)
|
||||
g_settings:setList('terminal-history', commandHistory)
|
||||
|
||||
removeEvent(flushEvent)
|
||||
|
||||
|
@ -172,7 +172,7 @@ function terminate()
|
|||
pos = oldPos,
|
||||
poped = poped
|
||||
}
|
||||
g_settings.setNode('terminal-window', settings)
|
||||
g_settings:setNode('terminal-window', settings)
|
||||
|
||||
g_keyboard.unbindKeyDown('Ctrl+T')
|
||||
g_logger.setOnLog(nil)
|
||||
|
@ -222,7 +222,7 @@ function toggle()
|
|||
hide()
|
||||
else
|
||||
if not firstShown then
|
||||
local settings = g_settings.getNode('terminal-window')
|
||||
local settings = g_settings:getNode('terminal-window')
|
||||
if settings then
|
||||
if settings.size then oldSize = size end
|
||||
if settings.pos then oldPos = settings.pos end
|
||||
|
|
|
@ -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
|
|
@ -14,6 +14,7 @@ Module
|
|||
dofile 'const'
|
||||
dofile 'util'
|
||||
dofile 'globals'
|
||||
dofile 'config'
|
||||
dofile 'settings'
|
||||
dofile 'keyboard'
|
||||
dofile 'mouse'
|
||||
|
|
|
@ -1,78 +1,4 @@
|
|||
-- @docclass
|
||||
g_settings = g_configs.getSettings()
|
||||
|
||||
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 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
|
||||
-- Reserved for settings specific functionality
|
|
@ -93,7 +93,7 @@ function UIMiniWindow:setup()
|
|||
|
||||
local oldParent = self:getParent()
|
||||
|
||||
local settings = g_settings.getNode('MiniWindows')
|
||||
local settings = g_settings:getNode('MiniWindows')
|
||||
if settings then
|
||||
local selfSettings = settings[self:getId()]
|
||||
if selfSettings then
|
||||
|
@ -245,7 +245,7 @@ end
|
|||
|
||||
function UIMiniWindow:getSettings(name)
|
||||
if not self.save then return nil end
|
||||
local settings = g_settings.getNode('MiniWindows')
|
||||
local settings = g_settings:getNode('MiniWindows')
|
||||
if settings then
|
||||
local selfSettings = settings[self:getId()]
|
||||
if selfSettings then
|
||||
|
@ -258,7 +258,7 @@ end
|
|||
function UIMiniWindow:setSettings(data)
|
||||
if not self.save then return end
|
||||
|
||||
local settings = g_settings.getNode('MiniWindows')
|
||||
local settings = g_settings:getNode('MiniWindows')
|
||||
if not settings then
|
||||
settings = {}
|
||||
end
|
||||
|
@ -272,13 +272,13 @@ function UIMiniWindow:setSettings(data)
|
|||
settings[id][key] = value
|
||||
end
|
||||
|
||||
g_settings.setNode('MiniWindows', settings)
|
||||
g_settings:setNode('MiniWindows', settings)
|
||||
end
|
||||
|
||||
function UIMiniWindow:eraseSettings(data)
|
||||
if not self.save then return end
|
||||
|
||||
local settings = g_settings.getNode('MiniWindows')
|
||||
local settings = g_settings:getNode('MiniWindows')
|
||||
if not settings then
|
||||
settings = {}
|
||||
end
|
||||
|
@ -292,7 +292,7 @@ function UIMiniWindow:eraseSettings(data)
|
|||
settings[id][key] = nil
|
||||
end
|
||||
|
||||
g_settings.setNode('MiniWindows', settings)
|
||||
g_settings:setNode('MiniWindows', settings)
|
||||
end
|
||||
|
||||
function UIMiniWindow:saveParent(parent)
|
||||
|
|
|
@ -131,7 +131,7 @@ function onMiniWindowClose()
|
|||
end
|
||||
|
||||
function getSortType()
|
||||
local settings = g_settings.getNode('BattleList')
|
||||
local settings = g_settings:getNode('BattleList')
|
||||
if not settings then
|
||||
return 'name'
|
||||
end
|
||||
|
@ -141,13 +141,13 @@ end
|
|||
function setSortType(state)
|
||||
settings = {}
|
||||
settings['sortType'] = state
|
||||
g_settings.mergeNode('BattleList', settings)
|
||||
g_settings:mergeNode('BattleList', settings)
|
||||
|
||||
checkCreatures()
|
||||
end
|
||||
|
||||
function getSortOrder()
|
||||
local settings = g_settings.getNode('BattleList')
|
||||
local settings = g_settings:getNode('BattleList')
|
||||
if not settings then
|
||||
return 'asc'
|
||||
end
|
||||
|
@ -157,7 +157,7 @@ end
|
|||
function setSortOrder(state)
|
||||
settings = {}
|
||||
settings['sortOrder'] = state
|
||||
g_settings.mergeNode('BattleList', settings)
|
||||
g_settings:mergeNode('BattleList', settings)
|
||||
|
||||
checkCreatures()
|
||||
end
|
||||
|
@ -171,7 +171,7 @@ function isSortDesc()
|
|||
end
|
||||
|
||||
function isHidingFilters()
|
||||
local settings = g_settings.getNode('BattleList')
|
||||
local settings = g_settings:getNode('BattleList')
|
||||
if not settings then
|
||||
return false
|
||||
end
|
||||
|
@ -181,7 +181,7 @@ end
|
|||
function setHidingFilters(state)
|
||||
settings = {}
|
||||
settings['hidingFilters'] = state
|
||||
g_settings.mergeNode('BattleList', settings)
|
||||
g_settings:mergeNode('BattleList', settings)
|
||||
end
|
||||
|
||||
function hideFilterPanel()
|
||||
|
|
|
@ -134,7 +134,7 @@ function online()
|
|||
if player then
|
||||
local char = g_game.getCharacterName()
|
||||
|
||||
local lastCombatControls = g_settings.getNode('LastCombatControls')
|
||||
local lastCombatControls = g_settings:getNode('LastCombatControls')
|
||||
|
||||
if not table.empty(lastCombatControls) then
|
||||
if lastCombatControls[char] then
|
||||
|
@ -167,7 +167,7 @@ function online()
|
|||
end
|
||||
|
||||
function offline()
|
||||
local lastCombatControls = g_settings.getNode('LastCombatControls')
|
||||
local lastCombatControls = g_settings:getNode('LastCombatControls')
|
||||
if not lastCombatControls then
|
||||
lastCombatControls = {}
|
||||
end
|
||||
|
@ -186,7 +186,7 @@ function offline()
|
|||
end
|
||||
|
||||
-- save last combat control settings
|
||||
g_settings.setNode('LastCombatControls', lastCombatControls)
|
||||
g_settings:setNode('LastCombatControls', lastCombatControls)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -242,11 +242,11 @@ end
|
|||
function save()
|
||||
local settings = {}
|
||||
settings.messageHistory = messageHistory
|
||||
g_settings.setNode('game_console', settings)
|
||||
g_settings:setNode('game_console', settings)
|
||||
end
|
||||
|
||||
function load()
|
||||
local settings = g_settings.getNode('game_console')
|
||||
local settings = g_settings:getNode('game_console')
|
||||
if settings then
|
||||
messageHistory = settings.messageHistory or {}
|
||||
end
|
||||
|
@ -263,7 +263,7 @@ end
|
|||
|
||||
function clear()
|
||||
-- save last open channels
|
||||
local lastChannelsOpen = g_settings.getNode('lastChannelsOpen') or {}
|
||||
local lastChannelsOpen = g_settings:getNode('lastChannelsOpen') or {}
|
||||
local char = g_game.getCharacterName()
|
||||
local savedChannels = {}
|
||||
local set = false
|
||||
|
@ -278,7 +278,7 @@ function clear()
|
|||
else
|
||||
lastChannelsOpen[char] = nil
|
||||
end
|
||||
g_settings.setNode('lastChannelsOpen', lastChannelsOpen)
|
||||
g_settings:setNode('lastChannelsOpen', lastChannelsOpen)
|
||||
|
||||
-- close channels
|
||||
for _, channelName in pairs(channels) do
|
||||
|
@ -1018,25 +1018,25 @@ function loadCommunicationSettings()
|
|||
communicationSettings.whitelistedPlayers = {}
|
||||
communicationSettings.ignoredPlayers = {}
|
||||
|
||||
local ignoreNode = g_settings.getNode('IgnorePlayers')
|
||||
local ignoreNode = g_settings:getNode('IgnorePlayers')
|
||||
if ignoreNode then
|
||||
for i = 1, #ignoreNode do
|
||||
table.insert(communicationSettings.ignoredPlayers, ignoreNode[i])
|
||||
end
|
||||
end
|
||||
|
||||
local whitelistNode = g_settings.getNode('WhitelistedPlayers')
|
||||
local whitelistNode = g_settings:getNode('WhitelistedPlayers')
|
||||
if whitelistNode then
|
||||
for i = 1, #whitelistNode do
|
||||
table.insert(communicationSettings.whitelistedPlayers, whitelistNode[i])
|
||||
end
|
||||
end
|
||||
|
||||
communicationSettings.useIgnoreList = g_settings.getBoolean('UseIgnoreList')
|
||||
communicationSettings.useWhiteList = g_settings.getBoolean('UseWhiteList')
|
||||
communicationSettings.privateMessages = g_settings.getBoolean('IgnorePrivateMessages')
|
||||
communicationSettings.yelling = g_settings.getBoolean('IgnoreYelling')
|
||||
communicationSettings.allowVIPs = g_settings.getBoolean('AllowVIPs')
|
||||
communicationSettings.useIgnoreList = g_settings:getBoolean('UseIgnoreList')
|
||||
communicationSettings.useWhiteList = g_settings:getBoolean('UseWhiteList')
|
||||
communicationSettings.privateMessages = g_settings:getBoolean('IgnorePrivateMessages')
|
||||
communicationSettings.yelling = g_settings:getBoolean('IgnoreYelling')
|
||||
communicationSettings.allowVIPs = g_settings:getBoolean('AllowVIPs')
|
||||
end
|
||||
|
||||
function saveCommunicationSettings()
|
||||
|
@ -1052,12 +1052,12 @@ function saveCommunicationSettings()
|
|||
table.insert(tmpWhiteList, whitelistedPlayers[i])
|
||||
end
|
||||
|
||||
g_settings.set('UseIgnoreList', communicationSettings.useIgnoreList)
|
||||
g_settings.set('UseWhiteList', communicationSettings.useWhiteList)
|
||||
g_settings.set('IgnorePrivateMessages', communicationSettings.privateMessages)
|
||||
g_settings.set('IgnoreYelling', communicationSettings.yelling)
|
||||
g_settings.setNode('IgnorePlayers', tmpIgnoreList)
|
||||
g_settings.setNode('WhitelistedPlayers', tmpWhiteList)
|
||||
g_settings:set('UseIgnoreList', communicationSettings.useIgnoreList)
|
||||
g_settings:set('UseWhiteList', communicationSettings.useWhiteList)
|
||||
g_settings:set('IgnorePrivateMessages', communicationSettings.privateMessages)
|
||||
g_settings:set('IgnoreYelling', communicationSettings.yelling)
|
||||
g_settings:setNode('IgnorePlayers', tmpIgnoreList)
|
||||
g_settings:setNode('WhitelistedPlayers', tmpWhiteList)
|
||||
end
|
||||
|
||||
function getIgnoredPlayers()
|
||||
|
@ -1240,7 +1240,7 @@ function online()
|
|||
g_keyboard.bindKeyDown('Ctrl+R', openPlayerReportRuleViolationWindow)
|
||||
end
|
||||
-- open last channels
|
||||
local lastChannelsOpen = g_settings.getNode('lastChannelsOpen')
|
||||
local lastChannelsOpen = g_settings:getNode('lastChannelsOpen')
|
||||
if lastChannelsOpen then
|
||||
local savedChannels = lastChannelsOpen[g_game.getCharacterName()]
|
||||
if savedChannels then
|
||||
|
|
|
@ -145,7 +145,7 @@ end
|
|||
function load(forceDefaults)
|
||||
hotkeysManagerLoaded = false
|
||||
|
||||
local hotkeySettings = g_settings.getNode('game_hotkeys')
|
||||
local hotkeySettings = g_settings:getNode('game_hotkeys')
|
||||
local hotkeys = {}
|
||||
|
||||
if not table.empty(hotkeySettings) then hotkeys = hotkeySettings end
|
||||
|
@ -192,7 +192,7 @@ function reload()
|
|||
end
|
||||
|
||||
function save()
|
||||
local hotkeySettings = g_settings.getNode('game_hotkeys') or {}
|
||||
local hotkeySettings = g_settings:getNode('game_hotkeys') or {}
|
||||
local hotkeys = hotkeySettings
|
||||
|
||||
if perServer then
|
||||
|
@ -223,8 +223,8 @@ function save()
|
|||
end
|
||||
|
||||
hotkeyList = hotkeys
|
||||
g_settings.setNode('game_hotkeys', hotkeySettings)
|
||||
g_settings.save()
|
||||
g_settings:setNode('game_hotkeys', hotkeySettings)
|
||||
g_settings:save()
|
||||
end
|
||||
|
||||
function loadDefautComboKeys()
|
||||
|
|
|
@ -178,11 +178,11 @@ end
|
|||
function save()
|
||||
local settings = {}
|
||||
settings.splitterMarginBottom = bottomSplitter:getMarginBottom()
|
||||
g_settings.setNode('game_interface', settings)
|
||||
g_settings:setNode('game_interface', settings)
|
||||
end
|
||||
|
||||
function load()
|
||||
local settings = g_settings.getNode('game_interface')
|
||||
local settings = g_settings:getNode('game_interface')
|
||||
if settings then
|
||||
if settings.splitterMarginBottom then
|
||||
bottomSplitter:setMarginBottom(settings.splitterMarginBottom)
|
||||
|
|
|
@ -48,7 +48,7 @@ function terminate()
|
|||
end
|
||||
|
||||
function loadVipInfo()
|
||||
local settings = g_settings.getNode('VipList')
|
||||
local settings = g_settings:getNode('VipList')
|
||||
if not settings then
|
||||
vipInfo = {}
|
||||
return
|
||||
|
@ -59,7 +59,7 @@ end
|
|||
function saveVipInfo()
|
||||
settings = {}
|
||||
settings['VipInfo'] = vipInfo
|
||||
g_settings.mergeNode('VipList', settings)
|
||||
g_settings:mergeNode('VipList', settings)
|
||||
end
|
||||
|
||||
|
||||
|
@ -212,13 +212,13 @@ end
|
|||
function hideOffline(state)
|
||||
settings = {}
|
||||
settings['hideOffline'] = state
|
||||
g_settings.mergeNode('VipList', settings)
|
||||
g_settings:mergeNode('VipList', settings)
|
||||
|
||||
refresh()
|
||||
end
|
||||
|
||||
function isHiddingOffline()
|
||||
local settings = g_settings.getNode('VipList')
|
||||
local settings = g_settings:getNode('VipList')
|
||||
if not settings then
|
||||
return false
|
||||
end
|
||||
|
@ -226,7 +226,7 @@ function isHiddingOffline()
|
|||
end
|
||||
|
||||
function getSortedBy()
|
||||
local settings = g_settings.getNode('VipList')
|
||||
local settings = g_settings:getNode('VipList')
|
||||
if not settings or not settings['sortedBy'] then
|
||||
return 'status'
|
||||
end
|
||||
|
@ -236,7 +236,7 @@ end
|
|||
function sortBy(state)
|
||||
settings = {}
|
||||
settings['sortedBy'] = state
|
||||
g_settings.mergeNode('VipList', settings)
|
||||
g_settings:mergeNode('VipList', settings)
|
||||
|
||||
refresh()
|
||||
end
|
||||
|
|
|
@ -55,7 +55,7 @@ function UIMinimap:disableAutoWalk()
|
|||
end
|
||||
|
||||
function UIMinimap:load()
|
||||
local settings = g_settings.getNode('Minimap')
|
||||
local settings = g_settings:getNode('Minimap')
|
||||
if settings then
|
||||
if settings.flags then
|
||||
for _,flag in pairs(settings.flags) do
|
||||
|
@ -76,7 +76,7 @@ function UIMinimap:save()
|
|||
})
|
||||
end
|
||||
settings.zoom = self:getZoom()
|
||||
g_settings.setNode('Minimap', settings)
|
||||
g_settings:setNode('Minimap', settings)
|
||||
end
|
||||
|
||||
local function onFlagMouseRelease(widget, pos, button)
|
||||
|
|
|
@ -70,7 +70,7 @@ void Config::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 == "") {
|
||||
remove(key);
|
||||
|
@ -94,12 +94,12 @@ void Config::setList(const std::string& key, const std::vector<std::string>& lis
|
|||
m_confsDoc->addChild(child);
|
||||
}
|
||||
|
||||
bool Config::exists(const std::string key)
|
||||
bool Config::exists(const std::string& 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);
|
||||
if(child)
|
||||
|
|
|
@ -39,16 +39,16 @@ public:
|
|||
bool save();
|
||||
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);
|
||||
std::string get(const std::string& key);
|
||||
std::string getValue(const std::string& key);
|
||||
std::vector<std::string> getList(const std::string& key);
|
||||
|
||||
void setNode(const std::string& key, const OTMLNodePtr& node);
|
||||
void mergeNode(const std::string& key, const OTMLNodePtr& node);
|
||||
OTMLNodePtr getNode(const std::string& key);
|
||||
|
||||
bool exists(const std::string key);
|
||||
bool exists(const std::string& key);
|
||||
void remove(const std::string& key);
|
||||
|
||||
std::string getFileName();
|
||||
|
|
|
@ -193,9 +193,9 @@ void Application::registerLuaFunctions()
|
|||
// Config
|
||||
g_lua.registerClass<Config>();
|
||||
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>("get", &Config::get);
|
||||
g_lua.bindClassMemberFunction<Config>("getValue", &Config::getValue);
|
||||
g_lua.bindClassMemberFunction<Config>("getList", &Config::getList);
|
||||
g_lua.bindClassMemberFunction<Config>("exists", &Config::exists);
|
||||
g_lua.bindClassMemberFunction<Config>("remove", &Config::remove);
|
||||
|
|
Loading…
Reference in New Issue