PageRenderTime 57ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/Tukui/modules/unitframes/layouts/asphyxia.lua

http://github.com/Asphyxia/Tukui
Lua | 1946 lines | 1525 code | 288 blank | 133 comment | 208 complexity | 1ad21f1ecaddee55cca2b3efd90c7399 MD5 | raw file
  1. local ADDON_NAME, ns = ...
  2. local oUF = ns.oUF or oUF
  3. assert(oUF, "Tukui was unable to locate oUF install.")
  4. ns._Objects = {}
  5. ns._Headers = {}
  6. local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
  7. if not C["unitframes"].enable == true then return end
  8. if C["unitframes"].style ~= "Asphyxia" then return end
  9. ------------------------------------------------------------------------
  10. -- local variables
  11. ------------------------------------------------------------------------
  12. local font1 = C["media"].uffont
  13. local font2 = C["media"].font
  14. local font = C["media"].pixelfont
  15. local normTex = C["media"].normTex
  16. local glowTex = C["media"].glowTex
  17. local bubbleTex = C["media"].bubbleTex
  18. local backdrop = {
  19. bgFile = C["media"].blank,
  20. insets = {top = -T.mult, left = -T.mult, bottom = -T.mult, right = -T.mult},
  21. }
  22. ------------------------------------------------------------------------
  23. -- Layout
  24. ------------------------------------------------------------------------
  25. local function Shared(self, unit)
  26. -- set our own colors
  27. self.colors = T.oUF_colors
  28. -- register click
  29. self:RegisterForClicks("AnyUp")
  30. self:SetScript('OnEnter', UnitFrame_OnEnter)
  31. self:SetScript('OnLeave', UnitFrame_OnLeave)
  32. -- menu? lol
  33. self.menu = T.SpawnMenu
  34. ------------------------------------------------------------------------
  35. -- Features we want for all units at the same time
  36. ------------------------------------------------------------------------
  37. -- here we create an invisible frame for all element we want to show over health/power.
  38. local InvFrame = CreateFrame("Frame", nil, self)
  39. InvFrame:SetFrameStrata("HIGH")
  40. InvFrame:SetFrameLevel(5)
  41. InvFrame:SetAllPoints()
  42. -- symbols, now put the symbol on the frame we created above.
  43. local RaidIcon = InvFrame:CreateTexture(nil, "OVERLAY")
  44. RaidIcon:SetTexture("Interface\\AddOns\\Tukui\\medias\\textures\\raidicons.blp") -- thx hankthetank for texture
  45. RaidIcon:SetHeight(20)
  46. RaidIcon:SetWidth(20)
  47. RaidIcon:SetPoint("TOP", 0, 11)
  48. self.RaidIcon = RaidIcon
  49. ------------------------------------------------------------------------
  50. -- Player and Target units layout (mostly mirror'd)
  51. ------------------------------------------------------------------------
  52. if (unit == "player" or unit == "target") then
  53. -- create a panel
  54. local panel = CreateFrame("Frame", nil, self)
  55. if T.lowversion then
  56. panel:CreatePanel("Default", 186, 21, "BOTTOM", self, "BOTTOM", 0, 0)
  57. else
  58. panel:CreatePanel("Default", 186, 21, "BOTTOM", self, "BOTTOM", 0, 0)
  59. end
  60. panel:SetFrameLevel(2)
  61. panel:SetFrameStrata("MEDIUM")
  62. panel:SetBackdropBorderColor(unpack(C["media"].altbordercolor))
  63. panel:SetAlpha(0)
  64. self.panel = panel
  65. -- health bar
  66. local health = CreateFrame('StatusBar', nil, self)
  67. health:Height(26)
  68. health:SetPoint("TOPLEFT")
  69. health:SetPoint("TOPRIGHT")
  70. health:SetStatusBarTexture(normTex)
  71. -- Border for HealthBar
  72. local HealthBorder = CreateFrame("Frame", nil, health)
  73. HealthBorder:SetPoint("TOPLEFT", health, "TOPLEFT", -2, 2)
  74. HealthBorder:SetPoint("BOTTOMRIGHT", health, "BOTTOMRIGHT", 2, -2)
  75. HealthBorder:SetTemplate("Default")
  76. HealthBorder:CreateShadow("Default")
  77. HealthBorder:SetFrameLevel(2)
  78. self.HealthBorder = HealthBorder
  79. -- health bar background
  80. local healthBG = health:CreateTexture(nil, 'BORDER')
  81. healthBG:SetAllPoints()
  82. healthBG:SetTexture(0, 0, 0)
  83. health.value = T.SetFontString(health, font, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  84. health.value:Point("RIGHT", health, "RIGHT", -4, 0)
  85. health.PostUpdate = T.PostUpdateHealth
  86. self.Health = health
  87. self.Health.bg = healthBG
  88. health.frequentUpdates = true
  89. if C["unitframes"].showsmooth == true then
  90. health.Smooth = true
  91. end
  92. if C["unitframes"].unicolor == true then
  93. health.colorTapping = false
  94. health.colorDisconnected = false
  95. health.colorClass = false
  96. health:SetStatusBarColor(.150, .150, .150, 1)
  97. healthBG:SetVertexColor(0, 0, 0, 1)
  98. else
  99. health.colorDisconnected = true
  100. health.colorTapping = true
  101. health.colorClass = true
  102. health.colorReaction = true
  103. end
  104. -- power
  105. local power = CreateFrame('StatusBar', nil, self)
  106. power:Size(230, 2)
  107. if unit == "player" then
  108. power:Point("TOPRIGHT", health, "BOTTOMRIGHT", 0, -7)
  109. elseif unit == "target" then
  110. power:Point("TOPLEFT", health, "BOTTOMLEFT", 0, -7)
  111. end
  112. power:SetStatusBarTexture(normTex)
  113. -- Border for Power
  114. local PowerBorder = CreateFrame("Frame", nil, power)
  115. PowerBorder:SetPoint("TOPLEFT", power, "TOPLEFT", -2, 2)
  116. PowerBorder:SetPoint("BOTTOMRIGHT", power, "BOTTOMRIGHT", 2, -2)
  117. PowerBorder:SetTemplate("Default")
  118. PowerBorder:CreateShadow("Default")
  119. PowerBorder:SetFrameLevel(power:GetFrameLevel() - 1)
  120. self.PowerBorder = PowerBorder
  121. local powerBG = power:CreateTexture(nil, 'BORDER')
  122. powerBG:SetAllPoints(power)
  123. powerBG:SetTexture(normTex)
  124. powerBG.multiplier = 0.3
  125. power.value = T.SetFontString(health, font, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  126. power.value:Point("LEFT", health, "LEFT", 4, 1)
  127. power.PreUpdate = T.PreUpdatePower
  128. power.PostUpdate = T.PostUpdatePower
  129. self.Power = power
  130. self.Power.bg = powerBG
  131. power.frequentUpdates = true
  132. power.colorDisconnected = true
  133. if C["unitframes"].showsmooth == true then
  134. power.Smooth = true
  135. end
  136. if C["unitframes"].unicolor == true then
  137. power.colorTapping = true
  138. power.colorClass = true
  139. power.colorReaction = true
  140. powerBG.multiplier = 0.1
  141. else
  142. power.colorPower = true
  143. end
  144. -- portraits
  145. if (C["unitframes"].charportrait == true) then
  146. local portrait = CreateFrame("PlayerModel", nil, health)
  147. portrait:SetFrameLevel(health:GetFrameLevel())
  148. portrait:SetAllPoints(health)
  149. portrait:SetAlpha(.15)
  150. portrait.PostUpdate = T.PortraitUpdate
  151. self.Portrait = portrait
  152. end
  153. if (C["unitframes"].classicon == true) then
  154. local classicon = CreateFrame("Frame", self:GetName().."_ClassIconBorder", self)
  155. classicon:CreateShadow("Default")
  156. if unit == "player" then
  157. classicon:CreatePanel("Default", 30, 30, "TOPRIGHT", health, "TOPLEFT", -5,2)
  158. elseif unit == "target" then
  159. classicon:CreatePanel("Default", 30, 30, "TOPLEFT", health, "TOPRIGHT", 5,2)
  160. end
  161. local class = classicon:CreateTexture(self:GetName().."_ClassIcon", "ARTWORK")
  162. class:Point("TOPLEFT", 2, -2)
  163. class:Point("BOTTOMRIGHT", -2, 2)
  164. self.ClassIcon = class
  165. end
  166. if T.myclass == "PRIEST" and C["unitframes"].weakenedsoulbar then
  167. local ws = CreateFrame("StatusBar", self:GetName().."_WeakenedSoul", power)
  168. ws:SetAllPoints(power)
  169. ws:SetStatusBarTexture(C.media.normTex)
  170. ws:GetStatusBarTexture():SetHorizTile(false)
  171. ws:SetBackdrop(backdrop)
  172. ws:SetBackdropColor(unpack(C.media.backdropcolor))
  173. ws:SetStatusBarColor(191/255, 10/255, 10/255)
  174. self.WeakenedSoul = ws
  175. end
  176. if (unit == "player") then
  177. -- combat icon
  178. local Combat = health:CreateTexture(nil, "OVERLAY")
  179. Combat:Height(19)
  180. Combat:Width(19)
  181. Combat:SetPoint("CENTER",0,0)
  182. Combat:SetVertexColor(0.69, 0.31, 0.31)
  183. self.Combat = Combat
  184. -- custom info (low mana warning)
  185. FlashInfo = CreateFrame("Frame", "TukuiFlashInfo", self)
  186. FlashInfo:SetScript("OnUpdate", T.UpdateManaLevel)
  187. FlashInfo.parent = self
  188. FlashInfo:SetAllPoints(health)
  189. FlashInfo.ManaLevel = T.SetFontString(FlashInfo, font, C["datatext"].fontsize+1, "MONOCHROMEOUTLINE")
  190. FlashInfo.ManaLevel:SetPoint("CENTER", health, "CENTER", 0, 1)
  191. self.FlashInfo = FlashInfo
  192. -- pvp status icon
  193. local PVP = health:CreateTexture(nil, "OVERLAY")
  194. PVP:SetHeight(32)
  195. PVP:SetWidth(32)
  196. PVP:SetPoint("CENTER", 5, -6)
  197. self.PvP = PVP
  198. if(UnitIsPVP(unit) and factionGroup) then
  199. if(factionGroup == 'Horde') then
  200. pvp:SetTexture([[Interface\AddOns\Tukui\medias\textures\Horde]])
  201. else
  202. pvp:SetTexture([[Interface\AddOns\Tukui\medias\textures\Alliance]])
  203. end
  204. end
  205. -- leader icon
  206. local Leader = InvFrame:CreateTexture(nil, "OVERLAY")
  207. Leader:Height(14)
  208. Leader:Width(14)
  209. Leader:Point("TOPLEFT", -9, 9)
  210. self.Leader = Leader
  211. -- master looter
  212. local MasterLooter = InvFrame:CreateTexture(nil, "OVERLAY")
  213. MasterLooter:Height(14)
  214. MasterLooter:Width(14)
  215. self.MasterLooter = MasterLooter
  216. self:RegisterEvent("PARTY_LEADER_CHANGED", T.MLAnchorUpdate)
  217. self:RegisterEvent("PARTY_MEMBERS_CHANGED", T.MLAnchorUpdate)
  218. --This is the edited code for the original rep/exp bar
  219. -- experience bar on player via mouseover for player currently levelling a character
  220. if T.level ~= MAX_PLAYER_LEVEL then
  221. local Experience = CreateFrame("StatusBar", self:GetName().."_Experience", self)
  222. Experience:SetStatusBarTexture(normTex)
  223. Experience:SetStatusBarColor(0, 0.4, 1, .8)
  224. Experience:Size(TukuiChatBackgroundLeft:GetWidth() - 4, 2)
  225. Experience:Point("BOTTOM", TukuiChatBackgroundLeft, "TOP", 0, 5)
  226. Experience:SetFrameLevel(8)
  227. Experience:SetFrameStrata("HIGH")
  228. Experience.Tooltip = true
  229. self.Experience = Experience
  230. local ExperienceBG = Experience:CreateTexture(nil, 'BORDER')
  231. ExperienceBG:SetAllPoints()
  232. ExperienceBG:SetTexture(normTex)
  233. ExperienceBG:SetVertexColor(0,0,0)
  234. Experience.Text = self.Experience:CreateFontString(nil, 'OVERLAY')
  235. Experience.Text:SetFont(font, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  236. Experience.Text:SetPoint('CENTER', 0, 1)
  237. Experience.Text:SetShadowOffset(T.mult, -T.mult)
  238. self.Experience.Text = Experience.Text
  239. self.Experience.PostUpdate = T.ExperienceText
  240. self.Experience.Rested = CreateFrame('StatusBar', nil, self.Experience)
  241. self.Experience.Rested:SetAllPoints(self.Experience)
  242. self.Experience.Rested:SetStatusBarTexture(normTex)
  243. self.Experience.Rested:SetStatusBarColor(1, 0, 1, 0.2)
  244. local Resting = self:CreateTexture(nil, "OVERLAY")
  245. Resting:SetHeight(28)
  246. Resting:SetWidth(28)
  247. Resting:SetPoint("BOTTOMRIGHT", self, "TOPLEFT", 10 -4)
  248. Resting:SetTexture([=[Interface\CharacterFrame\UI-StateIcon]=])
  249. Resting:SetTexCoord(0, 0.5, 0, 0.421875)
  250. self.Resting = Resting
  251. local ExperienceFrame = CreateFrame("Frame", nil, self.Experience)
  252. ExperienceFrame:SetPoint("TOPLEFT", T.Scale(-2), T.Scale(2))
  253. ExperienceFrame:SetPoint("BOTTOMRIGHT", T.Scale(2), T.Scale(-2))
  254. ExperienceFrame:SetTemplate("Transparent")
  255. ExperienceFrame:CreateShadow("Default")
  256. ExperienceFrame:SetFrameLevel(self.Experience:GetFrameLevel() - 1)
  257. local function ModifiedBackdrop(self)
  258. local color = RAID_CLASS_COLORS[T.myclass]
  259. self:SetBackdropColor(unpack(C["media"].backdropcolor))
  260. self:SetBackdropBorderColor(color.r, color.g, color.b)
  261. end
  262. local function OriginalBackdrop(self)
  263. self:SetBackdropColor(unpack(C["media"].backdropcolor))
  264. self:SetBackdropBorderColor(unpack(C["media"].bordercolor))
  265. end
  266. end
  267. -- reputation bar for max level character
  268. if T.level == MAX_PLAYER_LEVEL then
  269. local Reputation = CreateFrame("StatusBar", self:GetName().."_Reputation", self)
  270. Reputation:SetStatusBarTexture(normTex)
  271. Reputation:Size(TukuiChatBackgroundLeft:GetWidth() - 4, 2)
  272. Reputation:Point("BOTTOM", TukuiChatBackgroundLeft, "TOP", 0, 5)
  273. Reputation:SetFrameLevel(10)
  274. local ReputationBG = Reputation:CreateTexture(nil, 'BORDER')
  275. ReputationBG:SetAllPoints()
  276. ReputationBG:SetTexture(normTex)
  277. ReputationBG:SetVertexColor(0,0,0)
  278. Reputation.Text = Reputation:CreateFontString(nil, 'OVERLAY')
  279. Reputation.Text:SetFont(font, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  280. Reputation.Text:SetPoint('CENTER', 0, 1)
  281. Reputation.Text:SetShadowOffset(T.mult, -T.mult)
  282. Reputation.Text:Show()
  283. Reputation.PostUpdate = T.UpdateReputation
  284. Reputation.Text = Reputation.Text
  285. Reputation.PostUpdate = T.UpdateReputationColor
  286. Reputation.Tooltip = true
  287. self.Reputation = Reputation
  288. local ReputationFrame = CreateFrame("Frame", nil, self.Reputation)
  289. ReputationFrame:SetPoint("TOPLEFT", T.Scale(-2), T.Scale(2))
  290. ReputationFrame:SetPoint("BOTTOMRIGHT", T.Scale(2), T.Scale(-2))
  291. ReputationFrame:SetTemplate("Transparent")
  292. ReputationFrame:CreateShadow("Default")
  293. ReputationFrame:SetFrameLevel(self.Reputation:GetFrameLevel() - 1)
  294. local function ModifiedBackdrop(self)
  295. local color = RAID_CLASS_COLORS[T.myclass]
  296. self:SetBackdropColor(unpack(C["media"].backdropcolor))
  297. self:SetBackdropBorderColor(color.r, color.g, color.b)
  298. end
  299. local function OriginalBackdrop(self)
  300. self:SetBackdropColor(unpack(C["media"].backdropcolor))
  301. self:SetBackdropBorderColor(unpack(C["media"].bordercolor))
  302. end
  303. end
  304. -- show druid mana when shapeshifted in bear, cat or whatever
  305. if T.myclass == "DRUID" then
  306. CreateFrame("Frame"):SetScript("OnUpdate", function() T.UpdateDruidMana(self) end)
  307. local DruidMana = T.SetFontString(health, font1, 12)
  308. DruidMana:SetTextColor(1, 0.49, 0.04)
  309. self.DruidManaText = DruidMana
  310. end
  311. if C["unitframes"].classbar then
  312. if T.myclass == "DRUID" then
  313. -- DRUID MANA BAR
  314. local DruidManaBackground = CreateFrame("Frame", nil, self)
  315. DruidManaBackground:Point("BOTTOMLEFT", self, "TOPLEFT", 0, 7)
  316. DruidManaBackground:Size(230, 2)
  317. DruidManaBackground:SetFrameLevel(8)
  318. DruidManaBackground:SetFrameStrata("MEDIUM")
  319. DruidManaBackground:SetTemplate("Default")
  320. DruidManaBackground:SetBackdropBorderColor(0,0,0,0)
  321. local DruidManaBarStatus = CreateFrame('StatusBar', nil, DruidManaBackground)
  322. DruidManaBarStatus:SetPoint('LEFT', DruidManaBackground, 'LEFT', 0, 0)
  323. DruidManaBarStatus:SetSize(DruidManaBackground:GetWidth(), DruidManaBackground:GetHeight())
  324. DruidManaBarStatus:SetStatusBarTexture(normTex)
  325. DruidManaBarStatus:SetStatusBarColor(.30, .52, .90)
  326. DruidManaBarStatus:SetScript("OnShow", function() T.DruidBarDisplay(self, false) end)
  327. DruidManaBarStatus:SetScript("OnUpdate", function() T.DruidBarDisplay(self, true) end) -- just forcing 1 update on login for buffs/shadow/etc.
  328. DruidManaBarStatus:SetScript("OnHide", function() T.DruidBarDisplay(self, false) end)
  329. self.DruidManaBackground = DruidManaBackground
  330. self.DruidMana = DruidManaBarStatus
  331. DruidManaBackground.FrameBackdrop = CreateFrame( "Frame", nil, DruidManaBackground )
  332. DruidManaBackground.FrameBackdrop:SetTemplate( "Default" )
  333. DruidManaBackground.FrameBackdrop:SetPoint( "TOPLEFT", -2, 2 )
  334. DruidManaBackground.FrameBackdrop:SetPoint( "BOTTOMRIGHT", 2, -2 )
  335. DruidManaBackground.FrameBackdrop:SetFrameLevel( DruidManaBackground:GetFrameLevel() - 1 )
  336. local eclipseBar = CreateFrame('Frame', nil, self)
  337. eclipseBar:Point("LEFT", health, "TOPLEFT", 0, 8)
  338. eclipseBar:Size(230, 2)
  339. eclipseBar:SetFrameStrata("MEDIUM")
  340. eclipseBar:SetFrameLevel(8)
  341. eclipseBar:SetBackdropBorderColor(0,0,0,0)
  342. eclipseBar:SetScript("OnShow", function() T.DruidBarDisplay(self, false) end)
  343. eclipseBar:SetScript("OnHide", function() T.DruidBarDisplay(self, false) end)
  344. local lunarBar = CreateFrame('StatusBar', nil, eclipseBar)
  345. lunarBar:SetPoint('LEFT', eclipseBar, 'LEFT', 0, 0)
  346. lunarBar:SetSize(eclipseBar:GetWidth(), eclipseBar:GetHeight())
  347. lunarBar:SetStatusBarTexture(normTex)
  348. lunarBar:SetStatusBarColor(.30, .52, .90)
  349. eclipseBar.LunarBar = lunarBar
  350. local solarBar = CreateFrame('StatusBar', nil, eclipseBar)
  351. solarBar:SetPoint('LEFT', lunarBar:GetStatusBarTexture(), 'RIGHT', 0, 0)
  352. solarBar:SetSize(eclipseBar:GetWidth(), eclipseBar:GetHeight())
  353. solarBar:SetStatusBarTexture(normTex)
  354. solarBar:SetStatusBarColor(.80, .82, .60)
  355. eclipseBar.SolarBar = solarBar
  356. local eclipseBarText = eclipseBar:CreateFontString(nil, 'OVERLAY')
  357. eclipseBarText:SetPoint('TOP', eclipseBar, 0, 25)
  358. eclipseBarText:SetPoint('BOTTOM', eclipseBar)
  359. eclipseBarText:SetFont(font, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  360. eclipseBarText:SetShadowOffset(T.mult, -T.mult)
  361. eclipseBarText:SetShadowColor(0, 0, 0, 0.4)
  362. eclipseBar.PostUpdatePower = T.EclipseDirection
  363. -- hide "low mana" text on load if eclipseBar is shown
  364. if eclipseBar and eclipseBar:IsShown() then FlashInfo.ManaLevel:SetAlpha(0) end
  365. self.EclipseBar = eclipseBar
  366. self.EclipseBar.Text = eclipseBarText
  367. eclipseBar.FrameBackdrop = CreateFrame("Frame", nil, eclipseBar)
  368. eclipseBar.FrameBackdrop:SetTemplate("Default")
  369. eclipseBar.FrameBackdrop:CreateShadow("Default")
  370. eclipseBar.FrameBackdrop:SetPoint("TOPLEFT", -2, 2)
  371. eclipseBar.FrameBackdrop:SetPoint("BOTTOMRIGHT", 2, -2)
  372. eclipseBar.FrameBackdrop:SetFrameLevel(eclipseBar:GetFrameLevel() - 1)
  373. end
  374. -- set holy power bar or shard bar
  375. if (T.myclass == "WARLOCK" or T.myclass == "PALADIN") then
  376. local bars = CreateFrame("Frame", nil, self)
  377. bars:SetPoint("BOTTOMLEFT", self, "TOPLEFT", 0, 7)
  378. bars:Size(230, 2)
  379. bars:SetBackdropBorderColor(0,0,0,0)
  380. for i = 1, 3 do
  381. bars[i]=CreateFrame("StatusBar", self:GetName().."_Shard"..i, bars)
  382. bars[i]:Height(2)
  383. bars[i]:SetStatusBarTexture(normTex)
  384. bars[i]:GetStatusBarTexture():SetHorizTile(false)
  385. bars[i].bg = bars[i]:CreateTexture(nil, 'BORDER')
  386. if T.myclass == "WARLOCK" then
  387. bars[i]:SetStatusBarColor(148/255, 130/255, 201/255)
  388. bars[i].bg:SetTexture(148/255, 130/255, 201/255)
  389. elseif T.myclass == "PALADIN" then
  390. bars[i]:SetStatusBarColor(228/255,225/255,16/255)
  391. bars[i].bg:SetTexture(228/255,225/255,16/255)
  392. end
  393. if i == 1 then
  394. bars[i]:SetPoint("LEFT", bars)
  395. bars[i]:Width(229/3) -- setting SetWidth here just to fit fit 250 perfectly
  396. bars[i].bg:SetAllPoints(bars[i])
  397. else
  398. bars[i]:Point("LEFT", bars[i-1], "RIGHT", 1, 0)
  399. bars[i]:Width(229/3) -- setting SetWidth here just to fit fit 250 perfectly
  400. bars[i].bg:SetAllPoints(bars[i])
  401. end
  402. bars[i].bg:SetTexture(normTex)
  403. bars[i].bg:SetAlpha(.15)
  404. end
  405. if T.myclass == "WARLOCK" then
  406. bars.Override = T.UpdateShards
  407. self.SoulShards = bars
  408. elseif T.myclass == "PALADIN" then
  409. bars.Override = T.UpdateHoly
  410. self.HolyPower = bars
  411. end
  412. bars.FrameBackdrop = CreateFrame("Frame", nil, bars)
  413. bars.FrameBackdrop:SetTemplate("Default")
  414. bars.FrameBackdrop:CreateShadow("Default")
  415. bars.FrameBackdrop:SetPoint("TOPLEFT", -2, 2)
  416. bars.FrameBackdrop:SetPoint("BOTTOMRIGHT", 2, -2)
  417. bars.FrameBackdrop:SetFrameLevel(bars:GetFrameLevel() - 1)
  418. end
  419. -- deathknight runes
  420. if T.myclass == "DEATHKNIGHT" then
  421. local Runes = CreateFrame("Frame", nil, self)
  422. Runes:Point("BOTTOMLEFT", self, "TOPLEFT", 0, 7)
  423. Runes:Size(230, 2)
  424. for i = 1, 6 do
  425. Runes[i] = CreateFrame("StatusBar", self:GetName().."_Runes"..i, health)
  426. Runes[i]:SetHeight(2)
  427. if i == 1 then
  428. Runes[i]:SetWidth(35)
  429. else
  430. Runes[i]:SetWidth(229/6)
  431. end
  432. if (i == 1) then
  433. Runes[i]:Point("BOTTOMLEFT", self, "TOPLEFT", 0, 7)
  434. else
  435. Runes[i]:Point("TOPLEFT", Runes[i-1], "TOPRIGHT", 1, 0)
  436. end
  437. Runes[i]:SetStatusBarTexture(normTex)
  438. Runes[i]:GetStatusBarTexture():SetHorizTile(false)
  439. end
  440. self.Runes = Runes
  441. Runes.FrameBackdrop = CreateFrame("Frame", nil, Runes)
  442. Runes.FrameBackdrop:SetTemplate("Default")
  443. Runes.FrameBackdrop:CreateShadow("Default")
  444. Runes.FrameBackdrop:SetPoint("TOPLEFT", -2, 2)
  445. Runes.FrameBackdrop:SetPoint("BOTTOMRIGHT", 2, -2)
  446. Runes.FrameBackdrop:SetFrameLevel(Runes:GetFrameLevel() - 1)
  447. end
  448. -- shaman totem bar
  449. if T.myclass == "SHAMAN" then
  450. local TotemBar = {}
  451. TotemBar.Destroy = true
  452. for i = 1, 4 do
  453. TotemBar[i] = CreateFrame("StatusBar", self:GetName().."_TotemBar"..i, self)
  454. if (i == 1) then
  455. TotemBar[i]:Point("BOTTOMLEFT", self, "TOPLEFT", 0, 7)
  456. else
  457. TotemBar[i]:Point("TOPLEFT", TotemBar[i-1], "TOPRIGHT", 5, 0)
  458. end
  459. TotemBar[i]:SetStatusBarTexture(normTex)
  460. TotemBar[i]:Height(2)
  461. if i == 4 then
  462. TotemBar[i]:SetWidth(215/4)
  463. else
  464. TotemBar[i]:SetWidth(215/4)
  465. end
  466. TotemBar[i]:SetBackdrop(backdrop)
  467. TotemBar[i]:SetBackdropColor(0, 0, 0)
  468. TotemBar[i]:SetMinMaxValues(0, 1)
  469. TotemBar[i].bg = TotemBar[i]:CreateTexture(nil, "BORDER")
  470. TotemBar[i].bg:SetAllPoints(TotemBar[i])
  471. TotemBar[i].bg:SetTexture(normTex)
  472. TotemBar[i].bg.multiplier = 0.3
  473. TotemBar[i].FrameBackdrop = CreateFrame("Frame", nil, TotemBar[i])
  474. TotemBar[i].FrameBackdrop:SetTemplate("Default")
  475. TotemBar[i].FrameBackdrop:CreateShadow("Default")
  476. TotemBar[i].FrameBackdrop:SetPoint("TOPLEFT", -2, 2)
  477. TotemBar[i].FrameBackdrop:SetPoint("BOTTOMRIGHT", 2, -2)
  478. TotemBar[i].FrameBackdrop:SetFrameLevel(TotemBar[i]:GetFrameLevel() - 1)
  479. end
  480. self.TotemBar = TotemBar
  481. end
  482. end
  483. -- script for low mana
  484. self:SetScript("OnEnter", function(self)
  485. if self.EclipseBar and self.EclipseBar:IsShown() then
  486. self.EclipseBar.Text:Hide()
  487. end
  488. FlashInfo.ManaLevel:Hide()
  489. UnitFrame_OnEnter(self)
  490. end)
  491. self:SetScript("OnLeave", function(self)
  492. if self.EclipseBar and self.EclipseBar:IsShown() then
  493. self.EclipseBar.Text:Show()
  494. end
  495. FlashInfo.ManaLevel:Show()
  496. UnitFrame_OnLeave(self)
  497. end)
  498. end
  499. if (unit == "target") then
  500. -- Unit name on target
  501. local Name = health:CreateFontString(nil, "OVERLAY")
  502. Name:Point("CENTER", health, "CENTER", 0, 1)
  503. Name:SetJustifyH("LEFT")
  504. Name:SetFont(font, C["datatext"].fontsize+1, "MONOCHROMEOUTLINE")
  505. Name:SetShadowOffset(1.25, -1.25)
  506. self:Tag(Name, '[Tukui:getnamecolor][Tukui:nameshort] [Tukui:diffcolor][level] [shortclassification]')
  507. --self.Name = Name
  508. --combo points change to support sCombo
  509. local cp = T.SetFontString(self, font, 15, "MONOCHROMEOUTLINE")
  510. cp:SetPoint("RIGHT", health.border, "LEFT", -5, 0)
  511. self.CPoints = cp
  512. end
  513. if (unit == "target" and C["unitframes"].targetauras) or (unit == "player" and C["unitframes"].playerauras) then
  514. local buffs = CreateFrame("Frame", nil, self)
  515. local debuffs = CreateFrame("Frame", nil, self)
  516. if (T.myclass == "SHAMAN" or T.myclass == "DEATHKNIGHT" or T.myclass == "PALADIN" or T.myclass == "WARLOCK") and (C["unitframes"].playerauras) and (unit == "player") then
  517. if T.lowversion then
  518. buffs:SetPoint("TOPLEFT", self, "TOPLEFT", 0, 34)
  519. else
  520. buffs:SetPoint("TOPLEFT", self, "TOPLEFT", 0, 38)
  521. end
  522. else
  523. if T.lowversion then
  524. buffs:SetPoint("TOPLEFT", self, "TOPLEFT", 0, 26)
  525. else
  526. buffs:SetPoint("TOPLEFT", self, "TOPLEFT", -2, 32)
  527. end
  528. end
  529. if T.lowversion then
  530. buffs:SetHeight(21.5)
  531. buffs:SetWidth(186)
  532. buffs.size = 21.5
  533. buffs.num = 8
  534. debuffs:SetHeight(21.5)
  535. debuffs:SetWidth(186)
  536. debuffs:SetPoint("BOTTOMLEFT", buffs, "TOPLEFT", 0, 2)
  537. debuffs.size = 21.5
  538. debuffs.num = 24
  539. else
  540. buffs:SetHeight(26)
  541. buffs:SetWidth(252)
  542. buffs.size = 27.5
  543. buffs.num = 8
  544. debuffs:SetHeight(26)
  545. debuffs:SetWidth(247)
  546. debuffs:SetPoint("BOTTOMLEFT", buffs, "TOPLEFT", -2, 2)
  547. debuffs.size = 26
  548. debuffs.num = 24
  549. end
  550. buffs.spacing = 2
  551. buffs.initialAnchor = 'TOPLEFT'
  552. buffs.PostCreateIcon = T.PostCreateAura
  553. buffs.PostUpdateIcon = T.PostUpdateAura
  554. self.Buffs = buffs
  555. debuffs.spacing = 2
  556. debuffs.initialAnchor = 'TOPRIGHT'
  557. debuffs["growth-y"] = "UP"
  558. debuffs["growth-x"] = "LEFT"
  559. debuffs.PostCreateIcon = T.PostCreateAura
  560. debuffs.PostUpdateIcon = T.PostUpdateAura
  561. -- An option to show only our debuffs on target
  562. if unit == "target" then
  563. debuffs.onlyShowPlayer = C.unitframes.onlyselfdebuffs
  564. end
  565. self.Debuffs = debuffs
  566. end
  567. -- cast bar for player and target
  568. if (C["unitframes"].unitcastbar == true) then
  569. local castbar = CreateFrame("StatusBar", self:GetName().."CastBar", self)
  570. castbar:SetStatusBarTexture(normTex)
  571. castbar.bg = castbar:CreateTexture(nil, "BORDER")
  572. castbar.bg:SetAllPoints(castbar)
  573. castbar.bg:SetTexture(normTex)
  574. castbar.bg:SetVertexColor(.05, .05, .05)
  575. if unit == "player" then
  576. if C["unitframes"].cbicons == true then
  577. castbar:SetWidth(TukuiBar1:GetWidth() - 31)
  578. else
  579. castbar:SetWidth(TukuiBar1:GetWidth() - 4)
  580. end
  581. castbar:SetHeight(20)
  582. castbar:Point("BOTTOMRIGHT", TukuiBar1, "TOPRIGHT", -2, 5)
  583. elseif unit == "target" then
  584. if C["unitframes"].cbicons == true then
  585. castbar:SetWidth(225 - 28)
  586. else
  587. castbar:SetWidth(246)
  588. end
  589. castbar:SetHeight(20)
  590. castbar:Point("TOPRIGHT", self, "BOTTOMRIGHT", 0, 15)
  591. end
  592. castbar:SetFrameLevel(6)
  593. if( C["unitframes"].cbspark == true ) then
  594. castbar.Spark = castbar:CreateTexture(nil, 'OVERLAY')
  595. castbar.Spark:SetHeight(36)
  596. castbar.Spark:SetWidth(15)
  597. castbar.Spark:SetBlendMode('ADD')
  598. end
  599. -- Border
  600. castbar.border = CreateFrame("Frame", nil, castbar)
  601. castbar.border:CreatePanel("Default",1,1,"TOPLEFT", castbar, "TOPLEFT", -2, 2)
  602. castbar.border:CreateShadow("Default")
  603. castbar.border:Point("BOTTOMRIGHT", castbar, "BOTTOMRIGHT", 2, -2)
  604. castbar.CustomTimeText = T.CustomCastTimeText
  605. castbar.CustomDelayText = T.CustomCastDelayText
  606. castbar.PostCastStart = T.PostCastStart
  607. castbar.PostChannelStart = T.PostCastStart
  608. castbar.time = T.SetFontString(castbar,font, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  609. castbar.time:Point("RIGHT", castbar.bg, "RIGHT", -4, 0)
  610. castbar.time:SetTextColor(0, 4, 0)
  611. castbar.time:SetJustifyH("RIGHT")
  612. castbar.Text = T.SetFontString(castbar,font, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  613. castbar.Text:Point("LEFT", castbar.bg, "LEFT", 4, 0)
  614. castbar.Text:SetTextColor(0.3, 0.2, 1)
  615. castbar.Text:Width(100)
  616. castbar.Text:Height(10)
  617. if C["unitframes"].cbicons == true then
  618. castbar.button = CreateFrame("Frame", nil, castbar)
  619. castbar.button:Size(24)
  620. castbar.button:SetTemplate("Default")
  621. castbar.button:CreateShadow("Default")
  622. castbar.button:SetPoint("RIGHT",castbar,"LEFT", -5, 0)
  623. castbar.icon = castbar.button:CreateTexture(nil, "ARTWORK")
  624. castbar.icon:Point("TOPLEFT", castbar.button, 2, -2)
  625. castbar.icon:Point("BOTTOMRIGHT", castbar.button, -2, 2)
  626. castbar.icon:SetTexCoord(0.08, 0.92, 0.08, .92)
  627. end
  628. -- cast bar latency on player
  629. if unit == "player" and C["unitframes"].cblatency == true then
  630. castbar.safezone = castbar:CreateTexture(nil, "ARTWORK")
  631. castbar.safezone:SetTexture(normTex)
  632. castbar.safezone:SetVertexColor(0.8, 0.2, 0.2, 0.75)
  633. castbar.SafeZone = castbar.safezone
  634. end
  635. self.Castbar = castbar
  636. self.Castbar.Time = castbar.time
  637. self.Castbar.Icon = castbar.icon
  638. end
  639. -- add combat feedback support
  640. if C["unitframes"].combatfeedback == true then
  641. local CombatFeedbackText
  642. CombatFeedbackText = T.SetFontString(health, font, C["datatext"].fontsize+1, "MONOCHROMEOUTLINE")
  643. CombatFeedbackText:SetPoint("CENTER", 0, 1)
  644. CombatFeedbackText.colors = {
  645. DAMAGE = {0.69, 0.31, 0.31},
  646. CRUSHING = {0.69, 0.31, 0.31},
  647. CRITICAL = {0.69, 0.31, 0.31},
  648. GLANCING = {0.69, 0.31, 0.31},
  649. STANDARD = {0.84, 0.75, 0.65},
  650. IMMUNE = {0.84, 0.75, 0.65},
  651. ABSORB = {0.84, 0.75, 0.65},
  652. BLOCK = {0.84, 0.75, 0.65},
  653. RESIST = {0.84, 0.75, 0.65},
  654. MISS = {0.84, 0.75, 0.65},
  655. HEAL = {0.33, 0.59, 0.33},
  656. CRITHEAL = {0.33, 0.59, 0.33},
  657. ENERGIZE = {0.31, 0.45, 0.63},
  658. CRITENERGIZE = {0.31, 0.45, 0.63},
  659. }
  660. self.CombatFeedbackText = CombatFeedbackText
  661. end
  662. if C["unitframes"].healcomm then
  663. local mhpb = CreateFrame('StatusBar', nil, self.Health)
  664. mhpb:SetPoint('TOPLEFT', self.Health:GetStatusBarTexture(), 'TOPRIGHT', 0, 0)
  665. mhpb:SetPoint('BOTTOMLEFT', self.Health:GetStatusBarTexture(), 'BOTTOMRIGHT', 0, 0)
  666. if T.lowversion then
  667. mhpb:SetWidth(186)
  668. else
  669. mhpb:SetWidth(250)
  670. end
  671. mhpb:SetStatusBarTexture(normTex)
  672. mhpb:SetStatusBarColor(0, 1, 0.5, 0.25)
  673. mhpb:SetMinMaxValues(0,1)
  674. local ohpb = CreateFrame('StatusBar', nil, self.Health)
  675. ohpb:SetPoint('TOPLEFT', mhpb:GetStatusBarTexture(), 'TOPRIGHT', 0, 0)
  676. ohpb:SetPoint('BOTTOMLEFT', mhpb:GetStatusBarTexture(), 'BOTTOMRIGHT', 0, 0)
  677. ohpb:SetWidth(250)
  678. ohpb:SetStatusBarTexture(normTex)
  679. ohpb:SetStatusBarColor(0, 1, 0, 0.25)
  680. self.HealPrediction = {
  681. myBar = mhpb,
  682. otherBar = ohpb,
  683. maxOverflow = 1,
  684. }
  685. end
  686. -- player aggro
  687. if C["unitframes"].playeraggro == true then
  688. table.insert(self.__elements, T.UpdateThreat)
  689. self:RegisterEvent('PLAYER_TARGET_CHANGED', T.UpdateThreat)
  690. self:RegisterEvent('UNIT_THREAT_LIST_UPDATE', T.UpdateThreat)
  691. self:RegisterEvent('UNIT_THREAT_SITUATION_UPDATE', T.UpdateThreat)
  692. end
  693. end
  694. ------------------------------------------------------------------------
  695. -- Target of Target unit layout
  696. ------------------------------------------------------------------------
  697. if (unit == "targettarget") then
  698. -- create panel for both high and low version
  699. local panel = CreateFrame("Frame", nil, self)
  700. if T.lowversion then
  701. panel:CreatePanel("Default", 129, 17, "BOTTOM", self, "BOTTOM", 0, T.Scale(0))
  702. panel:SetFrameLevel(2)
  703. panel:SetFrameStrata("MEDIUM")
  704. panel:SetBackdropBorderColor(unpack(C["media"].bordercolor))
  705. panel:SetAlpha(0)
  706. self.panel = panel
  707. else
  708. panel:CreatePanel("Default", 129, 17, "BOTTOM", self, "BOTTOM", 0, T.Scale(0))
  709. panel:SetFrameLevel(2)
  710. panel:SetFrameStrata("MEDIUM")
  711. panel:SetBackdropBorderColor(unpack(C["media"].bordercolor))
  712. panel:SetAlpha(0)
  713. self.panel = panel
  714. end
  715. -- health bar
  716. local health = CreateFrame('StatusBar', nil, self)
  717. health:Height(15)
  718. health:SetPoint("TOPLEFT")
  719. health:SetPoint("TOPRIGHT")
  720. health:SetStatusBarTexture(normTex)
  721. -- Border for ToT
  722. local HealthBorder = CreateFrame("Frame", nil, health)
  723. HealthBorder:SetPoint("TOPLEFT", health, "TOPLEFT", -2, 2)
  724. HealthBorder:SetPoint("BOTTOMRIGHT", health, "BOTTOMRIGHT", 2, -2)
  725. HealthBorder:SetTemplate("Default")
  726. HealthBorder:CreateShadow("Default")
  727. HealthBorder:SetFrameLevel(2)
  728. self.HealthBorder = HealthBorder
  729. local healthBG = health:CreateTexture(nil, 'BORDER')
  730. healthBG:SetAllPoints()
  731. healthBG:SetTexture(0, 0, 0)
  732. self.Health = health
  733. self.Health.bg = healthBG
  734. health.frequentUpdates = true
  735. if C["unitframes"].showsmooth == true then
  736. health.Smooth = true
  737. end
  738. if C["unitframes"].unicolor == true then
  739. health.colorDisconnected = false
  740. health.colorClass = false
  741. health:SetStatusBarColor(.150, .150, .150, 1)
  742. healthBG:SetVertexColor(0, 0, 0, 1)
  743. else
  744. health.colorDisconnected = true
  745. health.colorClass = true
  746. health.colorReaction = true
  747. end
  748. -- power
  749. local power = CreateFrame('StatusBar', nil, self)
  750. power:Size(130, 2)
  751. power:Point("TOP", health, "BOTTOM", 0, -7)
  752. power:SetStatusBarTexture(normTex)
  753. -- Border for Power
  754. local PowerBorder = CreateFrame("Frame", nil, power)
  755. PowerBorder:SetPoint("TOPLEFT", power, "TOPLEFT", -2, 2)
  756. PowerBorder:SetPoint("BOTTOMRIGHT", power, "BOTTOMRIGHT", 2, -2)
  757. PowerBorder:SetTemplate("Default")
  758. PowerBorder:CreateShadow("Default")
  759. PowerBorder:SetFrameLevel(power:GetFrameLevel() - 1)
  760. self.PowerBorder = PowerBorder
  761. power.frequentUpdates = true
  762. if C["unitframes"].showsmooth == true then
  763. power.Smooth = true
  764. end
  765. local powerBG = power:CreateTexture(nil, 'BORDER')
  766. powerBG:SetAllPoints(power)
  767. powerBG:SetTexture(normTex)
  768. powerBG.multiplier = 0.3
  769. self.Power = power
  770. self.Power.bg = powerBG
  771. if C["unitframes"].showsmooth == true then
  772. power.Smooth = true
  773. end
  774. if C["unitframes"].unicolor == true then
  775. power.colorTapping = true
  776. power.colorClass = true
  777. power.colorReaction = true
  778. powerBG.multiplier = 0.1
  779. else
  780. power.colorPower = true
  781. end
  782. -- Unit name
  783. local Name = health:CreateFontString(nil, "OVERLAY")
  784. Name:SetPoint("CENTER", self.Health, "CENTER", 0, 1)
  785. Name:SetFont(font, C["datatext"].fontsize+1, "MONOCHROMEOUTLINE")
  786. Name:SetJustifyH("CENTER")
  787. self:Tag(Name, '[Tukui:getnamecolor][Tukui:namemedium]')
  788. self.Name = Name
  789. if C["unitframes"].totdebuffs == true then
  790. local debuffs = CreateFrame("Frame", nil, health)
  791. debuffs:SetHeight(24)
  792. debuffs:SetWidth(128)
  793. debuffs.size = 24
  794. debuffs.spacing = 3
  795. debuffs.num = 5
  796. debuffs:SetPoint("TOPLEFT", health, "TOPLEFT", -2, 29)
  797. debuffs.initialAnchor = "TOPLEFT"
  798. debuffs["growth-y"] = "UP"
  799. debuffs.PostCreateIcon = T.PostCreateAura
  800. debuffs.PostUpdateIcon = T.PostUpdateAura
  801. self.Debuffs = debuffs
  802. end
  803. end
  804. ------------------------------------------------------------------------
  805. -- Pet unit layout
  806. ------------------------------------------------------------------------
  807. if (unit == "pet") then
  808. -- create panel for both high and low version
  809. local panel = CreateFrame("Frame", nil, self)
  810. if T.lowversion then
  811. panel:CreatePanel("Default", 129, 17, "BOTTOM", self, "BOTTOM", 0, T.Scale(0))
  812. panel:SetFrameLevel(2)
  813. panel:SetFrameStrata("MEDIUM")
  814. panel:SetBackdropBorderColor(unpack(C["media"].bordercolor))
  815. panel:SetAlpha(0)
  816. self.panel = panel
  817. else
  818. panel:CreatePanel("Default", 129, 17, "BOTTOM", self, "BOTTOM", 0, T.Scale(0))
  819. panel:SetFrameLevel(2)
  820. panel:SetFrameStrata("MEDIUM")
  821. panel:SetBackdropBorderColor(unpack(C["media"].bordercolor))
  822. panel:SetAlpha(0)
  823. self.panel = panel
  824. end
  825. -- health bar
  826. local health = CreateFrame('StatusBar', nil, self)
  827. if C["unitframes"].extendedpet == true then
  828. health:Height(15)
  829. else
  830. health:Height(22)
  831. end
  832. health:SetPoint("TOPLEFT")
  833. health:SetPoint("TOPRIGHT")
  834. health:SetStatusBarTexture(normTex)
  835. -- Border for Health
  836. local HealthBorder = CreateFrame("Frame", nil, health)
  837. HealthBorder:SetPoint("TOPLEFT", health, "TOPLEFT", -2, 2)
  838. HealthBorder:SetPoint("BOTTOMRIGHT", health, "BOTTOMRIGHT", 2, -2)
  839. HealthBorder:SetTemplate("Default")
  840. HealthBorder:CreateShadow("Default")
  841. HealthBorder:SetFrameLevel(2)
  842. self.HealthBorder = HealthBorder
  843. health.PostUpdate = T.PostUpdatePetColor
  844. self.Health = health
  845. self.Health.bg = healthBG
  846. local healthBG = health:CreateTexture(nil, 'BORDER')
  847. healthBG:SetAllPoints()
  848. healthBG:SetTexture(0, 0, 0)
  849. health.frequentUpdates = true
  850. if C["unitframes"].showsmooth == true then
  851. health.Smooth = true
  852. end
  853. if C["unitframes"].unicolor == true then
  854. health.colorDisconnected = false
  855. health.colorClass = false
  856. health:SetStatusBarColor(.150, .150, .150, 1)
  857. healthBG:SetVertexColor(0, 0, 0, 1)
  858. else
  859. health.colorDisconnected = true
  860. health.colorClass = true
  861. health.colorReaction = true
  862. if T.myclass == "HUNTER" then
  863. health.colorHappiness = true
  864. end
  865. end
  866. -- power
  867. if C["unitframes"].extendedpet == true then
  868. local power = CreateFrame('StatusBar', nil, self)
  869. power:Size(130, 2)
  870. power:Point("TOP", health, "BOTTOM", 0, -7)
  871. power:SetStatusBarTexture(normTex)
  872. power.frequentUpdates = true
  873. power.colorPower = true
  874. if C["unitframes"].showsmooth == true then
  875. power.Smooth = true
  876. end
  877. local powerBG = power:CreateTexture(nil, 'BORDER')
  878. powerBG:SetAllPoints(power)
  879. powerBG:SetTexture(normTex)
  880. powerBG.multiplier = 0.3
  881. -- Border for Power
  882. local PowerBorder = CreateFrame("Frame", nil, power)
  883. PowerBorder:SetPoint("TOPLEFT", power, "TOPLEFT", -2, 2)
  884. PowerBorder:SetPoint("BOTTOMRIGHT", power, "BOTTOMRIGHT", 2, -2)
  885. PowerBorder:SetTemplate("Default")
  886. PowerBorder:CreateShadow("Default")
  887. PowerBorder:SetFrameLevel(power:GetFrameLevel() - 1)
  888. self.PowerBorder = PowerBorder
  889. self.Power = power
  890. self.Power.bg = powerBG
  891. end
  892. -- Unit name
  893. local Name = health:CreateFontString(nil, "OVERLAY")
  894. Name:SetPoint("CENTER", self.Health, "CENTER", 1, 1)
  895. Name:SetFont(font, C["datatext"].fontsize+1, "MONOCHROMEOUTLINE")
  896. Name:SetJustifyH("CENTER")
  897. self:Tag(Name, '[Tukui:getnamecolor][Tukui:namemedium]')
  898. self.Name = Name
  899. -- update pet name, this should fix "UNKNOWN" pet names on pet unit, health and bar color sometime being "grayish".
  900. self:RegisterEvent("UNIT_PET", T.updateAllElements)
  901. end
  902. ------------------------------------------------------------------------
  903. -- Pet target unit layout
  904. ------------------------------------------------------------------------
  905. if (unit == "pettarget") then
  906. -- health bar
  907. local health = CreateFrame('StatusBar', nil, self)
  908. health:Height(15)
  909. health:SetPoint("TOPLEFT")
  910. health:SetPoint("TOPRIGHT")
  911. health:SetStatusBarTexture(normTex)
  912. -- Border for ToT
  913. local HealthBorder = CreateFrame("Frame", nil, health)
  914. HealthBorder:SetPoint("TOPLEFT", health, "TOPLEFT", -2, 2)
  915. HealthBorder:SetPoint("BOTTOMRIGHT", health, "BOTTOMRIGHT", 2, -2)
  916. HealthBorder:SetTemplate("Default")
  917. HealthBorder:CreateShadow("Default")
  918. HealthBorder:SetFrameLevel(2)
  919. self.HealthBorder = HealthBorder
  920. local healthBG = health:CreateTexture(nil, 'BORDER')
  921. healthBG:SetAllPoints()
  922. healthBG:SetTexture(0, 0, 0)
  923. self.Health = health
  924. self.Health.bg = healthBG
  925. health.frequentUpdates = true
  926. if C["unitframes"].showsmooth == true then
  927. health.Smooth = true
  928. end
  929. if C["unitframes"].unicolor == true then
  930. health.colorDisconnected = false
  931. health.colorClass = false
  932. health:SetStatusBarColor(.150, .150, .150, 1)
  933. healthBG:SetVertexColor(0, 0, 0, 1)
  934. else
  935. health.colorDisconnected = true
  936. health.colorClass = true
  937. health.colorReaction = true
  938. end
  939. -- power
  940. local power = CreateFrame('StatusBar', nil, self)
  941. power:Size(128, 2)
  942. power:Point("TOP", health, "BOTTOM", 0, -7)
  943. power:SetStatusBarTexture(normTex)
  944. -- Border for Power
  945. local PowerBorder = CreateFrame("Frame", nil, power)
  946. PowerBorder:SetPoint("TOPLEFT", power, "TOPLEFT", -2, 2)
  947. PowerBorder:SetPoint("BOTTOMRIGHT", power, "BOTTOMRIGHT", 2, -2)
  948. PowerBorder:SetTemplate("Default")
  949. PowerBorder:CreateShadow("Default")
  950. PowerBorder:SetFrameLevel(power:GetFrameLevel() - 1)
  951. self.PowerBorder = PowerBorder
  952. power.frequentUpdates = true
  953. if C["unitframes"].showsmooth == true then
  954. power.Smooth = true
  955. end
  956. local powerBG = power:CreateTexture(nil, 'BORDER')
  957. powerBG:SetAllPoints(power)
  958. powerBG:SetTexture(normTex)
  959. powerBG.multiplier = 0.3
  960. self.Power = power
  961. self.Power.bg = powerBG
  962. if C["unitframes"].showsmooth == true then
  963. power.Smooth = true
  964. end
  965. if C["unitframes"].unicolor == true then
  966. power.colorTapping = true
  967. power.colorClass = true
  968. power.colorReaction = true
  969. powerBG.multiplier = 0.1
  970. else
  971. power.colorPower = true
  972. end
  973. -- Unit name
  974. local Name = health:CreateFontString(nil, "OVERLAY")
  975. Name:SetPoint("CENTER", self.Health, "CENTER", 0, 1)
  976. Name:SetFont(font, C["datatext"].fontsize+1, "MONOCHROMEOUTLINE")
  977. Name:SetJustifyH("CENTER")
  978. self:Tag(Name, '[Tukui:getnamecolor][Tukui:namemedium]')
  979. self.Name = Name
  980. -- update pet name, this should fix "UNKNOWN" pet names on pet unit, health and bar color sometime being "grayish".
  981. self:RegisterEvent("UNIT_PET", T.updateAllElements)
  982. end
  983. ------------------------------------------------------------------------
  984. -- Focus unit layout
  985. ------------------------------------------------------------------------
  986. if (unit == "focus") then
  987. -- health
  988. local health = CreateFrame('StatusBar', nil, self)
  989. health:Height(18)
  990. health:SetPoint("TOPLEFT")
  991. health:SetPoint("TOPRIGHT")
  992. health:SetStatusBarTexture(normTex)
  993. -- Border for Health
  994. local HealthBorder = CreateFrame("Frame", nil, health)
  995. HealthBorder:SetPoint("TOPLEFT", health, "TOPLEFT", -2, 2)
  996. HealthBorder:SetPoint("BOTTOMRIGHT", health, "BOTTOMRIGHT", 2, -2)
  997. HealthBorder:SetTemplate("Default")
  998. HealthBorder:CreateShadow("Default")
  999. HealthBorder:SetFrameLevel(2)
  1000. self.HealthBorder = HealthBorder
  1001. health.frequentUpdates = true
  1002. health.colorDisconnected = true
  1003. if C["unitframes"].showsmooth == true then
  1004. health.Smooth = true
  1005. end
  1006. health.colorClass = true
  1007. local healthBG = health:CreateTexture(nil, 'BORDER')
  1008. healthBG:SetAllPoints()
  1009. healthBG:SetTexture(0, 0, 0)
  1010. health.value = T.SetFontString(health, font, C["datatext"].fontsize+1, "MONOCHROMEOUTLINE")
  1011. health.value:Point("LEFT", 2, 0)
  1012. health.PostUpdate = T.PostUpdateHealth
  1013. self.Health = health
  1014. self.Health.bg = healthBG
  1015. health.frequentUpdates = true
  1016. if C["unitframes"].showsmooth == true then
  1017. health.Smooth = true
  1018. end
  1019. if C["unitframes"].unicolor == true then
  1020. health.colorDisconnected = false
  1021. health.colorClass = false
  1022. health:SetStatusBarColor(.150, .150, .150, 1)
  1023. healthBG:SetVertexColor(0, 0, 0, 1)
  1024. else
  1025. health.colorDisconnected = true
  1026. health.colorClass = true
  1027. health.colorReaction = true
  1028. end
  1029. -- power
  1030. local power = CreateFrame('StatusBar', nil, self)
  1031. power:Size(200, 2)
  1032. power:Point("TOP", health, "BOTTOM", 0, -7)
  1033. power:SetStatusBarTexture(normTex)
  1034. -- Border for Power
  1035. local PowerBorder = CreateFrame("Frame", nil, power)
  1036. PowerBorder:SetPoint("TOPLEFT", power, "TOPLEFT", -2, 2)
  1037. PowerBorder:SetPoint("BOTTOMRIGHT", power, "BOTTOMRIGHT", 2, -2)
  1038. PowerBorder:SetTemplate("Default")
  1039. PowerBorder:CreateShadow("Default")
  1040. PowerBorder:SetFrameLevel(power:GetFrameLevel() - 1)
  1041. self.PowerBorder = PowerBorder
  1042. power.frequentUpdates = true
  1043. power.colorPower = true
  1044. if C["unitframes"].showsmooth == true then
  1045. power.Smooth = true
  1046. end
  1047. local powerBG = power:CreateTexture(nil, 'BORDER')
  1048. powerBG:SetAllPoints(power)
  1049. powerBG:SetTexture(normTex)
  1050. powerBG.multiplier = 0.3
  1051. power.value = T.SetFontString(health, font, C["datatext"].fontsize+1, "MONOCHROMEOUTLINE")
  1052. power.value:Point("RIGHT", -2, 1)
  1053. power.PreUpdate = T.PreUpdatePower
  1054. power.PostUpdate = T.PostUpdatePower
  1055. self.Power = power
  1056. self.Power.bg = powerBG
  1057. -- names
  1058. local Name = health:CreateFontString(nil, "OVERLAY")
  1059. Name:SetPoint("CENTER", health, "CENTER", 0, 1)
  1060. Name:SetJustifyH("CENTER")
  1061. Name:SetFont(font, C["datatext"].fontsize+1, "MONOCHROMEOUTLINE")
  1062. Name:SetShadowColor(0, 0, 0)
  1063. Name:SetShadowOffset(1.25, -1.25)
  1064. self:Tag(Name, '[Tukui:getnamecolor][Tukui:nameshort]')
  1065. self.Name = Name
  1066. -- create debuff for arena units
  1067. local debuffs = CreateFrame("Frame", nil, self)
  1068. debuffs:SetHeight(26)
  1069. debuffs:SetWidth(200)
  1070. debuffs:Point('RIGHT', self, 'LEFT', -4, 0)
  1071. debuffs.size = 26
  1072. debuffs.num = 8
  1073. debuffs.spacing = 2
  1074. debuffs.initialAnchor = 'RIGHT'
  1075. debuffs["growth-x"] = "LEFT"
  1076. debuffs.PostCreateIcon = T.PostCreateAura
  1077. debuffs.PostUpdateIcon = T.PostUpdateAura
  1078. self.Debuffs = debuffs
  1079. local castbar = CreateFrame("StatusBar", self:GetName().."CastBar", self)
  1080. castbar:SetPoint("LEFT", 0, 0)
  1081. castbar:SetPoint("RIGHT", -23, 0)
  1082. castbar:SetPoint("BOTTOM", 0, -20)
  1083. castbar:SetHeight(16)
  1084. castbar:SetStatusBarTexture(normTex)
  1085. castbar:SetFrameLevel(6)
  1086. castbar.bg = CreateFrame("Frame", nil, castbar)
  1087. castbar.bg:SetTemplate("Default")
  1088. castbar.bg:CreateShadow("Default")
  1089. castbar.bg:SetBackdropBorderColor(unpack(C["media"].bordercolor))
  1090. castbar.bg:Point("TOPLEFT", -2, 2)
  1091. castbar.bg:Point("BOTTOMRIGHT", 2, -2)
  1092. castbar.bg:SetFrameLevel(5)
  1093. castbar.time = T.SetFontString(castbar,font, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  1094. castbar.time:Point("RIGHT", castbar, "RIGHT", -4, 0)
  1095. castbar.time:SetTextColor(0, 4, 0)
  1096. castbar.time:SetJustifyH("RIGHT")
  1097. castbar.CustomTimeText = T.CustomCastTimeText
  1098. castbar.Text = T.SetFontString(castbar,font, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  1099. castbar.Text:SetPoint("LEFT", castbar, "LEFT", 4, 0)
  1100. castbar.Text:SetTextColor(0.3, 0.2, 1)
  1101. castbar.Text:Width(100)
  1102. castbar.Text:Height(12)
  1103. castbar.CustomDelayText = T.CustomCastDelayText
  1104. castbar.PostCastStart =T.PostCastStart
  1105. castbar.PostChannelStart = T.PostCastStart
  1106. castbar.button = CreateFrame("Frame", nil, castbar)
  1107. castbar.button:Height(castbar:GetHeight()+4)
  1108. castbar.button:Width(castbar:GetHeight()+4)
  1109. castbar.button:Point("LEFT", castbar, "RIGHT", 5, 0)
  1110. castbar.button:SetTemplate("Default")
  1111. castbar.button:CreateShadow("Default")
  1112. castbar.button:SetBackdropBorderColor(unpack(C["media"].bordercolor))
  1113. castbar.icon = castbar.button:CreateTexture(nil, "ARTWORK")
  1114. castbar.icon:Point("TOPLEFT", castbar.button, 2, -2)
  1115. castbar.icon:Point("BOTTOMRIGHT", castbar.button, -2, 2)
  1116. castbar.icon:SetTexCoord(0.08, 0.92, 0.08, .92)
  1117. self.Castbar = castbar
  1118. self.Castbar.Time = castbar.time
  1119. self.Castbar.Icon = castbar.icon
  1120. end
  1121. ------------------------------------------------------------------------
  1122. -- Focus target unit layout
  1123. ------------------------------------------------------------------------
  1124. if (unit == "focustarget") then
  1125. -- health
  1126. local health = CreateFrame('StatusBar', nil, self)
  1127. health:Height(18)
  1128. health:SetPoint("TOPLEFT")
  1129. health:SetPoint("TOPRIGHT")
  1130. health:SetStatusBarTexture(normTex)
  1131. -- Border for Health
  1132. local HealthBorder = CreateFrame("Frame", nil, health)
  1133. HealthBorder:SetPoint("TOPLEFT", health, "TOPLEFT", -2, 2)
  1134. HealthBorder:SetPoint("BOTTOMRIGHT", health, "BOTTOMRIGHT", 2, -2)
  1135. HealthBorder:SetTemplate("Default")
  1136. HealthBorder:CreateShadow("Default")
  1137. HealthBorder:SetFrameLevel(2)
  1138. self.HealthBorder = HealthBorder
  1139. health.frequentUpdates = true
  1140. health.colorDisconnected = true
  1141. if C["unitframes"].showsmooth == true then
  1142. health.Smooth = true
  1143. end
  1144. health.colorClass = true
  1145. local healthBG = health:CreateTexture(nil, 'BORDER')
  1146. healthBG:SetAllPoints()
  1147. healthBG:SetTexture(0, 0, 0)
  1148. health.value = T.SetFontString(health, font, C["datatext"].fontsize+1, "MONOCHROMEOUTLINE")
  1149. health.value:Point("LEFT", 2, 0)
  1150. health.PostUpdate = T.PostUpdateHealth
  1151. self.Health = health
  1152. self.Health.bg = healthBG
  1153. health.frequentUpdates = true
  1154. if C["unitframes"].showsmooth == true then
  1155. health.Smooth = true
  1156. end
  1157. if C["unitframes"].unicolor == true then
  1158. health.colorDisconnected = false
  1159. health.colorClass = false
  1160. health:SetStatusBarColor(.150, .150, .150, 1)
  1161. healthBG:SetVertexColor(0, 0, 0, 1)
  1162. else
  1163. health.colorDisconnected = true
  1164. health.colorClass = true
  1165. health.colorReaction = true
  1166. end
  1167. -- power
  1168. local power = CreateFrame('StatusBar', nil, self)
  1169. power:Size(200, 2)
  1170. power:Point("TOP", health, "BOTTOM", 0, -7)
  1171. power:SetStatusBarTexture(normTex)
  1172. -- Border for Power
  1173. local PowerBorder = CreateFrame("Frame", nil, power)
  1174. PowerBorder:SetPoint("TOPLEFT", power, "TOPLEFT", -2, 2)
  1175. PowerBorder:SetPoint("BOTTOMRIGHT", power, "BOTTOMRIGHT", 2, -2)
  1176. PowerBorder:SetTemplate("Default")
  1177. PowerBorder:CreateShadow("Default")
  1178. PowerBorder:SetFrameLevel(power:GetFrameLevel() - 1)
  1179. self.PowerBorder = PowerBorder
  1180. power.frequentUpdates = true
  1181. power.colorPower = true
  1182. if C["unitframes"].showsmooth == true then
  1183. power.Smooth = true
  1184. end
  1185. local powerBG = power:CreateTexture(nil, 'BORDER')
  1186. powerBG:SetAllPoints(power)
  1187. powerBG:SetTexture(normTex)
  1188. powerBG.multiplier = 0.3
  1189. power.value = T.SetFontString(health, font, C["datatext"].fontsize+1, "MONOCHROMEOUTLINE")
  1190. power.value:Point("RIGHT", -2, 1)
  1191. power.PreUpdate = T.PreUpdatePower
  1192. power.PostUpdate = T.PostUpdatePower
  1193. self.Power = power
  1194. self.Power.bg = powerBG
  1195. -- names
  1196. local Name = health:CreateFontString(nil, "OVERLAY")
  1197. Name:SetPoint("CENTER", health, "CENTER", 0, 1)
  1198. Name:SetJustifyH("CENTER")
  1199. Name:SetFont(font, C["datatext"].fontsize+1, "MONOCHROMEOUTLINE")
  1200. Name:SetShadowColor(0, 0, 0)
  1201. Name:SetShadowOffset(1.25, -1.25)
  1202. self:Tag(Name, '[Tukui:getnamecolor][Tukui:nameshort]')
  1203. self.Name = Name
  1204. -- create debuff for arena units
  1205. local debuffs = CreateFrame("Frame", nil, self)
  1206. debuffs:SetHeight(26)
  1207. debuffs:SetWidth(200)
  1208. debuffs:Point('RIGHT', self, 'LEFT', -4, 0)
  1209. debuffs.size = 26
  1210. debuffs.num = 0
  1211. debuffs.spacing = 2
  1212. debuffs.initialAnchor = 'RIGHT'
  1213. debuffs["growth-x"] = "LEFT"
  1214. debuffs.PostCreateIcon = T.PostCreateAura
  1215. debuffs.PostUpdateIcon = T.PostUpdateAura
  1216. self.Debuffs = debuffs
  1217. local castbar = CreateFrame("StatusBar", self:GetName().."CastBar", self)
  1218. castbar:SetPoint("LEFT", 0, 0)
  1219. castbar:SetPoint("RIGHT", -23, 0)
  1220. castbar:SetPoint("BOTTOM", 0, -20)
  1221. castbar:SetHeight(16)
  1222. castbar:SetStatusBarTexture(normTex)
  1223. castbar:SetFrameLevel(6)
  1224. castbar.bg = CreateFrame("Frame", nil, castbar)
  1225. castbar.bg:SetTemplate("Default")
  1226. castbar.bg:CreateShadow("Default")
  1227. castbar.bg:SetBackdropBorderColor(unpack(C["media"].bordercolor))
  1228. castbar.bg:Point("TOPLEFT", -2, 2)
  1229. castbar.bg:Point("BOTTOMRIGHT", 2, -2)
  1230. castbar.bg:SetFrameLevel(5)
  1231. castbar.time = T.SetFontString(castbar,font, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  1232. castbar.time:Point("RIGHT", castbar, "RIGHT", -4, 0)
  1233. castbar.time:SetTextColor(0, 4, 0)
  1234. castbar.time:SetJustifyH("RIGHT")
  1235. castbar.CustomTimeText = T.CustomCastTimeText
  1236. castbar.Text = T.SetFontString(castbar,font, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  1237. castbar.Text:SetPoint("LEFT", castbar, "LEFT", 4, 0)
  1238. castbar.Text:SetTextColor(0.3, 0.2, 1)
  1239. castbar.Text:Width(100)
  1240. castbar.Text:Height(12)
  1241. castbar.CustomDelayText = T.CustomCastDelayText
  1242. castbar.PostCastStart = T.PostCastStart
  1243. castbar.PostChannelStart = T.PostCastStart
  1244. castbar.button = CreateFrame("Frame", nil, castbar)
  1245. castbar.button:Height(castbar:GetHeight()+4)
  1246. castbar.button:Width(castbar:GetHeight()+4)
  1247. castbar.button:Point("LEFT", castbar, "RIGHT", 5, 0)
  1248. castbar.button:SetTemplate("Default")
  1249. castbar.button:CreateShadow("Default")
  1250. castbar.button:SetBackdropBorderColor(unpack(C["media"].bordercolor))
  1251. castbar.icon = castbar.button:CreateTexture(nil, "ARTWORK")
  1252. castbar.icon:Point("TOPLEFT", castbar.button, 2, -2)
  1253. castbar.icon:Point("BOTTOMRIGHT", castbar.button, -2, 2)
  1254. castbar.icon:SetTexCoord(0.08, 0.92, 0.08, .92)
  1255. self.Castbar = castbar
  1256. self.Castbar.Time = castbar.time
  1257. self.Castbar.Icon = castbar.icon
  1258. end
  1259. ------------------------------------------------------------------------
  1260. -- Arena or boss units layout (both mirror'd)
  1261. ------------------------------------------------------------------------
  1262. if (unit and unit:find("arena%d") and C["arena"].unitframes == true) or (unit and unit:find("boss%d") and C["unitframes"].showboss == true) then
  1263. -- Right-click focus on arena or boss units
  1264. self:SetAttribute("type2", "focus")
  1265. -- health
  1266. local health = CreateFrame('StatusBar', nil, self)
  1267. health:Height(18)
  1268. health:SetPoint("TOPLEFT")
  1269. health:SetPoint("TOPRIGHT")
  1270. health:SetStatusBarTexture(normTex)
  1271. -- Border for Health
  1272. local HealthBorder = CreateFrame("Frame", nil, health)
  1273. HealthBorder:SetPoint("TOPLEFT", health, "TOPLEFT", -2, 2)
  1274. HealthBorder:SetPoint("BOTTOMRIGHT", health, "BOTTOMRIGHT", 2, -2)
  1275. HealthBorder:SetTemplate("Default")
  1276. HealthBorder:CreateShadow("Default")
  1277. HealthBorder:SetFrameLevel(2)
  1278. self.HealthBorder = HealthBorder
  1279. health.frequentUpdates = true
  1280. health.colorDisconnected = true
  1281. if C["unitframes"].showsmooth == true then
  1282. health.Smooth = true
  1283. end
  1284. health.colorClass = true
  1285. local healthBG = health:CreateTexture(nil, 'BORDER')
  1286. healthBG:SetAllPoints()
  1287. healthBG:SetTexture(0, 0, 0)
  1288. health.value = T.SetFontString(health, font, C["datatext"].fontsize+1, "MONOCHROMEOUTLINE")
  1289. health.value:Point("LEFT", 2, 0)
  1290. health.PostUpdate = T.PostUpdateHealth
  1291. self.Health = health
  1292. self.Health.bg = healthBG
  1293. health.frequentUpdates = true
  1294. if C["unitframes"].showsmooth == true then
  1295. health.Smooth = true
  1296. end
  1297. if C["unitframes"].unicolor == true then
  1298. health.colorDisconnected = false
  1299. health.colorClass = false
  1300. health:SetStatusBarColor(.150, .150, .150, 1)
  1301. healthBG:SetVertexColor(0, 0, 0, 1)
  1302. else
  1303. health.colorDisconnected = true
  1304. health.colorClass = true
  1305. health.colorReaction = true
  1306. end
  1307. -- power
  1308. local power = CreateFrame('StatusBar', nil, self)
  1309. power:Size(200, 2)
  1310. power:Point("TOP", health, "BOTTOM", 0, -7)
  1311. power:SetStatusBarTexture(normTex)
  1312. -- Border for Power
  1313. local PowerBorder = CreateFrame("Frame", nil, power)
  1314. PowerBorder:SetPoint("TOPLEFT", power, "TOPLEFT", -2, 2)
  1315. PowerBorder:SetPoint("BOTTOMRIGHT", power, "BOTTOMRIGHT", 2, -2)
  1316. PowerBorder:SetTemplate("Default")
  1317. PowerBorder:CreateShadow("Default")
  1318. PowerBorder:SetFrameLevel(power:GetFrameLevel() - 1)
  1319. self.PowerBorder = PowerBorder
  1320. power.frequentUpdates = true
  1321. power.colorPower = true
  1322. if C["unitframes"].showsmooth == true then
  1323. power.Smooth = true
  1324. end
  1325. local powerBG = power:CreateTexture(nil, 'BORDER')
  1326. powerBG:SetAllPoints(power)
  1327. powerBG:SetTexture(normTex)
  1328. powerBG.multiplier = 0.3
  1329. power.value = T.SetFontString(health, font, C["datatext"].fontsize+1, "MONOCHROMEOUTLINE")
  1330. power.value:Point("RIGHT", -2, 0.5)
  1331. power.PreUpdate = T.PreUpdatePower
  1332. power.PostUpdate = T.PostUpdatePower
  1333. self.Power = power
  1334. self.Power.bg = powerBG
  1335. -- names
  1336. local Name = health:CreateFontString(nil, "OVERLAY")
  1337. Name:SetPoint("CENTER", health, "CENTER", 0, 1)
  1338. Name:SetJustifyH("CENTER")
  1339. Name:SetFont(font, C["datatext"].fontsize+1, "MONOCHROMEOUTLINE")
  1340. Name:SetShadowColor(0, 0, 0)
  1341. Name:SetShadowOffset(1.25, -1.25)
  1342. Name.frequentUpdates = 0.2
  1343. self:Tag(Name, '[Tukui:getnamecolor][Tukui:nameshort]')
  1344. self.Name = Name
  1345. if (unit and unit:find("boss%d")) then
  1346. -- alt power bar
  1347. local AltPowerBar = CreateFrame("StatusBar", nil, self.Health)
  1348. AltPowerBar:SetFrameLevel(self.Health:GetFrameLevel() + 1)
  1349. AltPowerBar:Height(2)
  1350. AltPowerBar:SetStatusBarTexture(C.media.normTex)
  1351. AltPowerBar:GetStatusBarTexture():SetHorizTile(false)
  1352. AltPowerBar:SetStatusBarColor(1, 0, 0)
  1353. AltPowerBar:SetPoint("LEFT")
  1354. AltPowerBar:SetPoint("RIGHT")
  1355. AltPowerBar:SetPoint("TOP", self.Health, "TOP")
  1356. AltPowerBar:SetBackdrop(backdrop)
  1357. AltPowerBar:SetBackdropColor(0, 0, 0)
  1358. self.AltPowerBar = AltPowerBar
  1359. -- create buff at left of unit if they are boss units
  1360. local buffs = CreateFrame("Frame", nil, self)
  1361. buffs:SetHeight(31)
  1362. buffs:SetWidth(102)
  1363. buffs:Point("TOPRIGHT", self, "TOPLEFT", -5, 2)
  1364. buffs.size = 31
  1365. buffs.num = 3
  1366. buffs.spacing = 3
  1367. buffs.initialAnchor = 'RIGHT'
  1368. buffs["growth-x"] = "LEFT"
  1369. buffs.PostCreateIcon = T.PostCreateAura
  1370. buffs.PostUpdateIcon = T.PostUpdateAura
  1371. self.Buffs = buffs
  1372. -- because it appear that sometime elements are not correct.
  1373. self:HookScript("OnShow", T.updateAllElements)
  1374. end
  1375. -- create debuff for arena units
  1376. local debuffs = CreateFrame("Frame", nil, self)
  1377. debuffs:SetHeight(31)
  1378. debuffs:SetWidth(102)
  1379. debuffs:Point('TOPLEFT', self, 'TOPRIGHT', 5, 2)
  1380. debuffs.size = 31
  1381. debuffs.num = 3
  1382. debuffs.spacing = 3
  1383. debuffs.initialAnchor = 'LEFT'
  1384. debuffs["growth-x"] = "RIGHT"
  1385. debuffs.PostCreateIcon = T.PostCreateAura
  1386. debuffs.PostUpdateIcon = T.PostUpdateAura
  1387. self.Debuffs = debuffs
  1388. -- trinket feature via trinket plugin
  1389. if (C.arena.unitframes) and (unit and unit:find('arena%d')) then
  1390. local Trinketbg = CreateFrame("Frame", nil, self)
  1391. Trinketbg:SetHeight(31)
  1392. Trinketbg:SetWidth(31)
  1393. Trinketbg:Point("TOPRIGHT", self, "TOPLEFT", -5, 2)
  1394. Trinketbg:SetTemplate("Default")
  1395. Trinketbg:CreateShadow("Default")
  1396. Trinketbg:SetFrameLevel(0)
  1397. self.Trinketbg = Trinketbg
  1398. local Trinket = CreateFrame("Frame", nil, Trinketbg)
  1399. Trinket:SetAllPoints(Trinketbg)
  1400. Trinket:Point("TOPLEFT", Trinketbg, 2, -2)
  1401. Trinket:Point("BOTTOMRIGHT", Trinketbg, -2, 2)
  1402. Trinket:SetFrameLevel(1)
  1403. Trinket.trinketUseAnnounce = true
  1404. self.Trinket = Trinket
  1405. end
  1406. -- boss & arena frames cast bar!
  1407. local castbar = CreateFrame("StatusBar", self:GetName().."CastBar", self)
  1408. castbar:SetPoint("LEFT", 23, -1)
  1409. castbar:SetPoint("RIGHT", 0, -1)
  1410. castbar:SetPoint("BOTTOM", 0, -23)
  1411. castbar:SetHeight(16)
  1412. castbar:SetStatusBarTexture(normTex)
  1413. castbar:SetFrameLevel(6)
  1414. castbar.bg = CreateFrame("Frame", nil, castbar)
  1415. castbar.bg:SetTemplate("Default")
  1416. castbar.bg:CreateShadow("Default")
  1417. castbar.bg:SetBackdropBorderColor(unpack(C["media"].bordercolor))
  1418. castbar.bg:Point("TOPLEFT", -2, 2)
  1419. castbar.bg:Point("BOTTOMRIGHT", 2, -2)
  1420. castbar.bg:SetFrameLevel(5)
  1421. castbar.time = T.SetFontString(castbar,font, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  1422. castbar.time:Point("RIGHT", castbar, "RIGHT", -4, 0)
  1423. castbar.time:SetTextColor(0, 4, 0)
  1424. castbar.time:SetJustifyH("RIGHT")
  1425. castbar.CustomTimeText = T.CustomCastTimeText
  1426. castbar.Text = T.SetFontString(castbar,font, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  1427. castbar.Text:Point("LEFT", castbar, "LEFT", 4, 0)
  1428. castbar.Text:SetTextColor(0.3, 0.2, 1)
  1429. castbar.Text:Width(100)
  1430. castbar.Text:Height(10)
  1431. castbar.CustomDelayText = T.CustomCastDelayText
  1432. castbar.PostCastStart = T.PostCastStart
  1433. castbar.PostChannelStart = T.PostCastStart
  1434. castbar.button = CreateFrame("Frame", nil, castbar)
  1435. castbar.button:Height(castbar:GetHeight()+4)
  1436. castbar.button:Width(castbar:GetHeight()+4)
  1437. castbar.button:Point("RIGHT", castbar, "LEFT",-5, 0)
  1438. castbar.button:SetTemplate("Default")
  1439. castbar.button:CreateShadow("Default")
  1440. castbar.button:SetBackdropBorderColor(unpack(C["media"].bordercolor))
  1441. castbar.icon = castbar.button:CreateTexture(nil, "ARTWORK")
  1442. castbar.icon:Point("TOPLEFT", castbar.button, T.Scale(2), T.Scale(-2))
  1443. castbar.icon:Point("BOTTOMRIGHT", castbar.button, -2, 2)
  1444. castbar.icon:SetTexCoord(0.08, 0.92, 0.08, .92)
  1445. self.Castbar = castbar
  1446. self.Castbar.Time = castbar.time
  1447. self.Castbar.Icon = castbar.icon
  1448. end
  1449. ------------------------------------------------------------------------
  1450. -- Main tanks and Main Assists layout (both mirror'd)
  1451. ------------------------------------------------------------------------
  1452. if (self:GetParent():GetName():match"TukuiMainTank" or self:GetParent():GetName():match"TukuiMainAssist") then
  1453. -- Right-click focus on maintank or mainassist units
  1454. self:SetAttribute("type2", "focus")
  1455. -- health
  1456. local health = CreateFrame('StatusBar', nil, self)
  1457. health:Height(20)
  1458. health:SetPoint("TOPLEFT")
  1459. health:SetPoint("TOPRIGHT")
  1460. health:SetStatusBarTexture(normTex)
  1461. local healthBG = health:CreateTexture(nil, 'BORDER')
  1462. healthBG:SetAllPoints()
  1463. healthBG:SetTexture(0, 0, 0)
  1464. -- Border for HealthBar
  1465. local HealthBorder = CreateFrame("Frame", nil, health)
  1466. HealthBorder:SetPoint("TOPLEFT", health, "TOPLEFT", -2, 2)
  1467. HealthBorder:SetPoint("BOTTOMRIGHT", health, "BOTTOMRIGHT", 2, -2)
  1468. HealthBorder:SetTemplate("Default")
  1469. HealthBorder:CreateShadow("Default")
  1470. HealthBorder:SetFrameLevel(2)
  1471. self.HealthBorder = HealthBorder
  1472. self.Health = health
  1473. self.Health.bg = healthBG
  1474. health.frequentUpdates = true
  1475. if C["unitframes"].showsmooth == true then
  1476. health.Smooth = true
  1477. end
  1478. if C["unitframes"].unicolor == true then
  1479. health.colorDisconnected = false
  1480. health.colorClass = false
  1481. health:SetStatusBarColor(.150, .150, .150, 1)
  1482. healthBG:SetVertexColor(0, 0, 0, 1)
  1483. else
  1484. health.colorDisconnected = true
  1485. health.colorClass = true
  1486. health.colorReaction = true
  1487. end
  1488. -- names
  1489. local Name = health:CreateFontString(nil, "OVERLAY")
  1490. Name:SetPoint("CENTER", health, "CENTER", 0, 1)
  1491. Name:SetJustifyH("CENTER")
  1492. Name:SetFont(font, C["datatext"].fontsize+1, "MONOCHROMEOUTLINE")
  1493. Name:SetShadowColor(0, 0, 0)
  1494. Name:SetShadowOffset(1.25, -1.25)
  1495. self:Tag(Name, '[Tukui:getnamecolor][Tukui:nameshort]')
  1496. self.Name = Name
  1497. end
  1498. return self
  1499. end
  1500. ------------------------------------------------------------------------
  1501. -- Default position of Tukui unitframes
  1502. ------------------------------------------------------------------------
  1503. oUF:RegisterStyle('Tukui', Shared)
  1504. T.Player = 230
  1505. T.Target = 230
  1506. T.ToT = 130
  1507. T.Pet = 130
  1508. T.Focus = 115
  1509. T.Focustarget = 115
  1510. T.Boss = 200
  1511. T.Pettarget = 130
  1512. -----------------------------------------------------------------------
  1513. -- Unitframe Spawn
  1514. -----------------------------------------------------------------------
  1515. local player = oUF:Spawn('player', "TukuiPlayer")
  1516. local target = oUF:Spawn('target', "TukuiTarget")
  1517. local tot = oUF:Spawn('targettarget', "TukuiTargetTarget")
  1518. local pet = oUF:Spawn('pet', "TukuiPet")
  1519. local focus = oUF:Spawn('focus', "TukuiFocus")
  1520. -- Sizes
  1521. player:Size(T.Player, player.Health:GetHeight() + player.Power:GetHeight() + player.panel:GetHeight() + 6)
  1522. target:Size(T.Target, target.Health:GetHeight() + target.Power:GetHeight() + target.panel:GetHeight() + 6)
  1523. tot:Size(T.ToT, tot.Health:GetHeight() + tot.Power:GetHeight() + tot.panel:GetHeight() + 6)
  1524. pet:Size(T.Pet, pet.Health:GetHeight() + pet.Power:GetHeight() + pet.panel:GetHeight() + 6)
  1525. focus:Size(200, 25)
  1526. local f = CreateFrame("Frame")
  1527. f:RegisterEvent("PLAYER_ENTERING_WORLD")
  1528. f:SetScript("OnEvent", function(self, event, addon)
  1529. player:ClearAllPoints()
  1530. target:ClearAllPoints()
  1531. tot:ClearAllPoints()
  1532. pet:ClearAllPoints()
  1533. focus:ClearAllPoints()
  1534. if IsAddOnLoaded("Tukui_Raid") then
  1535. --[ DPS ]--
  1536. player:Point("TOP", UIParent, "BOTTOM", -170 , 260)
  1537. target:Point("TOP", UIParent, "BOTTOM", 170, 260)
  1538. tot:Point("TOPRIGHT", TukuiTarget, "BOTTOMRIGHT", 0, -20)
  1539. pet:Point("TOPLEFT", TukuiPlayer, "BOTTOMLEFT", 0, -20)
  1540. focus:Point("TOP", UIParent, "BOTTOM", -450, 602)
  1541. elseif IsAddOnLoaded("Tukui_Raid_Healing") then
  1542. --[ HEAL ]--
  1543. player:Point("TOP", UIParent, "BOTTOM", -309 , 350)
  1544. target:Point("TOP", UIParent, "BOTTOM", 309, 350)
  1545. tot:Point("TOPRIGHT", TukuiTarget, "BOTTOMRIGHT", 0, -25)
  1546. pet:Point("TOPLEFT", TukuiPlayer, "BOTTOMLEFT", 0, -25)
  1547. focus:Point("TOP", UIParent, "BOTTOM", -450, 602)
  1548. else
  1549. --[ NONE ]--
  1550. player:Point("TOP", UIParent, "BOTTOM", -309 , 350)
  1551. target:Point("TOP", UIParent, "BOTTOM", 309, 350)
  1552. tot:Point("TOPRIGHT", TukuiTarget, "BOTTOMRIGHT", 0, -25)
  1553. pet:Point("TOPLEFT", TukuiPlayer, "BOTTOMLEFT", 0, -25)
  1554. focus:Point("TOP", UIParent, "BOTTOM", -450, 602)
  1555. end
  1556. end)
  1557. -- pettarget
  1558. if C["unitframes"].pettarget == true then
  1559. local pettarget = oUF:Spawn('pettarget', "TukuiPetTarget")
  1560. pettarget:SetPoint("BOTTOMRIGHT", player, "TOPRIGHT", 0,5)
  1561. pettarget:Size(128, 26)
  1562. end
  1563. -- focus target
  1564. if C.unitframes.showfocustarget then
  1565. local focustarget = oUF:Spawn("focustarget", "TukuiFocusTarget")
  1566. focustarget:SetPoint("TOP", TukuiFocus, "BOTTOM", 0 , -35)
  1567. focustarget:Size(200, 29)
  1568. end
  1569. if C.arena.unitframes then
  1570. local arena = {}
  1571. for i = 1, 5 do
  1572. arena[i] = oUF:Spawn("arena"..i, "TukuiArena"..i)
  1573. if i == 1 then
  1574. arena[i]:SetPoint("TOP", UIParent, "BOTTOM", 500, 550)
  1575. else
  1576. arena[i]:SetPoint("BOTTOM", arena[i-1], "TOP", 0, 35)
  1577. end
  1578. arena[i]:Size(200, 27)
  1579. end
  1580. end
  1581. if C["unitframes"].showboss then
  1582. for i = 1,MAX_BOSS_FRAMES do
  1583. local t_boss = _G["Boss"..i.."TargetFrame"]
  1584. t_boss:UnregisterAllEvents()
  1585. t_boss.Show = T.dummy
  1586. t_boss:Hide()
  1587. _G["Boss"..i.."TargetFrame".."HealthBar"]:UnregisterAllEvents()
  1588. _G["Boss"..i.."TargetFrame".."ManaBar"]:UnregisterAllEvents()
  1589. end
  1590. end
  1591. local boss = {}
  1592. for i = 1, MAX_BOSS_FRAMES do
  1593. boss[i] = oUF:Spawn("boss"..i, "TukuiBoss"..i)
  1594. if i == 1 then
  1595. boss[i]:SetPoint("TOP", UIParent, "BOTTOM", 500, 550)
  1596. else
  1597. boss[i]:SetPoint('BOTTOM', boss[i-1], 'TOP', 0, 35)
  1598. end
  1599. boss[i]:Size(200, 27)
  1600. end
  1601. local assisttank_width = 100
  1602. local assisttank_height = 20
  1603. if C["unitframes"].maintank == true then
  1604. local tank = oUF:SpawnHeader('TukuiMainTank', nil, 'raid',
  1605. 'oUF-initialConfigFunction', ([[
  1606. self:SetWidth(%d)
  1607. self:SetHeight(%d)
  1608. ]]):format(assisttank_width, assisttank_height),
  1609. 'showRaid', true,
  1610. 'groupFilter', 'MAINTANK',
  1611. 'yOffset', 7,
  1612. 'point' , 'BOTTOM',
  1613. 'template', 'oUF_TukuiMtt'
  1614. )
  1615. tank:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
  1616. end
  1617. if C["unitframes"].mainassist == true then
  1618. local assist = oUF:SpawnHeader("TukuiMainAssist", nil, 'raid',
  1619. 'oUF-initialConfigFunction', ([[
  1620. self:SetWidth(%d)
  1621. self:SetHeight(%d)
  1622. ]]):format(assisttank_width, assisttank_height),
  1623. 'showRaid', true,
  1624. 'groupFilter', 'MAINASSIST',
  1625. 'yOffset', 7,
  1626. 'point' , 'BOTTOM',
  1627. 'template', 'oUF_TukuiMtt'
  1628. )
  1629. if C["unitframes"].maintank == true then
  1630. assist:SetPoint("TOPLEFT", TukuiMainTank, "BOTTOMLEFT", 2, -50)
  1631. else
  1632. assist:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
  1633. end
  1634. end
  1635. -- this is just a fake party to hide Blizzard frame if no Tukui raid layout are loaded.
  1636. local party = oUF:SpawnHeader("oUF_noParty", nil, "party", "showParty", true)
  1637. ------------------------------------------------------------------------
  1638. -- Right-Click on unit frames menu.
  1639. -- Doing this to remove SET_FOCUS eveywhere.
  1640. -- SET_FOCUS work only on default unitframes.
  1641. -- Main Tank and Main Assist, use /maintank and /mainassist commands.
  1642. ------------------------------------------------------------------------
  1643. -- Hunter Dismiss Pet Taint (Blizzard issue)
  1644. local PET_DISMISS = "PET_DISMISS"
  1645. if T.myclass == "HUNTER" then PET_DISMISS = nil end
  1646. do
  1647. UnitPopupMenus["SELF"] = { "PVP_FLAG", "LOOT_METHOD", "LOOT_THRESHOLD", "OPT_OUT_LOOT_TITLE", "LOOT_PROMOTE", "DUNGEON_DIFFICULTY", "RAID_DIFFICULTY", "RESET_INSTANCES", "RAID_TARGET_ICON", "SELECT_ROLE", "CONVERT_TO_PARTY", "CONVERT_TO_RAID", "LEAVE", "CANCEL" };
  1648. UnitPopupMenus["PET"] = { "PET_PAPERDOLL", "PET_RENAME", "PET_ABANDON", PET_DISMISS, "CANCEL" };
  1649. UnitPopupMenus["PARTY"] = { "MUTE", "UNMUTE", "PARTY_SILENCE", "PARTY_UNSILENCE", "RAID_SILENCE", "RAID_UNSILENCE", "BATTLEGROUND_SILENCE", "BATTLEGROUND_UNSILENCE", "WHISPER", "PROMOTE", "PROMOTE_GUIDE", "LOOT_PROMOTE", "VOTE_TO_KICK", "UNINVITE", "INSPECT", "ACHIEVEMENTS", "TRADE", "FOLLOW", "DUEL", "RAID_TARGET_ICON", "SELECT_ROLE", "PVP_REPORT_AFK", "RAF_SUMMON", "RAF_GRANT_LEVEL", "CANCEL" }
  1650. UnitPopupMenus["PLAYER"] = { "WHISPER", "INSPECT", "INVITE", "ACHIEVEMENTS", "TRADE", "FOLLOW", "DUEL", "RAID_TARGET_ICON", "RAF_SUMMON", "RAF_GRANT_LEVEL", "CANCEL" }
  1651. UnitPopupMenus["RAID_PLAYER"] = { "MUTE", "UNMUTE", "RAID_SILENCE", "RAID_UNSILENCE", "BATTLEGROUND_SILENCE", "BATTLEGROUND_UNSILENCE", "WHISPER", "INSPECT", "ACHIEVEMENTS", "TRADE", "FOLLOW", "DUEL", "RAID_TARGET_ICON", "SELECT_ROLE", "RAID_LEADER", "RAID_PROMOTE", "RAID_DEMOTE", "LOOT_PROMOTE", "RAID_REMOVE", "PVP_REPORT_AFK", "RAF_SUMMON", "RAF_GRANT_LEVEL", "CANCEL" };
  1652. UnitPopupMenus["RAID"] = { "MUTE", "UNMUTE", "RAID_SILENCE", "RAID_UNSILENCE", "BATTLEGROUND_SILENCE", "BATTLEGROUND_UNSILENCE", "RAID_LEADER", "RAID_PROMOTE", "RAID_MAINTANK", "RAID_MAINASSIST", "RAID_TARGET_ICON", "LOOT_PROMOTE", "RAID_DEMOTE", "RAID_REMOVE", "PVP_REPORT_AFK", "CANCEL" };
  1653. UnitPopupMenus["VEHICLE"] = { "RAID_TARGET_ICON", "VEHICLE_LEAVE", "CANCEL" }
  1654. UnitPopupMenus["TARGET"] = { "RAID_TARGET_ICON", "CANCEL" }
  1655. UnitPopupMenus["ARENAENEMY"] = { "CANCEL" }
  1656. UnitPopupMenus["FOCUS"] = { "RAID_TARGET_ICON", "CANCEL" }
  1657. UnitPopupMenus["BOSS"] = { "RAID_TARGET_ICON", "CANCEL" }
  1658. end