Fix global use of some variables
This commit is contained in:
parent
7fe8447326
commit
b677f7bb38
|
@ -80,7 +80,7 @@ lib['events']:SetScript("OnEvent", function(self, event, ...)
|
|||
if(specs and specs['sv'] and not addon['db']) then
|
||||
-- print('dbname',type(specs['sv']),type(specs['sv']) == 'boolean' and addonName or specs['sv'])
|
||||
local dbname = format('%sDB', type(specs['sv']) == 'boolean' and addonName or specs['sv'])
|
||||
addon['db'] = LibStub("AceDB-3.0"):New(dbname, type(specs['defaults']) == 'table' and specs['defaults'] or {}, true)
|
||||
addon['db'] = LibStub("AceDB-3.0"):New(dbname, type(specs['defaults']) == 'table' and specs['defaults'] or {}, 'Default')
|
||||
if(specs['ldb']) then
|
||||
local ldbobj = LibStub:GetLibrary("zzLDB"):AddLDB(specs['name'], specs['ldb'], addon['db'])
|
||||
end
|
||||
|
@ -88,13 +88,9 @@ lib['events']:SetScript("OnEvent", function(self, event, ...)
|
|||
local config = LibStub:GetLibrary("zzConfig")
|
||||
addon['options'] = config:InitConfig(addon, addonName)
|
||||
addon['options']['args']['profile'] = LibStub("AceDBOptions-3.0"):GetOptionsTable(addon['db'])
|
||||
function addon:RefreshConfig()
|
||||
self['db']['profile'][specs['name']] = {}
|
||||
if(specs['cfgRefresh']) then
|
||||
self['specs']['cfgRefresh'](addon['db'])
|
||||
end
|
||||
if(type(specs['cfgReset']) == 'function') then
|
||||
addon['db'].RegisterCallback(specs, "OnProfileReset", 'cfgReset')
|
||||
end
|
||||
addon['db'].RegisterCallback(addon, "OnProfileReset", "RefreshConfig")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,6 +31,11 @@ local function minimapSet(pref,value)
|
|||
db[pref[#pref]] = value
|
||||
ldbiconUpdate(objname)
|
||||
end
|
||||
local function notify(pref, value, oldvalue)
|
||||
if(type(pref['handler'].PrefChanged) == 'function') then
|
||||
pref['handler']:PrefChanged(pref, value, oldvalue)
|
||||
end
|
||||
end
|
||||
local function getPref(pref)
|
||||
if(type(pref['handler']['GetPref']) == 'function') then
|
||||
-- print("use handler getpref", pref[#pref])
|
||||
|
@ -46,7 +51,11 @@ local function setPref(pref,value)
|
|||
if(type(pref['handler']['SetPref']) == 'function') then
|
||||
pref['handler']:SetPref(pref,value)
|
||||
else
|
||||
local oldvalue = pref['handler']['db']['profile'][pref[#pref-1]][pref[#pref]]
|
||||
pref['handler']['db']['profile'][pref[#pref-1]][pref[#pref]] = value
|
||||
if(value ~= oldvalue) then
|
||||
notify(pref, value, oldvalue)
|
||||
end
|
||||
end
|
||||
end
|
||||
function lib:AddLDBIconOptions(options, conf)
|
||||
|
@ -105,8 +114,8 @@ function lib:AddConfigEntry(options, ...)
|
|||
}
|
||||
end
|
||||
options['args'][input[1]] = menu
|
||||
return menu
|
||||
end
|
||||
return menu
|
||||
end
|
||||
function lib:AddConfigMenu(options, parentName, handler, order, more)
|
||||
local menu = {
|
||||
|
|
|
@ -15,25 +15,24 @@ function lib:GetLDB(objname)
|
|||
return ldb:GetDataObjectByName(objname)
|
||||
end
|
||||
function lib:AddLDB(objname, obj, db)
|
||||
local obj = obj or {}
|
||||
obj['type'] = obj['type'] or 'launcher'
|
||||
obj['text'] = obj['text'] or objname
|
||||
if(obj['type '] == 'launcher') then
|
||||
obj['OnClick'] = obj['OnClick'] or proto_OnClick
|
||||
end
|
||||
if(ldb) then
|
||||
local ldbobj = ldb:GetDataObjectByName(objname) or ldb:NewDataObject(objname, obj)
|
||||
if(ldbobj) then
|
||||
if(not ldbicon:IsRegistered(objname)) then
|
||||
db['global']['ldbicons'] = db['global']['ldbicons'] or {}
|
||||
local sb = db['global']['ldbicons']
|
||||
sb[objname] = sb[objname] or CopyTable(defaults)
|
||||
-- print('reg', objname)
|
||||
ldbicon:Register(objname, ldbobj, sb[objname])
|
||||
end
|
||||
local obj = obj or {}
|
||||
obj['type'] = obj['type'] or 'launcher'
|
||||
obj['text'] = obj['text'] or objname
|
||||
if(obj['type '] == 'launcher') then
|
||||
obj['OnClick'] = obj['OnClick'] or proto_OnClick
|
||||
end
|
||||
if(ldb) then
|
||||
local ldbobj = ldb:GetDataObjectByName(objname) or ldb:NewDataObject(objname, obj)
|
||||
if(ldbobj) then
|
||||
if(not ldbicon:IsRegistered(objname)) then
|
||||
db['global']['ldbicons'] = db['global']['ldbicons'] or {}
|
||||
local sb = db['global']['ldbicons']
|
||||
sb[objname] = sb[objname] or CopyTable(defaults)
|
||||
ldbicon:Register(objname, ldbobj, sb[objname])
|
||||
end
|
||||
return ldbobj
|
||||
end
|
||||
return ldbobj
|
||||
end
|
||||
end
|
||||
function lib:Embed(target)
|
||||
for _,name in pairs(mixins) do
|
||||
|
|
Loading…
Reference in New Issue