Advertisement
Wetxius

Untitled

Feb 21st, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.39 KB | None | 0 0
  1. local T, C, L, _ = unpack(select(2, ...))
  2. if C.nameplate.enable ~= true then return end
  3.  
  4. ----------------------------------------------------------------------------------------
  5. -- Based on rNamePlates (by zork, editor Tukz)
  6. ----------------------------------------------------------------------------------------
  7. local Plates = CreateFrame("Frame", nil, WorldFrame)
  8. local NameplateParent = WorldFrame
  9. local NamePlateIndex
  10. local HiddenFrame = CreateFrame("Frame")
  11. HiddenFrame:Hide()
  12.  
  13. local goodR, goodG, goodB = unpack(C.nameplate.good_color)
  14. local badR, badG, badB = unpack(C.nameplate.bad_color)
  15. local transitionR, transitionG, transitionB = unpack(C.nameplate.near_color)
  16.  
  17. local NamePlates = CreateFrame("Frame", nil, UIParent)
  18. NamePlates:SetScript("OnEvent", function(self, event, ...) self[event](self, ...) end)
  19. if C.nameplate.track_auras == true then
  20. NamePlates:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  21. end
  22.  
  23. local healList, exClass = {}, {}
  24. local testing = false
  25. if C.nameplate.healer_icon == true then
  26. local lastCheck = 0
  27.  
  28. exClass.DEATHKNIGHT = true
  29. exClass.MAGE = true
  30. exClass.ROGUE = true
  31. exClass.WARLOCK = true
  32. exClass.WARRIOR = true
  33.  
  34. local t = CreateFrame("Frame")
  35. t.factions = {
  36. ["Horde"] = 1,
  37. ["Alliance"] = 0,
  38. }
  39. t.healers = {
  40. [L_PLANNER_DRUID_4] = true,
  41. [L_PLANNER_MONK_2] = true,
  42. [L_PLANNER_PALADIN_1] = true,
  43. [L_PLANNER_PRIEST_1] = true,
  44. }
  45.  
  46. local function CheckHealers(self, elapsed)
  47. lastCheck = lastCheck + elapsed
  48. if lastCheck > 30 then
  49. lastCheck = 0
  50. healList = {}
  51. for i = 1, GetNumBattlefieldScores() do
  52. local name, _, _, _, _, faction, _, _, _, _, _, _, _, _, _, talentSpec = GetBattlefieldScore(i)
  53. name = name:match("(.+)%-.+") or name
  54. if name and t.healers[talentSpec] and t.factions[UnitFactionGroup("player")] == faction then
  55. healList[name] = talentSpec
  56. end
  57. end
  58. end
  59. end
  60.  
  61. local function CheckLoc(self, event)
  62. if event == "PLAYER_ENTERING_WORLD" or event == "PLAYER_ENTERING_BATTLEGROUND" then
  63. local _, instanceType = IsInInstance()
  64. if instanceType == "pvp" then
  65. t:SetScript("OnUpdate", CheckHealers)
  66. else
  67. healList = {}
  68. t:SetScript("OnUpdate", nil)
  69. end
  70. end
  71. end
  72.  
  73. t:RegisterEvent("PLAYER_ENTERING_WORLD")
  74. t:RegisterEvent("PLAYER_ENTERING_BATTLEGROUND")
  75. t:SetScript("OnEvent", CheckLoc)
  76. end
  77.  
  78. local function Abbrev(name)
  79. local newname = (string.len(name) > 18) and string.gsub(name, "%s?(.[\128-\191]*)%S+%s", "%1. ") or name
  80. return T.UTF(newname, 18, false)
  81. end
  82.  
  83. local function CreateVirtualFrame(frame, point)
  84. if point == nil then point = frame end
  85. if point.backdrop then return end
  86.  
  87. frame.backdrop = frame:CreateTexture(nil, "BORDER")
  88. frame.backdrop:SetDrawLayer("BORDER", -8)
  89. frame.backdrop:SetPoint("TOPLEFT", point, "TOPLEFT", -T.noscalemult * 3, T.noscalemult * 3)
  90. frame.backdrop:SetPoint("BOTTOMRIGHT", point, "BOTTOMRIGHT", T.noscalemult * 3, -T.noscalemult * 3)
  91. frame.backdrop:SetTexture(unpack(C.media.backdrop_color))
  92.  
  93. frame.bordertop = frame:CreateTexture(nil, "BORDER")
  94. frame.bordertop:SetPoint("TOPLEFT", point, "TOPLEFT", -T.noscalemult * 2, T.noscalemult * 2)
  95. frame.bordertop:SetPoint("TOPRIGHT", point, "TOPRIGHT", T.noscalemult * 2, T.noscalemult * 2)
  96. frame.bordertop:SetHeight(T.noscalemult)
  97. frame.bordertop:SetTexture(unpack(C.media.border_color))
  98. frame.bordertop:SetDrawLayer("BORDER", -7)
  99.  
  100. frame.borderbottom = frame:CreateTexture(nil, "BORDER")
  101. frame.borderbottom:SetPoint("BOTTOMLEFT", point, "BOTTOMLEFT", -T.noscalemult * 2, -T.noscalemult * 2)
  102. frame.borderbottom:SetPoint("BOTTOMRIGHT", point, "BOTTOMRIGHT", T.noscalemult * 2, -T.noscalemult * 2)
  103. frame.borderbottom:SetHeight(T.noscalemult)
  104. frame.borderbottom:SetTexture(unpack(C.media.border_color))
  105. frame.borderbottom:SetDrawLayer("BORDER", -7)
  106.  
  107. frame.borderleft = frame:CreateTexture(nil, "BORDER")
  108. frame.borderleft:SetPoint("TOPLEFT", point, "TOPLEFT", -T.noscalemult * 2, T.noscalemult * 2)
  109. frame.borderleft:SetPoint("BOTTOMLEFT", point, "BOTTOMLEFT", T.noscalemult * 2, -T.noscalemult * 2)
  110. frame.borderleft:SetWidth(T.noscalemult)
  111. frame.borderleft:SetTexture(unpack(C.media.border_color))
  112. frame.borderleft:SetDrawLayer("BORDER", -7)
  113.  
  114. frame.borderright = frame:CreateTexture(nil, "BORDER")
  115. frame.borderright:SetPoint("TOPRIGHT", point, "TOPRIGHT", T.noscalemult * 2, T.noscalemult * 2)
  116. frame.borderright:SetPoint("BOTTOMRIGHT", point, "BOTTOMRIGHT", -T.noscalemult * 2, -T.noscalemult * 2)
  117. frame.borderright:SetWidth(T.noscalemult)
  118. frame.borderright:SetTexture(unpack(C.media.border_color))
  119. frame.borderright:SetDrawLayer("BORDER", -7)
  120. end
  121.  
  122. local function SetVirtualBorder(frame, r, g, b)
  123. frame.bordertop:SetTexture(r, g, b)
  124. frame.borderbottom:SetTexture(r, g, b)
  125. frame.borderleft:SetTexture(r, g, b)
  126. frame.borderright:SetTexture(r, g, b)
  127. end
  128.  
  129. function Plates:CreateAuraIcon(self)
  130. local button = CreateFrame("Frame", nil, self.Health)
  131. button:SetWidth(C.nameplate.auras_size)
  132. button:SetHeight(C.nameplate.auras_size)
  133.  
  134. button.bg = button:CreateTexture(nil, "BACKGROUND")
  135. button.bg:SetTexture(unpack(C.media.backdrop_color))
  136. button.bg:SetAllPoints(button)
  137.  
  138. button.bord = button:CreateTexture(nil, "BORDER")
  139. button.bord:SetTexture(unpack(C.media.border_color))
  140. button.bord:SetPoint("TOPLEFT", button, "TOPLEFT", T.noscalemult, -T.noscalemult)
  141. button.bord:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -T.noscalemult, T.noscalemult)
  142.  
  143. button.bg2 = button:CreateTexture(nil, "ARTWORK")
  144. button.bg2:SetTexture(unpack(C.media.backdrop_color))
  145. button.bg2:SetPoint("TOPLEFT", button, "TOPLEFT", T.noscalemult * 2, -T.noscalemult * 2)
  146. button.bg2:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -T.noscalemult * 2, T.noscalemult * 2)
  147.  
  148. button.icon = button:CreateTexture(nil, "OVERLAY")
  149. button.icon:SetPoint("TOPLEFT", button, "TOPLEFT", T.noscalemult * 3, -T.noscalemult * 3)
  150. button.icon:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -T.noscalemult * 3, T.noscalemult * 3)
  151. button.icon:SetTexCoord(0.1, 0.9, 0.1, 0.9)
  152.  
  153. button.cd = CreateFrame("Cooldown", nil, button)
  154. button.cd:SetAllPoints(button)
  155. button.cd:SetReverse(true)
  156.  
  157. button.count = button:CreateFontString(nil, "OVERLAY")
  158. button.count:SetFont(C.font.nameplates_font, C.font.nameplates_font_size * T.noscalemult, C.font.nameplates_font_style)
  159. button.count:SetShadowOffset(C.font.nameplates_font_shadow and 1 or 0, C.font.nameplates_font_shadow and -1 or 0)
  160. button.count:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", 0, 0)
  161.  
  162. return button
  163. end
  164.  
  165. -- Update an aura icon
  166. local function UpdateAuraIcon(button, unit, index, filter)
  167. local _, _, icon, count, _, duration, expirationTime, _, _, _, spellID = UnitAura(unit, index, filter)
  168.  
  169. button.icon:SetTexture(icon)
  170. button.cd:SetCooldown(expirationTime - duration, duration)
  171. button.expirationTime = expirationTime
  172. button.duration = duration
  173. button.spellID = spellID
  174. if count > 1 then
  175. button.count:SetText(count)
  176. else
  177. button.count:SetText("")
  178. end
  179. button.cd:SetScript("OnUpdate", function(self)
  180. if not button.cd.timer then
  181. self:SetScript("OnUpdate", nil)
  182. return
  183. end
  184. button.cd.timer.text:SetFont(C.font.nameplates_font, C.font.nameplates_font_size * T.noscalemult, C.font.nameplates_font_style)
  185. button.cd.timer.text:SetShadowOffset(C.font.nameplates_font_shadow and 1 or 0, C.font.nameplates_font_shadow and -1 or 0)
  186. end)
  187. button:Show()
  188. end
  189.  
  190. -- Filter auras on nameplate, and determine if we need to update them or not
  191. function Plates:OnAura(unit)
  192. if not self:IsShown() then
  193. return
  194. end
  195. if not C.nameplate.track_auras then return end
  196. local i = 1
  197. for index = 1, 40 do
  198. if i > C.nameplate.width / C.nameplate.auras_size then return end
  199. local match
  200. local name, _, _, _, _, duration, _, caster, _, _ = UnitAura(unit, index, "HARMFUL")
  201.  
  202. if T.DebuffWhiteList[name] and caster == "player" then match = true end
  203.  
  204. if duration and match == true then
  205. if not self.NewPlate.icons[i] then self.NewPlate.icons[i] = Plates:CreateAuraIcon(self.NewPlate) end
  206. local icon = self.NewPlate.icons[i]
  207. if i == 1 then icon:SetPoint("RIGHT", self.NewPlate.icons, "RIGHT") end
  208. if i ~= 1 and i <= C.nameplate.width / C.nameplate.auras_size then icon:SetPoint("RIGHT", self.NewPlate.icons[i-1], "LEFT", -2, 0) end
  209. i = i + 1
  210. UpdateAuraIcon(icon, unit, index, "HARMFUL")
  211. end
  212. end
  213. for index = i, #self.NewPlate.icons do self.NewPlate.icons[index]:Hide() end
  214. end
  215.  
  216. function Plates:GetColor()
  217. local Red, Green, Blue = self.ArtContainer.HealthBar:GetStatusBarColor()
  218. local texcoord = {0, 0, 0, 0}
  219. self.isClass = false
  220.  
  221. for class, _ in pairs(RAID_CLASS_COLORS) do
  222. Red, Green, Blue = floor(Red * 100 + 0.5) / 100, floor(Green * 100 + 0.5) / 100, floor(Blue * 100 + 0.5) / 100
  223. local AltBlue = Blue
  224.  
  225. if class == "MONK" then
  226. AltBlue = AltBlue - 0.01
  227. end
  228.  
  229. if RAID_CLASS_COLORS[class].r == Red and RAID_CLASS_COLORS[class].g == Green and RAID_CLASS_COLORS[class].b == AltBlue then
  230. self.isClass = true
  231. self.isFriendly = false
  232. if C.nameplate.class_icons == true then
  233. texcoord = CLASS_BUTTONS[class]
  234. self.NewPlate.class.Glow:Show()
  235. self.NewPlate.class:SetTexCoord(texcoord[1], texcoord[2], texcoord[3], texcoord[4])
  236. end
  237. Red, Green, Blue = unpack(T.oUF_colors.class[class])
  238. return Red, Green, Blue
  239. end
  240. end
  241.  
  242. self.isTapped = false
  243.  
  244. if (Red + Blue + Blue) == 1.59 then -- Tapped
  245. Red, Green, Blue = 0.6, 0.6, 0.6
  246. self.isFriendly = false
  247. self.isTapped = true
  248. elseif Green + Blue == 0 then -- Hostile
  249. Red, Green, Blue = unpack(T.oUF_colors.reaction[1])
  250. self.isFriendly = false
  251. elseif Red + Blue == 0 then -- Friendly NPC
  252. Red, Green, Blue = unpack(T.oUF_colors.power["MANA"])
  253. self.isFriendly = true
  254. elseif Red + Green > 1.95 then -- Neutral NPC
  255. Red, Green, Blue = unpack(T.oUF_colors.reaction[4])
  256. self.isFriendly = false
  257. elseif Red + Green == 0 then -- Friendly Player
  258. Red, Green, Blue = unpack(T.oUF_colors.reaction[5])
  259. self.isFriendly = true
  260. else
  261. self.isFriendly = false
  262. end
  263.  
  264. if C.nameplate.class_icons == true then
  265. if self.isClass == true then
  266. self.NewPlate.class.Glow:Show()
  267. else
  268. self.NewPlate.class.Glow:Hide()
  269. end
  270. self.NewPlate.class:SetTexCoord(texcoord[1], texcoord[2], texcoord[3], texcoord[4])
  271. end
  272.  
  273. return Red, Green, Blue
  274. end
  275.  
  276. function Plates:UpdateCastBar()
  277. local Red, Blue, Green = self.ArtContainer.CastBar:GetStatusBarColor()
  278. local Minimum, Maximum = self.ArtContainer.CastBar:GetMinMaxValues()
  279. local Current = self.ArtContainer.CastBar:GetValue()
  280. local Shield = self.ArtContainer.CastBarFrameShield
  281.  
  282. if Shield:IsShown() then
  283. self.NewPlate.CastBar:SetStatusBarColor(0.78, 0.25, 0.25)
  284. self.NewPlate.CastBar.Background:SetTexture(0.78, 0.25, 0.25, 0.2)
  285. else
  286. self.NewPlate.CastBar:SetStatusBarColor(Red, Blue, Green)
  287. self.NewPlate.CastBar.Background:SetTexture(0.75, 0.75, 0.25, 0.2)
  288. end
  289.  
  290. self.NewPlate.CastBar:SetMinMaxValues(Minimum, Maximum)
  291. self.NewPlate.CastBar:SetValue(Current)
  292.  
  293. local last = self.NewPlate.CastBar.last and self.NewPlate.CastBar.last or 0
  294. local finish = (Current > last) and (Maximum - Current) or Current
  295.  
  296. self.NewPlate.CastBar.Time:SetFormattedText("%.1f ", finish)
  297. self.NewPlate.CastBar.last = Current
  298. end
  299.  
  300. function Plates:CastOnShow()
  301. self.NewPlate.CastBar.Icon:SetTexture(self.ArtContainer.CastBarSpellIcon:GetTexture())
  302. if C.nameplate.show_castbar_name == true then
  303. self.NewPlate.CastBar.Name:SetText(self.ArtContainer.CastBarText:GetText())
  304. end
  305.  
  306. self.NewPlate.CastBar:Show()
  307. end
  308.  
  309. function Plates:CastOnHide()
  310. self.NewPlate.CastBar:Hide()
  311. end
  312.  
  313. function Plates:OnShow()
  314. self.NewPlate:Show()
  315. Plates.UpdateHealth(self)
  316.  
  317. local Name = self.NameContainer.NameText:GetText() or "Unknown"
  318. local Level = self.ArtContainer.LevelText:GetText() or ""
  319. local Boss, Elite = self.ArtContainer.HighLevelIcon, self.ArtContainer.EliteIcon
  320.  
  321. self.NewPlate.level:SetTextColor(self.ArtContainer.LevelText:GetTextColor())
  322. if Boss:IsShown() then
  323. Level = "??"
  324. self.NewPlate.level:SetTextColor(0.8, 0.05, 0)
  325. elseif Elite:IsShown() then
  326. Level = Level.."+"
  327. end
  328.  
  329. if C.nameplate.name_abbrev == true and C.nameplate.track_auras ~= true then
  330. self.NewPlate.Name:SetText(Abbrev(Name))
  331. else
  332. self.NewPlate.Name:SetText(Name)
  333. end
  334.  
  335. if tonumber(Level) == T.level and not Elite:IsShown() then
  336. self.NewPlate.level:SetText("")
  337. else
  338. self.NewPlate.level:SetText(Level)
  339. end
  340.  
  341. if C.nameplate.class_icons == true and self.isClass == true then
  342. self.NewPlate.level:SetPoint("RIGHT", self.NewPlate.Name, "LEFT", -2, 0)
  343. else
  344. self.NewPlate.level:SetPoint("RIGHT", self.NewPlate.Health, "LEFT", -2, 0)
  345. end
  346.  
  347. if C.nameplate.healer_icon == true then
  348. local name = gsub(self.NewPlate.Name:GetText(), "%s%(%*%)", "")
  349. if testing then
  350. self.NewPlate.HPHeal:Show()
  351. else
  352. if healList[name] then
  353. if exClass[healList[name]] then
  354. self.NewPlate.HPHeal:Hide()
  355. else
  356. self.NewPlate.HPHeal:Show()
  357. end
  358. else
  359. self.NewPlate.HPHeal:Hide()
  360. end
  361. end
  362. end
  363. end
  364.  
  365. -- function Plates:Highlight()
  366. -- if self.ArtContainer.Highlight:IsShown() then
  367. -- self.NewPlate.Health.Highlight:Show()
  368. -- else
  369. -- self.NewPlate.Health.Highlight:Hide()
  370. -- end
  371. -- end
  372.  
  373. function Plates:UpdateHealth()
  374. self.NewPlate.Health:SetMinMaxValues(self.ArtContainer.HealthBar:GetMinMaxValues())
  375. self.NewPlate.Health:SetValue(self.ArtContainer.HealthBar:GetValue() - 1) -- Blizzard bug fix
  376. self.NewPlate.Health:SetValue(self.ArtContainer.HealthBar:GetValue())
  377. end
  378.  
  379. function Plates:UpdateHealthColor()
  380. if not self:IsShown() then
  381. return
  382. end
  383.  
  384. local Red, Green, Blue = Plates.GetColor(self)
  385.  
  386. self.NewPlate.Health:SetStatusBarColor(Red, Green, Blue)
  387. self.NewPlate.Health.Background:SetTexture(Red, Green, Blue, 0.2)
  388. self.NewPlate.Name:SetTextColor(Red, Green, Blue)
  389.  
  390. if self.isClass or self.isTapped then return end
  391.  
  392. if C.nameplate.enhance_threat ~= true then
  393. if self.ArtContainer.AggroWarningTexture:IsShown() then
  394. local _, val = self.ArtContainer.AggroWarningTexture:GetVertexColor()
  395. if val > 0.7 then
  396. SetVirtualBorder(self.NewPlate.Health, transitionR, transitionG, transitionB)
  397. else
  398. SetVirtualBorder(self.NewPlate.Health, badR, badG, badB)
  399. end
  400. else
  401. SetVirtualBorder(self.NewPlate.Health, unpack(C.media.border_color))
  402. end
  403. else
  404. if not self.ArtContainer.AggroWarningTexture:IsShown() then
  405. if InCombatLockdown() and self.isFriendly ~= true then
  406. -- No Threat
  407. if T.Role == "Tank" then
  408. self.NewPlate.Health:SetStatusBarColor(badR, badG, badB)
  409. self.NewPlate.Health.Background:SetTexture(badR, badG, badB, 0.2)
  410. else
  411. self.NewPlate.Health:SetStatusBarColor(goodR, goodG, goodB)
  412. self.NewPlate.Health.Background:SetTexture(goodR, goodG, goodB, 0.2)
  413. end
  414. end
  415. else
  416. -- Ok we either have threat or we're losing/gaining it
  417. local r, g, b = self.ArtContainer.AggroWarningTexture:GetVertexColor()
  418. if g + b == 0 then
  419. -- Have Threat
  420. if T.Role == "Tank" then
  421. self.NewPlate.Health:SetStatusBarColor(goodR, goodG, goodB)
  422. self.NewPlate.Health.Background:SetTexture(goodR, goodG, goodB, 0.2)
  423. else
  424. self.NewPlate.Health:SetStatusBarColor(badR, badG, badB)
  425. self.NewPlate.Health.Background:SetTexture(badR, badG, badB, 0.2)
  426. end
  427. else
  428. -- Losing/Gaining Threat
  429. self.NewPlate.Health:SetStatusBarColor(transitionR, transitionG, transitionB)
  430. self.NewPlate.Health.Background:SetTexture(transitionR, transitionG, transitionB, 0.2)
  431. end
  432. end
  433. end
  434. end
  435.  
  436. function Plates:UpdateHealthText()
  437. local _, MaxHP = self.ArtContainer.HealthBar:GetMinMaxValues()
  438. local CurrentHP = self.ArtContainer.HealthBar:GetValue()
  439. local Percent = (CurrentHP / MaxHP) * 100
  440.  
  441. if C.nameplate.health_value == true then
  442. -- self.NewPlate.Health.Text:SetText(T.ShortValue(CurrentHP).." / "..T.ShortValue(MaxHP))
  443. self.NewPlate.Health.Text:SetFormattedText("%d%%", Percent)
  444. end
  445.  
  446. -- Setup frame shadow to change depending on enemy players health, also setup targetted unit to have white shadow
  447. if self.isClass == true or self.isFriendly == true then
  448. if Percent <= 50 and Percent >= 20 then
  449. SetVirtualBorder(self.NewPlate.Health, 1, 1, 0)
  450. elseif Percent < 20 then
  451. SetVirtualBorder(self.NewPlate.Health, 1, 0, 0)
  452. else
  453. SetVirtualBorder(self.NewPlate.Health, unpack(C.media.border_color))
  454. end
  455. elseif (self.isClass ~= true and self.isFriendly ~= true) and C.nameplate.enhance_threat == true then
  456. SetVirtualBorder(self.NewPlate.Health, unpack(C.media.border_color))
  457. end
  458.  
  459. if GetUnitName("target") and self.NewPlate:GetAlpha() == 1 then
  460. self.NewPlate.Health:SetSize((C.nameplate.width + C.nameplate.ad_width) * T.noscalemult, (C.nameplate.height + C.nameplate.ad_height) * T.noscalemult)
  461. self.NewPlate.CastBar:SetPoint("BOTTOMLEFT", self.NewPlate.Health, "BOTTOMLEFT", 0, -8-((C.nameplate.height + C.nameplate.ad_height) * T.noscalemult))
  462. self.NewPlate.CastBar.Icon:SetSize(((C.nameplate.height + C.nameplate.ad_height) * 2 * T.noscalemult) + 8, ((C.nameplate.height + C.nameplate.ad_height) * 2 * T.noscalemult) + 8)
  463. self.NewPlate.Health:SetFrameLevel(2)
  464. else
  465. self.NewPlate.Health:SetSize(C.nameplate.width * T.noscalemult, C.nameplate.height * T.noscalemult)
  466. self.NewPlate.CastBar:SetPoint("BOTTOMLEFT", self.NewPlate.Health, "BOTTOMLEFT", 0, -8-(C.nameplate.height * T.noscalemult))
  467. self.NewPlate.CastBar.Icon:SetSize((C.nameplate.height * 2 * T.noscalemult) + 8, (C.nameplate.height * 2 * T.noscalemult) + 8)
  468. self.NewPlate.Health:SetFrameLevel(1)
  469. end
  470.  
  471. if UnitExists("target") and self.NewPlate:GetAlpha() == 1 and GetUnitName("target") == self.NewPlate.Name:GetText() then
  472. self.NewPlate.guid = UnitGUID("target")
  473. self.NewPlate.unit = "target"
  474. Plates.OnAura(self, "target")
  475. elseif self.ArtContainer.Highlight:IsShown() and UnitExists("mouseover") and GetUnitName("mouseover") == self.NewPlate.Name:GetText() then
  476. self.NewPlate.guid = UnitGUID("mouseover")
  477. self.NewPlate.unit = "mouseover"
  478. Plates.OnAura(self, "mouseover")
  479. else
  480. self.NewPlate.unit = nil
  481. end
  482. end
  483.  
  484. local function NamePlateSizerOnSizeChanged(self, x, y)
  485. local plate = self.__owner
  486. if plate:IsShown() then
  487. if T.PlateBlacklist[plate.NameContainer.NameText:GetText()] then return end
  488. plate.NewPlate:Hide()
  489. plate.NewPlate:SetPoint("CENTER", WorldFrame, "BOTTOMLEFT", x, y)
  490. plate.NewPlate:Show()
  491. end
  492. end
  493.  
  494. local function NamePlateCreateSizer(self)
  495. local sizer = CreateFrame("Frame", nil, self.NewPlate)
  496. sizer.__owner = self
  497. sizer:SetPoint("BOTTOMLEFT", WorldFrame)
  498. sizer:SetPoint("TOPRIGHT", self, "CENTER")
  499. sizer:SetScript("OnSizeChanged", NamePlateSizerOnSizeChanged)
  500. end
  501.  
  502. function Plates:Skin(obj)
  503. NamePlateCreateSizer(obj)
  504. local Plate = obj
  505.  
  506. local HealthBar = Plate.ArtContainer.HealthBar
  507. local Border = Plate.ArtContainer.Border
  508. local Highlight = Plate.ArtContainer.Highlight
  509. local LevelText = Plate.ArtContainer.LevelText
  510. local RaidTargetIcon = Plate.ArtContainer.RaidTargetIcon
  511. local Elite = Plate.ArtContainer.EliteIcon
  512. local Threat = Plate.ArtContainer.AggroWarningTexture
  513. local Boss = Plate.ArtContainer.HighLevelIcon
  514. local CastBar = Plate.ArtContainer.CastBar
  515. local CastBarBorder = Plate.ArtContainer.CastBarBorder
  516. local CastBarSpellIcon = Plate.ArtContainer.CastBarSpellIcon
  517. local CastBarFrameShield = Plate.ArtContainer.CastBarFrameShield
  518. local CastBarText = Plate.ArtContainer.CastBarText
  519. local CastBarTextBG = Plate.ArtContainer.CastBarTextBG
  520.  
  521. local Name = Plate.NameContainer.NameText
  522. local level = Plate.ArtContainer.LevelText
  523.  
  524. HealthBar:SetParent(HiddenFrame)
  525. LevelText:SetParent(HiddenFrame)
  526. Border:SetParent(HiddenFrame)
  527. Name:SetParent(HiddenFrame)
  528.  
  529. CastBar:SetAlpha(0)
  530.  
  531. Boss:SetAlpha(0)
  532. Boss:SetTexture(nil)
  533. Highlight:SetAlpha(0)
  534. Highlight:SetTexture(nil)
  535. Elite:SetAlpha(0)
  536. Elite:SetTexture(nil)
  537. Threat:SetAlpha(0)
  538. Threat:SetTexture(nil)
  539.  
  540. self.Container[Plate] = CreateFrame("Frame", nil, self)
  541.  
  542. local NewPlate = self.Container[Plate]
  543. NewPlate:SetSize(C.nameplate.width * T.noscalemult, C.nameplate.height * T.noscalemult + C.nameplate.height * T.noscalemult)
  544. NewPlate:SetFrameStrata("BACKGROUND")
  545. NewPlate:SetFrameLevel(0)
  546.  
  547. NewPlate.Health = CreateFrame("StatusBar", nil, NewPlate)
  548. NewPlate.Health:SetFrameStrata("BACKGROUND")
  549. NewPlate.Health:SetFrameLevel(1)
  550. NewPlate.Health:SetSize(C.nameplate.width * T.noscalemult, C.nameplate.height * T.noscalemult)
  551. NewPlate.Health:SetStatusBarTexture(C.media.texture)
  552. NewPlate.Health:SetPoint("BOTTOM", 0, 0)
  553. CreateVirtualFrame(NewPlate.Health)
  554.  
  555. -- NewPlate.Health.Highlight = NewPlate.Health:CreateTexture(nil, "OVERLAY")
  556. -- NewPlate.Health.Highlight:SetTexture(1, 1, 1, 0.3)
  557. -- NewPlate.Health.Highlight:SetBlendMode("BLEND")
  558. -- NewPlate.Health.Highlight:SetAllPoints()
  559.  
  560. NewPlate.Health.Background = NewPlate.Health:CreateTexture(nil, "BORDER")
  561. NewPlate.Health.Background:SetTexture(C.media.texture)
  562. NewPlate.Health.Background:SetAllPoints()
  563.  
  564. if C.nameplate.health_value == true then
  565. NewPlate.Health.Text = NewPlate.Health:CreateFontString(nil, "OVERLAY")
  566. NewPlate.Health.Text:SetFont(C.font.nameplates_font, C.font.nameplates_font_size * T.noscalemult, C.font.nameplates_font_style)
  567. NewPlate.Health.Text:SetShadowOffset(C.font.nameplates_font_shadow and 1 or 0, C.font.nameplates_font_shadow and -1 or 0)
  568. NewPlate.Health.Text:SetPoint( "RIGHT", NewPlate.Health, "RIGHT", 0, 0)
  569. NewPlate.Health.Text:SetTextColor(1, 1, 1)
  570. end
  571.  
  572. NewPlate.Name = NewPlate.Health:CreateFontString(nil, "OVERLAY")
  573. NewPlate.Name:SetPoint("BOTTOMLEFT", NewPlate.Health, "TOPLEFT", -3, 4)
  574. NewPlate.Name:SetPoint("BOTTOMRIGHT", NewPlate.Health, "TOPRIGHT", 3, 4)
  575. NewPlate.Name:SetFont(C.font.nameplates_font, C.font.nameplates_font_size * T.noscalemult, C.font.nameplates_font_style)
  576. NewPlate.Name:SetShadowOffset(C.font.nameplates_font_shadow and 1 or 0, C.font.nameplates_font_shadow and -1 or 0)
  577.  
  578. NewPlate.level = NewPlate.Health:CreateFontString(nil, "OVERLAY")
  579. NewPlate.level:SetFont(C.font.nameplates_font, C.font.nameplates_font_size * T.noscalemult, C.font.nameplates_font_style)
  580. NewPlate.level:SetShadowOffset(C.font.nameplates_font_shadow and 1 or 0, C.font.nameplates_font_shadow and -1 or 0)
  581. NewPlate.level:SetTextColor(1, 1, 1)
  582. NewPlate.level:SetPoint("RIGHT", NewPlate.Health, "LEFT", -2, 0)
  583.  
  584. NewPlate.CastBar = CreateFrame("StatusBar", nil, NewPlate.Health)
  585. NewPlate.CastBar:SetFrameStrata("BACKGROUND")
  586. NewPlate.CastBar:SetFrameLevel(1)
  587. NewPlate.CastBar:SetStatusBarTexture(C.media.texture)
  588. NewPlate.CastBar:SetMinMaxValues(0, 100)
  589. NewPlate.CastBar:SetPoint("TOPRIGHT", NewPlate.Health, "BOTTOMRIGHT", 0, -8)
  590. NewPlate.CastBar:SetPoint("BOTTOMLEFT", NewPlate.Health, "BOTTOMLEFT", 0, -8-(C.nameplate.height * T.noscalemult))
  591. NewPlate.CastBar:SetValue(100)
  592. NewPlate.CastBar:Hide()
  593. CreateVirtualFrame(NewPlate.CastBar)
  594.  
  595. NewPlate.CastBar.Background = NewPlate.CastBar:CreateTexture(nil, "BORDER")
  596. NewPlate.CastBar.Background:SetTexture(0.75, 0.75, 0.25, 0.2)
  597. NewPlate.CastBar.Background:SetAllPoints()
  598.  
  599. NewPlate.CastBar.Icon = NewPlate.CastBar:CreateTexture(nil, "OVERLAY")
  600. -- NewPlate.CastBar.Icon:SetTexture(C.media.texture)
  601. NewPlate.CastBar.Icon:SetTexCoord(0.1, 0.9, 0.1, 0.9)
  602. NewPlate.CastBar.Icon:SetSize((C.nameplate.height * 2 * T.noscalemult) + 8, (C.nameplate.height * 2 * T.noscalemult) + 8)
  603. NewPlate.CastBar.Icon:SetPoint("TOPLEFT", NewPlate.Health, "TOPRIGHT", 8, 0)
  604. CreateVirtualFrame(NewPlate.CastBar, NewPlate.CastBar.Icon)
  605.  
  606. NewPlate.CastBar.Time = NewPlate.CastBar:CreateFontString(nil, "ARTWORK")
  607. NewPlate.CastBar.Time:SetPoint("RIGHT", NewPlate.CastBar, "RIGHT", 3, 0)
  608. NewPlate.CastBar.Time:SetFont(C.font.nameplates_font, C.font.nameplates_font_size * T.noscalemult, C.font.nameplates_font_style)
  609. NewPlate.CastBar.Time:SetShadowOffset(C.font.nameplates_font_shadow and 1 or 0, C.font.nameplates_font_shadow and -1 or 0)
  610. NewPlate.CastBar.Time:SetTextColor(1, 1, 1)
  611.  
  612. if C.nameplate.show_castbar_name == true then
  613. NewPlate.CastBar.Name = NewPlate.CastBar:CreateFontString(nil, "OVERLAY")
  614. NewPlate.CastBar.Name:SetPoint("LEFT", NewPlate.CastBar, "LEFT", 3, 0)
  615. NewPlate.CastBar.Name:SetPoint("RIGHT", NewPlate.CastBar.Time, "LEFT", -1, 0)
  616. NewPlate.CastBar.Name:SetFont(C.font.nameplates_font, C.font.nameplates_font_size * T.noscalemult, C.font.nameplates_font_style)
  617. NewPlate.CastBar.Name:SetShadowOffset(C.font.nameplates_font_shadow and 1 or 0, C.font.nameplates_font_shadow and -1 or 0)
  618. NewPlate.CastBar.Name:SetTextColor(1, 1, 1)
  619. NewPlate.CastBar.Name:SetHeight(C.font.nameplates_font_size)
  620. NewPlate.CastBar.Name:SetJustifyH("LEFT")
  621. end
  622.  
  623. RaidTargetIcon:ClearAllPoints()
  624. RaidTargetIcon:SetPoint("BOTTOM", NewPlate.Health, "TOP", 0, C.nameplate.track_auras == true and 38 or 16)
  625. RaidTargetIcon:SetSize((C.nameplate.height * 2 * T.noscalemult) + 8, (C.nameplate.height * 2 * T.noscalemult) + 8)
  626.  
  627. -- Aura tracking
  628. if C.nameplate.track_auras == true then
  629. if not NewPlate.icons then
  630. NewPlate.icons = CreateFrame("Frame", nil, NewPlate.Health)
  631. NewPlate.icons:SetPoint("BOTTOMRIGHT", NewPlate.Health, "TOPRIGHT", 0, C.font.nameplates_font_size + 7)
  632. NewPlate.icons:SetWidth(20 + C.nameplate.width)
  633. NewPlate.icons:SetHeight(C.nameplate.auras_size)
  634. NewPlate.icons:SetFrameLevel(NewPlate.Health:GetFrameLevel() + 2)
  635. end
  636. end
  637.  
  638. if C.nameplate.class_icons == true then
  639. NewPlate.class = NewPlate.Health:CreateTexture(nil, "OVERLAY")
  640. NewPlate.class:SetPoint("TOPRIGHT", NewPlate.Health, "TOPLEFT", -5, 2)
  641. NewPlate.class:SetTexture("Interface\\WorldStateFrame\\Icons-Classes")
  642. NewPlate.class:SetSize((C.nameplate.height * 2) + 11, (C.nameplate.height * 2) + 11)
  643.  
  644. NewPlate.class.Glow = CreateFrame("Frame", nil, NewPlate.Health)
  645. NewPlate.class.Glow:SetTemplate("Transparent")
  646. NewPlate.class.Glow:SetScale(T.noscalemult)
  647. NewPlate.class.Glow:SetPoint("TOPLEFT", NewPlate.class, "TOPLEFT", 0, 0)
  648. NewPlate.class.Glow:SetPoint("BOTTOMRIGHT", NewPlate.class, "BOTTOMRIGHT", 0, 0)
  649. NewPlate.class.Glow:SetFrameLevel(NewPlate.Health:GetFrameLevel() -1 > 0 and NewPlate.Health:GetFrameLevel() -1 or 0)
  650. NewPlate.class.Glow:Hide()
  651. end
  652.  
  653. if C.nameplate.healer_icon == true then
  654. NewPlate.HPHeal = NewPlate.Health:CreateFontString(nil, "OVERLAY")
  655. NewPlate.HPHeal:SetFont(C.font.nameplates_font, 32, C.font.nameplates_font_style)
  656. NewPlate.HPHeal:SetText("|cFFD53333+|r")
  657. if C.nameplate.track_auras == true then
  658. NewPlate.HPHeal:SetPoint("BOTTOM", NewPlate.Name, "TOP", 0, 13)
  659. else
  660. NewPlate.HPHeal:SetPoint("BOTTOM", NewPlate.Name, "TOP", 0, 0)
  661. end
  662. end
  663.  
  664. Plate.NewPlate = NewPlate
  665.  
  666. self.OnShow(Plate)
  667. Plate:HookScript("OnShow", self.OnShow)
  668. HealthBar:HookScript("OnValueChanged", function() self.UpdateHealth(Plate) end)
  669. CastBar:HookScript("OnShow", function() self.CastOnShow(Plate) end)
  670. CastBar:HookScript("OnHide", function() self.CastOnHide(Plate) end)
  671. CastBar:HookScript("OnValueChanged", function() self.UpdateCastBar(Plate) end)
  672.  
  673. Plate.IsSkinned = true
  674. NamePlateIndex = NamePlateIndex + 1
  675. end
  676.  
  677. function Plates:Search()
  678. if not NamePlateIndex then
  679. for _, BlizzardPlate in next, {WorldFrame:GetChildren()} do
  680. local Name = BlizzardPlate:GetName()
  681. if Name and string.match(Name, "^NamePlate%d+$") then
  682. NamePlateIndex = string.gsub(Name,"NamePlate","")
  683. break
  684. end
  685. end
  686. else
  687. local BlizzardPlate = _G["NamePlate"..NamePlateIndex]
  688. if BlizzardPlate and not BlizzardPlate.IsSkinned then
  689. self:Skin(BlizzardPlate)
  690. end
  691. end
  692. end
  693.  
  694. function Plates:Update()
  695. for Plate, NewPlate in pairs(self.Container) do
  696. if Plate:IsShown() then
  697. if Plate:GetAlpha() == 1 then
  698. NewPlate:SetAlpha(1)
  699. else
  700. NewPlate:SetAlpha(0.5)
  701. end
  702.  
  703. self.UpdateHealthColor(Plate)
  704. -- self.Highlight(Plate)
  705. self.UpdateHealthText(Plate)
  706. else
  707. NewPlate:Hide()
  708. end
  709. end
  710. end
  711.  
  712. function Plates:OnUpdate(elapsed)
  713. self:Search()
  714. self:Update()
  715. end
  716.  
  717. function Plates:Enable()
  718. if IsAddOnLoaded("CT_Viewport") then
  719. NameplateParent = UIParent
  720. end
  721.  
  722. SetCVar("bloatnameplates", 0)
  723. SetCVar("bloatthreat", 0)
  724.  
  725. self:SetAllPoints()
  726. self.Container = {}
  727. self:SetScript("OnUpdate", self.OnUpdate)
  728. end
  729.  
  730. Plates:Enable()
  731.  
  732. function Plates:MatchGUID(destGUID, spellID)
  733. if not self.NewPlate.guid then return end
  734.  
  735. if self.NewPlate.guid == destGUID then
  736. for _, icon in ipairs(self.NewPlate.icons) do
  737. if icon.spellID == spellID then
  738. icon:Hide()
  739. end
  740. end
  741. end
  742. end
  743.  
  744. function NamePlates:COMBAT_LOG_EVENT_UNFILTERED(_, event, ...)
  745. if event == "SPELL_AURA_REMOVED" then
  746. local _, sourceGUID, _, _, _, destGUID, _, _, _, spellID = ...
  747.  
  748. if sourceGUID == UnitGUID("player") or arg4 == UnitGUID("pet") then
  749. for Plate, NewPlate in pairs(Plates.Container) do
  750. if Plate:IsShown() then
  751. Plates.MatchGUID(Plate, destGUID, spellID)
  752. end
  753. end
  754. end
  755. end
  756. end
  757.  
  758. -- Only show nameplates when in combat
  759. if C.nameplate.combat == true then
  760. NamePlates:RegisterEvent("PLAYER_REGEN_ENABLED")
  761. NamePlates:RegisterEvent("PLAYER_REGEN_DISABLED")
  762.  
  763. function NamePlates:PLAYER_REGEN_ENABLED()
  764. SetCVar("nameplateShowEnemies", 0)
  765. end
  766.  
  767. function NamePlates:PLAYER_REGEN_DISABLED()
  768. SetCVar("nameplateShowEnemies", 1)
  769. end
  770. end
  771.  
  772. NamePlates:RegisterEvent("PLAYER_ENTERING_WORLD")
  773. function NamePlates:PLAYER_ENTERING_WORLD()
  774. if C.nameplate.combat == true then
  775. if InCombatLockdown() then
  776. SetCVar("nameplateShowEnemies", 1)
  777. else
  778. SetCVar("nameplateShowEnemies", 0)
  779. end
  780. end
  781. if C.nameplate.enhance_threat == true then
  782. SetCVar("threatWarning", 3)
  783. end
  784. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement