Advertisement
Wetxius

Untitled

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