diff --git a/scripts/cp_broker.sh b/scripts/cp_broker.sh index 6202add..255f8f0 100755 --- a/scripts/cp_broker.sh +++ b/scripts/cp_broker.sh @@ -3,4 +3,5 @@ declare -a StringArray=("zz_Bags" "zz_Coords" "zz_Friends" "zz_Infoclock" "zz_Ma for val in "${StringArray[@]}"; do echo $val cp -vra ../$val . -done \ No newline at end of file +done +cp -vra Libs zz_Skeleton \ No newline at end of file diff --git a/zz_Skeleton/Libs/zzAddOn/zzAddOn.lua b/zz_Skeleton/Libs/zzAddOn/zzAddOn.lua index 7d1c54a..1604720 100644 --- a/zz_Skeleton/Libs/zzAddOn/zzAddOn.lua +++ b/zz_Skeleton/Libs/zzAddOn/zzAddOn.lua @@ -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