Advertisement
Guest User

Ouf_Drk lib.lua

a guest
Aug 29th, 2011
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 40.64 KB | None | 0 0
  1. -----------------------------
  2. --| oUF_Drk
  3. --| by Drakull (2010)
  4. -----------------------------
  5. -- INIT
  6. -----------------------------
  7.  
  8. local addon, ns = ...
  9. local cfg = ns.cfg
  10. local cast = ns.cast
  11. local lib = CreateFrame("Frame")
  12.  
  13. local _, playerClass = UnitClass("player")
  14.  
  15. -----------------------------
  16. -- FUNCTIONS
  17. -----------------------------
  18. -- pixel perfect script of custom ui scale.
  19.  
  20. local retVal = function(self, val1, val2, val3)
  21. if self.mystyle == "player" or self.mystyle == "target" then
  22. return val1
  23. elseif self.mystyle == "raid" then
  24. return val3
  25. else
  26. return val2
  27. end
  28. end
  29.  
  30. local setFont = function(object, font, size, outline, shadow)
  31. local fs = object:CreateFontString(nil, "OVERLAY")
  32. fs:SetFont(font, size, outline)
  33. fs:SetShadowColor(0,0,0,0.8)
  34. fs:SetShadowOffset(shadow, shadow*(-1))
  35. return fs
  36. end
  37. local shadows = {
  38. edgeFile = "Interface\\AddOns\\oUF_Drk\\media\\glowTex",
  39. edgeSize = 4,
  40. insets = { left = 3, right = 3, top = 3, bottom = 3 }
  41. }
  42. function CreateShadowww(f, frameLevel)
  43. if f.shadow then return end
  44. local shadow = CreateFrame("Frame", nil, f)
  45. shadow:SetFrameLevel(frameLevel)
  46. shadow:SetPoint("TOPLEFT", -6, 6)
  47. shadow:SetPoint("BOTTOMRIGHT", 6, -6)
  48. shadow:SetBackdrop(shadows)
  49. shadow:SetBackdropColor(0, 0, 0, 0)
  50. shadow:SetBackdropBorderColor(0, 0, 0, 1)
  51. f.shadow = shadow
  52. return shadow
  53. end
  54. local createBGFrame = function(anchorFrame, frameLevel, outset)
  55. if not outset then
  56. outset = 5
  57. end
  58. local hintFrame = CreateFrame("Frame", nil, anchorFrame)
  59. hintFrame:SetPoint("TOPLEFT", -2, 2)
  60. hintFrame:SetPoint("BOTTOMRIGHT", 2, -2)
  61. hintFrame:SetFrameLevel(frameLevel)
  62.  
  63. local backdrop_tab = {
  64. bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=],
  65. edgeFile = "Interface\\Buttons\\WHITE8x8",
  66. tile = false,
  67. tileSize = 0,
  68. edgeSize = 1,
  69. insets = {
  70. left = 1,
  71. right = 1,
  72. top = 1,
  73. bottom = 1,
  74. },
  75. }
  76.  
  77. hintFrame:SetBackdrop(backdrop_tab);
  78. hintFrame:SetBackdropColor(0,0,0,1)
  79. hintFrame:SetBackdropBorderColor(.2,.2,.2,1)
  80. return hintFrame
  81. end
  82. do
  83. UpdateReputationColor = function(self, event, unit, bar)
  84. local name, id = GetWatchedFactionInfo()
  85. bar:SetStatusBarColor(FACTION_BAR_COLORS[id].r, FACTION_BAR_COLORS[id].g, FACTION_BAR_COLORS[id].b)
  86. end
  87. end
  88. function AltPowerBarOnToggle(self)
  89. local unit = self:GetParent().unit or self:GetParent():GetParent().unit
  90. if unit == nil or unit ~= "player" then return end
  91. end
  92. function AltPowerBarPostUpdate(self, min, cur, max)
  93. local perc = math.floor((cur/max)*100)
  94.  
  95. if perc < 35 then
  96. self:SetStatusBarColor(0, 1, 0)
  97. elseif perc < 70 then
  98. self:SetStatusBarColor(1, 1, 0)
  99. else
  100. self:SetStatusBarColor(1, 0, 0)
  101. end
  102.  
  103. local unit = self:GetParent().unit or self:GetParent():GetParent().unit
  104.  
  105. if unit == nil or unit ~= "player" then return end --Only want to see this on the players bar
  106.  
  107. local type = select(10, UnitAlternatePowerInfo(unit))
  108.  
  109. if self.text and perc > 0 then
  110. self.text:SetText(type..": ".."|cFF00A2FF"..format("%d%%", perc))
  111. elseif self.text then
  112. self.text:SetText(type..": ".."|cFF00A2FF".."0%")
  113. end
  114. end
  115. -- Health bar function
  116. local postUpdateHealth = function(Health, unit, min, max)
  117.  
  118. local disconnnected = not UnitIsConnected(unit)
  119. local dead = UnitIsDead(unit)
  120. local ghost = UnitIsGhost(unit)
  121.  
  122. Health:SetStatusBarColor(unpack(cfg.healthBarColor))
  123.  
  124. if disconnnected or dead or ghost then
  125. Health:SetValue(max)
  126.  
  127. if(disconnnected) then
  128. Health:SetStatusBarColor(0.1, 0.1, 0.1)
  129. elseif(ghost) then
  130. Health:SetStatusBarColor(1, 1, 1)
  131. elseif(dead) then
  132. Health:SetStatusBarColor(0.9, 0, 0)
  133. end
  134. else
  135. Health:SetValue(min)
  136. if(unit == "vehicle") then
  137. Health:SetStatusBarColor(22/255, 106/255, 44/255)
  138. end
  139. end
  140. Health.bg:SetAlpha(Health:GetAlpha())
  141. end
  142.  
  143. local OnEnter = function(self)
  144. UnitFrame_OnEnter(self)
  145. self.Highlight:Show()
  146.  
  147. if self.mystyle == "raid" then
  148. if self.LFDRole then
  149. self.LFDRole:SetAlpha(1)
  150. end
  151. end
  152. end
  153.  
  154. local OnLeave = function(self)
  155. UnitFrame_OnLeave(self)
  156. self.Highlight:Hide()
  157.  
  158. if self.mystyle == "raid" then
  159. if self.LFDRole then
  160. self.LFDRole:SetAlpha(0)
  161. end
  162. end
  163. end
  164.  
  165. lib.addHealthBar = function(self)
  166. local health = CreateFrame("StatusBar", nil, self)
  167. health:SetStatusBarTexture(cfg.statusBarTexture)
  168. health:GetStatusBarTexture():SetHorizTile(true)
  169. health:SetFrameLevel(1)
  170.  
  171. local healthBG = health:CreateTexture(nil, "BACKGROUND", nil, -7)
  172. healthBG:SetAllPoints(health)
  173. healthBG:SetTexture(cfg.statusBarTexture)
  174. health.bg = healthBG
  175.  
  176. local bgoverlay = health:CreateTexture(nil, "BACKGROUND", nil, -6)
  177. bgoverlay:SetPoint("TOPLEFT", health,"TOPLEFT", 0, 0)
  178. bgoverlay:SetPoint("BOTTOMRIGHT", health,"BOTTOMRIGHT", 0, 0)
  179. bgoverlay:SetTexture(cfg.portraitOverlayTexture)
  180. bgoverlay:SetVertexColor(0, 0, 0, 0.8)
  181.  
  182. self.Health = health
  183. if self.mystyle == "raid" then
  184. self.Health.PostUpdate = lib.postUpdateHealth
  185. else
  186. self.Health.Smooth = cfg.smoothHealth
  187. end
  188.  
  189. createBGFrame(self.Health, 0)
  190. CreateShadowww(self.Health, 1)
  191. -- Mouseover highlight
  192. self:SetScript("OnEnter", OnEnter)
  193. self:SetScript("OnLeave", OnLeave)
  194.  
  195. local hl = self.Health:CreateTexture(nil, "OVERLAY")
  196. hl:SetAllPoints(self.Health)
  197. hl:SetTexture(cfg.highlightTexture)
  198. hl:SetVertexColor(.5,.5,.5,.1)
  199. hl:SetBlendMode("ADD")
  200. hl:Hide()
  201. self.Highlight = hl
  202.  
  203. -- Heal Prediction
  204. if cfg.ShowIncHeals and (self.mystyle == "player" or self.mystyle == "raid") then
  205. mhpb = CreateFrame("StatusBar", nil, self.Health)
  206. mhpb:SetWidth(self:GetWidth())
  207. mhpb:SetPoint("TOPLEFT", self.Health:GetStatusBarTexture(), "TOPRIGHT")
  208. mhpb:SetPoint("BOTTOMLEFT", self.Health:GetStatusBarTexture(), "BOTTOMRIGHT")
  209. mhpb:SetStatusBarTexture(cfg.statusBarTexture)
  210. mhpb:SetStatusBarColor(1, 1, 1, 0.4)
  211. mhpb:SetFrameLevel(1)
  212.  
  213. ohpb = CreateFrame("StatusBar", nil, self.Health)
  214. ohpb:SetWidth(self:GetWidth())
  215. ohpb:SetPoint("TOPLEFT", mhpb:GetStatusBarTexture(), "TOPRIGHT")
  216. ohpb:SetPoint("BOTTOMLEFT", mhpb:GetStatusBarTexture(), "BOTTOMRIGHT")
  217. ohpb:SetStatusBarTexture(cfg.statusBarTexture)
  218. ohpb:SetStatusBarColor(1, 1, 1, 0.4)
  219. ohpb:SetFrameLevel(1)
  220.  
  221. self.HealPrediction = {
  222. myBar = mhpb,
  223. otherBar = ohpb,
  224. maxOverflow = 1,
  225. }
  226. end
  227.  
  228. -- Target and aggro borders
  229. if self.mystyle == "raid" then
  230. local borderTexture = {edgeFile = "Interface\\ChatFrame\\ChatFrameBackground", edgeSize = 1}
  231. -- Target border
  232. self.targetBorder = CreateFrame("Frame", nil, self)
  233. self.targetBorder:SetPoint("TOPLEFT", self, "TOPLEFT", -1, 1)
  234. self.targetBorder:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", 1, -1)
  235. self.targetBorder:SetBackdrop(borderTexture)
  236. self.targetBorder:SetFrameLevel(1)
  237. self.targetBorder:SetBackdropBorderColor(.7,.7,.7,1)
  238. self.targetBorder:Hide()
  239.  
  240. -- Aggro border
  241. self.aggroBorder = CreateFrame("Frame", nil, self)
  242. self.aggroBorder:SetPoint("TOPLEFT", self, "TOPLEFT", -2, 2)
  243. self.aggroBorder:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", 2, -2)
  244. self.aggroBorder:SetBackdrop(borderTexture)
  245. self.aggroBorder:SetFrameLevel(1)
  246. self.aggroBorder:Hide()
  247. end
  248. end
  249.  
  250. -- Power bar function
  251. local postUpdatePower = function(power, unit, min, max)
  252. power.Spark:SetPoint("CENTER", power, "LEFT", ((min / max) * power:GetWidth())-1, 0)
  253. local perc = min * 100 / max
  254. if perc < 3 or perc == 100 then
  255. power.Spark:Hide()
  256. else
  257. power.Spark:Show()
  258. end
  259. end
  260.  
  261. lib.addPowerBar = function(self)
  262. local power = CreateFrame("StatusBar", nil, self)
  263. power:SetStatusBarTexture(cfg.powerBarTexture)
  264. power:GetStatusBarTexture():SetHorizTile(true)
  265. power:SetFrameLevel(1)
  266.  
  267. local powerBG = power:CreateTexture(nil, "BORDER")
  268. powerBG:SetAllPoints(power)
  269. powerBG:SetTexture(cfg.powerBarTexture)
  270. power.bg = powerBG
  271.  
  272. self.Power = power
  273. if self.mystyle == "player" then self.Power.Smooth = cfg.smoothPower end
  274.  
  275. if self.mystyle ~= "player" and self.mystyle ~= "target" then
  276. self.Power:SetAlpha(0.5)
  277. self.Power:SetFrameLevel(2)
  278. self.Power:SetStatusBarTexture(cfg.backdropTexture)
  279. self.Power.bg:SetTexture(1, 1, 1, 0.5)
  280.  
  281. -- Power Spark
  282. sp = self.Power:CreateTexture(nil, "OVERLAY")
  283. sp:SetTexture[[Interface\CastingBar\UI-CastingBar-Spark]]
  284. sp:SetBlendMode("ADD")
  285. sp:SetAlpha(0.8)
  286. sp:SetHeight(7)
  287. sp:SetPoint("CENTER", power, "RIGHT", -1, 0)
  288.  
  289. self.Power.Spark = sp
  290. self.Power.PostUpdate = postUpdatePower
  291. else
  292. createBGFrame(self.Power, 0)
  293. CreateShadowww(self.Power, 0)
  294. end
  295. end
  296.  
  297. -- Portrait
  298. local postUpdatePortrait = function(element, unit)
  299. if unit == "target" then
  300. if not UnitExists(unit) or not UnitIsConnected(unit) or not UnitIsVisible(unit) then
  301. element:Hide()
  302. else
  303. element:Show()
  304. element:SetCamera(0)
  305. end
  306. end
  307. end
  308.  
  309. lib.addPortrait = function(self)
  310. local p = CreateFrame("PlayerModel", nil, self)
  311. p:SetSize(234, 22)
  312. p:SetFrameLevel(4)
  313. p:SetPoint("BOTTOM", self, "BOTTOM", 0, 8)
  314.  
  315. local darkoverlay = p:CreateTexture(nil, "OVERLAY")
  316. darkoverlay:SetPoint("TOPLEFT", p,"TOPLEFT", 0, 0)
  317. darkoverlay:SetPoint("BOTTOMRIGHT", p,"BOTTOMRIGHT", 0, 0)
  318. darkoverlay:SetTexture(cfg.debuffHighlightTexture)
  319. darkoverlay:SetVertexColor(0, 0, 0, 0.4)
  320.  
  321. local bg = p:CreateTexture(nil, "OVERLAY")
  322. bg:SetPoint("TOPLEFT", p,"TOPLEFT", 0, 0)
  323. bg:SetPoint("BOTTOMRIGHT", p,"BOTTOMRIGHT", 0, 0)
  324. bg:SetTexture(cfg.portraitBGTexture)
  325. bg:SetVertexColor(0, 0, 0, 0.4)
  326.  
  327. local overlay = p:CreateTexture(nil, "OVERLAY")
  328. overlay:SetPoint("TOPLEFT", p,"TOPLEFT", 0, 0)
  329. overlay:SetPoint("BOTTOMRIGHT", p,"BOTTOMRIGHT", 0, 0)
  330. overlay:SetTexture(cfg.portraitOverlayTexture)
  331. overlay:SetVertexColor(0, 0, 0, 1)
  332.  
  333. createBGFrame(p, 3)
  334. CreateShadowww(p, 4)
  335.  
  336. self.Portrait = p
  337. self.Portrait.PostUpdate = postUpdatePortrait
  338. self.Portrait:SetPortraitZoom(1)
  339. self.Portrait:SetPortraitZoom(.98)
  340. end
  341.  
  342. -- Target border
  343. lib.changedTarget = function(self, event, unit)
  344. if UnitIsUnit("target", self.unit) then
  345. self.targetBorder:Show()
  346. else
  347. self.targetBorder:Hide()
  348. end
  349. end
  350.  
  351. -- Aggro border
  352. lib.updateAggro = function(self, event, unit)
  353. if (self.unit ~= unit) then return end
  354.  
  355. local status = UnitThreatSituation(unit)
  356. unit = unit or self.unit
  357.  
  358. if status and status > 1 then
  359. local r, g, b = GetThreatStatusColor(status)
  360. self.aggroBorder:Show()
  361. self.aggroBorder:SetBackdropBorderColor(r, g, b, 1)
  362. else
  363. self.aggroBorder:SetBackdropBorderColor(r, g, b, 0)
  364. self.aggroBorder:Hide()
  365. end
  366. end
  367.  
  368. -- Text Tags
  369. lib.addTextTags = function(self, fontsize)
  370. local hp = setFont(self.Health, cfg.font, 12, "NONE", retVal(self,2,1,1))
  371. hp:SetPoint("TOPRIGHT", self.Health, "TOPRIGHT", retVal(self,-2,-2,-1), retVal(self,-3,-1,-11))
  372. hp:SetJustifyH("RIGHT")
  373. self:Tag(hp, retVal(self, "[drk:hp]", "[drk:hp]", "[drk:raidhp]"))
  374.  
  375. local name = setFont(self.Health, cfg.font, 12, "NONE", retVal(self,2,1,1))
  376. if self.mystyle == "raid" then
  377. name:SetPoint("TOPLEFT", self.Health, "TOPLEFT", 2, 0)
  378. else
  379. name:SetPoint("TOPLEFT", self.Health, "TOPLEFT", 2, -3)
  380. end
  381.  
  382.  
  383. name:SetJustifyH("LEFT")
  384. if self.mystyle == "targettarget" then
  385. name:SetPoint("TOPLEFT", self.Health, "TOPLEFT", 2, -1)
  386. end
  387. if self.mystyle == "raid" then
  388. name:SetPoint("RIGHT", self, "RIGHT", -1, 0)
  389. else
  390. name:SetPoint("RIGHT", hp, "LEFT", 0, 0)
  391. end
  392.  
  393. if self.mystyle == "player" then
  394. self:Tag(name, "[drk:color][drk:power][drk:afkdnd]")
  395. elseif self.mystyle == "target" then
  396. self:Tag(name, "[drk:level] [drk:color][name][drk:afkdnd]")
  397. else
  398. self:Tag(name, "[drk:color][name]")
  399. end
  400.  
  401. if ((playerClass == "ROGUE" or playerClass == "DRUID")) and self.mystyle == "target" then
  402. local CPoints = setFont(self.Portrait, cfg.font, 25, "OUTLINE", 0)
  403. CPoints:SetPoint("CENTER", self.Portrait, "CENTER", 0, 0)
  404. CPoints:SetJustifyH("CENTER")
  405. CPoints:SetAlpha(0.6)
  406. self:Tag(CPoints, "[myComboPoints]")
  407. if(playerClass == "ROGUE") then
  408. local DPTracker = setFont(self.Portrait, cfg.font, 11, "OUTLINE", 0)
  409. DPTracker:SetPoint("BOTTOMLEFT", CPoints, "TOPRIGHT",0,-13)
  410. DPTracker:SetJustifyH("CENTER")
  411. DPTracker:SetAlpha(0.6)
  412. DPTracker:SetShadowOffset(1, -1)
  413. self:Tag(DPTracker, "[myDeadlyPoison]")
  414. end
  415. end
  416. end
  417.  
  418. -- Frame Icons
  419. lib.addIcons = function(self)
  420. -- common stuff
  421. local hintFrame = CreateFrame("Frame", nil, self)
  422. hintFrame:SetAllPoints(self)
  423. hintFrame:SetFrameLevel(10)
  424. hintFrame:SetAlpha(0.9)
  425.  
  426. -- Leader icon
  427. li = hintFrame:CreateTexture(nil, "OVERLAY")
  428. li:SetPoint("TOPLEFT", hintFrame, 0, 8)
  429. li:SetSize(12,12)
  430. self.Leader = li
  431.  
  432. -- Assistant icon
  433. ai = hintFrame:CreateTexture(nil, "OVERLAY")
  434. ai:SetPoint("TOPLEFT", hintFrame, 0, 8)
  435. ai:SetSize(12,12)
  436. self.Assistant = ai
  437.  
  438. -- Master Looter icon
  439. local ml = hintFrame:CreateTexture(nil, "OVERLAY")
  440. ml:SetSize(10,10)
  441. ml:SetPoint("LEFT", self.Assistant, "RIGHT")
  442. self.MasterLooter = ml
  443.  
  444. -- Raid Marks
  445. local rm = hintFrame:CreateTexture(nil,"OVERLAY")
  446. rm:SetPoint("CENTER", hintFrame, "TOP", 0, 2)
  447. rm:SetSize(retVal(self, 16, 13, 12), retVal(self, 16, 13, 12))
  448. self.RaidIcon = rm
  449.  
  450. -- Frame specific stuff
  451. if self.mystyle == "player" then
  452. -- Combat icon
  453. comb = hintFrame:CreateTexture(nil, "OVERLAY")
  454. comb:SetSize(15,15)
  455. comb:SetPoint("CENTER", hintFrame, "BOTTOMRIGHT", 0, 0)
  456. comb:SetTexture("Interface\\CharacterFrame\\UI-StateIcon")
  457. comb:SetTexCoord(0.58, 0.90, 0.08, 0.41)
  458. self.Combat = comb
  459.  
  460. -- Resting Icon
  461. rest = hintFrame:CreateTexture(nil, "OVERLAY")
  462. rest:SetSize(15,15)
  463. rest:SetPoint("CENTER", hintFrame, "BOTTOMLEFT", 0, 0)
  464. rest:SetTexture("Interface\\CharacterFrame\\UI-StateIcon")
  465. rest:SetTexCoord(0.09, 0.43, 0.08, 0.42)
  466. self.Resting = rest
  467.  
  468. -- PvP Icon
  469. pvp = hintFrame:CreateTexture(nil, "OVERLAY")
  470. local faction = PvPCheck
  471. if faction == "Horde" then
  472. pvp:SetTexCoord(0.08, 0.58, 0.045, 0.545)
  473. elseif faction == "Alliance" then
  474. pvp:SetTexCoord(0.07, 0.58, 0.06, 0.57)
  475. else
  476. pvp:SetTexCoord(0.05, 0.605, 0.015, 0.57)
  477. end
  478. pvp:SetHeight(20)
  479. pvp:SetWidth(20)
  480. pvp:SetPoint("TOPRIGHT", 10, 10)
  481. self.PvP = pvp
  482. elseif self.mystyle == "target" then
  483. -- Quest Mob Icon
  484. local qicon = hintFrame:CreateTexture(nil, "OVERLAY")
  485. qicon:SetPoint("CENTER", hintFrame, "TOPLEFT", 0, 0)
  486. qicon:SetSize(20, 20)
  487. self.QuestIcon = qicon
  488. elseif self.mystyle == "raid" then
  489. -- LFD Role Icon
  490. role = hintFrame:CreateTexture(nil, "OVERLAY")
  491. role:SetSize(13, 13)
  492. role:SetPoint("CENTER", hintFrame, "BOTTOMLEFT", 1, 0)
  493. self.LFDRole = role
  494. self.LFDRole:SetAlpha(0)
  495. -- Ready Check icon
  496. rCheck = hintFrame:CreateTexture(nil, "OVERLAY")
  497. rCheck:SetSize(14, 14)
  498. rCheck:SetPoint("BOTTOMLEFT", hintFrame, "TOPRIGHT", -13, -12)
  499. self.ReadyCheck = rCheck
  500. end
  501. end
  502.  
  503. -- Class Bars
  504. lib.addClassBar = function(self)
  505. if cfg.classBar and (playerClass == "WARLOCK" or playerClass == "DEATHKNIGHT" or playerClass == "PALADIN" or playerClass == "DRUID" or playerClass == "SHAMAN") then
  506. local barFrame = CreateFrame("Frame", nil, self)
  507. local barGlow
  508. barFrame:SetPoint("TOPLEFT", self, "BOTTOMLEFT", 0, -7)
  509. barFrame:SetHeight(4)
  510. barFrame:SetWidth(self:GetWidth())
  511. barFrame:SetFrameLevel(4)
  512.  
  513. if playerClass ~= "SHAMAN" then
  514. barGlow = createBGFrame(barFrame, 3)
  515. CreateShadowww(barFrame, 4)
  516. end
  517.  
  518. if playerClass == "WARLOCK" then
  519. local ssOverride = function(self, event, unit, powerType)
  520. if(self.unit ~= unit or (powerType and powerType ~= "SOUL_SHARDS")) then return end
  521. local ss = self.SoulShards
  522. local num = UnitPower(unit, SPELL_POWER_SOUL_SHARDS)
  523. for i = 1, SHARD_BAR_NUM_SHARDS do
  524. if(i <= num) then
  525. ss[i]:SetAlpha(1)
  526. else
  527. ss[i]:SetAlpha(0.2)
  528. end
  529. end
  530. end
  531.  
  532. for i= 1, 3 do
  533. local shard = CreateFrame("StatusBar", nil, barFrame)
  534. shard:SetSize((self:GetWidth() / 3)-2, 4)
  535. shard:SetStatusBarTexture(cfg.statusBarTexture)
  536. shard:SetStatusBarColor(.86,.44, 1)
  537. shard:SetFrameLevel(4)
  538.  
  539. if (i == 1) then
  540. shard:SetPoint("LEFT", barFrame, "LEFT", 0, 0)
  541. else
  542. shard:SetPoint("TOPLEFT", barFrame[i-1], "TOPRIGHT", 3, 0)
  543. end
  544. barFrame[i] = shard
  545. end
  546. self.SoulShards = barFrame
  547. self.SoulShards.Override = ssOverride
  548. elseif playerClass == "DEATHKNIGHT" then
  549. oUF.colors.runes = {{0.87, 0.12, 0.23};{0.40, 0.95, 0.20};{0.14, 0.50, 1};{.70, .21, 0.94};}
  550. for i= 1, 6 do
  551. local rune = CreateFrame("StatusBar", nil, barFrame)
  552. rune:SetSize((self:GetWidth() / 6)-2, 4)
  553. rune:SetStatusBarTexture(cfg.statusBarTexture)
  554. rune:SetFrameLevel(4)
  555.  
  556. if (i == 1) then
  557. rune:SetPoint("LEFT", barFrame, "LEFT", 1, 0)
  558. else
  559. rune:SetPoint("TOPLEFT", barFrame[i-1], "TOPRIGHT", 2, 0)
  560. end
  561.  
  562. local runeBG = rune:CreateTexture(nil, "BACKGROUND")
  563. runeBG:SetAllPoints(rune)
  564. runeBG:SetTexture(cfg.statusBarTexture)
  565. rune.bg = runeBG
  566. rune.bg.multiplier = 0.3
  567. barFrame[i] = rune
  568. end
  569. self.Runes = barFrame
  570. elseif playerClass == "PALADIN" then
  571. local hpOverride = function(self, event, unit, powerType)
  572. if(self.unit ~= unit or (powerType and powerType ~= "HOLY_POWER")) then return end
  573.  
  574. local hp = self.HolyPower
  575. if(hp.PreUpdate) then hp:PreUpdate(unit) end
  576.  
  577. local num = UnitPower(unit, SPELL_POWER_HOLY_POWER)
  578. for i = 1, MAX_HOLY_POWER do
  579. if(i <= num) then
  580. hp[i]:SetAlpha(1)
  581. else
  582. hp[i]:SetAlpha(0.2)
  583. end
  584. end
  585. end
  586.  
  587. for i = 1, 3 do
  588. local holyShard = CreateFrame("StatusBar", self:GetName().."_Holypower"..i, self)
  589. holyShard:SetHeight(4)
  590. holyShard:SetWidth((self:GetWidth() / 3)-2)
  591. holyShard:SetStatusBarTexture(cfg.statusBarTexture)
  592. holyShard:SetStatusBarColor(.9,.95,.33)
  593. holyShard:SetFrameLevel(4)
  594.  
  595. if (i == 1) then
  596. holyShard:SetPoint("LEFT", barFrame, "LEFT", 0, 0)
  597. else
  598. holyShard:SetPoint("TOPLEFT", barFrame[i-1], "TOPRIGHT", 3, 0)
  599. end
  600. barFrame[i] = holyShard
  601. end
  602. self.HolyPower = barFrame
  603. self.HolyPower.Override = hpOverride
  604. elseif playerClass == "DRUID" then
  605. local eclipseBarBuff = function(self, unit)
  606. if self.hasSolarEclipse then
  607. self.eBarBG:SetBackdropBorderColor(1,1,.5,.7)
  608. elseif self.hasLunarEclipse then
  609. self.eBarBG:SetBackdropBorderColor(.2,.2,1,.7)
  610. else
  611. self.eBarBG:SetBackdropBorderColor(0,0,0,1)
  612. end
  613. end
  614.  
  615. barFrame.eBarBG = barGlow
  616.  
  617. local lunarBar = CreateFrame("StatusBar", nil, barFrame)
  618. lunarBar:SetPoint("LEFT", barFrame, "LEFT", 0, 0)
  619. lunarBar:SetSize(barFrame:GetWidth(), barFrame:GetHeight())
  620. lunarBar:SetStatusBarTexture(cfg.statusBarTexture)
  621. lunarBar:SetStatusBarColor(0, .1, .7)
  622. lunarBar:SetFrameLevel(5)
  623. barFrame.LunarBar = lunarBar
  624.  
  625. local solarBar = CreateFrame("StatusBar", nil, barFrame)
  626. solarBar:SetPoint("LEFT", lunarBar:GetStatusBarTexture(), "RIGHT", 0, 0)
  627. solarBar:SetSize(barFrame:GetWidth(), barFrame:GetHeight())
  628. solarBar:SetStatusBarTexture(cfg.statusBarTexture)
  629. solarBar:SetStatusBarColor(1,1,.13)
  630. solarBar:SetFrameLevel(5)
  631. barFrame.SolarBar = solarBar
  632.  
  633. local EBText = setFont(solarBar, cfg.font, 10, "OUTLINE", 2)
  634. EBText:SetPoint("CENTER", barFrame, "CENTER", 0, 0)
  635. self:Tag(EBText, "[pereclipse]")
  636.  
  637. self.EclipseBar = barFrame
  638. self.EclipseBar.PostUnitAura = eclipseBarBuff
  639. elseif playerClass == "SHAMAN" then
  640. local barFrame = CreateFrame("Frame", nil, self)
  641. barFrame:SetPoint("TOPLEFT", self, "BOTTOMLEFT", 0, -5)
  642. barFrame:SetHeight(4)
  643. barFrame:SetWidth(self:GetWidth())
  644. barFrame:SetFrameLevel(3)
  645.  
  646. barFrame.Destroy = true
  647. barFrame.UpdateColors = true
  648.  
  649. oUF.colors.totems = {
  650. { 255/255, 072/255, 000/255 }, -- fire
  651. { 073/255, 230/255, 057/255 }, -- earth
  652. { 069/255, 176/255, 218/255 }, -- water
  653. { 157/255, 091/255, 231/255 } -- air
  654. }
  655.  
  656. for i = 1, 4 do
  657. local totem = CreateFrame("Frame", nil, barFrame)
  658. totem:SetSize((self:GetWidth() / 4.2)-i+1, 4)
  659. if i == 1 then
  660. totem:SetPoint("LEFT", barFrame, "LEFT", 0, 0)
  661. else
  662. totem:SetPoint("LEFT", barFrame[i-1], "RIGHT", 6, 0)
  663. end
  664. totem:SetFrameLevel(4)
  665.  
  666. createBGFrame(totem, 3)
  667. CreateShadowww(totem, 4)
  668.  
  669. local bar = CreateFrame("StatusBar", nil, totem)
  670. bar:SetAllPoints(totem)
  671. bar:SetStatusBarTexture(cfg.statusBarTexture)
  672. totem.StatusBar = bar
  673.  
  674. totem.bg = totem:CreateTexture(nil, "BACKGROUND")
  675. totem.bg:SetAllPoints()
  676. totem.bg:SetTexture(cfg.statusBarTexture)
  677. totem.bg.multiplier = 0.3
  678.  
  679. barFrame[i] = totem
  680. end
  681. self.TotemBar = barFrame
  682.  
  683. end
  684. end
  685. end
  686.  
  687. -- Buffs and Debuffs
  688. local format = string.format
  689.  
  690. local customAuraFilter = function(icons, _, icon, name, _, _, _, _, _, _, caster, _, _, spellID)
  691. local isPlayer
  692.  
  693. if(caster == "player" or caster == "vehicle") then
  694. isPlayer = true
  695. end
  696.  
  697. if((icons.onlyShowPlayer and isPlayer) or (not icons.onlyShowPlayer and name)) then
  698. icon.isPlayer = isPlayer
  699. icon.owner = caster
  700. end
  701.  
  702. return
  703. end
  704.  
  705.  
  706. local updateTooltip = function(self)
  707. GameTooltip:SetUnitAura(self.parent:GetParent().unit, self:GetID(), self.filter)
  708.  
  709. if self.owner and UnitExists(self.owner) then
  710. GameTooltip:AddLine(format("|cff1369ca* Cast by %s|r", UnitName(self.owner) or UNKNOWN))
  711. end
  712.  
  713. GameTooltip:Show()
  714. end
  715.  
  716. local formatTime = function(s)
  717. local day, hour, minute = 86400, 3600, 60
  718. if s >= day then
  719. return format("%dd", floor(s/day + 0.5)), s % day
  720. elseif s >= hour then
  721. return format("%dh", floor(s/hour + 0.5)), s % hour
  722. elseif s >= minute then
  723. return format("%dm", floor(s/minute + 0.5)), s % minute
  724. elseif s >= minute / 12 then
  725. return floor(s + 0.5), (s * 100 - floor(s * 100))/100
  726. end
  727. return format("%.1f", s), (s * 100 - floor(s * 100))/100
  728. end
  729.  
  730. local setTimer = function (self, elapsed)
  731. if self.timeLeft then
  732. self.elapsed = (self.elapsed or 0) + elapsed
  733. if self.elapsed >= 0.1 then
  734. if not self.first then
  735. self.timeLeft = self.timeLeft - self.elapsed
  736. else
  737. self.timeLeft = self.timeLeft - GetTime()
  738. self.first = false
  739. end
  740. if self.timeLeft > 0 then
  741. local time = formatTime(self.timeLeft)
  742. self.time:SetText(time)
  743. if self.timeLeft < 5 then
  744. self.time:SetTextColor(1, 0.5, 0.5)
  745. else
  746. self.time:SetTextColor(.7, .7, .7)
  747. end
  748. else
  749. self.time:Hide()
  750. self:SetScript("OnUpdate", nil)
  751. end
  752. self.elapsed = 0
  753. end
  754. end
  755. end
  756.  
  757. local postCreateIcon = function(element, button)
  758. local diffPos = 0
  759. local self = element:GetParent()
  760. if self.mystyle == "target" then diffPos = 1 end
  761.  
  762. element.disableCooldown = true
  763. button.cd.noOCC = true
  764. button.cd.noCooldownCount = true
  765.  
  766. createBGFrame(button, 0)
  767. CreateShadowww(button, 1)
  768.  
  769. local time = setFont(button, cfg.font, 11, "OUTLINE", 1)
  770. time:SetPoint("CENTER", button, "TOP", 2+diffPos, 0)
  771. time:SetJustifyH("CENTER")
  772. time:SetVertexColor(1,1,1)
  773. button.time = time
  774.  
  775. local count = setFont(button, cfg.font, 11, "OUTLINE", 1)
  776. count:SetPoint("CENTER", button, "BOTTOMRIGHT", 0, 3)
  777. count:SetJustifyH("RIGHT")
  778. button.count = count
  779.  
  780. button.UpdateTooltip = updateTooltip
  781.  
  782. button.icon:SetTexCoord(0.08, 0.92, 0.08, 0.92)
  783. button.icon:SetDrawLayer("ARTWORK")
  784. end
  785.  
  786. local postUpdateIcon = function(element, unit, button, index)
  787. local _, _, _, _, _, duration, expirationTime, unitCaster, _ = UnitAura(unit, index, button.filter)
  788.  
  789. if duration and duration > 0 then
  790. button.time:Show()
  791. button.timeLeft = expirationTime
  792. button:SetScript("OnUpdate", setTimer)
  793. else
  794. button.time:Hide()
  795. button.timeLeft = math.huge
  796. button:SetScript("OnUpdate", nil)
  797. end
  798.  
  799. -- Desaturate non-Player Debuffs
  800. if(button.debuff) then
  801. if(unit == "target") then
  802. if (unitCaster == "player" or unitCaster == "vehicle") then
  803. button.icon:SetDesaturated(false)
  804. elseif(not UnitPlayerControlled(unit)) then -- If Unit is Player Controlled don"t desaturate debuffs
  805. button:SetBackdropColor(0, 0, 0)
  806. button.overlay:SetVertexColor(0.3, 0.3, 0.3)
  807. button.icon:SetDesaturated(true)
  808. end
  809. end
  810. end
  811. button:SetScript('OnMouseUp', function(self, mouseButton)
  812. if mouseButton == 'RightButton' then
  813. CancelUnitBuff('player', index)
  814. end end)
  815. button.first = true
  816. end
  817.  
  818. lib.addBuffs = function(self, position)
  819. local buffs = CreateFrame("Frame", nil, self)
  820. buffs:SetPoint(position.anchorPoint, position.relativeFrame and position.relativeFrame or self, position.relativePoint, position.offsetX, position.offsetY)
  821. buffs:SetSize(position.width, position.height)
  822. buffs.num = position.number
  823. buffs.size = position.size
  824. if self.mystyle == "target" then
  825. buffs.spacing = 7
  826. end
  827. if self.mystyle == "player" then
  828. buffs.spacing = 10
  829. end
  830. buffs.initialAnchor = position.anchorPoint
  831. buffs["growth-x"] = position.growthX
  832. buffs["growth-y"] = position.growthY
  833. buffs.PostCreateIcon = postCreateIcon
  834. buffs.PostUpdateIcon = postUpdateIcon
  835.  
  836. self.Buffs = buffs
  837. end
  838.  
  839. lib.addDebuffs = function(self, position)
  840. local debuffs = CreateFrame("Frame", nil, self)
  841. local myFrame = self.Runes and self.Runes or
  842. self.TotemBar and self.TotemBar or
  843. self.SoulShards and self.SoulShards or
  844. self.HolyPower and self.HolyPower or
  845. self.EclipseBar and self.EclipseBar or
  846. self
  847.  
  848. debuffs:SetPoint(position.anchorPoint, position.relativeFrame and position.relativeFrame or myFrame, position.relativePoint, position.offsetX, position.offsetY)
  849. debuffs:SetSize(position.width, position.height)
  850. debuffs.num = position.number
  851. debuffs.size = position.size
  852. debuffs.spacing = cfg.auras.spacing
  853. if self.mystyle == "player" then
  854. debuffs.spacing = 9
  855. end
  856. if self.mystyle == "target" then
  857. debuffs.spacing = 8
  858. end
  859. debuffs.initialAnchor = position.anchorPoint
  860. debuffs["growth-x"] = position.growthX
  861. debuffs["growth-y"] = position.growthY
  862. debuffs.onlyShowPlayer = position.playerOnly
  863. debuffs.PostCreateIcon = postCreateIcon
  864. debuffs.PostUpdateIcon = postUpdateIcon
  865.  
  866. self.Debuffs = debuffs
  867. end
  868.  
  869. -- cast bar function
  870. local cbDefaultColor = {137/255, 153/255, 170/255}
  871.  
  872. local function customTimeText(element, duration)
  873. element.Time:SetFormattedText("%.1f / %.1f", element.channeling and duration or (element.max - duration), element.max)
  874. end
  875.  
  876. local function customDelayText(element, duration)
  877. element.Time:SetFormattedText("%.1f |cffff0000-%.1f|r / %.1f", element.channeling and duration or (element.max - duration), element.delay, element.max)
  878. end
  879.  
  880. local function postCastStart(element, unit)
  881. if element.Text then
  882. local text = element.Text:GetText()
  883. element.Text:SetText("|cffffff88"..text.."|r")
  884. end
  885. if element.Inline then
  886. element:SetStatusBarColor(1,1,1,0.35)
  887. else
  888. local cbColor = RAID_CLASS_COLORS[select(2, UnitClass(unit))]
  889. local myMulti = 0.2
  890. if UnitIsPlayer(unit) and cbColor then
  891. element:SetStatusBarColor(cbColor.r, cbColor.g, cbColor.b)
  892. element.bg:SetTexture(cbColor.r * myMulti, cbColor.g * myMulti, cbColor.b * myMulti)
  893. else
  894. element:SetStatusBarColor(cbDefaultColor[1], cbDefaultColor[2], cbDefaultColor[3])
  895. element.bg:SetTexture(cbDefaultColor[1] * myMulti, cbDefaultColor[2] * myMulti, cbDefaultColor[3] * myMulti)
  896. end
  897. end
  898. end
  899.  
  900. lib.addCastBar = function(self, inline)
  901. if not cfg.Castbars then return end
  902. local cbHeight = 18
  903. local relativeFrame = self.Debuffs and self.Debuffs or self
  904. local textBorder = "NONE"
  905. local flvl = 1
  906.  
  907. if inline then
  908. textBorder = "OUTLINE"
  909. if self.mystyle == "player" or self.mystyle == "target" then
  910. relativeFrame = self.Portrait
  911. else
  912. relativeFrame = self
  913. end
  914. cbHeight = relativeFrame:GetHeight()
  915. end
  916.  
  917. local castbar = CreateFrame("StatusBar", nil, self)
  918. castbar:SetStatusBarTexture(cfg.statusBarTexture)
  919. castbar:SetFrameLevel(5)
  920.  
  921. castbar.Inline = inline
  922.  
  923. if not inline then
  924. createBGFrame(castbar, 0)
  925.  
  926. local bgoverlay = castbar:CreateTexture(nil, "BACKGROUND", nil, -5)
  927. bgoverlay:SetPoint("TOPLEFT", castbar,"TOPLEFT", 0, 0)
  928. bgoverlay:SetPoint("BOTTOMRIGHT", castbar,"BOTTOMRIGHT", 0, 0)
  929. bgoverlay:SetTexture(cfg.portraitOverlayTexture)
  930. bgoverlay:SetVertexColor(0, 0, 0, 0.8)
  931.  
  932. local castbarDummy = CreateFrame("Frame", nil, castbar)
  933. castbarDummy:SetSize(cbHeight, cbHeight)
  934. castbarDummy:SetPoint("TOPRIGHT", castbar, "TOPLEFT", -5, 0)
  935. createBGFrame(castbarDummy, 0)
  936.  
  937. local castbarIcon = castbarDummy:CreateTexture(nil, "ARTWORK")
  938. castbarIcon:SetAllPoints(castbarDummy)
  939. castbarIcon:SetTexCoord(0.08, 0.92, 0.08, 0.92)
  940. castbar.Icon = castbarIcon
  941.  
  942. castbar:SetSize(relativeFrame:GetWidth()-cbHeight-5, cbHeight)
  943. castbar:SetPoint("TOPRIGHT", relativeFrame, "BOTTOMRIGHT", 0, -3)
  944. else
  945. castbar:SetAllPoints(relativeFrame)
  946. end
  947.  
  948. if self.mystyle == "player" or self.mystyle == "target" then
  949. if not inline then
  950. local castbarBG = castbar:CreateTexture(nil, "BACKGROUND", nil, -6)
  951. castbarBG:SetAllPoints(castbar)
  952. castbar.bg = castbarBG
  953. end
  954. local castbarTime = setFont(castbar, cfg.font, 12, textBorder, 1)
  955. castbarTime:SetPoint("RIGHT", castbar, "RIGHT", -2, 1)
  956. castbarTime:SetJustifyH("RIGHT")
  957. castbar.Time = castbarTime
  958.  
  959. local castbarText = setFont(castbar, cfg.font, 12, textBorder, 1)
  960. castbarText:SetPoint("LEFT", castbar, "LEFT", 2, 1)
  961. castbarText:SetPoint("RIGHT", castbarTime, "LEFT", -4, 0)
  962. castbarText:SetJustifyH("LEFT")
  963. castbar.Text = castbarText
  964. end
  965.  
  966. if self.mystyle == "target" then flvl = 4 end
  967.  
  968. if self.mystyle == "player" then
  969. castbar.SafeZone = castbar:CreateTexture(nil, "OVERLAY", nil, -4)
  970. castbar.SafeZone:SetAlpha(0.35)
  971. elseif self.mystyle == "target" or self.mystyle == "focus" then
  972. local shield = createBGFrame(castbar, flvl)
  973. shield:SetBackdropColor(0.65, 0, 0, 1)
  974. shield:SetBackdropBorderColor(0, 0, 0, 0)
  975. castbar.Shield = shield
  976. end
  977.  
  978. local spark = castbar:CreateTexture(nil, "OVERLAY")
  979. spark:SetBlendMode("ADD")
  980. spark:SetAlpha(0.3)
  981. spark:SetHeight(cbHeight*2.5)
  982. castbar.Spark = spark
  983.  
  984. self.Castbar = castbar
  985. if castbar.Time then
  986. self.Castbar.CustomTimeText = customTimeText
  987. self.Castbar.CustomDelayText = customDelayText
  988. end
  989. self.Castbar.PostCastStart = postCastStart
  990. self.Castbar.PostChannelStart = postCastStart
  991. end
  992.  
  993. -----------------------------
  994. -- PLUGINS
  995. -----------------------------
  996.  
  997. -- AuraWatch
  998. local AWPostCreateIcon = function(AWatch, icon, spellID, name, self)
  999. icon.cd:SetReverse()
  1000. local count = setFont(icon, cfg.nanofont, 10, "OUTLINE", 0)
  1001. count:SetPoint("CENTER", icon, "BOTTOM", 3, 3)
  1002. icon.count = count
  1003. createBGFrame(icon, 4, 3)
  1004. CreateShadowww(icon, 4)
  1005. end
  1006.  
  1007. lib.addAuraWatch = function(self)
  1008. if cfg.showAuraWatch then
  1009. local auras = {}
  1010. local spellIDs = {
  1011. DEATHKNIGHT = {
  1012. },
  1013. DRUID = {
  1014. 33763, -- Lifebloom
  1015. 8936, -- Regrowth
  1016. 774, -- Rejuvenation
  1017. 48438, -- Wild Growth
  1018. },
  1019. HUNTER = {
  1020. 34477, -- Misdirection
  1021. },
  1022. MAGE = {
  1023. 54646, -- Focus Magic
  1024. },
  1025. PALADIN = {
  1026. 53563, -- Beacon of Light
  1027. 25771, -- Forbearance
  1028. },
  1029. PRIEST = {
  1030. 17, -- Power Word: Shield
  1031. 139, -- Renew
  1032. 33076, -- Prayer of Mending
  1033. 6788, -- Weakened Soul
  1034. },
  1035. ROGUE = {
  1036. 57934, -- Tricks of the Trade
  1037. },
  1038. SHAMAN = {
  1039. 974, -- Earth Shield
  1040. 61295, -- Riptide
  1041. },
  1042. WARLOCK = {
  1043. 20707, -- Soulstone Resurrection
  1044. },
  1045. WARRIOR = {
  1046. 50720, -- Vigilance
  1047. },
  1048. }
  1049.  
  1050. auras.onlyShowPresent = true
  1051. auras.anyUnit = true
  1052. auras.PostCreateIcon = AWPostCreateIcon
  1053. -- Set any other AuraWatch settings
  1054. auras.icons = {}
  1055.  
  1056. for i, sid in pairs(spellIDs[playerClass]) do
  1057. local icon = CreateFrame("Frame", nil, self)
  1058. icon.spellID = sid
  1059. -- set the dimensions and positions
  1060. icon:SetWidth(10)
  1061. icon:SetHeight(10)
  1062. icon:SetFrameLevel(5)
  1063. icon:SetPoint("BOTTOMRIGHT", self, "BOTTOMLEFT", 12 * i, 5)
  1064.  
  1065. auras.icons[sid] = icon
  1066. end
  1067. self.AuraWatch = auras
  1068. end
  1069. end
  1070.  
  1071. -- debuffHighlight
  1072. lib.addDebuffHighlight = function (self)
  1073. if cfg.enableDebuffHighlight then
  1074. local dbh = self.Health:CreateTexture(nil, "OVERLAY")
  1075. dbh:SetAllPoints(self.Health)
  1076. dbh:SetTexture(cfg.glowTexture)
  1077. dbh:SetBlendMode("ADD")
  1078. dbh:SetVertexColor(0,0,0,0) -- set alpha to 0 to hide the texture
  1079. self.DebuffHighlight = dbh
  1080. self.DebuffHighlightAlpha = 0.8
  1081. self.DebuffHighlightFilter = true
  1082. end
  1083. end
  1084.  
  1085. -- oUF_CombatFeedback
  1086. lib.addCombatFeedback = function(self)
  1087. if IsAddOnLoaded("oUF_CombatFeedback") then
  1088. local obj = self.Portrait and self.Portrait or self.Health
  1089. local cbft = setFont(obj, cfg.font, 20, "THICKOUTLINE", 0)
  1090. cbft:SetPoint("CENTER", obj, "CENTER")
  1091.  
  1092. self.CombatFeedbackText = cbft
  1093. self.CombatFeedbackText.ignoreEnergize = true
  1094. end
  1095. end
  1096. lib.ThreatBar = function(self)
  1097. if cfg.ThreatBar then
  1098. local ThreatBar = CreateFrame("StatusBar", self:GetName()..'_ThreatBar', UIParent)
  1099. ThreatBar:SetFrameLevel(5)
  1100. ThreatBar:SetPoint("BOTTOM", UIParent,"BOTTOM", 0, 150)
  1101. ThreatBar:SetWidth(348)
  1102. ThreatBar:SetHeight(16)
  1103. ThreatBar:SetStatusBarTexture(cfg.statusBarTexture)
  1104. ThreatBar.Text = setFont(ThreatBar, cfg.font, 12, "OUTLINE", 2)
  1105. ThreatBar.Text:SetPoint("RIGHT", ThreatBar, "RIGHT", -30, 0)
  1106. ThreatBar.Title = setFont(ThreatBar, cfg.font, 12, "OUTLINE", 2)
  1107. ThreatBar.Title:SetText("Threat on current target:")
  1108. ThreatBar.Title:SetPoint("LEFT", ThreatBar, "LEFT", 30, 0)
  1109. ThreatBar.bg = ThreatBar:CreateTexture(nil, 'BORDER')
  1110. ThreatBar.bg:SetAllPoints(ThreatBar)
  1111. ThreatBar.bg:SetTexture(0.1,0.1,0.1)
  1112. ThreatBar.useRawThreat = false
  1113.  
  1114. local h = CreateFrame("Frame", nil, ThreatBar)
  1115. h:SetFrameLevel(4)
  1116. h:SetPoint("TOPLEFT",0,0)
  1117. h:SetPoint("BOTTOMRIGHT",0,0)
  1118. createBGFrame(h,1)
  1119. CreateShadowww(h,2)
  1120.  
  1121. self.ThreatBar = ThreatBar
  1122. end
  1123. end
  1124. lib.Experience = function(self)
  1125. if cfg.Experiencebar then
  1126. local Experience = CreateFrame('StatusBar', nil, self)
  1127. Experience:SetStatusBarTexture(cfg.statusBarTexture)
  1128. Experience:SetStatusBarColor(0, 0.7, 1)
  1129. Experience:SetPoint('BOTTOMLEFT', UIParent,'BOTTOMLEFT', 12, 145)
  1130. Experience:SetHeight(5)
  1131. Experience:SetWidth(338)
  1132.  
  1133. Experience:SetFrameLevel(11)
  1134. Experience.Tooltip = true
  1135.  
  1136. local h = CreateFrame("Frame", nil, Experience)
  1137. h:SetFrameLevel(10)
  1138. h:SetPoint("TOPLEFT",0,0)
  1139. h:SetPoint("BOTTOMRIGHT",0,0)
  1140. createBGFrame(h,1)
  1141. CreateShadowww(h,2)
  1142.  
  1143. local Rested = CreateFrame('StatusBar', nil, Experience)
  1144. Rested:SetStatusBarTexture(cfg.statusBarTexture)
  1145. Rested:SetStatusBarColor(0, 0.4, 1, 0.6)
  1146. Rested:SetAllPoints(Experience)
  1147.  
  1148. self.Experience = Experience
  1149. self.Experience.Rested = Rested
  1150. self.Experience.PostUpdate = ExperiencePostUpdate
  1151. end
  1152. end
  1153. lib.Reputation = function(self)
  1154. if cfg.Reputationbar then
  1155. local Reputation = CreateFrame('StatusBar', nil, self)
  1156. Reputation:SetStatusBarTexture(cfg.statusBarTexture)
  1157. Reputation:SetWidth(338)
  1158.  
  1159. Reputation:SetHeight(5)
  1160. Reputation:SetPoint('BOTTOMLEFT', UIParent,'BOTTOMLEFT', 12, 145)
  1161. Reputation:SetFrameLevel(30)
  1162.  
  1163. local h = CreateFrame("Frame", nil, Reputation)
  1164. h:SetFrameLevel(10)
  1165. h:SetPoint("TOPLEFT",0,0)
  1166. h:SetPoint("BOTTOMRIGHT",0,0)
  1167. createBGFrame(h,1)
  1168. CreateShadowww(h,2)
  1169. Reputation.PostUpdate = UpdateReputationColor
  1170. Reputation.Tooltip = true
  1171. self.Reputation = Reputation
  1172. end
  1173. end
  1174. lib.AltPowerBar = function(self)
  1175. if cfg.AltPowerBar then
  1176. local AltPowerBar = CreateFrame("StatusBar", nil, self.Health)
  1177. AltPowerBar:SetHeight(10)
  1178. AltPowerBar:SetWidth(338)
  1179.  
  1180. AltPowerBar:SetStatusBarTexture(cfg.statusBarTexture)
  1181. AltPowerBar:EnableMouse(true)
  1182. AltPowerBar:SetFrameStrata("HIGH")
  1183. AltPowerBar:SetFrameLevel(5)
  1184. AltPowerBar:SetPoint('TOP', UIParent,'TOP', 0, -10)
  1185.  
  1186. local h = CreateFrame("Frame", nil, AltPowerBar)
  1187. h:SetFrameLevel(4)
  1188. h:SetPoint("TOPLEFT",0,0)
  1189. h:SetPoint("BOTTOMRIGHT",0,0)
  1190. createBGFrame(h,1)
  1191. CreateShadowww(h,2)
  1192.  
  1193. AltPowerBar.text = setFont(AltPowerBar, cfg.font, 12, "THINOUTLINE", 2)
  1194. AltPowerBar.text:SetPoint("CENTER")
  1195. AltPowerBar.text:SetJustifyH("CENTER")
  1196.  
  1197. AltPowerBar:HookScript("OnShow", AltPowerBarOnToggle)
  1198. AltPowerBar:HookScript("OnHide", AltPowerBarOnToggle)
  1199.  
  1200. self.AltPowerBar = AltPowerBar
  1201. self.AltPowerBar.PostUpdate = AltPowerBarPostUpdate
  1202. end
  1203. end
  1204. -- raid debuffs
  1205. lib.raidDebuffs = function(f)
  1206. if cfg.showRaidDebuffs then
  1207. local raid_debuffs = {
  1208. debuffs = {
  1209. -- Any Zone
  1210. ["Viper Sting"] = 12, -- Viper Sting
  1211. ["Wound Poison"] = 9, -- Wound Poison
  1212. ["Mortal Strike"] = 8, -- Mortal Strike
  1213. ["Furious Attacks"] = 8, -- Furious Attacks
  1214. ["Aimed Shot"] = 8, -- Aimed Shot
  1215. ["Counterspell"] = 10, -- Counterspell
  1216. ["Blind"] = 10, -- Blind
  1217. ["Cyclone"] = 10, -- Cyclone
  1218. ["Polymorph"] = 7, -- Polymorph
  1219. ["Entangling Roots"] = 7, -- Entangling Roots
  1220. ["Freezing Trap"] = 7, -- Freezing Trap
  1221. ["Crippling Poison"] = 6, -- Crippling Poison
  1222. ["Hamstring"] = 5, -- Hamstring
  1223. ["Wing Clip"] = 5, -- Wing Clip
  1224. ["Fear"] = 3, -- Fear
  1225. ["Psychic Scream"] = 3, -- Psychic Scream
  1226. ["Howl of Terror"] = 3, -- Howl of Terror
  1227. -- Naxxramas
  1228. ["Locust Swarm"] = 12,
  1229. ["Necrotic Poison"] = 12,
  1230. ["Web Wrap"] = 12,
  1231. ["Jagged Knife"] = 12,
  1232. ["Mutating Injection"] = 12,
  1233. ["Detonate Mana"] = 12,
  1234. ["Frost Blast"] = 12,
  1235. ["Chains of Kel'Thuzad"] = 12,
  1236. -- Ulduar
  1237. ["Slag Pot"] = 12,
  1238. ["Gravity Bomb"] = 12,
  1239. ["Light Bomb"] = 12,
  1240. ["Fusion Punch"] = 12,
  1241. ["Static Disruption"] = 12,
  1242. ["Stone Grip"] = 12,
  1243. ["Crunch Armor"] = 12,
  1244. ["Flash Freeze"] = 12,
  1245. ["Unbalancing Strike"] = 12,
  1246. ["Iron Roots"] = 12,
  1247. ["Nature's Fury"] = 12,
  1248. ["Napalm Shell"] = 12,
  1249. ["Mark of the Faceless"] = 12,
  1250. ["Sara's Fevor"] = 12,
  1251. ["Squeeze"] = 12,
  1252. ["Phase Punch"] = 12,
  1253. -- Trial of the Crusader
  1254. -- Beasts
  1255. ["Impale"] = 12,
  1256. ["Snobolled!"] = 12,
  1257. ["Paralytic Toxin"] = 12,
  1258. ["Burning Bile"] = 12,
  1259. ["Arctic Breathe"] = 12,
  1260. -- Jaraxxus
  1261. ["Mistress' Kiss"] = 12,
  1262. ["Legion Flame"] = 12,
  1263. ["Incinerate Flesh"] = 11,
  1264. -- Twins
  1265. ["Touch of Darkness"] = 12,
  1266. ["Touch of Light"] = 12,
  1267. -- Anub
  1268. ["Pursued by Anub'arak"] = 12,
  1269. ["Penetrating Cold"] = 12,
  1270. -- Trial of the Grand Crusader
  1271. -- Beasts
  1272. ["Impale"] = 12,
  1273. ["Snobolled!"] = 12,
  1274. ["Paralytic Toxin"] = 12,
  1275. ["Burning Bile"] = 12,
  1276. ["Arctic Breathe"] = 12,
  1277. -- Jaraxxus
  1278. ["Mistress' Kiss"] = 12,
  1279. ["Legion Flame"] = 12,
  1280. ["Incinerate Flesh"] = 11,
  1281. -- Twins
  1282. ["Touch of Darkness"] = 12,
  1283. ["Touch of Light"] = 12,
  1284. -- Anub
  1285. ["Pursued by Anub'arak"] = 12,
  1286. ["Penetrating Cold"] = 12,
  1287. -- Icecrown Citadel
  1288. -- Lord Marrowgar
  1289. ["Impaled"] = 12,
  1290. -- Gunship Battle
  1291. ["Wounding Strike"] = 12,
  1292. -- Saurfang
  1293. ["Boiling Blood"] = 12,
  1294. ["Mark of the Fallen Champion"] = 12,
  1295. -- Festergut
  1296. ["Gas Spore"] = 12,
  1297. ["Vile Gas"] = 12,
  1298. -- Rotface
  1299. ["Mutated Infection"] = 12,
  1300. -- Putricide
  1301. ["Gaseous Bloat"] = 12,
  1302. ["Volatile Ooze Adhesive"] = 12,
  1303. -- Lana'thel
  1304. ["Pact of the Darkfallen"] = 12,
  1305. ["Essence of the Blood Queen"] = 10,
  1306. -- Sindragosa
  1307. ["Frost Beacon"] = 12,
  1308. -- ["Unchained Magic"] = 10,
  1309. ["Instability"] = 12,
  1310. -- Lich King
  1311. ["Necrotic Plague"] = 12,
  1312. ["Pain and Suffering"] = 12,
  1313. ["Infest"] = 11,
  1314. -- Ruby Sanctum
  1315. ["Enervating Brand"] = 12, -- Enervating Brand
  1316. ["Blazing Aura"] = 12, -- Blazing Aura
  1317. ["Fiery Combustion"] = 12, -- Fiery Combustion
  1318. ["Mark of Combustion"] = 12, -- Mark of Combustion (Fire)
  1319. ["Soul Consumption"] = 12, -- Soul Consumption
  1320. ["Mark Of Consumption"] = 12, -- Mark Of Consumption (Soul)
  1321. },
  1322. }
  1323.  
  1324. local instDebuffs = {}
  1325. local instances = raid_debuffs.instances
  1326. local getzone = function()
  1327. local zone = GetInstanceInfo()
  1328. if instances[zone] then
  1329. instDebuffs = instances[zone]
  1330. else
  1331. instDebuffs = {}
  1332. end
  1333. end
  1334.  
  1335. local debuffs = raid_debuffs.debuffs
  1336. local CustomFilter = function(icons, ...)
  1337. local _, icon, name, _, _, _, dtype = ...
  1338. if instDebuffs[name] then
  1339. icon.priority = instDebuffs[name]
  1340. return true
  1341. elseif debuffs[name] then
  1342. icon.priority = debuffs[name]
  1343. return true
  1344. else
  1345. icon.priority = 0
  1346. end
  1347. end
  1348.  
  1349. local dbsize = 13
  1350. local debuffs = CreateFrame("Frame", nil, f)
  1351. debuffs:SetWidth(dbsize) debuffs:SetHeight(dbsize)
  1352. debuffs:SetPoint("TOPRIGHT", -10, 3)
  1353. debuffs.size = dbsize
  1354.  
  1355. debuffs.CustomFilter = CustomFilter
  1356. f.raidDebuffs = debuffs
  1357. end
  1358. end
  1359.  
  1360. --hand the lib to the namespace for further usage...this is awesome because you can reuse functions in any of your layout files
  1361. ns.lib = lib
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement