Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ===================================================================
- -- Initialization.
- -- ===================================================================
- local _, AddonTable = ...
- -- ===================================================================
- -- Functions.
- -- ===================================================================
- -- This function sets common properties between all unit frames.
- function AddonTable:SharedProperties(frame)
- -- Exclude any frames that rely on SpawnHeader.
- if (not frame.HeaderUnit) then
- frame:SetSize(frame.width, frame.height)
- frame:SetScale(AddonTable.Config.scale)
- end
- frame:RegisterForClicks("AnyUp")
- frame:SetScript("OnEnter", UnitFrame_OnEnter)
- frame:SetScript("OnLeave", UnitFrame_OnLeave)
- end
- -- This function is for generating the background of the unit frame.
- function AddonTable:GenerateBackground(frame)
- frame:SetBackdrop(AddonTable.Config.backdropTable)
- frame:SetBackdropColor(0, 0, 0, 0.5)
- frame:SetBackdropBorderColor(0, 0, 0, 1)
- end
- -- This function is for generating the divider between the health and power bars.
- function AddonTable:GenerateDivider(frame)
- local divider = frame:CreateTexture()
- divider:SetHeight(1)
- divider:SetTexture(0, 0, 0, 1)
- divider:SetPoint("TOPRIGHT", frame.Health, "BOTTOMRIGHT", 0, 0)
- divider:SetPoint("TOPLEFT", frame.Health, "BOTTOMLEFT", 0, 0)
- end
- -- This function is for generating the health bar.
- function AddonTable:GenerateHealthBar(frame)
- local Health = CreateFrame("Statusbar", nil, frame)
- Health:SetStatusBarTexture(AddonTable.Config.statusBarTexture)
- Health:SetSize(frame.width - 2, frame.hpBarHeight)
- Health:SetPoint("TOP", 0, -1)
- -- Options to use for all health bars.
- Health.frequentUpdates = true
- -- Register with oUF.
- frame.Health = Health
- end
- -- This function is for generating the power bar.
- function AddonTable:GeneratePowerBar(frame)
- local Power = CreateFrame("Statusbar", nil, frame)
- Power:SetStatusBarTexture(AddonTable.Config.statusBarTexture)
- Power:SetSize(frame.width - 2, frame.powerBarHeight)
- Power:SetPoint("BOTTOM", 0, 1)
- -- Options to use for all power bars.
- Power.colorPower = true
- Power.colorDisconnected = true
- Power.frequentUpdates = true
- -- Register with oUF.
- frame.Power = Power
- end
- -- This function is for generating cast bars.
- function AddonTable:GenerateCastBar(frame)
- -- Create the cast bar status bar frame.
- local Castbar = CreateFrame("Statusbar", nil, frame)
- local backgroundHelper = CreateFrame("Frame", nil, Castbar)
- backgroundHelper:SetSize(frame.width, 17)
- backgroundHelper:SetPoint("TOP", frame, "BOTTOM", 0, -1)
- AddonTable:GenerateBackground(backgroundHelper)
- backgroundHelper:SetFrameLevel(Castbar:GetFrameLevel() - 1)
- Castbar:SetPoint("TOPLEFT", backgroundHelper, 1, -1)
- Castbar:SetPoint("BOTTOMRIGHT", backgroundHelper, -1, 1)
- Castbar:SetStatusBarTexture(AddonTable.Config.statusBarTexture)
- Castbar:SetStatusBarColor(0.4, 0.6, 0.8, 1)
- -- Add a timer.
- local Time = Castbar:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
- Time:SetPoint("RIGHT", Castbar, -3, 0)
- Time:SetFont(AddonTable.Config.font, 11)
- -- Add spell text.
- local Text = Castbar:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
- Text:SetPoint("LEFT", Castbar, 3, 0)
- Text:SetFont(AddonTable.Config.font, 11)
- -- Register the different components with oUF.
- frame.Castbar = Castbar
- frame.Castbar.Time = Time
- frame.Castbar.Text = Text
- end
- -- This function manages unit frame border highlighting.
- AddonTable.UnitFrameBorderHighlight = function(frame)
- if (UnitThreatSituation(frame.unit) == 3) then
- frame:SetBackdropBorderColor(1, 0, 0, 1)
- elseif (UnitExists("target")) and (UnitIsUnit(frame.unit, "target")) then
- frame:SetBackdropBorderColor(1, 1, 1, 1)
- else
- frame:SetBackdropBorderColor(0, 0, 0, 1)
- end
- end
- -- ===================================================================
- -- Aura Functions.
- -- ===================================================================
- -- This function is called after an aura is created.
- local PostCreateIcon = function(frame, button)
- button.overlay:SetTexture(AddonTable.Config.auraTexture)
- button.overlay:SetTexCoord(0, 1, 0, 1)
- button.overlay:ClearAllPoints()
- button.overlay:SetPoint("TOPLEFT", -1, 1)
- button.overlay:SetPoint("BOTTOMRIGHT", 1, -1)
- end
- -- This function is called after an aura updates.
- local PostUpdateIcon = function(frame, unit, button)
- if button.cd:IsShown() then
- button.overlay:SetParent(button.cd)
- else
- button.overlay:SetParent(button)
- end
- end
- -- This function is for generating auras.
- function AddonTable:GenerateAuras(frame, auraType, auraSize, auraNum, auraSpacing, growthX, growthY, buffsPerRow, initialAnchor, ...)
- local Auras = CreateFrame("Frame", nil, frame)
- Auras.size = auraSize
- Auras.num = auraNum
- Auras.spacing = auraSpacing
- Auras.initialAnchor = initialAnchor
- Auras["growth-x"] = growthX
- Auras["growth-y"] = growthY
- Auras:SetWidth((auraSize + auraSpacing) * buffsPerRow)
- Auras:SetHeight((auraSize + auraSpacing) * (auraNum / buffsPerRow))
- Auras:SetPoint(...)
- Auras.PostCreateIcon = PostCreateIcon
- Auras.PostUpdateIcon = PostUpdateIcon
- -- Set auraType sensitive settings and register with oUF.
- if (auraType == "buff") then
- Auras.showBuffType = true
- frame.Buffs = Auras
- elseif (auraType == "debuff") then
- Auras.showDebuffType = true
- frame.Debuffs = Auras
- end
- end
- -- ===================================================================
- -- Text Functions.
- -- ===================================================================
- -- Name Text (Top-Left)
- function AddonTable:GenerateNameText(frame)
- local NameText = frame.Health:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
- NameText:SetFont(AddonTable.Config.font, 11)
- NameText:SetJustifyH("LEFT")
- NameText:SetPoint("LEFT", 4, 0)
- frame:Tag(NameText, "[clam:name]")
- end
- -- Health Text (Top-Right)
- function AddonTable:GenerateHealthText(frame)
- local HealthText = frame.Health:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
- HealthText:SetFont(AddonTable.Config.font, 11)
- HealthText:SetJustifyH("RIGHT")
- HealthText:SetPoint("RIGHT", -3, 0)
- frame:Tag(HealthText, "[curhp]/[maxhp] | [perhp]%")
- end
- -- Classification Text (Bottom-Left)
- function AddonTable:GenerateClassificationText(frame)
- local ClassificationText = frame.Power:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
- ClassificationText:SetFont(AddonTable.Config.font, 11)
- ClassificationText:SetJustifyH("LEFT")
- ClassificationText:SetPoint("LEFT", 4, 0)
- frame:Tag(ClassificationText, "[smartlevel] [race] [raidcolor][smartclass]")
- end
- -- Power Text (Bottom-Right)
- function AddonTable:GeneratePowerText(frame)
- local PowerText = frame.Power:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
- PowerText:SetFont(AddonTable.Config.font, 11)
- PowerText:SetJustifyH("RIGHT")
- PowerText:SetPoint("RIGHT", -3, 0)
- frame:Tag(PowerText, "[curpp]/[maxpp] | [perpp]%")
- end
- -- Deficit Text (Right)
- function AddonTable:GenerateDeficitText(frame)
- local DeficitText = frame.Health:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
- DeficitText:SetFont(AddonTable.Config.font, 11)
- DeficitText:SetJustifyH("RIGHT")
- DeficitText:SetPoint("RIGHT", -3, 0)
- frame:Tag(DeficitText, "[clam:deficit]")
- end
- -- Raid Deficit Text
- function AddonTable:GenerateRaidText(frame)
- local RaidDeficitText = frame.Health:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
- RaidDeficitText:SetFont(AddonTable.Config.font, 11)
- RaidDeficitText:SetJustifyH("CENTER")
- RaidDeficitText:SetPoint("CENTER", 0, 0)
- frame:Tag(RaidDeficitText, "[clam:role][clam:raid]")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement