Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local T, C, L, _ = unpack(select(2, ...))
- ----------------------------------------------------------------------------------------
- -- Number value function
- ----------------------------------------------------------------------------------------
- T.Round = function(number, decimals)
- if not decimals then decimals = 0 end
- return (("%%.%df"):format(decimals)):format(number)
- end
- T.ShortValue = function(value)
- if value >= 1e8 then
- return ("%.0fm"):format(value / 1e6)
- elseif value >= 1e7 then
- return ("%.1fm"):format(value / 1e6):gsub("%.?0+([km])$", "%1")
- elseif value >= 1e6 then
- return ("%.2fm"):format(value / 1e6):gsub("%.?0+([km])$", "%1")
- elseif value >= 1e5 then
- return ("%.0fk"):format(value / 1e3)
- elseif value >= 1e3 then
- return ("%.1fk"):format(value / 1e3):gsub("%.?0+([km])$", "%1")
- else
- return value
- end
- end
- T.RGBToHex = function(r, g, b)
- r = tonumber(r) <= 1 and tonumber(r) >= 0 and tonumber(r) or 0
- g = tonumber(g) <= tonumber(g) and tonumber(g) >= 0 and tonumber(g) or 0
- b = tonumber(b) <= 1 and tonumber(b) >= 0 and tonumber(b) or 0
- return string.format("|cff%02x%02x%02x", r * 255, g * 255, b * 255)
- end
- ----------------------------------------------------------------------------------------
- -- Chat channel check
- ----------------------------------------------------------------------------------------
- T.CheckChat = function(warning)
- if IsInGroup(LE_PARTY_CATEGORY_INSTANCE) then
- return "INSTANCE_CHAT"
- elseif IsInRaid(LE_PARTY_CATEGORY_HOME) then
- if warning and (UnitIsGroupLeader("player") or UnitIsGroupAssistant("player") or IsEveryoneAssistant()) then
- return "RAID_WARNING"
- else
- return "RAID"
- end
- elseif IsInGroup(LE_PARTY_CATEGORY_HOME) then
- return "PARTY"
- end
- return "SAY"
- end
- ----------------------------------------------------------------------------------------
- -- Player's Role and Specialization check
- ----------------------------------------------------------------------------------------
- T.CheckSpec = function(spec)
- local activeGroup = GetActiveSpecGroup()
- if activeGroup and GetSpecialization(false, false, activeGroup) then
- return spec == GetSpecialization(false, false, activeGroup)
- end
- end
- local isCaster = {
- DEATHKNIGHT = {nil, nil, nil},
- DEMONHUNTER = {nil, nil},
- DRUID = {true}, -- Balance
- HUNTER = {nil, nil, nil},
- MAGE = {true, true, true},
- MONK = {nil, nil, nil},
- PALADIN = {nil, nil, nil},
- PRIEST = {nil, nil, true}, -- Shadow
- ROGUE = {nil, nil, nil},
- SHAMAN = {true}, -- Elemental
- WARLOCK = {true, true, true},
- WARRIOR = {nil, nil, nil}
- }
- local function CheckRole(self, event, unit)
- local spec = GetSpecialization()
- local role = spec and GetSpecializationRole(spec)
- if role == "TANK" then
- T.Role = "Tank"
- elseif role == "HEALER" then
- T.Role = "Healer"
- elseif role == "DAMAGER" then
- if isCaster[T.class][spec] then
- T.Role = "Caster"
- else
- T.Role = "Melee"
- end
- end
- end
- local RoleUpdater = CreateFrame("Frame")
- RoleUpdater:RegisterEvent("PLAYER_ENTERING_WORLD")
- RoleUpdater:RegisterEvent("PLAYER_TALENT_UPDATE")
- RoleUpdater:SetScript("OnEvent", CheckRole)
- ----------------------------------------------------------------------------------------
- -- UTF functions
- ----------------------------------------------------------------------------------------
- T.UTF = function(string, i, dots)
- if not string then return end
- local bytes = string:len()
- if bytes <= i then
- return string
- else
- local len, pos = 0, 1
- while (pos <= bytes) do
- len = len + 1
- local c = string:byte(pos)
- if c > 0 and c <= 127 then
- pos = pos + 1
- elseif c >= 192 and c <= 223 then
- pos = pos + 2
- elseif c >= 224 and c <= 239 then
- pos = pos + 3
- elseif c >= 240 and c <= 247 then
- pos = pos + 4
- end
- if len == i then break end
- end
- if len == i and pos <= bytes then
- return string:sub(1, pos - 1)..(dots and "..." or "")
- else
- return string
- end
- end
- end
- ----------------------------------------------------------------------------------------
- -- Style functions
- ----------------------------------------------------------------------------------------
- T.SkinFuncs = {}
- T.SkinFuncs["ShestakUI"] = {}
- function T.SkinScrollBar(frame)
- if _G[frame:GetName().."BG"] then
- _G[frame:GetName().."BG"]:SetTexture(nil)
- end
- if _G[frame:GetName().."Track"] then
- _G[frame:GetName().."Track"]:SetTexture(nil)
- end
- if _G[frame:GetName().."Top"] then
- _G[frame:GetName().."Top"]:SetTexture(nil)
- end
- if _G[frame:GetName().."Bottom"] then
- _G[frame:GetName().."Bottom"]:SetTexture(nil)
- end
- if _G[frame:GetName().."Middle"] then
- _G[frame:GetName().."Middle"]:SetTexture(nil)
- end
- if _G[frame:GetName().."ScrollUpButton"] and _G[frame:GetName().."ScrollDownButton"] then
- _G[frame:GetName().."ScrollUpButton"]:StripTextures()
- if not _G[frame:GetName().."ScrollUpButton"].icon then
- T.SkinNextPrevButton(_G[frame:GetName().."ScrollUpButton"])
- _G[frame:GetName().."ScrollUpButton"]:SetSize(_G[frame:GetName().."ScrollUpButton"]:GetWidth() + 7, _G[frame:GetName().."ScrollUpButton"]:GetHeight() + 7)
- scrolldn = false
- end
- _G[frame:GetName().."ScrollDownButton"]:StripTextures()
- if not _G[frame:GetName().."ScrollDownButton"].icon then
- T.SkinNextPrevButton(_G[frame:GetName().."ScrollDownButton"])
- _G[frame:GetName().."ScrollDownButton"]:SetSize(_G[frame:GetName().."ScrollDownButton"]:GetWidth() + 7, _G[frame:GetName().."ScrollDownButton"]:GetHeight() + 7)
- scrolldn = true
- end
- if frame:GetThumbTexture() then
- frame:GetThumbTexture():SetTexture(nil)
- if not frame.thumbbg then
- frame.thumbbg = CreateFrame("Frame", nil, frame)
- frame.thumbbg:SetPoint("TOPLEFT", frame:GetThumbTexture(), "TOPLEFT", 0, -3)
- frame.thumbbg:SetPoint("BOTTOMRIGHT", frame:GetThumbTexture(), "BOTTOMRIGHT", 0, 3)
- frame.thumbbg:SetTemplate("Overlay")
- if frame.trackbg then
- frame.thumbbg:SetFrameLevel(frame.trackbg:GetFrameLevel())
- end
- frame:HookScript("OnShow", function()
- local _, maxValue = frame:GetMinMaxValues()
- if maxValue == 0 then
- frame:SetAlpha(0)
- else
- frame:SetAlpha(1)
- end
- end)
- frame:HookScript("OnMinMaxChanged", function()
- local _, maxValue = frame:GetMinMaxValues()
- if maxValue == 0 then
- frame:SetAlpha(0)
- else
- frame:SetAlpha(1)
- end
- end)
- frame:HookScript("OnDisable", function()
- frame:SetAlpha(0)
- end)
- frame:HookScript("OnEnable", function()
- frame:SetAlpha(1)
- end)
- end
- end
- end
- end
- local tabs = {
- "LeftDisabled",
- "MiddleDisabled",
- "RightDisabled",
- "Left",
- "Middle",
- "Right",
- }
- function T.SkinTab(tab, bg)
- if not tab then return end
- for _, object in pairs(tabs) do
- local tex = _G[tab:GetName()..object]
- if tex then
- tex:SetTexture(nil)
- end
- end
- if tab.GetHighlightTexture and tab:GetHighlightTexture() then
- tab:GetHighlightTexture():SetTexture(nil)
- else
- tab:StripTextures()
- end
- tab.backdrop = CreateFrame("Frame", nil, tab)
- tab.backdrop:SetFrameLevel(tab:GetFrameLevel() - 1)
- if bg then
- tab.backdrop:SetTemplate("Overlay")
- tab.backdrop:SetPoint("TOPLEFT", 3, -7)
- tab.backdrop:SetPoint("BOTTOMRIGHT", -3, 2)
- else
- tab.backdrop:SetTemplate("Transparent")
- tab.backdrop:SetPoint("TOPLEFT", 10, -3)
- tab.backdrop:SetPoint("BOTTOMRIGHT", -10, 3)
- end
- end
- function T.SkinNextPrevButton(btn, left)
- local normal, pushed, disabled
- local isPrevButton = btn:GetName() and (string.find(btn:GetName(), "Left") or string.find(btn:GetName(), "Prev") or string.find(btn:GetName(), "Decrement") or string.find(btn:GetName(), "Back")) or left
- local isScrollUpButton = btn:GetName() and string.find(btn:GetName(), "ScrollUp")
- local isScrollDownButton = btn:GetName() and string.find(btn:GetName(), "ScrollDown")
- if btn:GetNormalTexture() then
- normal = btn:GetNormalTexture():GetTexture()
- end
- if btn:GetPushedTexture() then
- pushed = btn:GetPushedTexture():GetTexture()
- end
- if btn:GetDisabledTexture() then
- disabled = btn:GetDisabledTexture():GetTexture()
- end
- btn:StripTextures()
- if not normal then
- if isPrevButton then
- normal = "Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Up"
- elseif isScrollUpButton then
- normal = "Interface\\ChatFrame\\UI-ChatIcon-ScrollUp-Up"
- elseif isScrollDownButton then
- normal = "Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Up"
- else
- normal = "Interface\\Buttons\\UI-SpellbookIcon-NextPage-Up"
- end
- end
- if not pushed then
- if isPrevButton then
- pushed = "Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Down"
- elseif isScrollUpButton then
- pushed = "Interface\\ChatFrame\\UI-ChatIcon-ScrollUp-Down"
- elseif isScrollDownButton then
- pushed = "Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Down"
- else
- pushed = "Interface\\Buttons\\UI-SpellbookIcon-NextPage-Down"
- end
- end
- if not disabled then
- if isPrevButton then
- disabled = "Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Disabled"
- elseif isScrollUpButton then
- disabled = "Interface\\ChatFrame\\UI-ChatIcon-ScrollUp-Disabled"
- elseif isScrollDownButton then
- disabled = "Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Disabled"
- else
- disabled = "Interface\\Buttons\\UI-SpellbookIcon-NextPage-Disabled"
- end
- end
- btn:SetNormalTexture(normal)
- btn:SetPushedTexture(pushed)
- btn:SetDisabledTexture(disabled)
- btn:SetTemplate("Overlay")
- btn:SetSize(btn:GetWidth() - 7, btn:GetHeight() - 7)
- if normal and pushed and disabled then
- btn:GetNormalTexture():SetTexCoord(0.3, 0.29, 0.3, 0.81, 0.65, 0.29, 0.65, 0.81)
- if btn:GetPushedTexture() then
- btn:GetPushedTexture():SetTexCoord(0.3, 0.35, 0.3, 0.81, 0.65, 0.35, 0.65, 0.81)
- end
- if btn:GetDisabledTexture() then
- btn:GetDisabledTexture():SetTexCoord(0.3, 0.29, 0.3, 0.75, 0.65, 0.29, 0.65, 0.75)
- end
- btn:GetNormalTexture():ClearAllPoints()
- btn:GetNormalTexture():SetPoint("TOPLEFT", 2, -2)
- btn:GetNormalTexture():SetPoint("BOTTOMRIGHT", -2, 2)
- if btn:GetDisabledTexture() then
- btn:GetDisabledTexture():SetAllPoints(btn:GetNormalTexture())
- end
- if btn:GetPushedTexture() then
- btn:GetPushedTexture():SetAllPoints(btn:GetNormalTexture())
- end
- btn:GetHighlightTexture():SetTexture(1, 1, 1, 0.3)
- btn:GetHighlightTexture():SetAllPoints(btn:GetNormalTexture())
- end
- end
- function T.SkinRotateButton(btn)
- btn:SetTemplate("Default")
- btn:SetSize(btn:GetWidth() - 14, btn:GetHeight() - 14)
- btn:GetNormalTexture():SetTexCoord(0.3, 0.29, 0.3, 0.65, 0.69, 0.29, 0.69, 0.65)
- btn:GetPushedTexture():SetTexCoord(0.3, 0.29, 0.3, 0.65, 0.69, 0.29, 0.69, 0.65)
- btn:GetHighlightTexture():SetTexture(1, 1, 1, 0.3)
- btn:GetNormalTexture():ClearAllPoints()
- btn:GetNormalTexture():SetPoint("TOPLEFT", 2, -2)
- btn:GetNormalTexture():SetPoint("BOTTOMRIGHT", -2, 2)
- btn:GetPushedTexture():SetAllPoints(btn:GetNormalTexture())
- btn:GetHighlightTexture():SetAllPoints(btn:GetNormalTexture())
- end
- function T.SkinEditBox(frame, width, height)
- if _G[frame:GetName()] then
- if _G[frame:GetName().."Left"] then _G[frame:GetName().."Left"]:Kill() end
- if _G[frame:GetName().."Middle"] then _G[frame:GetName().."Middle"]:Kill() end
- if _G[frame:GetName().."Right"] then _G[frame:GetName().."Right"]:Kill() end
- if _G[frame:GetName().."Mid"] then _G[frame:GetName().."Mid"]:Kill() end
- end
- if frame.Left then frame.Left:Kill() end
- if frame.Right then frame.Right:Kill() end
- if frame.Middle then frame.Middle:Kill() end
- frame:CreateBackdrop("Overlay")
- if frame:GetName() and (frame:GetName():find("Gold") or frame:GetName():find("Silver") or frame:GetName():find("Copper")) then
- if frame:GetName():find("Gold") then
- frame.backdrop:SetPoint("TOPLEFT", -3, 1)
- frame.backdrop:SetPoint("BOTTOMRIGHT", -3, 0)
- else
- frame.backdrop:SetPoint("TOPLEFT", -3, 1)
- frame.backdrop:SetPoint("BOTTOMRIGHT", -13, 0)
- end
- end
- if width then frame:SetWidth(width) end
- if height then frame:SetHeight(height) end
- end
- function T.SkinDropDownBox(frame, width)
- local button = _G[frame:GetName().."Button"] or _G[frame:GetName().."_Button"]
- if not width then width = 155 end
- frame:StripTextures()
- frame:SetWidth(width)
- if _G[frame:GetName().."Text"] then
- _G[frame:GetName().."Text"]:ClearAllPoints()
- _G[frame:GetName().."Text"]:SetPoint("RIGHT", button, "LEFT", -2, 0)
- end
- button:ClearAllPoints()
- button:SetPoint("RIGHT", frame, "RIGHT", -10, 3)
- button.SetPoint = T.dummy
- scrolldn = false
- T.SkinNextPrevButton(button)
- frame:CreateBackdrop("Overlay")
- frame:SetFrameLevel(frame:GetFrameLevel() + 2)
- frame.backdrop:SetPoint("TOPLEFT", 20, -2)
- frame.backdrop:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", 2, -2)
- end
- function T.SkinCheckBox(frame, default)
- frame:SetNormalTexture("")
- frame:SetPushedTexture("")
- frame:CreateBackdrop("Overlay")
- frame:SetFrameLevel(frame:GetFrameLevel() + 2)
- frame.backdrop:SetPoint("TOPLEFT", 4, -4)
- frame.backdrop:SetPoint("BOTTOMRIGHT", -4, 4)
- if frame.SetHighlightTexture then
- local highligh = frame:CreateTexture(nil, nil, self)
- highligh:SetTexture(1, 1, 1, 0.3)
- highligh:SetPoint("TOPLEFT", frame, 6, -6)
- highligh:SetPoint("BOTTOMRIGHT", frame, -6, 6)
- frame:SetHighlightTexture(highligh)
- end
- if frame.SetCheckedTexture then
- if default then return end
- local checked = frame:CreateTexture(nil, nil, self)
- checked:SetTexture(1, 0.82, 0, 0.8)
- checked:SetPoint("TOPLEFT", frame, 6, -6)
- checked:SetPoint("BOTTOMRIGHT", frame, -6, 6)
- frame:SetCheckedTexture(checked)
- end
- if frame.SetDisabledCheckedTexture then
- local disabled = frame:CreateTexture(nil, nil, self)
- disabled:SetTexture(0.6, 0.6, 0.6, 0.75)
- disabled:SetPoint("TOPLEFT", frame, 6, -6)
- disabled:SetPoint("BOTTOMRIGHT", frame, -6, 6)
- frame:SetDisabledCheckedTexture(disabled)
- end
- frame:HookScript("OnDisable", function(self)
- if not self.SetDisabledTexture then return end
- if self:GetChecked() then
- self:SetDisabledTexture(disabled)
- else
- self:SetDisabledTexture("")
- end
- end)
- end
- function T.SkinCloseButton(f, point, text, pixel)
- f:StripTextures()
- f:SetTemplate("Overlay")
- f:SetSize(18, 18)
- if not text then text = "x" end
- if not f.text then
- if pixel then
- f.text = f:FontString(nil, C.media.pixel_font, 8)
- f.text:SetPoint("CENTER", 0, 0)
- else
- f.text = f:FontString(nil, C.media.normal_font, 17)
- f.text:SetPoint("CENTER", 0, 1)
- end
- f.text:SetText(text)
- end
- if point then
- f:SetPoint("TOPRIGHT", point, "TOPRIGHT", -4, -4)
- else
- f:SetPoint("TOPRIGHT", -4, -4)
- end
- f:HookScript("OnEnter", T.SetModifiedBackdrop)
- f:HookScript("OnLeave", T.SetOriginalBackdrop)
- end
- function T.HandleIcon(icon, parent)
- parent = parent or icon:GetParent()
- icon:SetTexCoord(0.1, 0.9, 0.1, 0.9)
- parent:CreateBackdrop("Default")
- icon:SetParent(parent.backdrop)
- end
- function T.SkinSlider(f)
- f:SetBackdrop(nil)
- local bd = CreateFrame("Frame", nil, f)
- bd:SetTemplate("Overlay")
- if f:GetOrientation() == "VERTICAL" then
- bd:SetPoint("TOPLEFT", -2, -6)
- bd:SetPoint("BOTTOMRIGHT", 2, 6)
- else
- bd:SetPoint("TOPLEFT", 14, -2)
- bd:SetPoint("BOTTOMRIGHT", -15, 3)
- end
- bd:SetFrameLevel(f:GetFrameLevel() - 1)
- local slider = select(4, f:GetRegions())
- slider:SetTexture("Interface\\CastingBar\\UI-CastingBar-Spark")
- slider:SetBlendMode("ADD")
- end
- local LoadBlizzardSkin = CreateFrame("Frame")
- LoadBlizzardSkin:RegisterEvent("ADDON_LOADED")
- LoadBlizzardSkin:SetScript("OnEvent", function(self, event, addon)
- if IsAddOnLoaded("Skinner") or IsAddOnLoaded("Aurora") or not C.skins.blizzard_frames then
- self:UnregisterEvent("ADDON_LOADED")
- return
- end
- for _addon, skinfunc in pairs(T.SkinFuncs) do
- if type(skinfunc) == "function" then
- if _addon == addon then
- if skinfunc then
- skinfunc()
- end
- end
- elseif type(skinfunc) == "table" then
- if _addon == addon then
- for _, skinfunc in pairs(T.SkinFuncs[_addon]) do
- if skinfunc then
- skinfunc()
- end
- end
- end
- end
- end
- end)
- ----------------------------------------------------------------------------------------
- -- Unit frames functions
- ----------------------------------------------------------------------------------------
- if C.unitframe.enable ~= true then return end
- local _, ns = ...
- local oUF = ns.oUF
- T.UpdateAllElements = function(frame)
- for _, v in ipairs(frame.__elements) do
- v(frame, "UpdateElement", frame.unit)
- end
- end
- local SetUpAnimGroup = function(self)
- self.anim = self:CreateAnimationGroup("Flash")
- self.anim.fadein = self.anim:CreateAnimation("ALPHA", "FadeIn")
- self.anim.fadein:SetChange(1)
- self.anim.fadein:SetOrder(2)
- self.anim.fadeout = self.anim:CreateAnimation("ALPHA", "FadeOut")
- self.anim.fadeout:SetChange(-1)
- self.anim.fadeout:SetOrder(1)
- end
- local Flash = function(self, duration)
- if not self.anim then
- SetUpAnimGroup(self)
- end
- if not self.anim:IsPlaying() or duration ~= self.anim.fadein:GetDuration() then
- self.anim.fadein:SetDuration(duration)
- self.anim.fadeout:SetDuration(duration)
- self.anim:Play()
- end
- end
- local StopFlash = function(self)
- if self.anim then
- self.anim:Finish()
- end
- end
- T.SetFontString = function(parent, fontName, fontHeight, fontStyle)
- local fs = parent:CreateFontString(nil, "ARTWORK")
- fs:SetFont(fontName, fontHeight, fontStyle)
- fs:SetShadowOffset(C.font.unit_frames_font_shadow and 1 or 0, C.font.unit_frames_font_shadow and -1 or 0)
- return fs
- end
- T.PostUpdateHealth = function(health, unit, min, max)
- if unit and unit:find("arena%dtarget") then return end
- if not UnitIsConnected(unit) or UnitIsDead(unit) or UnitIsGhost(unit) then
- health:SetValue(0)
- if not UnitIsConnected(unit) then
- health.value:SetText("|cffD7BEA5"..L_UF_OFFLINE.."|r")
- elseif UnitIsDead(unit) then
- health.value:SetText("|cffD7BEA5"..L_UF_DEAD.."|r")
- elseif UnitIsGhost(unit) then
- health.value:SetText("|cffD7BEA5"..L_UF_GHOST.."|r")
- end
- else
- local r, g, b
- if (C.unitframe.own_color ~= true and C.unitframe.enemy_health_color and unit == "target" and UnitIsEnemy(unit, "player") and UnitIsPlayer(unit)) or (C.unitframe.own_color ~= true and unit == "target" and not UnitIsPlayer(unit) and UnitIsFriend(unit, "player")) then
- local c = T.oUF_colors.reaction[UnitReaction(unit, "player")]
- if c then
- r, g, b = c[1], c[2], c[3]
- health:SetStatusBarColor(r, g, b)
- else
- r, g, b = 0.3, 0.7, 0.3
- health:SetStatusBarColor(r, g, b)
- end
- end
- if unit == "pet" or unit == "vehicle" then
- local _, class = UnitClass("player")
- local r, g, b = unpack(T.oUF_colors.class[class])
- if C.unitframe.own_color == true then
- health:SetStatusBarColor(unpack(C.unitframe.uf_color))
- health.bg:SetVertexColor(0.1, 0.1, 0.1)
- else
- if b then
- health:SetStatusBarColor(r, g, b)
- if health.bg and health.bg.multiplier then
- local mu = health.bg.multiplier
- health.bg:SetVertexColor(r * mu, g * mu, b * mu)
- end
- end
- end
- end
- if C.unitframe.bar_color_value == true and not (UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit)) then
- if C.unitframe.own_color == true then
- r, g, b = C.unitframe.uf_color[1], C.unitframe.uf_color[2], C.unitframe.uf_color[3]
- else
- r, g, b = health:GetStatusBarColor()
- end
- local newr, newg, newb = oUF.ColorGradient(min, max, 1, 0, 0, 1, 1, 0, r, g, b)
- health:SetStatusBarColor(newr, newg, newb)
- if health.bg and health.bg.multiplier then
- local mu = health.bg.multiplier
- health.bg:SetVertexColor(newr * mu, newg * mu, newb * mu)
- end
- end
- if min ~= max then
- r, g, b = oUF.ColorGradient(min, max, 0.69, 0.31, 0.31, 0.65, 0.63, 0.35, 0.33, 0.59, 0.33)
- if unit == "player" and health:GetAttribute("normalUnit") ~= "pet" then
- if C.unitframe.show_total_value == true then
- if C.unitframe.color_value == true then
- health.value:SetFormattedText("|cff559655%s|r |cffD7BEA5-|r |cff559655%s|r", T.ShortValue(min), T.ShortValue(max))
- else
- health.value:SetFormattedText("|cffffffff%s - %s|r", T.ShortValue(min), T.ShortValue(max))
- end
- else
- if C.unitframe.color_value == true then
- health.value:SetFormattedText("|cffAF5050%d|r |cffD7BEA5-|r |cff%02x%02x%02x%d%%|r", min, r * 255, g * 255, b * 255, floor(min / max * 100))
- else
- health.value:SetFormattedText("|cffffffff%d - %d%%|r", min, floor(min / max * 100))
- end
- end
- elseif unit == "target" then
- if C.unitframe.show_total_value == true then
- if C.unitframe.color_value == true then
- health.value:SetFormattedText("|cff559655%s|r |cffD7BEA5-|r |cff559655%s|r", T.ShortValue(min), T.ShortValue(max))
- else
- health.value:SetFormattedText("|cffffffff%s - %s|r", T.ShortValue(min), T.ShortValue(max))
- end
- else
- if C.unitframe.color_value == true then
- health.value:SetFormattedText("|cff%02x%02x%02x%d%%|r |cffD7BEA5-|r |cffAF5050%s|r", r * 255, g * 255, b * 255, floor(min / max * 100), T.ShortValue(min))
- else
- health.value:SetFormattedText("|cffffffff%d%% - %s|r", floor(min / max * 100), T.ShortValue(min))
- end
- end
- elseif unit and unit:find("boss%d") then
- if C.unitframe.color_value == true then
- health.value:SetFormattedText("|cff%02x%02x%02x%d%%|r |cffD7BEA5-|r |cffAF5050%s|r", r * 255, g * 255, b * 255, floor(min / max * 100), T.ShortValue(min))
- else
- health.value:SetFormattedText("|cffffffff%d%% - %s|r", floor(min / max * 100), T.ShortValue(min))
- end
- else
- if C.unitframe.color_value == true then
- health.value:SetFormattedText("|cff%02x%02x%02x%d%%|r", r * 255, g * 255, b * 255, floor(min / max * 100))
- else
- health.value:SetFormattedText("|cffffffff%d%%|r", floor(min / max * 100))
- end
- end
- else
- if unit == "player" and unit ~= "pet" then
- if C.unitframe.color_value == true then
- health.value:SetText("|cff559655"..max.."|r")
- else
- health.value:SetText("|cffffffff"..max.."|r")
- end
- else
- if C.unitframe.color_value == true then
- health.value:SetText("|cff559655"..T.ShortValue(max).."|r")
- else
- health.value:SetText("|cffffffff"..T.ShortValue(max).."|r")
- end
- end
- end
- end
- end
- T.PostUpdateRaidHealth = function(health, unit, min, max)
- local self = health:GetParent()
- local power = self.Power
- local border = self.backdrop
- if not UnitIsConnected(unit) or UnitIsDead(unit) or UnitIsGhost(unit) then
- health:SetValue(0)
- if not UnitIsConnected(unit) then
- health.value:SetText("|cffD7BEA5"..L_UF_OFFLINE.."|r")
- elseif UnitIsDead(unit) then
- health.value:SetText("|cffD7BEA5"..L_UF_DEAD.."|r")
- elseif UnitIsGhost(unit) then
- health.value:SetText("|cffD7BEA5"..L_UF_GHOST.."|r")
- end
- else
- local r, g, b
- if not UnitIsPlayer(unit) and UnitIsFriend(unit, "player") and C.unitframe.own_color ~= true then
- local c = T.oUF_colors.reaction[5]
- local r, g, b = c[1], c[2], c[3]
- health:SetStatusBarColor(r, g, b)
- if health.bg and health.bg.multiplier then
- local mu = health.bg.multiplier
- health.bg:SetVertexColor(r * mu, g * mu, b * mu)
- end
- end
- if C.unitframe.bar_color_value == true and not (UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit)) then
- if C.unitframe.own_color == true then
- r, g, b = C.unitframe.uf_color[1], C.unitframe.uf_color[2], C.unitframe.uf_color[3]
- else
- r, g, b = health:GetStatusBarColor()
- end
- local newr, newg, newb = oUF.ColorGradient(min, max, 1, 0, 0, 1, 1, 0, r, g, b)
- health:SetStatusBarColor(newr, newg, newb)
- if health.bg and health.bg.multiplier then
- local mu = health.bg.multiplier
- health.bg:SetVertexColor(newr * mu, newg * mu, newb * mu)
- end
- end
- if min ~= max then
- r, g, b = oUF.ColorGradient(min, max, 0.69, 0.31, 0.31, 0.65, 0.63, 0.35, 0.33, 0.59, 0.33)
- if self:GetParent():GetName():match("oUF_PartyDPS") then
- if C.unitframe.color_value == true then
- health.value:SetFormattedText("|cffAF5050%s|r |cffD7BEA5-|r |cff%02x%02x%02x%d%%|r", T.ShortValue(min), r * 255, g * 255, b * 255, floor(min / max * 100))
- else
- health.value:SetFormattedText("|cffffffff%s - %d%%|r", T.ShortValue(min), floor(min / max * 100))
- end
- else
- if C.unitframe.color_value == true then
- if C.raidframe.deficit_health == true then
- health.value:SetText("|cffffffff".."-"..T.ShortValue(max - min))
- else
- health.value:SetFormattedText("|cff%02x%02x%02x%d%%|r", r * 255, g * 255, b * 255, floor(min / max * 100))
- end
- else
- if C.raidframe.deficit_health == true then
- health.value:SetText("|cffffffff".."-"..T.ShortValue(max - min))
- else
- health.value:SetFormattedText("|cffffffff%d%%|r", floor(min / max * 100))
- end
- end
- end
- else
- if C.unitframe.color_value == true then
- health.value:SetText("|cff559655"..T.ShortValue(max).."|r")
- else
- health.value:SetText("|cffffffff"..T.ShortValue(max).."|r")
- end
- end
- if C.raidframe.alpha_health == true then
- if min / max > 0.95 then
- health:SetAlpha(0.6)
- power:SetAlpha(0.6)
- border:SetAlpha(0.6)
- else
- health:SetAlpha(1)
- power:SetAlpha(1)
- border:SetAlpha(1)
- end
- end
- end
- end
- T.PreUpdatePower = function(power, unit)
- local _, pToken = UnitPowerType(unit)
- local color = T.oUF_colors.power[pToken]
- if color then
- power:SetStatusBarColor(color[1], color[2], color[3])
- end
- end
- T.PostUpdatePower = function(power, unit, min, max)
- if unit and unit:find("arena%dtarget") then return end
- local self = power:GetParent()
- local pType, pToken = UnitPowerType(unit)
- local color = T.oUF_colors.power[pToken]
- if color then
- power.value:SetTextColor(color[1], color[2], color[3])
- end
- if not UnitIsConnected(unit) or UnitIsDead(unit) or UnitIsGhost(unit) then
- power:SetValue(0)
- end
- if unit == "focus" or unit == "focustarget" or unit == "targettarget" or (self:GetParent():GetName():match("oUF_RaidDPS")) then return end
- if not UnitIsConnected(unit) then
- power.value:SetText()
- elseif UnitIsDead(unit) or UnitIsGhost(unit) or max == 0 then
- power.value:SetText()
- else
- if min ~= max then
- if pType == 0 and pToken ~= "POWER_TYPE_DINO_SONIC" then
- if unit == "target" then
- if C.unitframe.show_total_value == true then
- if C.unitframe.color_value == true then
- power.value:SetFormattedText("%s |cffD7BEA5-|r %s", T.ShortValue(max - (max - min)), T.ShortValue(max))
- else
- power.value:SetFormattedText("|cffffffff%s - %s|r", T.ShortValue(max - (max - min)), T.ShortValue(max))
- end
- else
- if C.unitframe.color_value == true then
- power.value:SetFormattedText("%d%% |cffD7BEA5-|r %s", floor(min / max * 100), T.ShortValue(max - (max - min)))
- else
- power.value:SetFormattedText("|cffffffff%d%% - %s|r", floor(min / max * 100), T.ShortValue(max - (max - min)))
- end
- end
- elseif (unit == "player" and power:GetAttribute("normalUnit") == "pet") or unit == "pet" then
- if C.unitframe.show_total_value == true then
- if C.unitframe.color_value == true then
- power.value:SetFormattedText("%s |cffD7BEA5-|r %s", T.ShortValue(max - (max - min)), T.ShortValue(max))
- else
- power.value:SetFormattedText("%s |cffffffff-|r %s", T.ShortValue(max - (max - min)), T.ShortValue(max))
- end
- else
- if C.unitframe.color_value == true then
- power.value:SetFormattedText("%d%%", floor(min / max * 100))
- else
- power.value:SetFormattedText("|cffffffff%d%%|r", floor(min / max * 100))
- end
- end
- elseif unit and (unit:find("arena%d") or unit:find("boss%d")) then
- if C.unitframe.color_value == true then
- power.value:SetFormattedText("|cffD7BEA5%d%% - %s|r", floor(min / max * 100), T.ShortValue(max - (max - min)))
- else
- power.value:SetFormattedText("|cffffffff%d%% - %s|r", floor(min / max * 100), T.ShortValue(max - (max - min)))
- end
- elseif self:GetParent():GetName():match("oUF_PartyDPS") then
- if C.unitframe.color_value == true then
- power.value:SetFormattedText("%s |cffD7BEA5-|r %d%%", T.ShortValue(max - (max - min)), floor(min / max * 100))
- else
- power.value:SetFormattedText("|cffffffff%s - %d%%|r", T.ShortValue(max - (max - min)), floor(min / max * 100))
- end
- else
- if C.unitframe.show_total_value == true then
- if C.unitframe.color_value == true then
- power.value:SetFormattedText("%s |cffD7BEA5-|r %s", T.ShortValue(max - (max - min)), T.ShortValue(max))
- else
- power.value:SetFormattedText("|cffffffff%s - %s|r", T.ShortValue(max - (max - min)), T.ShortValue(max))
- end
- else
- if C.unitframe.color_value == true then
- power.value:SetFormattedText("%d |cffD7BEA5-|r %d%%", max - (max - min), floor(min / max * 100))
- else
- power.value:SetFormattedText("|cffffffff%d - %d%%|r", max - (max - min), floor(min / max * 100))
- end
- end
- end
- else
- if C.unitframe.color_value == true then
- power.value:SetText(max - (max - min))
- else
- power.value:SetText("|cffffffff"..max - (max - min).."|r")
- end
- end
- else
- if unit == "pet" or unit == "target" or (unit and unit:find("arena%d")) or (self:GetParent():GetName():match("oUF_PartyDPS")) then
- if C.unitframe.color_value == true then
- power.value:SetText(T.ShortValue(min))
- else
- power.value:SetText("|cffffffff"..T.ShortValue(min).."|r")
- end
- else
- if C.unitframe.color_value == true then
- power.value:SetText(min)
- else
- power.value:SetText("|cffffffff"..min.."|r")
- end
- end
- end
- end
- end
- T.UpdateManaLevel = function(self, elapsed)
- self.elapsed = (self.elapsed or 0) + elapsed
- if self.elapsed < 0.2 then return end
- self.elapsed = 0
- if UnitPowerType("player") ~= 0 then
- if T.class == "MONK" then
- self.ManaLevel:SetText()
- end
- return
- end
- local percMana = UnitMana("player") / UnitManaMax("player") * 100
- if percMana <= 20 and not UnitIsDeadOrGhost("player") then
- self.ManaLevel:SetText("|cffaf5050"..MANA_LOW.."|r")
- Flash(self, 0.3)
- else
- self.ManaLevel:SetText()
- StopFlash(self)
- end
- end
- T.UpdateClassMana = function(self)
- if self.unit ~= "player" then return end
- if UnitPowerType("player") ~= 0 then
- local min = UnitPower("player", 0)
- local max = UnitPowerMax("player", 0)
- local percMana = min / max * 100
- if percMana <= 20 and not UnitIsDeadOrGhost("player") then
- self.FlashInfo.ManaLevel:SetText("|cffaf5050"..MANA_LOW.."|r")
- Flash(self.FlashInfo, 0.3)
- else
- self.FlashInfo.ManaLevel:SetText()
- StopFlash(self.FlashInfo)
- end
- if min ~= max then
- if self.Power.value:GetText() then
- self.ClassMana:SetPoint("RIGHT", self.Power.value, "LEFT", -1, 0)
- self.ClassMana:SetFormattedText("%d%%|r |cffD7BEA5-|r", floor(min / max * 100))
- self.ClassMana:SetJustifyH("RIGHT")
- else
- self.ClassMana:SetPoint("LEFT", self.Power, "LEFT", 4, 0)
- self.ClassMana:SetFormattedText("%d%%", floor(min / max * 100))
- end
- else
- self.ClassMana:SetText()
- end
- self.ClassMana:SetAlpha(1)
- else
- self.ClassMana:SetAlpha(0)
- end
- end
- T.UpdatePvPStatus = function(self, elapsed)
- if self.elapsed and self.elapsed > 0.2 then
- local unit = self.unit
- local time = GetPVPTimer()
- local min = format("%01.f", floor((time / 1000) / 60))
- local sec = format("%02.f", floor((time / 1000) - min * 60))
- if self.Status then
- local factionGroup = UnitFactionGroup(unit)
- if UnitIsPVPFreeForAll(unit) then
- if time ~= 301000 and time ~= -1 then
- self.Status:SetText(PVP.." ".."["..min..":"..sec.."]")
- else
- self.Status:SetText(PVP)
- end
- elseif factionGroup and UnitIsPVP(unit) then
- if time ~= 301000 and time ~= -1 then
- self.Status:SetText(PVP.." ".."["..min..":"..sec.."]")
- else
- self.Status:SetText(PVP)
- end
- else
- self.Status:SetText("")
- end
- end
- self.elapsed = 0
- else
- self.elapsed = (self.elapsed or 0) + elapsed
- end
- end
- T.UpdateShadowOrb = function(self, event, unit, powerType)
- if self.unit ~= unit or (powerType and powerType ~= "SHADOW_ORBS") then return end
- local num = UnitPower(unit, SPELL_POWER_SHADOW_ORBS)
- local numMax = UnitPowerMax("player", SPELL_POWER_SHADOW_ORBS)
- local barWidth = self.ShadowOrbsBar:GetWidth()
- local spacing = select(4, self.ShadowOrbsBar[4]:GetPoint())
- local lastBar = 0
- if numMax ~= self.ShadowOrbsBar.maxPower then
- if numMax == 3 then
- self.ShadowOrbsBar[4]:Hide()
- self.ShadowOrbsBar[5]:Hide()
- for i = 1, 3 do
- if i ~= 3 then
- self.ShadowOrbsBar[i]:SetWidth(barWidth / 3)
- lastBar = lastBar + (barWidth / 3 + spacing)
- else
- self.ShadowOrbsBar[i]:SetWidth(barWidth - lastBar)
- end
- end
- else
- self.ShadowOrbsBar[4]:Show()
- self.ShadowOrbsBar[5]:Show()
- for i = 1, 5 do
- self.ShadowOrbsBar[i]:SetWidth(self.ShadowOrbsBar[i].width)
- end
- end
- self.ShadowOrbsBar.maxPower = numMax
- end
- for i = 1, 5 do
- if i <= num then
- self.ShadowOrbsBar[i]:SetAlpha(1)
- else
- self.ShadowOrbsBar[i]:SetAlpha(0.2)
- end
- end
- end
- T.UpdateHoly = function(self, event, unit, powerType)
- if self.unit ~= unit or (powerType and powerType ~= "HOLY_POWER") then return end
- local num = UnitPower(unit, SPELL_POWER_HOLY_POWER)
- local numMax = UnitPowerMax("player", SPELL_POWER_HOLY_POWER)
- local barWidth = self.HolyPower:GetWidth()
- local spacing = select(4, self.HolyPower[4]:GetPoint())
- local lastBar = 0
- if numMax ~= self.HolyPower.maxPower then
- if numMax == 3 then
- self.HolyPower[4]:Hide()
- self.HolyPower[5]:Hide()
- for i = 1, 3 do
- if i ~= 3 then
- self.HolyPower[i]:SetWidth(barWidth / 3)
- lastBar = lastBar + (barWidth / 3 + spacing)
- else
- self.HolyPower[i]:SetWidth(barWidth - lastBar)
- end
- end
- else
- self.HolyPower[4]:Show()
- self.HolyPower[5]:Show()
- for i = 1, 5 do
- self.HolyPower[i]:SetWidth(self.HolyPower[i].width)
- end
- end
- self.HolyPower.maxPower = numMax
- end
- for i = 1, 5 do
- if i <= num then
- self.HolyPower[i]:SetAlpha(1)
- else
- self.HolyPower[i]:SetAlpha(0.2)
- end
- end
- end
- T.EclipseDirection = function(self)
- if GetEclipseDirection() == "sun" then
- self.Text:SetText("|cff4478BC>>|r")
- elseif GetEclipseDirection() == "moon" then
- self.Text:SetText("|cffE5994C<<|r")
- else
- self.Text:SetText("")
- end
- end
- T.UpdateEclipse = function(self, login)
- local eb = self.EclipseBar
- local txt = self.EclipseBar.Text
- if login then
- eb:SetScript("OnUpdate", nil)
- end
- if eb:IsShown() or (T.class == "DRUID" and C.unitframe_class_bar.combo == true) then
- txt:Show()
- if self.Debuffs then self.Debuffs:SetPoint("BOTTOMRIGHT", self, "TOPRIGHT", 2, 19) end
- else
- txt:Hide()
- if self.Debuffs then self.Debuffs:SetPoint("BOTTOMRIGHT", self, "TOPRIGHT", 2, 5) end
- end
- end
- T.UpdateReputationColor = function(self, event, unit, bar)
- local name, id = GetWatchedFactionInfo()
- bar:SetStatusBarColor(FACTION_BAR_COLORS[id].r, FACTION_BAR_COLORS[id].g, FACTION_BAR_COLORS[id].b)
- bar.bg:SetVertexColor(FACTION_BAR_COLORS[id].r, FACTION_BAR_COLORS[id].g, FACTION_BAR_COLORS[id].b, 0.2)
- end
- T.UpdateComboPoint = function(self, event, unit)
- if unit == "pet" then return end
- local cpoints = self.CPoints
- local cp = (UnitHasVehicleUI("player") or UnitHasVehicleUI("vehicle")) and UnitPower("vehicle", 4) or UnitPower("player", 4)
- for i = 1, MAX_COMBO_POINTS do
- if i <= cp then
- cpoints[i]:SetAlpha(1)
- self.Anticipation[i]:SetStatusBarColor(0.2, 0.2, 0.2)
- else
- cpoints[i]:SetAlpha(0.2)
- self.Anticipation[i]:SetStatusBarColor(0.8, 0.8, 0.8)
- end
- end
- if T.class == "DRUID" and C.unitframe_class_bar.combo_always ~= true then
- local function CatForm(self, event, unit)
- local unit = self.unit or "player"
- local name = UnitBuff(unit, GetSpellInfo(768)) or UnitBuff(unit, GetSpellInfo(171745))
- if name then
- cpoints:Show()
- if self.Debuffs then self.Debuffs:SetPoint("BOTTOMRIGHT", self, "TOPRIGHT", 2, 19) end
- else
- cpoints:Hide()
- if self.Debuffs then self.Debuffs:SetPoint("BOTTOMRIGHT", self, "TOPRIGHT", 2, 5) end
- end
- end
- local frame = CreateFrame("Frame")
- frame:RegisterEvent("UNIT_AURA")
- frame:SetScript("OnEvent", CatForm)
- CatForm(self, event, unit)
- end
- end
- T.UpdateComboPointOld = function(self, event, unit)
- if unit == "pet" then return end
- local cpoints = self.CPoints
- local cp
- if UnitHasVehicleUI("player") or UnitHasVehicleUI("vehicle") then
- cp = GetComboPoints("vehicle", "target")
- else
- cp = GetComboPoints("player", "target")
- end
- for i = 1, MAX_COMBO_POINTS do
- if i <= cp then
- cpoints[i]:SetAlpha(1)
- else
- cpoints[i]:SetAlpha(0.2)
- end
- end
- if cpoints[1]:GetAlpha() == 1 then
- for i = 1, MAX_COMBO_POINTS do
- cpoints:Show()
- cpoints[i]:Show()
- end
- else
- for i = 1, MAX_COMBO_POINTS do
- cpoints:Hide()
- cpoints[i]:Hide()
- end
- end
- if self.RangeBar then
- if cpoints[1]:IsShown() and self.RangeBar:IsShown() then
- cpoints:SetPoint("BOTTOMLEFT", self, "TOPLEFT", 0, 21)
- if self.Auras then self.Auras:SetPoint("BOTTOMLEFT", self, "TOPLEFT", -2, 33) end
- elseif cpoints[1]:IsShown() or self.RangeBar:IsShown() then
- cpoints:SetPoint("BOTTOMLEFT", self, "TOPLEFT", 0, 7)
- if self.Auras then self.Auras:SetPoint("BOTTOMLEFT", self, "TOPLEFT", -2, 19) end
- elseif self.Friendship and self.Friendship:IsShown() then
- if self.Auras then self.Auras:SetPoint("BOTTOMLEFT", self, "TOPLEFT", -2, 19) end
- else
- if self.Auras then self.Auras:SetPoint("BOTTOMLEFT", self, "TOPLEFT", -2, 5) end
- end
- else
- if cpoints[1]:IsShown() or (self.Friendship and self.Friendship:IsShown()) then
- if self.Auras then self.Auras:SetPoint("BOTTOMLEFT", self, "TOPLEFT", -2, 19) end
- else
- if self.Auras then self.Auras:SetPoint("BOTTOMLEFT", self, "TOPLEFT", -2, 5) end
- end
- end
- end
- local ticks = {}
- local channelingTicks = T.CastBarTicks
- local setBarTicks = function(Castbar, ticknum)
- for k, v in pairs(ticks) do
- v:Hide()
- end
- if ticknum and ticknum > 0 then
- local delta = Castbar:GetWidth() / ticknum
- for k = 1, ticknum do
- if not ticks[k] then
- ticks[k] = Castbar:CreateTexture(nil, "OVERLAY")
- ticks[k]:SetTexture(C.media.texture)
- ticks[k]:SetVertexColor(unpack(C.media.border_color))
- ticks[k]:SetWidth(1)
- ticks[k]:SetHeight(Castbar:GetHeight())
- ticks[k]:SetDrawLayer("OVERLAY", 7)
- end
- ticks[k]:ClearAllPoints()
- ticks[k]:SetPoint("CENTER", Castbar, "RIGHT", -delta * k, 0)
- ticks[k]:Show()
- end
- end
- end
- T.PostCastStart = function(Castbar, unit, name, castid)
- Castbar.channeling = false
- if unit == "vehicle" then unit = "player" end
- if unit == "player" and C.unitframe.castbar_latency == true and Castbar.Latency then
- local _, _, _, lag = GetNetStats()
- local latency = GetTime() - (Castbar.castSent or 0)
- lag = lag / 1e3 > Castbar.max and Castbar.max or lag / 1e3
- latency = latency > Castbar.max and lag or latency
- Castbar.Latency:SetText(("%dms"):format(latency * 1e3))
- Castbar.SafeZone:SetWidth(Castbar:GetWidth() * latency / Castbar.max)
- Castbar.SafeZone:ClearAllPoints()
- Castbar.SafeZone:SetPoint("TOPRIGHT")
- Castbar.SafeZone:SetPoint("BOTTOMRIGHT")
- Castbar.castSent = nil
- end
- if unit == "player" and C.unitframe.castbar_ticks == true then
- setBarTicks(Castbar, 0)
- end
- local r, g, b, color
- if UnitIsPlayer(unit) then
- local _, class = UnitClass(unit)
- color = T.oUF_colors.class[class]
- else
- local reaction = T.oUF_colors.reaction[UnitReaction(unit, "player")]
- if reaction then
- r, g, b = reaction[1], reaction[2], reaction[3]
- else
- r, g, b = 1, 1, 1
- end
- end
- if color then
- r, g, b = color[1], color[2], color[3]
- end
- if Castbar.interrupt and UnitCanAttack("player", unit) then
- Castbar:SetStatusBarColor(0.8, 0, 0)
- Castbar.bg:SetVertexColor(0.8, 0, 0, 0.2)
- Castbar.Overlay:SetBackdropBorderColor(0.8, 0, 0)
- if C.unitframe.castbar_icon == true and (unit == "target" or unit == "focus") then
- Castbar.Button:SetBackdropBorderColor(0.8, 0, 0)
- end
- else
- if unit == "pet" or unit == "vehicle" then
- local _, class = UnitClass("player")
- local r, g, b = unpack(T.oUF_colors.class[class])
- if C.unitframe.own_color == true then
- Castbar:SetStatusBarColor(unpack(C.unitframe.uf_color))
- Castbar.bg:SetVertexColor(C.unitframe.uf_color[1], C.unitframe.uf_color[2], C.unitframe.uf_color[3], 0.2)
- else
- if b then
- Castbar:SetStatusBarColor(r, g, b)
- Castbar.bg:SetVertexColor(r, g, b, 0.2)
- end
- end
- else
- if C.unitframe.own_color == true then
- Castbar:SetStatusBarColor(unpack(C.unitframe.uf_color))
- Castbar.bg:SetVertexColor(C.unitframe.uf_color[1], C.unitframe.uf_color[2], C.unitframe.uf_color[3], 0.2)
- else
- Castbar:SetStatusBarColor(r, g, b)
- Castbar.bg:SetVertexColor(r, g, b, 0.2)
- end
- end
- Castbar.Overlay:SetBackdropBorderColor(unpack(C.media.border_color))
- if C.unitframe.castbar_icon == true and (unit == "target" or unit == "focus") then
- Castbar.Button:SetBackdropBorderColor(unpack(C.media.border_color))
- end
- end
- end
- T.PostChannelStart = function(Castbar, unit, name)
- Castbar.channeling = true
- if unit == "vehicle" then unit = "player" end
- if unit == "player" and C.unitframe.castbar_latency == true and Castbar.Latency then
- local _, _, _, lag = GetNetStats()
- local latency = GetTime() - (Castbar.castSent or 0)
- lag = lag / 1e3 > Castbar.max and Castbar.max or lag / 1e3
- latency = latency > Castbar.max and lag or latency
- Castbar.Latency:SetText(("%dms"):format(latency * 1e3))
- Castbar.SafeZone:SetWidth(Castbar:GetWidth() * latency / Castbar.max)
- Castbar.SafeZone:ClearAllPoints()
- Castbar.SafeZone:SetPoint("TOPLEFT")
- Castbar.SafeZone:SetPoint("BOTTOMLEFT")
- Castbar.castSent = nil
- end
- if unit == "player" and C.unitframe.castbar_ticks == true then
- local spell = UnitChannelInfo(unit)
- Castbar.channelingTicks = channelingTicks[spell] or 0
- setBarTicks(Castbar, Castbar.channelingTicks)
- end
- local r, g, b, color
- if UnitIsPlayer(unit) then
- local _, class = UnitClass(unit)
- color = T.oUF_colors.class[class]
- else
- local reaction = T.oUF_colors.reaction[UnitReaction(unit, "player")]
- if reaction then
- r, g, b = reaction[1], reaction[2], reaction[3]
- else
- r, g, b = 1, 1, 1
- end
- end
- if color then
- r, g, b = color[1], color[2], color[3]
- end
- if Castbar.interrupt and UnitCanAttack("player", unit) then
- Castbar:SetStatusBarColor(0.8, 0, 0)
- Castbar.bg:SetVertexColor(0.8, 0, 0, 0.2)
- Castbar.Overlay:SetBackdropBorderColor(0.8, 0, 0)
- if C.unitframe.castbar_icon == true and (unit == "target" or unit == "focus") then
- Castbar.Button:SetBackdropBorderColor(0.8, 0, 0)
- end
- else
- if unit == "pet" or unit == "vehicle" then
- local _, class = UnitClass("player")
- local r, g, b = unpack(T.oUF_colors.class[class])
- if C.unitframe.own_color == true then
- Castbar:SetStatusBarColor(unpack(C.unitframe.uf_color))
- Castbar.bg:SetVertexColor(C.unitframe.uf_color[1], C.unitframe.uf_color[2], C.unitframe.uf_color[3], 0.2)
- else
- if b then
- Castbar:SetStatusBarColor(r, g, b)
- Castbar.bg:SetVertexColor(r, g, b, 0.2)
- end
- end
- else
- if C.unitframe.own_color == true then
- Castbar:SetStatusBarColor(unpack(C.unitframe.uf_color))
- Castbar.bg:SetVertexColor(C.unitframe.uf_color[1], C.unitframe.uf_color[2], C.unitframe.uf_color[3], 0.2)
- else
- Castbar:SetStatusBarColor(r, g, b)
- Castbar.bg:SetVertexColor(r, g, b, 0.2)
- end
- end
- Castbar.Overlay:SetBackdropBorderColor(unpack(C.media.border_color))
- if C.unitframe.castbar_icon == true and (unit == "target" or unit == "focus") then
- Castbar.Button:SetBackdropBorderColor(unpack(C.media.border_color))
- end
- end
- end
- T.CustomCastTimeText = function(self, duration)
- self.Time:SetText(("%.1f / %.1f"):format(self.channeling and duration or self.max - duration, self.max))
- end
- T.CustomCastDelayText = function(self, duration)
- self.Time:SetText(("%.1f |cffaf5050%s %.1f|r"):format(self.channeling and duration or self.max - duration, self.channeling and "-" or "+", abs(self.delay)))
- end
- local FormatTime = function(s)
- local day, hour, minute = 86400, 3600, 60
- if s >= day then
- return format("%dd", floor(s / day + 0.5)), s % day
- elseif s >= hour then
- return format("%dh", floor(s / hour + 0.5)), s % hour
- elseif s >= minute then
- return format("%dm", floor(s / minute + 0.5)), s % minute
- elseif s >= minute / 12 then
- return floor(s + 0.5), (s * 100 - floor(s * 100)) / 100
- end
- return format("%.1f", s), (s * 100 - floor(s * 100)) / 100
- end
- local CreateAuraTimer = function(self, elapsed)
- if self.timeLeft then
- self.elapsed = (self.elapsed or 0) + elapsed
- if self.elapsed >= 0.1 then
- if not self.first then
- self.timeLeft = self.timeLeft - self.elapsed
- else
- self.timeLeft = self.timeLeft - GetTime()
- self.first = false
- end
- if self.timeLeft > 0 then
- local time = FormatTime(self.timeLeft)
- self.remaining:SetText(time)
- self.remaining:SetTextColor(1, 1, 1)
- else
- self.remaining:Hide()
- self:SetScript("OnUpdate", nil)
- end
- self.elapsed = 0
- end
- end
- end
- T.AuraTrackerTime = function(self, elapsed)
- if self.active then
- self.timeleft = self.timeleft - elapsed
- if self.timeleft <= 5 then
- self.text:SetTextColor(1, 0, 0)
- else
- self.text:SetTextColor(1, 1, 1)
- end
- if self.timeleft <= 0 then
- self.icon:SetTexture("")
- self.text:SetText("")
- end
- self.text:SetFormattedText("%.1f", self.timeleft)
- end
- end
- T.HideAuraFrame = function(self)
- if self.unit == "player" then
- if not C.aura.player_auras then
- BuffFrame:UnregisterEvent("UNIT_AURA")
- BuffFrame:Hide()
- TemporaryEnchantFrame:Hide()
- self.Debuffs:Hide()
- end
- elseif self.unit == "pet" and not C.aura.pet_debuffs or self.unit == "focus" and not C.aura.focus_debuffs
- or self.unit == "focustarget" and not C.aura.fot_debuffs or self.unit == "targettarget" and not C.aura.tot_debuffs then
- self.Debuffs:Hide()
- elseif self.unit == "target" and not C.aura.target_auras then
- self.Auras:Hide()
- end
- end
- T.PostCreateAura = function(element, button)
- button:SetTemplate("Default")
- button.remaining = T.SetFontString(button, C.font.auras_font, C.font.auras_font_size, C.font.auras_font_style)
- button.remaining:SetShadowOffset(C.font.auras_font_shadow and 1 or 0, C.font.auras_font_shadow and -1 or 0)
- button.remaining:SetPoint("CENTER", button, "CENTER", 1, 1)
- button.remaining:SetJustifyH("CENTER")
- button.cd.noOCC = true
- button.cd.noCooldownCount = true
- button.icon:SetPoint("TOPLEFT", 2, -2)
- button.icon:SetPoint("BOTTOMRIGHT", -2, 2)
- button.icon:SetTexCoord(0.1, 0.9, 0.1, 0.9)
- button.count:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", 1, 0)
- button.count:SetJustifyH("RIGHT")
- button.count:SetFont(C.font.auras_font, C.font.auras_font_size, C.font.auras_font_style)
- button.count:SetShadowOffset(C.font.auras_font_shadow and 1 or 0, C.font.auras_font_shadow and -1 or 0)
- if C.aura.show_spiral == true then
- element.disableCooldown = false
- button.cd:SetReverse(true)
- button.cd:SetPoint("TOPLEFT", button, "TOPLEFT", 2, -2)
- button.cd:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -2, 2)
- button.parent = CreateFrame("Frame", nil, button)
- button.parent:SetFrameLevel(button.cd:GetFrameLevel() + 1)
- button.count:SetParent(button.parent)
- button.remaining:SetParent(button.parent)
- else
- element.disableCooldown = true
- end
- end
- T.PostUpdateIcon = function(icons, unit, icon, index, offset, filter, isDebuff, duration, timeLeft)
- local _, _, _, _, dtype, duration, expirationTime, _, isStealable = UnitAura(unit, index, icon.filter)
- local playerUnits = {
- player = true,
- pet = true,
- vehicle = true,
- }
- if icon.debuff then
- if not UnitIsFriend("player", unit) and not playerUnits[icon.owner] then
- if C.aura.player_aura_only then
- icon:Hide()
- else
- icon:SetBackdropBorderColor(unpack(C.media.border_color))
- icon.icon:SetDesaturated(true)
- end
- else
- if C.aura.debuff_color_type == true then
- local color = DebuffTypeColor[dtype] or DebuffTypeColor.none
- icon:SetBackdropBorderColor(color.r, color.g, color.b)
- icon.icon:SetDesaturated(false)
- else
- icon:SetBackdropBorderColor(1, 0, 0)
- end
- end
- else
- if (isStealable or ((T.class == "MAGE" or T.class == "PRIEST" or T.class == "SHAMAN" or T.class == "HUNTER") and dtype == "Magic")) and not UnitIsFriend("player", unit) then
- icon:SetBackdropBorderColor(1, 0.85, 0)
- else
- icon:SetBackdropBorderColor(unpack(C.media.border_color))
- end
- icon.icon:SetDesaturated(false)
- end
- if duration and duration > 0 and C.aura.show_timer == true then
- icon.remaining:Show()
- icon.timeLeft = expirationTime
- icon:SetScript("OnUpdate", CreateAuraTimer)
- else
- icon.remaining:Hide()
- icon.timeLeft = math.huge
- icon:SetScript("OnUpdate", nil)
- end
- icon.first = true
- end
- T.UpdateThreat = function(self, event, unit)
- if self.unit ~= unit then return end
- local threat = UnitThreatSituation(self.unit)
- if threat and threat > 1 then
- r, g, b = GetThreatStatusColor(threat)
- self.backdrop:SetBackdropBorderColor(r, g, b)
- else
- self.backdrop:SetBackdropBorderColor(unpack(C.media.border_color))
- end
- end
- local CountOffSets = {
- TOPLEFT = {9, 0},
- TOPRIGHT = {-8, 0},
- BOTTOMLEFT = {9, 0},
- BOTTOMRIGHT = {-8, 0},
- LEFT = {9, 0},
- RIGHT = {-8, 0},
- TOP = {0, 0},
- BOTTOM = {0, 0},
- }
- T.CreateAuraWatchIcon = function(self, icon)
- icon:SetTemplate("Default")
- icon.icon:SetPoint("TOPLEFT", icon, 1, -1)
- icon.icon:SetPoint("BOTTOMRIGHT", icon, -1, 1)
- icon.icon:SetTexCoord(0.1, 0.9, 0.1, 0.9)
- icon.icon:SetDrawLayer("ARTWORK")
- if icon.cd then
- icon.cd:SetReverse(true)
- end
- icon.overlay:SetTexture()
- end
- T.CreateAuraWatch = function(self, unit)
- local auras = CreateFrame("Frame", nil, self)
- auras:SetPoint("TOPLEFT", self.Health, 0, 0)
- auras:SetPoint("BOTTOMRIGHT", self.Health, 0, 0)
- auras.icons = {}
- auras.PostCreateIcon = T.CreateAuraWatchIcon
- if not C.aura.show_timer then
- auras.hideCooldown = true
- end
- local buffs = {}
- if T.RaidBuffs["ALL"] then
- for key, value in pairs(T.RaidBuffs["ALL"]) do
- tinsert(buffs, value)
- end
- end
- if T.RaidBuffs[T.class] then
- for key, value in pairs(T.RaidBuffs[T.class]) do
- tinsert(buffs, value)
- end
- end
- if buffs then
- for key, spell in pairs(buffs) do
- local icon = CreateFrame("Frame", nil, auras)
- icon.spellID = spell[1]
- icon.anyUnit = spell[4]
- icon.strictMatching = spell[5]
- icon:SetWidth(7)
- icon:SetHeight(7)
- icon:SetPoint(spell[2], 0, 0)
- local tex = icon:CreateTexture(nil, "OVERLAY")
- tex:SetAllPoints(icon)
- tex:SetTexture(C.media.blank)
- if spell[3] then
- tex:SetVertexColor(unpack(spell[3]))
- else
- tex:SetVertexColor(0.8, 0.8, 0.8)
- end
- local count = T.SetFontString(icon, C.font.unit_frames_font, C.font.unit_frames_font_size, C.font.unit_frames_font_style)
- count:SetPoint("CENTER", unpack(CountOffSets[spell[2]]))
- icon.count = count
- auras.icons[spell[1]] = icon
- end
- end
- self.AuraWatch = auras
- end
Add Comment
Please, Sign In to add comment