Update Libs
parent
ccc1969e57
commit
3c142c4e08
|
@ -1,4 +1,4 @@
|
|||
local lib = LibStub:NewLibrary("zzAddOn", 7)
|
||||
local lib = LibStub:NewLibrary("zzAddOn", 8)
|
||||
if not lib then return end
|
||||
local config = LibStub:GetLibrary("zzConfig")
|
||||
lib['callbacks'] = lib['callbacks'] or LibStub:GetLibrary("CallbackHandler-1.0"):New(lib)
|
||||
|
@ -42,12 +42,23 @@ local function joinTables(tab1, tab2, prefix)
|
|||
end
|
||||
end
|
||||
end
|
||||
function lib:AddChild(child)
|
||||
child['parent'] = self
|
||||
self['children'] = self['children'] or {}
|
||||
self['children'][#self['children'] + 1] = child
|
||||
if(child['specs']['defaults']) then
|
||||
joinTables(self['specs']['defaults'], child['specs']['defaults'])
|
||||
local function childExists(parent, child)
|
||||
if(parent['children']) then
|
||||
for i = 1, #parent['children'] do
|
||||
if(parent['children'][i]['specs']['name'] == child['specs']['name']) then return true end
|
||||
end
|
||||
end
|
||||
end
|
||||
function lib:AddChild(parentName, child)
|
||||
local parent = self:GetAddOn(parentName)
|
||||
if(parent) then
|
||||
parent['children'] = parent['children'] or {}
|
||||
if(childExists(parent, child)) then return end
|
||||
child['parent'] = parent
|
||||
parent['children'][#parent['children'] + 1] = child
|
||||
if(child['specs']['defaults']) then
|
||||
joinTables(parent['specs']['defaults'], child['specs']['defaults'])
|
||||
end
|
||||
end
|
||||
end
|
||||
function lib:RegisterEvent(event, globalfunc)
|
||||
|
@ -88,23 +99,14 @@ end
|
|||
function lib:NewAddOn(addonName, addonTable)
|
||||
local specs = self['specs']
|
||||
local childName = specs['name']
|
||||
--[[ if(lib['addons'][childName]) then
|
||||
local oldchild = lib['addons'][childName]
|
||||
local parent = oldchild:GetParent()
|
||||
if(parent) then
|
||||
errormsg(format("%s already loaded by %s", childName, parent['specs']['name']))
|
||||
else
|
||||
errormsg(format("|%s already loaded", childName))
|
||||
end
|
||||
return
|
||||
end ]]
|
||||
if(type(childName) == 'string') then
|
||||
self.GetAddOnTable = function() return addonTable end
|
||||
lib['addons'][childName] = self
|
||||
local child = lib['addons'][childName]
|
||||
lib:Embed(self)
|
||||
if(childName ~= addonName) then
|
||||
local parent = lib['addons'][addonName]
|
||||
parent:AddChild(self)
|
||||
parent:AddChild(parent['specs']['name'], self)
|
||||
end
|
||||
if(self['events']) then
|
||||
for ev, func in pairs(self['events']) do
|
||||
|
|
Loading…
Reference in New Issue