Wetxius

Untitled

May 16th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 51.11 KB | None | 0 0
  1. local T, C, L, _ = unpack(select(2, ...))
  2.  
  3. ----------------------------------------------------------------------------------------
  4. -- Number value function
  5. ----------------------------------------------------------------------------------------
  6. T.Round = function(number, decimals)
  7. if not decimals then decimals = 0 end
  8. return (("%%.%df"):format(decimals)):format(number)
  9. end
  10.  
  11. T.ShortValue = function(value)
  12. if value >= 1e8 then
  13. return ("%.0fm"):format(value / 1e6)
  14. elseif value >= 1e7 then
  15. return ("%.1fm"):format(value / 1e6):gsub("%.?0+([km])$", "%1")
  16. elseif value >= 1e6 then
  17. return ("%.2fm"):format(value / 1e6):gsub("%.?0+([km])$", "%1")
  18. elseif value >= 1e5 then
  19. return ("%.0fk"):format(value / 1e3)
  20. elseif value >= 1e3 then
  21. return ("%.1fk"):format(value / 1e3):gsub("%.?0+([km])$", "%1")
  22. else
  23. return value
  24. end
  25. end
  26.  
  27. T.RGBToHex = function(r, g, b)
  28. r = tonumber(r) <= 1 and tonumber(r) >= 0 and tonumber(r) or 0
  29. g = tonumber(g) <= tonumber(g) and tonumber(g) >= 0 and tonumber(g) or 0
  30. b = tonumber(b) <= 1 and tonumber(b) >= 0 and tonumber(b) or 0
  31. return string.format("|cff%02x%02x%02x", r * 255, g * 255, b * 255)
  32. end
  33.  
  34. ----------------------------------------------------------------------------------------
  35. -- Chat channel check
  36. ----------------------------------------------------------------------------------------
  37. T.CheckChat = function(warning)
  38. if IsInGroup(LE_PARTY_CATEGORY_INSTANCE) then
  39. return "INSTANCE_CHAT"
  40. elseif IsInRaid(LE_PARTY_CATEGORY_HOME) then
  41. if warning and (UnitIsGroupLeader("player") or UnitIsGroupAssistant("player") or IsEveryoneAssistant()) then
  42. return "RAID_WARNING"
  43. else
  44. return "RAID"
  45. end
  46. elseif IsInGroup(LE_PARTY_CATEGORY_HOME) then
  47. return "PARTY"
  48. end
  49. return "SAY"
  50. end
  51.  
  52. ----------------------------------------------------------------------------------------
  53. -- Player's Role and Specialization check
  54. ----------------------------------------------------------------------------------------
  55. T.CheckSpec = function(spec)
  56. local activeGroup = GetActiveSpecGroup()
  57. if activeGroup and GetSpecialization(false, false, activeGroup) then
  58. return spec == GetSpecialization(false, false, activeGroup)
  59. end
  60. end
  61.  
  62. local isCaster = {
  63. DEATHKNIGHT = {nil, nil, nil},
  64. DEMONHUNTER = {nil, nil},
  65. DRUID = {true}, -- Balance
  66. HUNTER = {nil, nil, nil},
  67. MAGE = {true, true, true},
  68. MONK = {nil, nil, nil},
  69. PALADIN = {nil, nil, nil},
  70. PRIEST = {nil, nil, true}, -- Shadow
  71. ROGUE = {nil, nil, nil},
  72. SHAMAN = {true}, -- Elemental
  73. WARLOCK = {true, true, true},
  74. WARRIOR = {nil, nil, nil}
  75. }
  76.  
  77. local function CheckRole(self, event, unit)
  78. local spec = GetSpecialization()
  79. local role = spec and GetSpecializationRole(spec)
  80.  
  81. if role == "TANK" then
  82. T.Role = "Tank"
  83. elseif role == "HEALER" then
  84. T.Role = "Healer"
  85. elseif role == "DAMAGER" then
  86. if isCaster[T.class][spec] then
  87. T.Role = "Caster"
  88. else
  89. T.Role = "Melee"
  90. end
  91. end
  92. end
  93. local RoleUpdater = CreateFrame("Frame")
  94. RoleUpdater:RegisterEvent("PLAYER_ENTERING_WORLD")
  95. RoleUpdater:RegisterEvent("PLAYER_TALENT_UPDATE")
  96. RoleUpdater:SetScript("OnEvent", CheckRole)
  97.  
  98. ----------------------------------------------------------------------------------------
  99. -- UTF functions
  100. ----------------------------------------------------------------------------------------
  101. T.UTF = function(string, i, dots)
  102. if not string then return end
  103. local bytes = string:len()
  104. if bytes <= i then
  105. return string
  106. else
  107. local len, pos = 0, 1
  108. while (pos <= bytes) do
  109. len = len + 1
  110. local c = string:byte(pos)
  111. if c > 0 and c <= 127 then
  112. pos = pos + 1
  113. elseif c >= 192 and c <= 223 then
  114. pos = pos + 2
  115. elseif c >= 224 and c <= 239 then
  116. pos = pos + 3
  117. elseif c >= 240 and c <= 247 then
  118. pos = pos + 4
  119. end
  120. if len == i then break end
  121. end
  122. if len == i and pos <= bytes then
  123. return string:sub(1, pos - 1)..(dots and "..." or "")
  124. else
  125. return string
  126. end
  127. end
  128. end
  129.  
  130. ----------------------------------------------------------------------------------------
  131. -- Style functions
  132. ----------------------------------------------------------------------------------------
  133. T.SkinFuncs = {}
  134. T.SkinFuncs["ShestakUI"] = {}
  135.  
  136. function T.SkinScrollBar(frame)
  137. if _G[frame:GetName().."BG"] then
  138. _G[frame:GetName().."BG"]:SetTexture(nil)
  139. end
  140. if _G[frame:GetName().."Track"] then
  141. _G[frame:GetName().."Track"]:SetTexture(nil)
  142. end
  143. if _G[frame:GetName().."Top"] then
  144. _G[frame:GetName().."Top"]:SetTexture(nil)
  145. end
  146. if _G[frame:GetName().."Bottom"] then
  147. _G[frame:GetName().."Bottom"]:SetTexture(nil)
  148. end
  149. if _G[frame:GetName().."Middle"] then
  150. _G[frame:GetName().."Middle"]:SetTexture(nil)
  151. end
  152.  
  153. if _G[frame:GetName().."ScrollUpButton"] and _G[frame:GetName().."ScrollDownButton"] then
  154. _G[frame:GetName().."ScrollUpButton"]:StripTextures()
  155. if not _G[frame:GetName().."ScrollUpButton"].icon then
  156. T.SkinNextPrevButton(_G[frame:GetName().."ScrollUpButton"])
  157. _G[frame:GetName().."ScrollUpButton"]:SetSize(_G[frame:GetName().."ScrollUpButton"]:GetWidth() + 7, _G[frame:GetName().."ScrollUpButton"]:GetHeight() + 7)
  158. scrolldn = false
  159. end
  160.  
  161. _G[frame:GetName().."ScrollDownButton"]:StripTextures()
  162. if not _G[frame:GetName().."ScrollDownButton"].icon then
  163. T.SkinNextPrevButton(_G[frame:GetName().."ScrollDownButton"])
  164. _G[frame:GetName().."ScrollDownButton"]:SetSize(_G[frame:GetName().."ScrollDownButton"]:GetWidth() + 7, _G[frame:GetName().."ScrollDownButton"]:GetHeight() + 7)
  165. scrolldn = true
  166. end
  167.  
  168. if frame:GetThumbTexture() then
  169. frame:GetThumbTexture():SetTexture(nil)
  170. if not frame.thumbbg then
  171. frame.thumbbg = CreateFrame("Frame", nil, frame)
  172. frame.thumbbg:SetPoint("TOPLEFT", frame:GetThumbTexture(), "TOPLEFT", 0, -3)
  173. frame.thumbbg:SetPoint("BOTTOMRIGHT", frame:GetThumbTexture(), "BOTTOMRIGHT", 0, 3)
  174. frame.thumbbg:SetTemplate("Overlay")
  175. if frame.trackbg then
  176. frame.thumbbg:SetFrameLevel(frame.trackbg:GetFrameLevel())
  177. end
  178.  
  179. frame:HookScript("OnShow", function()
  180. local _, maxValue = frame:GetMinMaxValues()
  181. if maxValue == 0 then
  182. frame:SetAlpha(0)
  183. else
  184. frame:SetAlpha(1)
  185. end
  186. end)
  187.  
  188. frame:HookScript("OnMinMaxChanged", function()
  189. local _, maxValue = frame:GetMinMaxValues()
  190. if maxValue == 0 then
  191. frame:SetAlpha(0)
  192. else
  193. frame:SetAlpha(1)
  194. end
  195. end)
  196.  
  197. frame:HookScript("OnDisable", function()
  198. frame:SetAlpha(0)
  199. end)
  200.  
  201. frame:HookScript("OnEnable", function()
  202. frame:SetAlpha(1)
  203. end)
  204. end
  205. end
  206. end
  207. end
  208.  
  209. local tabs = {
  210. "LeftDisabled",
  211. "MiddleDisabled",
  212. "RightDisabled",
  213. "Left",
  214. "Middle",
  215. "Right",
  216. }
  217.  
  218. function T.SkinTab(tab, bg)
  219. if not tab then return end
  220.  
  221. for _, object in pairs(tabs) do
  222. local tex = _G[tab:GetName()..object]
  223. if tex then
  224. tex:SetTexture(nil)
  225. end
  226. end
  227.  
  228. if tab.GetHighlightTexture and tab:GetHighlightTexture() then
  229. tab:GetHighlightTexture():SetTexture(nil)
  230. else
  231. tab:StripTextures()
  232. end
  233.  
  234. tab.backdrop = CreateFrame("Frame", nil, tab)
  235. tab.backdrop:SetFrameLevel(tab:GetFrameLevel() - 1)
  236. if bg then
  237. tab.backdrop:SetTemplate("Overlay")
  238. tab.backdrop:SetPoint("TOPLEFT", 3, -7)
  239. tab.backdrop:SetPoint("BOTTOMRIGHT", -3, 2)
  240. else
  241. tab.backdrop:SetTemplate("Transparent")
  242. tab.backdrop:SetPoint("TOPLEFT", 10, -3)
  243. tab.backdrop:SetPoint("BOTTOMRIGHT", -10, 3)
  244. end
  245. end
  246.  
  247. function T.SkinNextPrevButton(btn, left)
  248. local normal, pushed, disabled
  249. 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
  250. local isScrollUpButton = btn:GetName() and string.find(btn:GetName(), "ScrollUp")
  251. local isScrollDownButton = btn:GetName() and string.find(btn:GetName(), "ScrollDown")
  252.  
  253. if btn:GetNormalTexture() then
  254. normal = btn:GetNormalTexture():GetTexture()
  255. end
  256.  
  257. if btn:GetPushedTexture() then
  258. pushed = btn:GetPushedTexture():GetTexture()
  259. end
  260.  
  261. if btn:GetDisabledTexture() then
  262. disabled = btn:GetDisabledTexture():GetTexture()
  263. end
  264.  
  265. btn:StripTextures()
  266.  
  267. if not normal then
  268. if isPrevButton then
  269. normal = "Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Up"
  270. elseif isScrollUpButton then
  271. normal = "Interface\\ChatFrame\\UI-ChatIcon-ScrollUp-Up"
  272. elseif isScrollDownButton then
  273. normal = "Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Up"
  274. else
  275. normal = "Interface\\Buttons\\UI-SpellbookIcon-NextPage-Up"
  276. end
  277. end
  278.  
  279. if not pushed then
  280. if isPrevButton then
  281. pushed = "Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Down"
  282. elseif isScrollUpButton then
  283. pushed = "Interface\\ChatFrame\\UI-ChatIcon-ScrollUp-Down"
  284. elseif isScrollDownButton then
  285. pushed = "Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Down"
  286. else
  287. pushed = "Interface\\Buttons\\UI-SpellbookIcon-NextPage-Down"
  288. end
  289. end
  290.  
  291. if not disabled then
  292. if isPrevButton then
  293. disabled = "Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Disabled"
  294. elseif isScrollUpButton then
  295. disabled = "Interface\\ChatFrame\\UI-ChatIcon-ScrollUp-Disabled"
  296. elseif isScrollDownButton then
  297. disabled = "Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Disabled"
  298. else
  299. disabled = "Interface\\Buttons\\UI-SpellbookIcon-NextPage-Disabled"
  300. end
  301. end
  302.  
  303. btn:SetNormalTexture(normal)
  304. btn:SetPushedTexture(pushed)
  305. btn:SetDisabledTexture(disabled)
  306.  
  307. btn:SetTemplate("Overlay")
  308. btn:SetSize(btn:GetWidth() - 7, btn:GetHeight() - 7)
  309.  
  310. if normal and pushed and disabled then
  311. btn:GetNormalTexture():SetTexCoord(0.3, 0.29, 0.3, 0.81, 0.65, 0.29, 0.65, 0.81)
  312. if btn:GetPushedTexture() then
  313. btn:GetPushedTexture():SetTexCoord(0.3, 0.35, 0.3, 0.81, 0.65, 0.35, 0.65, 0.81)
  314. end
  315. if btn:GetDisabledTexture() then
  316. btn:GetDisabledTexture():SetTexCoord(0.3, 0.29, 0.3, 0.75, 0.65, 0.29, 0.65, 0.75)
  317. end
  318.  
  319. btn:GetNormalTexture():ClearAllPoints()
  320. btn:GetNormalTexture():SetPoint("TOPLEFT", 2, -2)
  321. btn:GetNormalTexture():SetPoint("BOTTOMRIGHT", -2, 2)
  322. if btn:GetDisabledTexture() then
  323. btn:GetDisabledTexture():SetAllPoints(btn:GetNormalTexture())
  324. end
  325. if btn:GetPushedTexture() then
  326. btn:GetPushedTexture():SetAllPoints(btn:GetNormalTexture())
  327. end
  328. btn:GetHighlightTexture():SetTexture(1, 1, 1, 0.3)
  329. btn:GetHighlightTexture():SetAllPoints(btn:GetNormalTexture())
  330. end
  331. end
  332.  
  333. function T.SkinRotateButton(btn)
  334. btn:SetTemplate("Default")
  335. btn:SetSize(btn:GetWidth() - 14, btn:GetHeight() - 14)
  336.  
  337. btn:GetNormalTexture():SetTexCoord(0.3, 0.29, 0.3, 0.65, 0.69, 0.29, 0.69, 0.65)
  338. btn:GetPushedTexture():SetTexCoord(0.3, 0.29, 0.3, 0.65, 0.69, 0.29, 0.69, 0.65)
  339.  
  340. btn:GetHighlightTexture():SetTexture(1, 1, 1, 0.3)
  341.  
  342. btn:GetNormalTexture():ClearAllPoints()
  343. btn:GetNormalTexture():SetPoint("TOPLEFT", 2, -2)
  344. btn:GetNormalTexture():SetPoint("BOTTOMRIGHT", -2, 2)
  345. btn:GetPushedTexture():SetAllPoints(btn:GetNormalTexture())
  346. btn:GetHighlightTexture():SetAllPoints(btn:GetNormalTexture())
  347. end
  348.  
  349. function T.SkinEditBox(frame, width, height)
  350. if _G[frame:GetName()] then
  351. if _G[frame:GetName().."Left"] then _G[frame:GetName().."Left"]:Kill() end
  352. if _G[frame:GetName().."Middle"] then _G[frame:GetName().."Middle"]:Kill() end
  353. if _G[frame:GetName().."Right"] then _G[frame:GetName().."Right"]:Kill() end
  354. if _G[frame:GetName().."Mid"] then _G[frame:GetName().."Mid"]:Kill() end
  355. end
  356.  
  357. if frame.Left then frame.Left:Kill() end
  358. if frame.Right then frame.Right:Kill() end
  359. if frame.Middle then frame.Middle:Kill() end
  360.  
  361. frame:CreateBackdrop("Overlay")
  362.  
  363. if frame:GetName() and (frame:GetName():find("Gold") or frame:GetName():find("Silver") or frame:GetName():find("Copper")) then
  364. if frame:GetName():find("Gold") then
  365. frame.backdrop:SetPoint("TOPLEFT", -3, 1)
  366. frame.backdrop:SetPoint("BOTTOMRIGHT", -3, 0)
  367. else
  368. frame.backdrop:SetPoint("TOPLEFT", -3, 1)
  369. frame.backdrop:SetPoint("BOTTOMRIGHT", -13, 0)
  370. end
  371. end
  372.  
  373. if width then frame:SetWidth(width) end
  374. if height then frame:SetHeight(height) end
  375. end
  376.  
  377. function T.SkinDropDownBox(frame, width)
  378. local button = _G[frame:GetName().."Button"] or _G[frame:GetName().."_Button"]
  379. if not width then width = 155 end
  380.  
  381. frame:StripTextures()
  382. frame:SetWidth(width)
  383.  
  384. if _G[frame:GetName().."Text"] then
  385. _G[frame:GetName().."Text"]:ClearAllPoints()
  386. _G[frame:GetName().."Text"]:SetPoint("RIGHT", button, "LEFT", -2, 0)
  387. end
  388.  
  389. button:ClearAllPoints()
  390. button:SetPoint("RIGHT", frame, "RIGHT", -10, 3)
  391. button.SetPoint = T.dummy
  392. scrolldn = false
  393. T.SkinNextPrevButton(button)
  394.  
  395. frame:CreateBackdrop("Overlay")
  396. frame:SetFrameLevel(frame:GetFrameLevel() + 2)
  397. frame.backdrop:SetPoint("TOPLEFT", 20, -2)
  398. frame.backdrop:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", 2, -2)
  399. end
  400.  
  401. function T.SkinCheckBox(frame, default)
  402. frame:SetNormalTexture("")
  403. frame:SetPushedTexture("")
  404. frame:CreateBackdrop("Overlay")
  405. frame:SetFrameLevel(frame:GetFrameLevel() + 2)
  406. frame.backdrop:SetPoint("TOPLEFT", 4, -4)
  407. frame.backdrop:SetPoint("BOTTOMRIGHT", -4, 4)
  408.  
  409. if frame.SetHighlightTexture then
  410. local highligh = frame:CreateTexture(nil, nil, self)
  411. highligh:SetTexture(1, 1, 1, 0.3)
  412. highligh:SetPoint("TOPLEFT", frame, 6, -6)
  413. highligh:SetPoint("BOTTOMRIGHT", frame, -6, 6)
  414. frame:SetHighlightTexture(highligh)
  415. end
  416.  
  417. if frame.SetCheckedTexture then
  418. if default then return end
  419. local checked = frame:CreateTexture(nil, nil, self)
  420. checked:SetTexture(1, 0.82, 0, 0.8)
  421. checked:SetPoint("TOPLEFT", frame, 6, -6)
  422. checked:SetPoint("BOTTOMRIGHT", frame, -6, 6)
  423. frame:SetCheckedTexture(checked)
  424. end
  425.  
  426. if frame.SetDisabledCheckedTexture then
  427. local disabled = frame:CreateTexture(nil, nil, self)
  428. disabled:SetTexture(0.6, 0.6, 0.6, 0.75)
  429. disabled:SetPoint("TOPLEFT", frame, 6, -6)
  430. disabled:SetPoint("BOTTOMRIGHT", frame, -6, 6)
  431. frame:SetDisabledCheckedTexture(disabled)
  432. end
  433.  
  434. frame:HookScript("OnDisable", function(self)
  435. if not self.SetDisabledTexture then return end
  436. if self:GetChecked() then
  437. self:SetDisabledTexture(disabled)
  438. else
  439. self:SetDisabledTexture("")
  440. end
  441. end)
  442. end
  443.  
  444. function T.SkinCloseButton(f, point, text, pixel)
  445. f:StripTextures()
  446. f:SetTemplate("Overlay")
  447. f:SetSize(18, 18)
  448.  
  449. if not text then text = "x" end
  450. if not f.text then
  451. if pixel then
  452. f.text = f:FontString(nil, C.media.pixel_font, 8)
  453. f.text:SetPoint("CENTER", 0, 0)
  454. else
  455. f.text = f:FontString(nil, C.media.normal_font, 17)
  456. f.text:SetPoint("CENTER", 0, 1)
  457. end
  458. f.text:SetText(text)
  459. end
  460.  
  461. if point then
  462. f:SetPoint("TOPRIGHT", point, "TOPRIGHT", -4, -4)
  463. else
  464. f:SetPoint("TOPRIGHT", -4, -4)
  465. end
  466.  
  467. f:HookScript("OnEnter", T.SetModifiedBackdrop)
  468. f:HookScript("OnLeave", T.SetOriginalBackdrop)
  469. end
  470.  
  471. function T.HandleIcon(icon, parent)
  472. parent = parent or icon:GetParent()
  473.  
  474. icon:SetTexCoord(0.1, 0.9, 0.1, 0.9)
  475. parent:CreateBackdrop("Default")
  476. icon:SetParent(parent.backdrop)
  477. end
  478.  
  479. function T.SkinSlider(f)
  480. f:SetBackdrop(nil)
  481.  
  482. local bd = CreateFrame("Frame", nil, f)
  483. bd:SetTemplate("Overlay")
  484. if f:GetOrientation() == "VERTICAL" then
  485. bd:SetPoint("TOPLEFT", -2, -6)
  486. bd:SetPoint("BOTTOMRIGHT", 2, 6)
  487. else
  488. bd:SetPoint("TOPLEFT", 14, -2)
  489. bd:SetPoint("BOTTOMRIGHT", -15, 3)
  490. end
  491. bd:SetFrameLevel(f:GetFrameLevel() - 1)
  492.  
  493. local slider = select(4, f:GetRegions())
  494. slider:SetTexture("Interface\\CastingBar\\UI-CastingBar-Spark")
  495. slider:SetBlendMode("ADD")
  496. end
  497.  
  498. local LoadBlizzardSkin = CreateFrame("Frame")
  499. LoadBlizzardSkin:RegisterEvent("ADDON_LOADED")
  500. LoadBlizzardSkin:SetScript("OnEvent", function(self, event, addon)
  501. if IsAddOnLoaded("Skinner") or IsAddOnLoaded("Aurora") or not C.skins.blizzard_frames then
  502. self:UnregisterEvent("ADDON_LOADED")
  503. return
  504. end
  505.  
  506. for _addon, skinfunc in pairs(T.SkinFuncs) do
  507. if type(skinfunc) == "function" then
  508. if _addon == addon then
  509. if skinfunc then
  510. skinfunc()
  511. end
  512. end
  513. elseif type(skinfunc) == "table" then
  514. if _addon == addon then
  515. for _, skinfunc in pairs(T.SkinFuncs[_addon]) do
  516. if skinfunc then
  517. skinfunc()
  518. end
  519. end
  520. end
  521. end
  522. end
  523. end)
  524.  
  525. ----------------------------------------------------------------------------------------
  526. -- Unit frames functions
  527. ----------------------------------------------------------------------------------------
  528. if C.unitframe.enable ~= true then return end
  529. local _, ns = ...
  530. local oUF = ns.oUF
  531.  
  532. T.UpdateAllElements = function(frame)
  533. for _, v in ipairs(frame.__elements) do
  534. v(frame, "UpdateElement", frame.unit)
  535. end
  536. end
  537.  
  538. local SetUpAnimGroup = function(self)
  539. self.anim = self:CreateAnimationGroup("Flash")
  540. self.anim.fadein = self.anim:CreateAnimation("ALPHA", "FadeIn")
  541. self.anim.fadein:SetChange(1)
  542. self.anim.fadein:SetOrder(2)
  543.  
  544. self.anim.fadeout = self.anim:CreateAnimation("ALPHA", "FadeOut")
  545. self.anim.fadeout:SetChange(-1)
  546. self.anim.fadeout:SetOrder(1)
  547. end
  548.  
  549. local Flash = function(self, duration)
  550. if not self.anim then
  551. SetUpAnimGroup(self)
  552. end
  553.  
  554. if not self.anim:IsPlaying() or duration ~= self.anim.fadein:GetDuration() then
  555. self.anim.fadein:SetDuration(duration)
  556. self.anim.fadeout:SetDuration(duration)
  557. self.anim:Play()
  558. end
  559. end
  560.  
  561. local StopFlash = function(self)
  562. if self.anim then
  563. self.anim:Finish()
  564. end
  565. end
  566.  
  567. T.SetFontString = function(parent, fontName, fontHeight, fontStyle)
  568. local fs = parent:CreateFontString(nil, "ARTWORK")
  569. fs:SetFont(fontName, fontHeight, fontStyle)
  570. fs:SetShadowOffset(C.font.unit_frames_font_shadow and 1 or 0, C.font.unit_frames_font_shadow and -1 or 0)
  571. return fs
  572. end
  573.  
  574. T.PostUpdateHealth = function(health, unit, min, max)
  575. if unit and unit:find("arena%dtarget") then return end
  576. if not UnitIsConnected(unit) or UnitIsDead(unit) or UnitIsGhost(unit) then
  577. health:SetValue(0)
  578. if not UnitIsConnected(unit) then
  579. health.value:SetText("|cffD7BEA5"..L_UF_OFFLINE.."|r")
  580. elseif UnitIsDead(unit) then
  581. health.value:SetText("|cffD7BEA5"..L_UF_DEAD.."|r")
  582. elseif UnitIsGhost(unit) then
  583. health.value:SetText("|cffD7BEA5"..L_UF_GHOST.."|r")
  584. end
  585. else
  586. local r, g, b
  587. 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
  588. local c = T.oUF_colors.reaction[UnitReaction(unit, "player")]
  589. if c then
  590. r, g, b = c[1], c[2], c[3]
  591. health:SetStatusBarColor(r, g, b)
  592. else
  593. r, g, b = 0.3, 0.7, 0.3
  594. health:SetStatusBarColor(r, g, b)
  595. end
  596. end
  597. if unit == "pet" or unit == "vehicle" then
  598. local _, class = UnitClass("player")
  599. local r, g, b = unpack(T.oUF_colors.class[class])
  600. if C.unitframe.own_color == true then
  601. health:SetStatusBarColor(unpack(C.unitframe.uf_color))
  602. health.bg:SetVertexColor(0.1, 0.1, 0.1)
  603. else
  604. if b then
  605. health:SetStatusBarColor(r, g, b)
  606. if health.bg and health.bg.multiplier then
  607. local mu = health.bg.multiplier
  608. health.bg:SetVertexColor(r * mu, g * mu, b * mu)
  609. end
  610. end
  611. end
  612. end
  613. if C.unitframe.bar_color_value == true and not (UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit)) then
  614. if C.unitframe.own_color == true then
  615. r, g, b = C.unitframe.uf_color[1], C.unitframe.uf_color[2], C.unitframe.uf_color[3]
  616. else
  617. r, g, b = health:GetStatusBarColor()
  618. end
  619. local newr, newg, newb = oUF.ColorGradient(min, max, 1, 0, 0, 1, 1, 0, r, g, b)
  620.  
  621. health:SetStatusBarColor(newr, newg, newb)
  622. if health.bg and health.bg.multiplier then
  623. local mu = health.bg.multiplier
  624. health.bg:SetVertexColor(newr * mu, newg * mu, newb * mu)
  625. end
  626. end
  627. if min ~= max then
  628. 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)
  629. if unit == "player" and health:GetAttribute("normalUnit") ~= "pet" then
  630. if C.unitframe.show_total_value == true then
  631. if C.unitframe.color_value == true then
  632. health.value:SetFormattedText("|cff559655%s|r |cffD7BEA5-|r |cff559655%s|r", T.ShortValue(min), T.ShortValue(max))
  633. else
  634. health.value:SetFormattedText("|cffffffff%s - %s|r", T.ShortValue(min), T.ShortValue(max))
  635. end
  636. else
  637. if C.unitframe.color_value == true then
  638. 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))
  639. else
  640. health.value:SetFormattedText("|cffffffff%d - %d%%|r", min, floor(min / max * 100))
  641. end
  642. end
  643. elseif unit == "target" then
  644. if C.unitframe.show_total_value == true then
  645. if C.unitframe.color_value == true then
  646. health.value:SetFormattedText("|cff559655%s|r |cffD7BEA5-|r |cff559655%s|r", T.ShortValue(min), T.ShortValue(max))
  647. else
  648. health.value:SetFormattedText("|cffffffff%s - %s|r", T.ShortValue(min), T.ShortValue(max))
  649. end
  650. else
  651. if C.unitframe.color_value == true then
  652. 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))
  653. else
  654. health.value:SetFormattedText("|cffffffff%d%% - %s|r", floor(min / max * 100), T.ShortValue(min))
  655. end
  656. end
  657. elseif unit and unit:find("boss%d") then
  658. if C.unitframe.color_value == true then
  659. 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))
  660. else
  661. health.value:SetFormattedText("|cffffffff%d%% - %s|r", floor(min / max * 100), T.ShortValue(min))
  662. end
  663. else
  664. if C.unitframe.color_value == true then
  665. health.value:SetFormattedText("|cff%02x%02x%02x%d%%|r", r * 255, g * 255, b * 255, floor(min / max * 100))
  666. else
  667. health.value:SetFormattedText("|cffffffff%d%%|r", floor(min / max * 100))
  668. end
  669. end
  670. else
  671. if unit == "player" and unit ~= "pet" then
  672. if C.unitframe.color_value == true then
  673. health.value:SetText("|cff559655"..max.."|r")
  674. else
  675. health.value:SetText("|cffffffff"..max.."|r")
  676. end
  677. else
  678. if C.unitframe.color_value == true then
  679. health.value:SetText("|cff559655"..T.ShortValue(max).."|r")
  680. else
  681. health.value:SetText("|cffffffff"..T.ShortValue(max).."|r")
  682. end
  683. end
  684. end
  685. end
  686. end
  687.  
  688. T.PostUpdateRaidHealth = function(health, unit, min, max)
  689. local self = health:GetParent()
  690. local power = self.Power
  691. local border = self.backdrop
  692. if not UnitIsConnected(unit) or UnitIsDead(unit) or UnitIsGhost(unit) then
  693. health:SetValue(0)
  694. if not UnitIsConnected(unit) then
  695. health.value:SetText("|cffD7BEA5"..L_UF_OFFLINE.."|r")
  696. elseif UnitIsDead(unit) then
  697. health.value:SetText("|cffD7BEA5"..L_UF_DEAD.."|r")
  698. elseif UnitIsGhost(unit) then
  699. health.value:SetText("|cffD7BEA5"..L_UF_GHOST.."|r")
  700. end
  701. else
  702. local r, g, b
  703. if not UnitIsPlayer(unit) and UnitIsFriend(unit, "player") and C.unitframe.own_color ~= true then
  704. local c = T.oUF_colors.reaction[5]
  705. local r, g, b = c[1], c[2], c[3]
  706. health:SetStatusBarColor(r, g, b)
  707. if health.bg and health.bg.multiplier then
  708. local mu = health.bg.multiplier
  709. health.bg:SetVertexColor(r * mu, g * mu, b * mu)
  710. end
  711. end
  712. if C.unitframe.bar_color_value == true and not (UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit)) then
  713. if C.unitframe.own_color == true then
  714. r, g, b = C.unitframe.uf_color[1], C.unitframe.uf_color[2], C.unitframe.uf_color[3]
  715. else
  716. r, g, b = health:GetStatusBarColor()
  717. end
  718. local newr, newg, newb = oUF.ColorGradient(min, max, 1, 0, 0, 1, 1, 0, r, g, b)
  719.  
  720. health:SetStatusBarColor(newr, newg, newb)
  721. if health.bg and health.bg.multiplier then
  722. local mu = health.bg.multiplier
  723. health.bg:SetVertexColor(newr * mu, newg * mu, newb * mu)
  724. end
  725. end
  726. if min ~= max then
  727. 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)
  728. if self:GetParent():GetName():match("oUF_PartyDPS") then
  729. if C.unitframe.color_value == true then
  730. 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))
  731. else
  732. health.value:SetFormattedText("|cffffffff%s - %d%%|r", T.ShortValue(min), floor(min / max * 100))
  733. end
  734. else
  735. if C.unitframe.color_value == true then
  736. if C.raidframe.deficit_health == true then
  737. health.value:SetText("|cffffffff".."-"..T.ShortValue(max - min))
  738. else
  739. health.value:SetFormattedText("|cff%02x%02x%02x%d%%|r", r * 255, g * 255, b * 255, floor(min / max * 100))
  740. end
  741. else
  742. if C.raidframe.deficit_health == true then
  743. health.value:SetText("|cffffffff".."-"..T.ShortValue(max - min))
  744. else
  745. health.value:SetFormattedText("|cffffffff%d%%|r", floor(min / max * 100))
  746. end
  747. end
  748. end
  749. else
  750. if C.unitframe.color_value == true then
  751. health.value:SetText("|cff559655"..T.ShortValue(max).."|r")
  752. else
  753. health.value:SetText("|cffffffff"..T.ShortValue(max).."|r")
  754. end
  755. end
  756. if C.raidframe.alpha_health == true then
  757. if min / max > 0.95 then
  758. health:SetAlpha(0.6)
  759. power:SetAlpha(0.6)
  760. border:SetAlpha(0.6)
  761. else
  762. health:SetAlpha(1)
  763. power:SetAlpha(1)
  764. border:SetAlpha(1)
  765. end
  766. end
  767. end
  768. end
  769.  
  770. T.PreUpdatePower = function(power, unit)
  771. local _, pToken = UnitPowerType(unit)
  772.  
  773. local color = T.oUF_colors.power[pToken]
  774. if color then
  775. power:SetStatusBarColor(color[1], color[2], color[3])
  776. end
  777. end
  778.  
  779. T.PostUpdatePower = function(power, unit, min, max)
  780. if unit and unit:find("arena%dtarget") then return end
  781. local self = power:GetParent()
  782. local pType, pToken = UnitPowerType(unit)
  783. local color = T.oUF_colors.power[pToken]
  784.  
  785. if color then
  786. power.value:SetTextColor(color[1], color[2], color[3])
  787. end
  788.  
  789. if not UnitIsConnected(unit) or UnitIsDead(unit) or UnitIsGhost(unit) then
  790. power:SetValue(0)
  791. end
  792.  
  793. if unit == "focus" or unit == "focustarget" or unit == "targettarget" or (self:GetParent():GetName():match("oUF_RaidDPS")) then return end
  794.  
  795. if not UnitIsConnected(unit) then
  796. power.value:SetText()
  797. elseif UnitIsDead(unit) or UnitIsGhost(unit) or max == 0 then
  798. power.value:SetText()
  799. else
  800. if min ~= max then
  801. if pType == 0 and pToken ~= "POWER_TYPE_DINO_SONIC" then
  802. if unit == "target" then
  803. if C.unitframe.show_total_value == true then
  804. if C.unitframe.color_value == true then
  805. power.value:SetFormattedText("%s |cffD7BEA5-|r %s", T.ShortValue(max - (max - min)), T.ShortValue(max))
  806. else
  807. power.value:SetFormattedText("|cffffffff%s - %s|r", T.ShortValue(max - (max - min)), T.ShortValue(max))
  808. end
  809. else
  810. if C.unitframe.color_value == true then
  811. power.value:SetFormattedText("%d%% |cffD7BEA5-|r %s", floor(min / max * 100), T.ShortValue(max - (max - min)))
  812. else
  813. power.value:SetFormattedText("|cffffffff%d%% - %s|r", floor(min / max * 100), T.ShortValue(max - (max - min)))
  814. end
  815. end
  816. elseif (unit == "player" and power:GetAttribute("normalUnit") == "pet") or unit == "pet" then
  817. if C.unitframe.show_total_value == true then
  818. if C.unitframe.color_value == true then
  819. power.value:SetFormattedText("%s |cffD7BEA5-|r %s", T.ShortValue(max - (max - min)), T.ShortValue(max))
  820. else
  821. power.value:SetFormattedText("%s |cffffffff-|r %s", T.ShortValue(max - (max - min)), T.ShortValue(max))
  822. end
  823. else
  824. if C.unitframe.color_value == true then
  825. power.value:SetFormattedText("%d%%", floor(min / max * 100))
  826. else
  827. power.value:SetFormattedText("|cffffffff%d%%|r", floor(min / max * 100))
  828. end
  829. end
  830. elseif unit and (unit:find("arena%d") or unit:find("boss%d")) then
  831. if C.unitframe.color_value == true then
  832. power.value:SetFormattedText("|cffD7BEA5%d%% - %s|r", floor(min / max * 100), T.ShortValue(max - (max - min)))
  833. else
  834. power.value:SetFormattedText("|cffffffff%d%% - %s|r", floor(min / max * 100), T.ShortValue(max - (max - min)))
  835. end
  836. elseif self:GetParent():GetName():match("oUF_PartyDPS") then
  837. if C.unitframe.color_value == true then
  838. power.value:SetFormattedText("%s |cffD7BEA5-|r %d%%", T.ShortValue(max - (max - min)), floor(min / max * 100))
  839. else
  840. power.value:SetFormattedText("|cffffffff%s - %d%%|r", T.ShortValue(max - (max - min)), floor(min / max * 100))
  841. end
  842. else
  843. if C.unitframe.show_total_value == true then
  844. if C.unitframe.color_value == true then
  845. power.value:SetFormattedText("%s |cffD7BEA5-|r %s", T.ShortValue(max - (max - min)), T.ShortValue(max))
  846. else
  847. power.value:SetFormattedText("|cffffffff%s - %s|r", T.ShortValue(max - (max - min)), T.ShortValue(max))
  848. end
  849. else
  850. if C.unitframe.color_value == true then
  851. power.value:SetFormattedText("%d |cffD7BEA5-|r %d%%", max - (max - min), floor(min / max * 100))
  852. else
  853. power.value:SetFormattedText("|cffffffff%d - %d%%|r", max - (max - min), floor(min / max * 100))
  854. end
  855. end
  856. end
  857. else
  858. if C.unitframe.color_value == true then
  859. power.value:SetText(max - (max - min))
  860. else
  861. power.value:SetText("|cffffffff"..max - (max - min).."|r")
  862. end
  863. end
  864. else
  865. if unit == "pet" or unit == "target" or (unit and unit:find("arena%d")) or (self:GetParent():GetName():match("oUF_PartyDPS")) then
  866. if C.unitframe.color_value == true then
  867. power.value:SetText(T.ShortValue(min))
  868. else
  869. power.value:SetText("|cffffffff"..T.ShortValue(min).."|r")
  870. end
  871. else
  872. if C.unitframe.color_value == true then
  873. power.value:SetText(min)
  874. else
  875. power.value:SetText("|cffffffff"..min.."|r")
  876. end
  877. end
  878. end
  879. end
  880. end
  881.  
  882. T.UpdateManaLevel = function(self, elapsed)
  883. self.elapsed = (self.elapsed or 0) + elapsed
  884. if self.elapsed < 0.2 then return end
  885. self.elapsed = 0
  886.  
  887. if UnitPowerType("player") ~= 0 then
  888. if T.class == "MONK" then
  889. self.ManaLevel:SetText()
  890. end
  891. return
  892. end
  893.  
  894. local percMana = UnitMana("player") / UnitManaMax("player") * 100
  895.  
  896. if percMana <= 20 and not UnitIsDeadOrGhost("player") then
  897. self.ManaLevel:SetText("|cffaf5050"..MANA_LOW.."|r")
  898. Flash(self, 0.3)
  899. else
  900. self.ManaLevel:SetText()
  901. StopFlash(self)
  902. end
  903. end
  904.  
  905. T.UpdateClassMana = function(self)
  906. if self.unit ~= "player" then return end
  907.  
  908. if UnitPowerType("player") ~= 0 then
  909. local min = UnitPower("player", 0)
  910. local max = UnitPowerMax("player", 0)
  911.  
  912. local percMana = min / max * 100
  913. if percMana <= 20 and not UnitIsDeadOrGhost("player") then
  914. self.FlashInfo.ManaLevel:SetText("|cffaf5050"..MANA_LOW.."|r")
  915. Flash(self.FlashInfo, 0.3)
  916. else
  917. self.FlashInfo.ManaLevel:SetText()
  918. StopFlash(self.FlashInfo)
  919. end
  920.  
  921. if min ~= max then
  922. if self.Power.value:GetText() then
  923. self.ClassMana:SetPoint("RIGHT", self.Power.value, "LEFT", -1, 0)
  924. self.ClassMana:SetFormattedText("%d%%|r |cffD7BEA5-|r", floor(min / max * 100))
  925. self.ClassMana:SetJustifyH("RIGHT")
  926. else
  927. self.ClassMana:SetPoint("LEFT", self.Power, "LEFT", 4, 0)
  928. self.ClassMana:SetFormattedText("%d%%", floor(min / max * 100))
  929. end
  930. else
  931. self.ClassMana:SetText()
  932. end
  933.  
  934. self.ClassMana:SetAlpha(1)
  935. else
  936. self.ClassMana:SetAlpha(0)
  937. end
  938. end
  939.  
  940. T.UpdatePvPStatus = function(self, elapsed)
  941. if self.elapsed and self.elapsed > 0.2 then
  942. local unit = self.unit
  943. local time = GetPVPTimer()
  944.  
  945. local min = format("%01.f", floor((time / 1000) / 60))
  946. local sec = format("%02.f", floor((time / 1000) - min * 60))
  947. if self.Status then
  948. local factionGroup = UnitFactionGroup(unit)
  949. if UnitIsPVPFreeForAll(unit) then
  950. if time ~= 301000 and time ~= -1 then
  951. self.Status:SetText(PVP.." ".."["..min..":"..sec.."]")
  952. else
  953. self.Status:SetText(PVP)
  954. end
  955. elseif factionGroup and UnitIsPVP(unit) then
  956. if time ~= 301000 and time ~= -1 then
  957. self.Status:SetText(PVP.." ".."["..min..":"..sec.."]")
  958. else
  959. self.Status:SetText(PVP)
  960. end
  961. else
  962. self.Status:SetText("")
  963. end
  964. end
  965. self.elapsed = 0
  966. else
  967. self.elapsed = (self.elapsed or 0) + elapsed
  968. end
  969. end
  970.  
  971. T.UpdateShadowOrb = function(self, event, unit, powerType)
  972. if self.unit ~= unit or (powerType and powerType ~= "SHADOW_ORBS") then return end
  973. local num = UnitPower(unit, SPELL_POWER_SHADOW_ORBS)
  974. local numMax = UnitPowerMax("player", SPELL_POWER_SHADOW_ORBS)
  975. local barWidth = self.ShadowOrbsBar:GetWidth()
  976. local spacing = select(4, self.ShadowOrbsBar[4]:GetPoint())
  977. local lastBar = 0
  978.  
  979. if numMax ~= self.ShadowOrbsBar.maxPower then
  980. if numMax == 3 then
  981. self.ShadowOrbsBar[4]:Hide()
  982. self.ShadowOrbsBar[5]:Hide()
  983. for i = 1, 3 do
  984. if i ~= 3 then
  985. self.ShadowOrbsBar[i]:SetWidth(barWidth / 3)
  986. lastBar = lastBar + (barWidth / 3 + spacing)
  987. else
  988. self.ShadowOrbsBar[i]:SetWidth(barWidth - lastBar)
  989. end
  990. end
  991. else
  992. self.ShadowOrbsBar[4]:Show()
  993. self.ShadowOrbsBar[5]:Show()
  994. for i = 1, 5 do
  995. self.ShadowOrbsBar[i]:SetWidth(self.ShadowOrbsBar[i].width)
  996. end
  997. end
  998. self.ShadowOrbsBar.maxPower = numMax
  999. end
  1000.  
  1001. for i = 1, 5 do
  1002. if i <= num then
  1003. self.ShadowOrbsBar[i]:SetAlpha(1)
  1004. else
  1005. self.ShadowOrbsBar[i]:SetAlpha(0.2)
  1006. end
  1007. end
  1008. end
  1009.  
  1010. T.UpdateHoly = function(self, event, unit, powerType)
  1011. if self.unit ~= unit or (powerType and powerType ~= "HOLY_POWER") then return end
  1012. local num = UnitPower(unit, SPELL_POWER_HOLY_POWER)
  1013. local numMax = UnitPowerMax("player", SPELL_POWER_HOLY_POWER)
  1014. local barWidth = self.HolyPower:GetWidth()
  1015. local spacing = select(4, self.HolyPower[4]:GetPoint())
  1016. local lastBar = 0
  1017.  
  1018. if numMax ~= self.HolyPower.maxPower then
  1019. if numMax == 3 then
  1020. self.HolyPower[4]:Hide()
  1021. self.HolyPower[5]:Hide()
  1022. for i = 1, 3 do
  1023. if i ~= 3 then
  1024. self.HolyPower[i]:SetWidth(barWidth / 3)
  1025. lastBar = lastBar + (barWidth / 3 + spacing)
  1026. else
  1027. self.HolyPower[i]:SetWidth(barWidth - lastBar)
  1028. end
  1029. end
  1030. else
  1031. self.HolyPower[4]:Show()
  1032. self.HolyPower[5]:Show()
  1033. for i = 1, 5 do
  1034. self.HolyPower[i]:SetWidth(self.HolyPower[i].width)
  1035. end
  1036. end
  1037. self.HolyPower.maxPower = numMax
  1038. end
  1039.  
  1040. for i = 1, 5 do
  1041. if i <= num then
  1042. self.HolyPower[i]:SetAlpha(1)
  1043. else
  1044. self.HolyPower[i]:SetAlpha(0.2)
  1045. end
  1046. end
  1047. end
  1048.  
  1049. T.EclipseDirection = function(self)
  1050. if GetEclipseDirection() == "sun" then
  1051. self.Text:SetText("|cff4478BC>>|r")
  1052. elseif GetEclipseDirection() == "moon" then
  1053. self.Text:SetText("|cffE5994C<<|r")
  1054. else
  1055. self.Text:SetText("")
  1056. end
  1057. end
  1058.  
  1059. T.UpdateEclipse = function(self, login)
  1060. local eb = self.EclipseBar
  1061. local txt = self.EclipseBar.Text
  1062.  
  1063. if login then
  1064. eb:SetScript("OnUpdate", nil)
  1065. end
  1066.  
  1067. if eb:IsShown() or (T.class == "DRUID" and C.unitframe_class_bar.combo == true) then
  1068. txt:Show()
  1069. if self.Debuffs then self.Debuffs:SetPoint("BOTTOMRIGHT", self, "TOPRIGHT", 2, 19) end
  1070. else
  1071. txt:Hide()
  1072. if self.Debuffs then self.Debuffs:SetPoint("BOTTOMRIGHT", self, "TOPRIGHT", 2, 5) end
  1073. end
  1074. end
  1075.  
  1076. T.UpdateReputationColor = function(self, event, unit, bar)
  1077. local name, id = GetWatchedFactionInfo()
  1078. bar:SetStatusBarColor(FACTION_BAR_COLORS[id].r, FACTION_BAR_COLORS[id].g, FACTION_BAR_COLORS[id].b)
  1079. bar.bg:SetVertexColor(FACTION_BAR_COLORS[id].r, FACTION_BAR_COLORS[id].g, FACTION_BAR_COLORS[id].b, 0.2)
  1080. end
  1081.  
  1082. T.UpdateComboPoint = function(self, event, unit)
  1083. if unit == "pet" then return end
  1084.  
  1085. local cpoints = self.CPoints
  1086. local cp = (UnitHasVehicleUI("player") or UnitHasVehicleUI("vehicle")) and UnitPower("vehicle", 4) or UnitPower("player", 4)
  1087.  
  1088. for i = 1, MAX_COMBO_POINTS do
  1089. if i <= cp then
  1090. cpoints[i]:SetAlpha(1)
  1091. self.Anticipation[i]:SetStatusBarColor(0.2, 0.2, 0.2)
  1092. else
  1093. cpoints[i]:SetAlpha(0.2)
  1094. self.Anticipation[i]:SetStatusBarColor(0.8, 0.8, 0.8)
  1095. end
  1096. end
  1097.  
  1098. if T.class == "DRUID" and C.unitframe_class_bar.combo_always ~= true then
  1099. local function CatForm(self, event, unit)
  1100. local unit = self.unit or "player"
  1101. local name = UnitBuff(unit, GetSpellInfo(768)) or UnitBuff(unit, GetSpellInfo(171745))
  1102. if name then
  1103. cpoints:Show()
  1104. if self.Debuffs then self.Debuffs:SetPoint("BOTTOMRIGHT", self, "TOPRIGHT", 2, 19) end
  1105. else
  1106. cpoints:Hide()
  1107. if self.Debuffs then self.Debuffs:SetPoint("BOTTOMRIGHT", self, "TOPRIGHT", 2, 5) end
  1108. end
  1109. end
  1110.  
  1111. local frame = CreateFrame("Frame")
  1112. frame:RegisterEvent("UNIT_AURA")
  1113. frame:SetScript("OnEvent", CatForm)
  1114. CatForm(self, event, unit)
  1115. end
  1116. end
  1117.  
  1118. T.UpdateComboPointOld = function(self, event, unit)
  1119. if unit == "pet" then return end
  1120.  
  1121. local cpoints = self.CPoints
  1122. local cp
  1123. if UnitHasVehicleUI("player") or UnitHasVehicleUI("vehicle") then
  1124. cp = GetComboPoints("vehicle", "target")
  1125. else
  1126. cp = GetComboPoints("player", "target")
  1127. end
  1128.  
  1129. for i = 1, MAX_COMBO_POINTS do
  1130. if i <= cp then
  1131. cpoints[i]:SetAlpha(1)
  1132. else
  1133. cpoints[i]:SetAlpha(0.2)
  1134. end
  1135. end
  1136.  
  1137. if cpoints[1]:GetAlpha() == 1 then
  1138. for i = 1, MAX_COMBO_POINTS do
  1139. cpoints:Show()
  1140. cpoints[i]:Show()
  1141. end
  1142. else
  1143. for i = 1, MAX_COMBO_POINTS do
  1144. cpoints:Hide()
  1145. cpoints[i]:Hide()
  1146. end
  1147. end
  1148.  
  1149. if self.RangeBar then
  1150. if cpoints[1]:IsShown() and self.RangeBar:IsShown() then
  1151. cpoints:SetPoint("BOTTOMLEFT", self, "TOPLEFT", 0, 21)
  1152. if self.Auras then self.Auras:SetPoint("BOTTOMLEFT", self, "TOPLEFT", -2, 33) end
  1153. elseif cpoints[1]:IsShown() or self.RangeBar:IsShown() then
  1154. cpoints:SetPoint("BOTTOMLEFT", self, "TOPLEFT", 0, 7)
  1155. if self.Auras then self.Auras:SetPoint("BOTTOMLEFT", self, "TOPLEFT", -2, 19) end
  1156. elseif self.Friendship and self.Friendship:IsShown() then
  1157. if self.Auras then self.Auras:SetPoint("BOTTOMLEFT", self, "TOPLEFT", -2, 19) end
  1158. else
  1159. if self.Auras then self.Auras:SetPoint("BOTTOMLEFT", self, "TOPLEFT", -2, 5) end
  1160. end
  1161. else
  1162. if cpoints[1]:IsShown() or (self.Friendship and self.Friendship:IsShown()) then
  1163. if self.Auras then self.Auras:SetPoint("BOTTOMLEFT", self, "TOPLEFT", -2, 19) end
  1164. else
  1165. if self.Auras then self.Auras:SetPoint("BOTTOMLEFT", self, "TOPLEFT", -2, 5) end
  1166. end
  1167. end
  1168. end
  1169.  
  1170. local ticks = {}
  1171. local channelingTicks = T.CastBarTicks
  1172.  
  1173. local setBarTicks = function(Castbar, ticknum)
  1174. for k, v in pairs(ticks) do
  1175. v:Hide()
  1176. end
  1177. if ticknum and ticknum > 0 then
  1178. local delta = Castbar:GetWidth() / ticknum
  1179. for k = 1, ticknum do
  1180. if not ticks[k] then
  1181. ticks[k] = Castbar:CreateTexture(nil, "OVERLAY")
  1182. ticks[k]:SetTexture(C.media.texture)
  1183. ticks[k]:SetVertexColor(unpack(C.media.border_color))
  1184. ticks[k]:SetWidth(1)
  1185. ticks[k]:SetHeight(Castbar:GetHeight())
  1186. ticks[k]:SetDrawLayer("OVERLAY", 7)
  1187. end
  1188. ticks[k]:ClearAllPoints()
  1189. ticks[k]:SetPoint("CENTER", Castbar, "RIGHT", -delta * k, 0)
  1190. ticks[k]:Show()
  1191. end
  1192. end
  1193. end
  1194.  
  1195. T.PostCastStart = function(Castbar, unit, name, castid)
  1196. Castbar.channeling = false
  1197. if unit == "vehicle" then unit = "player" end
  1198.  
  1199. if unit == "player" and C.unitframe.castbar_latency == true and Castbar.Latency then
  1200. local _, _, _, lag = GetNetStats()
  1201. local latency = GetTime() - (Castbar.castSent or 0)
  1202. lag = lag / 1e3 > Castbar.max and Castbar.max or lag / 1e3
  1203. latency = latency > Castbar.max and lag or latency
  1204. Castbar.Latency:SetText(("%dms"):format(latency * 1e3))
  1205. Castbar.SafeZone:SetWidth(Castbar:GetWidth() * latency / Castbar.max)
  1206. Castbar.SafeZone:ClearAllPoints()
  1207. Castbar.SafeZone:SetPoint("TOPRIGHT")
  1208. Castbar.SafeZone:SetPoint("BOTTOMRIGHT")
  1209. Castbar.castSent = nil
  1210. end
  1211.  
  1212. if unit == "player" and C.unitframe.castbar_ticks == true then
  1213. setBarTicks(Castbar, 0)
  1214. end
  1215.  
  1216. local r, g, b, color
  1217. if UnitIsPlayer(unit) then
  1218. local _, class = UnitClass(unit)
  1219. color = T.oUF_colors.class[class]
  1220. else
  1221. local reaction = T.oUF_colors.reaction[UnitReaction(unit, "player")]
  1222. if reaction then
  1223. r, g, b = reaction[1], reaction[2], reaction[3]
  1224. else
  1225. r, g, b = 1, 1, 1
  1226. end
  1227. end
  1228.  
  1229. if color then
  1230. r, g, b = color[1], color[2], color[3]
  1231. end
  1232.  
  1233. if Castbar.interrupt and UnitCanAttack("player", unit) then
  1234. Castbar:SetStatusBarColor(0.8, 0, 0)
  1235. Castbar.bg:SetVertexColor(0.8, 0, 0, 0.2)
  1236. Castbar.Overlay:SetBackdropBorderColor(0.8, 0, 0)
  1237. if C.unitframe.castbar_icon == true and (unit == "target" or unit == "focus") then
  1238. Castbar.Button:SetBackdropBorderColor(0.8, 0, 0)
  1239. end
  1240. else
  1241. if unit == "pet" or unit == "vehicle" then
  1242. local _, class = UnitClass("player")
  1243. local r, g, b = unpack(T.oUF_colors.class[class])
  1244. if C.unitframe.own_color == true then
  1245. Castbar:SetStatusBarColor(unpack(C.unitframe.uf_color))
  1246. Castbar.bg:SetVertexColor(C.unitframe.uf_color[1], C.unitframe.uf_color[2], C.unitframe.uf_color[3], 0.2)
  1247. else
  1248. if b then
  1249. Castbar:SetStatusBarColor(r, g, b)
  1250. Castbar.bg:SetVertexColor(r, g, b, 0.2)
  1251. end
  1252. end
  1253. else
  1254. if C.unitframe.own_color == true then
  1255. Castbar:SetStatusBarColor(unpack(C.unitframe.uf_color))
  1256. Castbar.bg:SetVertexColor(C.unitframe.uf_color[1], C.unitframe.uf_color[2], C.unitframe.uf_color[3], 0.2)
  1257. else
  1258. Castbar:SetStatusBarColor(r, g, b)
  1259. Castbar.bg:SetVertexColor(r, g, b, 0.2)
  1260. end
  1261. end
  1262. Castbar.Overlay:SetBackdropBorderColor(unpack(C.media.border_color))
  1263. if C.unitframe.castbar_icon == true and (unit == "target" or unit == "focus") then
  1264. Castbar.Button:SetBackdropBorderColor(unpack(C.media.border_color))
  1265. end
  1266. end
  1267. end
  1268.  
  1269. T.PostChannelStart = function(Castbar, unit, name)
  1270. Castbar.channeling = true
  1271. if unit == "vehicle" then unit = "player" end
  1272.  
  1273. if unit == "player" and C.unitframe.castbar_latency == true and Castbar.Latency then
  1274. local _, _, _, lag = GetNetStats()
  1275. local latency = GetTime() - (Castbar.castSent or 0)
  1276. lag = lag / 1e3 > Castbar.max and Castbar.max or lag / 1e3
  1277. latency = latency > Castbar.max and lag or latency
  1278. Castbar.Latency:SetText(("%dms"):format(latency * 1e3))
  1279. Castbar.SafeZone:SetWidth(Castbar:GetWidth() * latency / Castbar.max)
  1280. Castbar.SafeZone:ClearAllPoints()
  1281. Castbar.SafeZone:SetPoint("TOPLEFT")
  1282. Castbar.SafeZone:SetPoint("BOTTOMLEFT")
  1283. Castbar.castSent = nil
  1284. end
  1285.  
  1286. if unit == "player" and C.unitframe.castbar_ticks == true then
  1287. local spell = UnitChannelInfo(unit)
  1288. Castbar.channelingTicks = channelingTicks[spell] or 0
  1289. setBarTicks(Castbar, Castbar.channelingTicks)
  1290. end
  1291.  
  1292. local r, g, b, color
  1293. if UnitIsPlayer(unit) then
  1294. local _, class = UnitClass(unit)
  1295. color = T.oUF_colors.class[class]
  1296. else
  1297. local reaction = T.oUF_colors.reaction[UnitReaction(unit, "player")]
  1298. if reaction then
  1299. r, g, b = reaction[1], reaction[2], reaction[3]
  1300. else
  1301. r, g, b = 1, 1, 1
  1302. end
  1303. end
  1304.  
  1305. if color then
  1306. r, g, b = color[1], color[2], color[3]
  1307. end
  1308.  
  1309. if Castbar.interrupt and UnitCanAttack("player", unit) then
  1310. Castbar:SetStatusBarColor(0.8, 0, 0)
  1311. Castbar.bg:SetVertexColor(0.8, 0, 0, 0.2)
  1312. Castbar.Overlay:SetBackdropBorderColor(0.8, 0, 0)
  1313. if C.unitframe.castbar_icon == true and (unit == "target" or unit == "focus") then
  1314. Castbar.Button:SetBackdropBorderColor(0.8, 0, 0)
  1315. end
  1316. else
  1317. if unit == "pet" or unit == "vehicle" then
  1318. local _, class = UnitClass("player")
  1319. local r, g, b = unpack(T.oUF_colors.class[class])
  1320. if C.unitframe.own_color == true then
  1321. Castbar:SetStatusBarColor(unpack(C.unitframe.uf_color))
  1322. Castbar.bg:SetVertexColor(C.unitframe.uf_color[1], C.unitframe.uf_color[2], C.unitframe.uf_color[3], 0.2)
  1323. else
  1324. if b then
  1325. Castbar:SetStatusBarColor(r, g, b)
  1326. Castbar.bg:SetVertexColor(r, g, b, 0.2)
  1327. end
  1328. end
  1329. else
  1330. if C.unitframe.own_color == true then
  1331. Castbar:SetStatusBarColor(unpack(C.unitframe.uf_color))
  1332. Castbar.bg:SetVertexColor(C.unitframe.uf_color[1], C.unitframe.uf_color[2], C.unitframe.uf_color[3], 0.2)
  1333. else
  1334. Castbar:SetStatusBarColor(r, g, b)
  1335. Castbar.bg:SetVertexColor(r, g, b, 0.2)
  1336. end
  1337. end
  1338. Castbar.Overlay:SetBackdropBorderColor(unpack(C.media.border_color))
  1339. if C.unitframe.castbar_icon == true and (unit == "target" or unit == "focus") then
  1340. Castbar.Button:SetBackdropBorderColor(unpack(C.media.border_color))
  1341. end
  1342. end
  1343. end
  1344.  
  1345. T.CustomCastTimeText = function(self, duration)
  1346. self.Time:SetText(("%.1f / %.1f"):format(self.channeling and duration or self.max - duration, self.max))
  1347. end
  1348.  
  1349. T.CustomCastDelayText = function(self, duration)
  1350. self.Time:SetText(("%.1f |cffaf5050%s %.1f|r"):format(self.channeling and duration or self.max - duration, self.channeling and "-" or "+", abs(self.delay)))
  1351. end
  1352.  
  1353. local FormatTime = function(s)
  1354. local day, hour, minute = 86400, 3600, 60
  1355. if s >= day then
  1356. return format("%dd", floor(s / day + 0.5)), s % day
  1357. elseif s >= hour then
  1358. return format("%dh", floor(s / hour + 0.5)), s % hour
  1359. elseif s >= minute then
  1360. return format("%dm", floor(s / minute + 0.5)), s % minute
  1361. elseif s >= minute / 12 then
  1362. return floor(s + 0.5), (s * 100 - floor(s * 100)) / 100
  1363. end
  1364. return format("%.1f", s), (s * 100 - floor(s * 100)) / 100
  1365. end
  1366.  
  1367. local CreateAuraTimer = function(self, elapsed)
  1368. if self.timeLeft then
  1369. self.elapsed = (self.elapsed or 0) + elapsed
  1370. if self.elapsed >= 0.1 then
  1371. if not self.first then
  1372. self.timeLeft = self.timeLeft - self.elapsed
  1373. else
  1374. self.timeLeft = self.timeLeft - GetTime()
  1375. self.first = false
  1376. end
  1377. if self.timeLeft > 0 then
  1378. local time = FormatTime(self.timeLeft)
  1379. self.remaining:SetText(time)
  1380. self.remaining:SetTextColor(1, 1, 1)
  1381. else
  1382. self.remaining:Hide()
  1383. self:SetScript("OnUpdate", nil)
  1384. end
  1385. self.elapsed = 0
  1386. end
  1387. end
  1388. end
  1389.  
  1390. T.AuraTrackerTime = function(self, elapsed)
  1391. if self.active then
  1392. self.timeleft = self.timeleft - elapsed
  1393. if self.timeleft <= 5 then
  1394. self.text:SetTextColor(1, 0, 0)
  1395. else
  1396. self.text:SetTextColor(1, 1, 1)
  1397. end
  1398. if self.timeleft <= 0 then
  1399. self.icon:SetTexture("")
  1400. self.text:SetText("")
  1401. end
  1402. self.text:SetFormattedText("%.1f", self.timeleft)
  1403. end
  1404. end
  1405.  
  1406. T.HideAuraFrame = function(self)
  1407. if self.unit == "player" then
  1408. if not C.aura.player_auras then
  1409. BuffFrame:UnregisterEvent("UNIT_AURA")
  1410. BuffFrame:Hide()
  1411. TemporaryEnchantFrame:Hide()
  1412. self.Debuffs:Hide()
  1413. end
  1414. elseif self.unit == "pet" and not C.aura.pet_debuffs or self.unit == "focus" and not C.aura.focus_debuffs
  1415. or self.unit == "focustarget" and not C.aura.fot_debuffs or self.unit == "targettarget" and not C.aura.tot_debuffs then
  1416. self.Debuffs:Hide()
  1417. elseif self.unit == "target" and not C.aura.target_auras then
  1418. self.Auras:Hide()
  1419. end
  1420. end
  1421.  
  1422. T.PostCreateAura = function(element, button)
  1423. button:SetTemplate("Default")
  1424.  
  1425. button.remaining = T.SetFontString(button, C.font.auras_font, C.font.auras_font_size, C.font.auras_font_style)
  1426. button.remaining:SetShadowOffset(C.font.auras_font_shadow and 1 or 0, C.font.auras_font_shadow and -1 or 0)
  1427. button.remaining:SetPoint("CENTER", button, "CENTER", 1, 1)
  1428. button.remaining:SetJustifyH("CENTER")
  1429.  
  1430. button.cd.noOCC = true
  1431. button.cd.noCooldownCount = true
  1432.  
  1433. button.icon:SetPoint("TOPLEFT", 2, -2)
  1434. button.icon:SetPoint("BOTTOMRIGHT", -2, 2)
  1435. button.icon:SetTexCoord(0.1, 0.9, 0.1, 0.9)
  1436.  
  1437. button.count:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", 1, 0)
  1438. button.count:SetJustifyH("RIGHT")
  1439. button.count:SetFont(C.font.auras_font, C.font.auras_font_size, C.font.auras_font_style)
  1440. button.count:SetShadowOffset(C.font.auras_font_shadow and 1 or 0, C.font.auras_font_shadow and -1 or 0)
  1441.  
  1442. if C.aura.show_spiral == true then
  1443. element.disableCooldown = false
  1444. button.cd:SetReverse(true)
  1445. button.cd:SetPoint("TOPLEFT", button, "TOPLEFT", 2, -2)
  1446. button.cd:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -2, 2)
  1447. button.parent = CreateFrame("Frame", nil, button)
  1448. button.parent:SetFrameLevel(button.cd:GetFrameLevel() + 1)
  1449. button.count:SetParent(button.parent)
  1450. button.remaining:SetParent(button.parent)
  1451. else
  1452. element.disableCooldown = true
  1453. end
  1454. end
  1455.  
  1456. T.PostUpdateIcon = function(icons, unit, icon, index, offset, filter, isDebuff, duration, timeLeft)
  1457. local _, _, _, _, dtype, duration, expirationTime, _, isStealable = UnitAura(unit, index, icon.filter)
  1458.  
  1459. local playerUnits = {
  1460. player = true,
  1461. pet = true,
  1462. vehicle = true,
  1463. }
  1464.  
  1465. if icon.debuff then
  1466. if not UnitIsFriend("player", unit) and not playerUnits[icon.owner] then
  1467. if C.aura.player_aura_only then
  1468. icon:Hide()
  1469. else
  1470. icon:SetBackdropBorderColor(unpack(C.media.border_color))
  1471. icon.icon:SetDesaturated(true)
  1472. end
  1473. else
  1474. if C.aura.debuff_color_type == true then
  1475. local color = DebuffTypeColor[dtype] or DebuffTypeColor.none
  1476. icon:SetBackdropBorderColor(color.r, color.g, color.b)
  1477. icon.icon:SetDesaturated(false)
  1478. else
  1479. icon:SetBackdropBorderColor(1, 0, 0)
  1480. end
  1481. end
  1482. else
  1483. 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
  1484. icon:SetBackdropBorderColor(1, 0.85, 0)
  1485. else
  1486. icon:SetBackdropBorderColor(unpack(C.media.border_color))
  1487. end
  1488. icon.icon:SetDesaturated(false)
  1489. end
  1490.  
  1491. if duration and duration > 0 and C.aura.show_timer == true then
  1492. icon.remaining:Show()
  1493. icon.timeLeft = expirationTime
  1494. icon:SetScript("OnUpdate", CreateAuraTimer)
  1495. else
  1496. icon.remaining:Hide()
  1497. icon.timeLeft = math.huge
  1498. icon:SetScript("OnUpdate", nil)
  1499. end
  1500.  
  1501. icon.first = true
  1502. end
  1503.  
  1504. T.UpdateThreat = function(self, event, unit)
  1505. if self.unit ~= unit then return end
  1506. local threat = UnitThreatSituation(self.unit)
  1507. if threat and threat > 1 then
  1508. r, g, b = GetThreatStatusColor(threat)
  1509. self.backdrop:SetBackdropBorderColor(r, g, b)
  1510. else
  1511. self.backdrop:SetBackdropBorderColor(unpack(C.media.border_color))
  1512. end
  1513. end
  1514.  
  1515. local CountOffSets = {
  1516. TOPLEFT = {9, 0},
  1517. TOPRIGHT = {-8, 0},
  1518. BOTTOMLEFT = {9, 0},
  1519. BOTTOMRIGHT = {-8, 0},
  1520. LEFT = {9, 0},
  1521. RIGHT = {-8, 0},
  1522. TOP = {0, 0},
  1523. BOTTOM = {0, 0},
  1524. }
  1525.  
  1526. T.CreateAuraWatchIcon = function(self, icon)
  1527. icon:SetTemplate("Default")
  1528. icon.icon:SetPoint("TOPLEFT", icon, 1, -1)
  1529. icon.icon:SetPoint("BOTTOMRIGHT", icon, -1, 1)
  1530. icon.icon:SetTexCoord(0.1, 0.9, 0.1, 0.9)
  1531. icon.icon:SetDrawLayer("ARTWORK")
  1532. if icon.cd then
  1533. icon.cd:SetReverse(true)
  1534. end
  1535. icon.overlay:SetTexture()
  1536. end
  1537.  
  1538. T.CreateAuraWatch = function(self, unit)
  1539. local auras = CreateFrame("Frame", nil, self)
  1540. auras:SetPoint("TOPLEFT", self.Health, 0, 0)
  1541. auras:SetPoint("BOTTOMRIGHT", self.Health, 0, 0)
  1542. auras.icons = {}
  1543. auras.PostCreateIcon = T.CreateAuraWatchIcon
  1544.  
  1545. if not C.aura.show_timer then
  1546. auras.hideCooldown = true
  1547. end
  1548.  
  1549. local buffs = {}
  1550.  
  1551. if T.RaidBuffs["ALL"] then
  1552. for key, value in pairs(T.RaidBuffs["ALL"]) do
  1553. tinsert(buffs, value)
  1554. end
  1555. end
  1556.  
  1557. if T.RaidBuffs[T.class] then
  1558. for key, value in pairs(T.RaidBuffs[T.class]) do
  1559. tinsert(buffs, value)
  1560. end
  1561. end
  1562.  
  1563. if buffs then
  1564. for key, spell in pairs(buffs) do
  1565. local icon = CreateFrame("Frame", nil, auras)
  1566. icon.spellID = spell[1]
  1567. icon.anyUnit = spell[4]
  1568. icon.strictMatching = spell[5]
  1569. icon:SetWidth(7)
  1570. icon:SetHeight(7)
  1571. icon:SetPoint(spell[2], 0, 0)
  1572.  
  1573. local tex = icon:CreateTexture(nil, "OVERLAY")
  1574. tex:SetAllPoints(icon)
  1575. tex:SetTexture(C.media.blank)
  1576. if spell[3] then
  1577. tex:SetVertexColor(unpack(spell[3]))
  1578. else
  1579. tex:SetVertexColor(0.8, 0.8, 0.8)
  1580. end
  1581.  
  1582. local count = T.SetFontString(icon, C.font.unit_frames_font, C.font.unit_frames_font_size, C.font.unit_frames_font_style)
  1583. count:SetPoint("CENTER", unpack(CountOffSets[spell[2]]))
  1584. icon.count = count
  1585.  
  1586. auras.icons[spell[1]] = icon
  1587. end
  1588. end
  1589.  
  1590. self.AuraWatch = auras
  1591. end
Add Comment
Please, Sign In to add comment