View Single Post
11-30-15, 01:07 PM   #11
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
I have tried to do the seperate header thing, however the header is still filling the empty spaces in the groups for some reason:



Here is my full work in progress code:

Lua Code:
  1. local Raid = { }
  2.  
  3. local roleColors = {
  4.     TANK    = {0.2, 0.2, 0.8},
  5.     HEALER  = {0, 0.7, 0},
  6.     DAMAGER = {0.7, 0, 0},
  7.     NONE    = {0.7, 0.7, 0.7},
  8. }
  9.  
  10. local function CreateUnitFrame(header, frameName)
  11.     local frame = _G[frameName]
  12.  
  13.     frame:RegisterForClicks("AnyUp")
  14.  
  15.     frame.bg = frame.bg or frame:CreateTexture(nil, "BACKGROUND")
  16.     frame.bg:SetAllPoints()
  17.     frame.role = frame.role or frame:CreateTexture()
  18.     frame.role:SetSize(8, 8)
  19.     frame.role:SetPoint("TOPLEFT")
  20.  
  21.     frame:SetScript("OnAttributeChanged", function(self, name, value)
  22.         if name == "unit" then
  23.             if value then
  24.                 Raid:UpdateDisplay(self)
  25.             end
  26.         end
  27.     end)
  28.  
  29.     --[[frame:SetScript("OnEvent", function(self)
  30.        
  31.     end)]]
  32.  
  33.     frame:SetScript("OnEnter", function(self)
  34.         GameTooltip:SetOwner(self, "ANCHOR_LEFT")
  35.         if self.unit then
  36.             GameTooltip_SetDefaultAnchor(GameTooltip, UIParent)
  37.             GameTooltip:SetUnit(self.unit)
  38.             if UnitIsPlayer(self.unit) then
  39.                 local class, classFileName = UnitClass(self.unit)
  40.                 local color = RAID_CLASS_COLORS[classFileName]
  41.                 GameTooltipTextLeft1:SetTextColor(color.r, color.g, color.b, 1)
  42.             else
  43.                 local r, g, b, a = UnitSelectionColor(unit)
  44.                 GameTooltipTextLeft1:SetTextColor(r, g, b, 1)
  45.             end
  46.             GameTooltip:Show()
  47.         end
  48.     end)
  49.     frame:SetScript("OnLeave", GameTooltip_Hide)
  50.  
  51.     --[[frame:HookScript("OnShow", function(self)
  52.        
  53.     end)
  54.     frame:HookScript("OnHide", function(self)
  55.        
  56.     end)]]
  57.  
  58.     return frame
  59. end
  60.  
  61. function Raid:OnLoad()
  62.     self.events = CreateFrame("Frame")
  63.     self.events:SetScript("OnEvent", function(self, event, ...)
  64.         --print(event, ...)
  65.         Raid[event](Raid, ...)
  66.     end)
  67.  
  68.     --[[self.update = CreateFrame("Frame")
  69.     self.update:SetScript("OnUpdate", function(self, elapsed)
  70.         Raid:OnUpdate(self, elapsed)
  71.     end)]]
  72.  
  73.     self.headers = { }
  74.  
  75.     local start = 1
  76.     for i = 1, 8 do
  77.         self.headers[i] = CreateFrame("Frame", "ZPerl2RaidGroup"..i, UIParent, "SecureRaidGroupHeaderTemplate")
  78.         if i == 1 then
  79.             self.headers[i]:SetPoint("Left", UIParent, "Left", 20, 0)
  80.         else
  81.             self.headers[i]:SetPoint("TopLeft", self.headers[i - 1], "TopRight", 0, 0)
  82.         end
  83.  
  84.         self.headers[i]:SetAttribute("showRaid", true)
  85.         if i == 1 then
  86.             self.headers[i]:SetAttribute("showParty", true)
  87.             self.headers[i]:SetAttribute("showPlayer", true)
  88.         end
  89.         --self.headers[i]:SetAttribute("useparent-unit", true)
  90.         --self.headers[i]:SetAttribute("strictFiltering", nil)
  91.         self.headers[i]:SetAttribute("startingIndex", start)
  92.         self.headers[i]:SetAttribute("maxColumns", 1)
  93.         self.headers[i]:SetAttribute("unitsPerColumn", 5)
  94.  
  95.         self.headers[i]:SetAttribute("sortMethod", nil)
  96.  
  97.         self.headers[i]:SetAttribute("minWidth", 0)
  98.         self.headers[i]:SetAttribute("minHeight", 0)
  99.  
  100.         self.headers[i]:SetAttribute("xOffset", 0)
  101.         self.headers[i]:SetAttribute("yOffset", 0)
  102.         self.headers[i]:SetAttribute("point", "TOP")
  103.  
  104.         self.headers[i]:SetAttribute("columnSpacing", 1)
  105.         self.headers[i]:SetAttribute("columnAnchorPoint", "LEFT")
  106.  
  107.         --self.headers[i]:SetAttribute("groupBy", "ASSIGNEDROLE")
  108.         --self.headers[i]:SetAttribute("groupingOrder", "TANK,HEALER,DAMAGER,NONE")
  109.         self.headers[i]:SetAttribute("groupBy", "GROUP")
  110.         self.headers[i]:SetAttribute("groupingOrder", "1,2,3,4,5,6,7,8")
  111.  
  112.         self.headers[i]:SetAttribute("template", "SecureUnitButtonTemplate")
  113.  
  114.         self.headers[i]:SetAttribute("initial-unitWatch", true)
  115.  
  116.         self.headers[i]:SetAttribute("style-width", 50)
  117.         self.headers[i]:SetAttribute("style-height", 25)
  118.         self.headers[i]:SetAttribute("style-scale", 1)
  119.  
  120.         self.headers[i]:SetID(i)
  121.  
  122.         self.headers[i]:SetAttribute("initialConfigFunction", [[
  123.             local header = self:GetParent()
  124.  
  125.             self:SetHeight(header:GetAttribute("style-height"))
  126.             self:SetWidth(header:GetAttribute("style-width"))
  127.             self:SetScale(header:GetAttribute("style-scale"))
  128.  
  129.             self:SetAttribute("maxColumns", 1)
  130.             self:SetAttribute("unitsPerColumn", 5)
  131.             self:SetAttribute("toggleForVehicle", true)
  132.  
  133.             self:SetAttribute("*type1", "target")
  134.             self:SetAttribute("type2", "togglemenu")
  135.  
  136.             self:SetAttribute("isHeaderDriven", true)
  137.  
  138.             header:CallMethod("initialConfigFunction", self:GetName())
  139.         ]])
  140.  
  141.         self.headers[i].initialConfigFunction = CreateUnitFrame
  142.  
  143.         self.headers[i]:Show()
  144.  
  145.         start = start + 5
  146.     end
  147.  
  148.     self:RegisterEvents()
  149. end
  150.  
  151. function Raid:RegisterEvents()
  152.     local events = {
  153.         "PLAYER_ENTERING_WORLD",
  154.         --"GROUP_ROSTER_UPDATE",
  155.         "ROLE_CHANGED_INFORM",
  156.     }
  157.  
  158.     for i = 1, #events do
  159.         local event = events[i]
  160.         self.events:RegisterEvent(event)
  161.     end
  162. end
  163.  
  164. function Raid:PLAYER_ENTERING_WORLD()
  165.     self:UpdateDisplayAll()
  166. end
  167.  
  168. function Raid:GROUP_ROSTER_UPDATE()
  169.     self:UpdateDisplayAll()
  170. end
  171.  
  172. function Raid:GUILD_PARTY_STATE_UPDATED()
  173.     self:UpdateDisplayAll()
  174. end
  175.  
  176. function Raid:ROLE_CHANGED_INFORM()
  177.     self:UpdateDisplayAll()
  178. end
  179.  
  180. function Raid:UpdateDisplay(frame)
  181.     local unit = frame:GetAttribute("unit")
  182.     if unit then
  183.         local guid = UnitGUID(unit)
  184.         --if guid ~= frame.guid then
  185.             frame.unit = unit
  186.             frame.guid = guid
  187.             if unit then
  188.                 local _, class = UnitClass(unit)
  189.                 local classColor = RAID_CLASS_COLORS[class]
  190.                 if classColor then
  191.                     frame.bg:SetTexture(classColor.r, classColor.g, classColor.b)
  192.                 end
  193.                 frame.role:SetTexture(unpack(roleColors[UnitGroupRolesAssigned(unit)]))
  194.             end
  195.         --end
  196.     end
  197. end
  198.  
  199. function Raid:UpdateDisplayAll()
  200.     for i = 1, 8 do
  201.         for _, frame in ipairs(self.headers[i]) do
  202.         --for j = 1, 5 do
  203.             --local frame = self.headers[i]:GetAttribute("child"..j)
  204.             if frame then
  205.                 local unit = frame:GetAttribute("unit")
  206.                 frame.unit = unit
  207.                 --local guid = UnitGUID(unit)
  208.                 --frame.guid = guid
  209.                 if unit then
  210.                     local _, class = UnitClass(unit)
  211.                     local classColor = RAID_CLASS_COLORS[class]
  212.                     if classColor then
  213.                         frame.bg:SetTexture(classColor.r, classColor.g, classColor.b)
  214.                     end
  215.                     frame.role:SetTexture(unpack(roleColors[UnitGroupRolesAssigned(unit)]))
  216.                 end
  217.             end
  218.         end
  219.     end
  220. end
  221.  
  222. Raid:OnLoad()

Last edited by Resike : 11-30-15 at 01:10 PM.
  Reply With Quote