Quantcast

party fix

Steven Jackson [09-14-14 - 00:30]
party fix
Filename
Interface/AddOns/SVUI/packages/unit/SVUnit.lua
Interface/AddOns/SVUI/packages/unit/frames.lua
diff --git a/Interface/AddOns/SVUI/packages/unit/SVUnit.lua b/Interface/AddOns/SVUI/packages/unit/SVUnit.lua
index 3ee1ed4..04c9b48 100644
--- a/Interface/AddOns/SVUI/packages/unit/SVUnit.lua
+++ b/Interface/AddOns/SVUI/packages/unit/SVUnit.lua
@@ -1291,7 +1291,10 @@ function MOD:UpdateGroupConfig(headerFrame, setForced)
 			definedEnvs[func] = nil
 		end
 		RegisterStateDriver(headerFrame, "visibility", db.visibility)
-		headerFrame:GetScript("OnEvent")(headerFrame, "PLAYER_ENTERING_WORLD")
+		local eventScript = headerFrame:GetScript("OnEvent")
+		if eventScript then
+			eventScript(headerFrame, "PLAYER_ENTERING_WORLD")
+		end
 	end

 	for i = 1, #headerFrame.groups do
diff --git a/Interface/AddOns/SVUI/packages/unit/frames.lua b/Interface/AddOns/SVUI/packages/unit/frames.lua
index 970a268..f90b17c 100644
--- a/Interface/AddOns/SVUI/packages/unit/frames.lua
+++ b/Interface/AddOns/SVUI/packages/unit/frames.lua
@@ -42,7 +42,7 @@ local ceil,tinsert = math.ceil,table.insert
 LOCAL DATA
 ##########################################################
 ]]--
-local CONSTRUCTORS = {}
+local CONSTRUCTORS, GROUP_UPDATES = {}, {}
 local lastArenaFrame, lastBossFrame
 local sortMapping = {
     ["DOWN_RIGHT"] = {[1]="TOP",[2]="TOPLEFT",[3]="LEFT",[4]="RIGHT",[5]="LEFT",[6]=1,[7]=-1,[8]=false},
@@ -1203,7 +1203,7 @@ local UpdateRaidSubUnit = function(self, key, db)
     self:UpdateAllElements()
 end

-local Raid10Update = function(self)
+GROUP_UPDATES["raid10"] = function(self)
     local frame = self:GetParent()
     if not frame.positioned then
         frame:ClearAllPoints()
@@ -1232,7 +1232,7 @@ local Raid10Update = function(self)
     end
 end

-local Raid25Update = function(self)
+GROUP_UPDATES["raid25"] = function(self)
     local frame = self:GetParent()
     if not frame.positioned then
         frame:ClearAllPoints()
@@ -1261,7 +1261,7 @@ local Raid25Update = function(self)
     end
 end

-local Raid40Update = function(self)
+GROUP_UPDATES["raid40"] = function(self)
     local frame = self:GetParent()
     if not frame.positioned then
         frame:ClearAllPoints()
@@ -1340,7 +1340,6 @@ CONSTRUCTORS["raid10"] = function(self, unit)
     self.Buffs = MOD:CreateBuffs(self, key)
     self.Debuffs = MOD:CreateDebuffs(self, key)
     self.AuraWatch = MOD:CreateAuraWatch(self, key)
-    self.GroupUpdate = Raid10Update
     return SetRaidFrame(self)
 end

@@ -1355,7 +1354,6 @@ CONSTRUCTORS["raid25"] = function(self, unit)
     self.Buffs = MOD:CreateBuffs(self, key)
     self.Debuffs = MOD:CreateDebuffs(self, key)
     self.AuraWatch = MOD:CreateAuraWatch(self, key)
-    self.GroupUpdate = Raid25Update
     return SetRaidFrame(self)
 end

@@ -1370,7 +1368,6 @@ CONSTRUCTORS["raid40"] = function(self, unit)
     self.Buffs = MOD:CreateBuffs(self, key)
     self.Debuffs = MOD:CreateDebuffs(self, key)
     self.AuraWatch = MOD:CreateAuraWatch(self, key)
-    self.GroupUpdate = Raid40Update
     return SetRaidFrame(self)
 end
 --[[
@@ -1397,7 +1394,7 @@ local RaidPetVisibility = function(self, event)
     end
 end

-local UpdateRaidPetFrame = function(self)
+GROUP_UPDATES["raidpet"] = function(self)
     local raidPets = self:GetParent()
     if not raidPets.positioned then
         raidPets:ClearAllPoints()
@@ -1461,8 +1458,6 @@ CONSTRUCTORS["raidpet"] = function(self, unit)
     self.TargetGlow = shadow
     tinsert(self.__elements, UpdateTargetGlow)

-    self.GroupUpdate = UpdateRaidPetFrame
-
     self:RegisterEvent("PLAYER_TARGET_CHANGED", UpdateTargetGlow)
     self:RegisterEvent("PLAYER_ENTERING_WORLD", UpdateTargetGlow)
     return self
@@ -1543,7 +1538,7 @@ local UpdatePartySubUnit = function(self, key, db)
     self:UpdateAllElements()
 end

-local UpdatePartyFrame = function(self)
+GROUP_UPDATES["party"] = function(self)
     local group = self:GetParent()
     if not group.positioned then
         group:ClearAllPoints()
@@ -1559,6 +1554,7 @@ local UpdatePartyFrame = function(self)
     local db = MOD.db[key]
     local index = 1;
     local childFrame = self:GetAttribute("child"..index)
+
     while childFrame do
         UpdatePartySubUnit(childFrame, key, db)
         if(_G[childFrame:GetName().."Pet"]) then
@@ -1624,8 +1620,6 @@ CONSTRUCTORS["party"] = function(self, unit)
         self:RegisterEvent("GROUP_ROSTER_UPDATE", UpdateTargetGlow)
     end

-    self.GroupUpdate = UpdatePartyFrame
-
     self.Range = { insideAlpha = 1, outsideAlpha = 1 }
     return self
 end
@@ -2003,11 +1997,9 @@ local SecureHeaderClear = function(self)
     self:SetAttribute("yOffset", nil)
 end

-local function ConstructGroupHeader(parentFrame, filter, styleName, headerName, template1, groupName, template2, updateFunc)
-    local db = MOD.db[groupName]
-    local UNIT_WIDTH, UNIT_HEIGHT = MOD:GetActiveSize(db)
-
-    updateFunc = updateFunc or parentFrame.GroupUpdate or SV.fubar
+function MOD:ConstructGroupHeader(parentFrame, filter, styleName, headerName, template1, groupName, template2, updateFunc)
+    local db = self.db[groupName]
+    local UNIT_WIDTH, UNIT_HEIGHT = self:GetActiveSize(db)

     oUF_Villain:SetActiveStyle(styleName)
     local groupHeader = oUF_Villain:SpawnHeader(headerName, template2, nil,
@@ -2022,7 +2014,7 @@ local function ConstructGroupHeader(parentFrame, filter, styleName, headerName,
     groupHeader:SetParent(parentFrame)
     groupHeader:Show()

-    groupHeader.Update = updateFunc
+    groupHeader.Update = updateFunc or GROUP_UPDATES[groupName]
     groupHeader.MediaUpdate = GroupMediaUpdate
     groupHeader.ClearAllAttributes = SecureHeaderClear

@@ -2040,14 +2032,15 @@ function MOD:SetGroupFrame(key, filter, template1, forceUpdate, template2)
     local realName = key:gsub("(.)", upper, 1)
     local styleName = "SVUI_"..realName
     local frame, groupName
+
     if(not self.Headers[key]) then
         oUF_Villain:RegisterStyle(styleName, CONSTRUCTORS[key])
         oUF_Villain:SetActiveStyle(styleName)

         if(key == "tank") then
-            frame = ConstructGroupHeader(SVUI_UnitFrameParent, filter, styleName, styleName, template1, key, template2, UpdateTankFrame)
+            frame = self:ConstructGroupHeader(SVUI_UnitFrameParent, filter, styleName, styleName, template1, key, template2, UpdateTankFrame)
         elseif(key == "assist") then
-            frame = ConstructGroupHeader(SVUI_UnitFrameParent, filter, styleName, styleName, template1, key, template2, UpdateAssistFrame)
+            frame = self:ConstructGroupHeader(SVUI_UnitFrameParent, filter, styleName, styleName, template1, key, template2, UpdateAssistFrame)
         else
             frame = CreateFrame("Frame", styleName, SVUI_UnitFrameParent, "SecureHandlerStateTemplate")
             frame.groups = {}
@@ -2075,14 +2068,14 @@ function MOD:SetGroupFrame(key, filter, template1, forceUpdate, template2)
         if(db.customSorting) then
             if(not frame.groups[1]) then
                 groupName = styleName .. "Group1"
-                local subunit = ConstructGroupHeader(frame, 1, styleName, groupName, template1, key, template2)
+                local subunit = self:ConstructGroupHeader(frame, 1, styleName, groupName, template1, key, template2)
                 frame.groups[1] = subunit
             end
         else
             for i = 1, db.groupCount do
                 if(not frame.groups[i]) then
                     groupName = styleName .. "Group" .. i
-                    local subunit = ConstructGroupHeader(frame, i, styleName, groupName, template1, key, template2)
+                    local subunit = self:ConstructGroupHeader(frame, i, styleName, groupName, template1, key, template2)
                     frame.groups[i] = subunit
                 end
             end