Advertisement
Guest User

Untitled

a guest
Nov 18th, 2013
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.83 KB | None | 0 0
  1. -- ===================================================================
  2. -- Initialization.
  3. -- ===================================================================
  4.     local _, AddonTable = ...
  5.  
  6. -- ===================================================================
  7. -- Functions.
  8. -- ===================================================================
  9.     -- This function sets common properties between all unit frames.
  10.     function AddonTable:SharedProperties(frame)
  11.         -- Exclude any frames that rely on SpawnHeader.
  12.         if (not frame.HeaderUnit) then
  13.             frame:SetSize(frame.width, frame.height)
  14.             frame:SetScale(AddonTable.Config.scale)
  15.         end
  16.  
  17.         frame:RegisterForClicks("AnyUp")
  18.         frame:SetScript("OnEnter", UnitFrame_OnEnter)
  19.         frame:SetScript("OnLeave", UnitFrame_OnLeave)
  20.     end
  21.  
  22.     -- This function is for generating the background of the unit frame.
  23.     function AddonTable:GenerateBackground(frame)
  24.         frame:SetBackdrop(AddonTable.Config.backdropTable)
  25.         frame:SetBackdropColor(0, 0, 0, 0.5)
  26.         frame:SetBackdropBorderColor(0, 0, 0, 1)
  27.     end
  28.  
  29.     -- This function is for generating the divider between the health and power bars.
  30.     function AddonTable:GenerateDivider(frame)
  31.         local divider = frame:CreateTexture()
  32.         divider:SetHeight(1)
  33.         divider:SetTexture(0, 0, 0, 1)
  34.  
  35.         divider:SetPoint("TOPRIGHT", frame.Health, "BOTTOMRIGHT", 0, 0)
  36.         divider:SetPoint("TOPLEFT", frame.Health, "BOTTOMLEFT", 0, 0)
  37.     end
  38.  
  39.     -- This function is for generating the health bar.
  40.     function AddonTable:GenerateHealthBar(frame)
  41.         local Health = CreateFrame("Statusbar", nil, frame)
  42.         Health:SetStatusBarTexture(AddonTable.Config.statusBarTexture)
  43.         Health:SetSize(frame.width - 2, frame.hpBarHeight)
  44.         Health:SetPoint("TOP", 0, -1)
  45.  
  46.         -- Options to use for all health bars.
  47.         Health.frequentUpdates = true
  48.  
  49.         -- Register with oUF.
  50.         frame.Health = Health
  51.     end
  52.  
  53.     -- This function is for generating the power bar.
  54.     function AddonTable:GeneratePowerBar(frame)
  55.         local Power = CreateFrame("Statusbar", nil, frame)
  56.         Power:SetStatusBarTexture(AddonTable.Config.statusBarTexture)
  57.         Power:SetSize(frame.width - 2, frame.powerBarHeight)
  58.         Power:SetPoint("BOTTOM", 0, 1)
  59.  
  60.         -- Options to use for all power bars.
  61.         Power.colorPower = true
  62.         Power.colorDisconnected = true
  63.         Power.frequentUpdates = true
  64.  
  65.         -- Register with oUF.
  66.         frame.Power = Power
  67.     end
  68.  
  69.     -- This function is for generating cast bars.
  70.     function AddonTable:GenerateCastBar(frame)
  71.         -- Create the cast bar status bar frame.
  72.         local Castbar = CreateFrame("Statusbar", nil, frame)
  73.         local backgroundHelper = CreateFrame("Frame", nil, Castbar)
  74.  
  75.         backgroundHelper:SetSize(frame.width, 17)
  76.         backgroundHelper:SetPoint("TOP", frame, "BOTTOM", 0, -1)
  77.         AddonTable:GenerateBackground(backgroundHelper)
  78.         backgroundHelper:SetFrameLevel(Castbar:GetFrameLevel() - 1)
  79.  
  80.         Castbar:SetPoint("TOPLEFT", backgroundHelper, 1, -1)
  81.         Castbar:SetPoint("BOTTOMRIGHT", backgroundHelper, -1, 1)
  82.         Castbar:SetStatusBarTexture(AddonTable.Config.statusBarTexture)
  83.         Castbar:SetStatusBarColor(0.4, 0.6, 0.8, 1)
  84.  
  85.         -- Add a timer.
  86.         local Time = Castbar:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
  87.         Time:SetPoint("RIGHT", Castbar, -3, 0)
  88.         Time:SetFont(AddonTable.Config.font, 11)
  89.  
  90.         -- Add spell text.
  91.         local Text = Castbar:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
  92.         Text:SetPoint("LEFT", Castbar, 3, 0)
  93.         Text:SetFont(AddonTable.Config.font, 11)
  94.  
  95.         -- Register the different components with oUF.
  96.         frame.Castbar      = Castbar
  97.         frame.Castbar.Time = Time
  98.         frame.Castbar.Text = Text
  99.     end
  100.  
  101.     -- This function manages unit frame border highlighting.
  102.     AddonTable.UnitFrameBorderHighlight = function(frame)
  103.         if (UnitThreatSituation(frame.unit) == 3) then
  104.             frame:SetBackdropBorderColor(1, 0, 0, 1)
  105.         elseif (UnitExists("target")) and (UnitIsUnit(frame.unit, "target")) then
  106.             frame:SetBackdropBorderColor(1, 1, 1, 1)
  107.         else
  108.             frame:SetBackdropBorderColor(0, 0, 0, 1)
  109.         end
  110.     end
  111.  
  112. -- ===================================================================
  113. -- Aura Functions.
  114. -- ===================================================================
  115.     -- This function is called after an aura is created.
  116.     local PostCreateIcon = function(frame, button)
  117.         button.overlay:SetTexture(AddonTable.Config.auraTexture)
  118.         button.overlay:SetTexCoord(0, 1, 0, 1)
  119.         button.overlay:ClearAllPoints()
  120.         button.overlay:SetPoint("TOPLEFT", -1, 1)
  121.         button.overlay:SetPoint("BOTTOMRIGHT", 1, -1)
  122.     end
  123.  
  124.     -- This function is called after an aura updates.
  125.     local PostUpdateIcon = function(frame, unit, button)
  126.         if button.cd:IsShown() then
  127.             button.overlay:SetParent(button.cd)
  128.         else
  129.             button.overlay:SetParent(button)
  130.         end
  131.     end
  132.  
  133.     -- This function is for generating auras.
  134.     function AddonTable:GenerateAuras(frame, auraType, auraSize, auraNum, auraSpacing, growthX, growthY, buffsPerRow, initialAnchor, ...)
  135.         local Auras = CreateFrame("Frame", nil, frame)
  136.         Auras.size          = auraSize
  137.         Auras.num           = auraNum
  138.         Auras.spacing       = auraSpacing
  139.         Auras.initialAnchor = initialAnchor
  140.         Auras["growth-x"]   = growthX
  141.         Auras["growth-y"]   = growthY
  142.  
  143.         Auras:SetWidth((auraSize + auraSpacing) * buffsPerRow)
  144.         Auras:SetHeight((auraSize + auraSpacing) * (auraNum / buffsPerRow))
  145.  
  146.         Auras:SetPoint(...)
  147.  
  148.         Auras.PostCreateIcon = PostCreateIcon
  149.         Auras.PostUpdateIcon = PostUpdateIcon
  150.  
  151.         -- Set auraType sensitive settings and register with oUF.
  152.         if (auraType == "buff") then
  153.             Auras.showBuffType = true
  154.             frame.Buffs = Auras
  155.         elseif (auraType == "debuff") then
  156.             Auras.showDebuffType = true
  157.             frame.Debuffs = Auras
  158.         end
  159.     end
  160.  
  161. -- ===================================================================
  162. -- Text Functions.
  163. -- ===================================================================
  164.     -- Name Text (Top-Left)
  165.     function AddonTable:GenerateNameText(frame)
  166.         local NameText = frame.Health:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
  167.         NameText:SetFont(AddonTable.Config.font, 11)
  168.         NameText:SetJustifyH("LEFT")
  169.         NameText:SetPoint("LEFT", 4, 0)
  170.  
  171.         frame:Tag(NameText, "[clam:name]")
  172.     end
  173.  
  174.     -- Health Text (Top-Right)
  175.     function AddonTable:GenerateHealthText(frame)
  176.         local HealthText = frame.Health:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
  177.         HealthText:SetFont(AddonTable.Config.font, 11)
  178.         HealthText:SetJustifyH("RIGHT")
  179.         HealthText:SetPoint("RIGHT", -3, 0)
  180.  
  181.         frame:Tag(HealthText, "[curhp]/[maxhp] | [perhp]%")
  182.     end
  183.  
  184.     -- Classification Text (Bottom-Left)
  185.     function AddonTable:GenerateClassificationText(frame)
  186.         local ClassificationText = frame.Power:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
  187.         ClassificationText:SetFont(AddonTable.Config.font, 11)
  188.         ClassificationText:SetJustifyH("LEFT")
  189.         ClassificationText:SetPoint("LEFT", 4, 0)
  190.  
  191.         frame:Tag(ClassificationText, "[smartlevel] [race] [raidcolor][smartclass]")
  192.     end
  193.  
  194.     -- Power Text (Bottom-Right)
  195.     function AddonTable:GeneratePowerText(frame)
  196.         local PowerText = frame.Power:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
  197.         PowerText:SetFont(AddonTable.Config.font, 11)
  198.         PowerText:SetJustifyH("RIGHT")
  199.         PowerText:SetPoint("RIGHT", -3, 0)
  200.  
  201.         frame:Tag(PowerText, "[curpp]/[maxpp] | [perpp]%")
  202.     end
  203.  
  204.     -- Deficit Text (Right)
  205.     function AddonTable:GenerateDeficitText(frame)
  206.         local DeficitText = frame.Health:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
  207.         DeficitText:SetFont(AddonTable.Config.font, 11)
  208.         DeficitText:SetJustifyH("RIGHT")
  209.         DeficitText:SetPoint("RIGHT", -3, 0)
  210.  
  211.         frame:Tag(DeficitText, "[clam:deficit]")
  212.     end
  213.  
  214.     -- Raid Deficit Text
  215.     function AddonTable:GenerateRaidText(frame)
  216.         local RaidDeficitText = frame.Health:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
  217.         RaidDeficitText:SetFont(AddonTable.Config.font, 11)
  218.         RaidDeficitText:SetJustifyH("CENTER")
  219.         RaidDeficitText:SetPoint("CENTER", 0, 0)
  220.  
  221.         frame:Tag(RaidDeficitText, "[clam:role][clam:raid]")
  222.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement