Cokedriver

BasicUI New

Mar 23rd, 2014
623
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 199.76 KB | None | 0 0
  1. local BasicUI = LibStub("AceAddon-3.0"):NewAddon("BasicUI")
  2. local LSM = LibStub("LibSharedMedia-3.0")
  3. local BASIC_BORDER = [[Interface\Tooltips\UI-Tooltip-Border]]
  4. local BASIC_BACKGROUND = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]]
  5. local BASIC_STATUSBAR = [[Interface\TargetingFrame\UI-StatusBar]]
  6. local BASIC_BORDERPANEL = [[Interface\AddOns\BasicUI\Media\UI-DialogBox-Border.blp]]
  7.  
  8. SlashCmdList['RELOADUI'] = function()
  9. ReloadUI()
  10. end
  11. SLASH_RELOADUI1 = '/rl'
  12.  
  13. local defaults = {
  14.  
  15. profile = {
  16.  
  17. fontEnable = true,
  18. fontNormal = [[Interface\Addons\BasicUI\Media\NORMAL.ttf]],
  19. fontBold = [[Interface\Addons\BasicUI\Media\BOLD.ttf]],
  20. fontItalic = [[Interface\Addons\BasicUI\Media\ITALIC.ttf]],
  21. fontBoldItalic = [[Interface\Addons\BasicUI\Media\BOLDITALIC.ttf]],
  22. fontNumber = [[Interface\Addons\BasicUI\Media\NUMBER.ttf]],
  23. fontSize = 15,
  24. classcolor = true,
  25.  
  26. buttons = {
  27. enable = true,
  28. showHotKeys = false,
  29. showMacronames = false,
  30. auraborder = false,
  31.  
  32. -- Button Colors
  33. color = {
  34. enable = true,
  35. OutOfRange = { r = 0.9, g = 0, b = 0 },
  36. OutOfMana = { r = 0, g = 0, b = 0.9 },
  37. NotUsable = { r = 0.3, g = 0.3, b = 0.3 },
  38. },
  39. },
  40. castbar = {
  41. enable = true,
  42. border = BASIC_BORDER,
  43. background = BASIC_BACKGROUND,
  44. statusbar = BASIC_STATUSBAR,
  45.  
  46.  
  47. CastingBarFrame = {
  48. enable = true,
  49. fontSize = 18,
  50. textPosition = "CENTER",
  51. enableLag = true,
  52. enableTimer = true,
  53. selfAnchor = "BOTTOM",
  54. relAnchor = "BOTTOM",
  55. offSetX = 0,
  56. offSetY = 175,
  57. },
  58. TargetFrameSpellBar = {
  59. enable = false,
  60. fontSize = 18,
  61. textPosition = "CENTER",
  62. enableLag = true,
  63. enableTimer = true,
  64. selfAnchor = "TOP",
  65. relAnchor = "TOP",
  66. offSetX = 0,
  67. offSetY = -250,
  68. },
  69. FocusFrameSpellBar = {
  70. enable = true,
  71. fontSize = 18,
  72. textPosition = "CENTER",
  73. enableLag = true,
  74. enableTimer = true,
  75. selfAnchor = "TOP",
  76. relAnchor = "TOP",
  77. offSetX = 0,
  78. offSetY = -165,
  79. },
  80. MirrorTimer1 = {
  81. enable = true,
  82. fontSize = 18,
  83. enableTimer = true,
  84. selfAnchor = "TOP",
  85. relAnchor = "TOP",
  86. offSetX = 0,
  87. offSetY = -75,
  88. },
  89. PetCastingBarFrame = {
  90. enable = true,
  91. fontSize = 18,
  92. textPosition = "CENTER",
  93. enableTimer = true,
  94. selfAnchor = "BOTTOM",
  95. relAnchor = "BOTTOM",
  96. offSetX = 0,
  97. offSetY = 200,
  98. },
  99. },
  100. chat = {
  101. enable = true,
  102. disableFade = false,
  103. chatOutline = false,
  104. windowborder = false,
  105. enableborder = false,
  106.  
  107. -- Chat Media
  108. border = BASIC_BORDER,
  109. background = BASIC_BACKGROUND,
  110. editboxborder = BASIC_BORDER,
  111. editboxbackground = BASIC_BACKGROUND,
  112. sound = [[Interface\Addons\BasicUI\Media\Whisper.mp3]],
  113.  
  114. enableBottomButton = true,
  115. enableHyperlinkTooltip = true,
  116. enableBorderColoring = true,
  117.  
  118. tab = {
  119. fontSize = 15,
  120. fontOutline = true,
  121. normalColor = {r = 1, g = 1, b = 1},
  122. specialColor = {r = 1, g = 0, b = 1},
  123. selectedColor = {r = 0, g = 0.75, b = 1},
  124. },
  125. },
  126. datapanel = {
  127. enable = true,
  128. battleground = true, -- enable 3 stats in battleground only that replace stat1,stat2,stat3.
  129. bag = false, -- True = Open Backpack; False = Open All bags
  130.  
  131. -- nData Media
  132. border = BASIC_BORDERPANEL, -- Border for Datapanel ( Choose either Datapanel or Neav for border choice)
  133. background = BASIC_BACKGROUND, -- Background for Datapanel
  134.  
  135. -- Color Datatext
  136. color = true, -- Enable Datatext Coloring
  137. customcolor = { r = 1, g = 1, b = 1}, -- Color of Text for Datapanel
  138. classcolor = true, -- Enable Classcolor for Text
  139.  
  140. panel = "bottom", -- 3 Choices for panel placement = "top", "bottom", or "shortbar". Shortbar is to match nMainbar shortbar.
  141. armor = 0, -- show your armor value against the level mob you are currently targeting.
  142. avd = 0, -- show your current avoidance against the level of the mob your targeting
  143. bags = 9, -- show space used in bags on panel.
  144. haste = 0, -- show your haste rating on panels.
  145. system = 0, -- show total memory and others systems info (FPS/MS) on panel.
  146. guild = 4, -- show number on guildmate connected on panel.
  147. dur = 8, -- show your equipment durability on panel.
  148. friends = 6, -- show number of friends connected.
  149. dps_text = 0, -- show a dps meter on panel.
  150. hps_text = 0, -- show a heal meter on panel.
  151. spec = 5, -- show your current spec on panel.
  152. coords = 0, -- show your current coords on panel.
  153. pro = 7, -- shows your professions and tradeskills
  154. stat1 = 1, -- Stat Based on your Role (Avoidance-Tank, AP-Melee, SP/HP-Caster)
  155. stat2 = 3, -- Stat Based on your Role (Armor-Tank, Crit-Melee, Crit-Caster)
  156. recount = 2, -- Stat Based on Recount"s DPS
  157. recountraiddps = false, -- Enables tracking or Recounts Raid DPS
  158. calltoarms = 0, -- Show Current Call to Arms.
  159.  
  160. },
  161. -- Merchant Options
  162. merchant = {
  163. enable = true, -- enable merchant module.
  164. sellMisc = true, -- allows the user to add spacific items to sell at merchant (please see the local filter in merchant.lua)
  165. autoSellGrey = true, -- autosell grey items at merchant.
  166. autoRepair = true, -- autorepair at merchant.
  167. gpay = false, -- let your guild pay for your repairs if they allow.
  168. },
  169. nameplates = {
  170. enable = true,
  171. enableTankMode = true, -- Color the nameplate threat border green, if you have no aggro
  172. colorNameWithThreat = true, -- The name has the same color as the threat of the unit (better visibility)
  173.  
  174. showFullHP = true,
  175. showLevel = true,
  176. showTargetBorder = true,
  177. showEliteBorder = true,
  178. showTotemIcon = true,
  179. abbrevLongNames = true,
  180. },
  181.  
  182. -- Quest Options
  183. quest = {
  184. enable = true, -- enable quest module.
  185. autocomplete = false, -- enable the autoaccept quest and autocomplete quest if no reward.
  186. },
  187.  
  188. vendor = {
  189. enable = true,
  190. },
  191.  
  192. vellum = {
  193. enable = true,
  194. },
  195.  
  196. -- Tooltip
  197. tooltip = {
  198. enable = true, -- Move the tooltip up so its not overlapping the MainMenubar
  199. fontSize = 15,
  200. fontOutline = true,
  201. disableFade = false, -- Can cause errors or a buggy tooltip!
  202. abbrevRealmNames = true,
  203. border = BASIC_BORDER,
  204. background = BASIC_BACKGROUND,
  205. statusbar = BASIC_STATUSBAR,
  206. hideInCombat = false, -- Hide unit frame tooltips during combat
  207. hideRealmText = true, -- Hide the coalesced/interactive realm text
  208. reactionBorderColor = true,
  209. itemqualityBorderColor = true,
  210.  
  211. showPlayerTitles = true,
  212. showPVPIcons = false, -- Show pvp icons instead of just a prefix
  213. showMouseoverTarget = true,
  214. showOnMouseover = false,
  215. showUnitRole = true,
  216. showItemLevel = true,
  217. showSpecializationIcon = false,
  218.  
  219. position = {
  220. selfAnchor = "BOTTOM",
  221. relAnchor = "BOTTOM",
  222. offSetX = 0,
  223. offSetY = 200,
  224. },
  225.  
  226. healthbar = {
  227. showHealthValue = true,
  228. showOutline = true,
  229. healthFormat = '$cur / $max', -- Possible: $cur, $max, $deficit, $perc, $smartperc, $smartcolorperc, $colorperc
  230. healthFullFormat = '$cur', -- if the tooltip unit has 100% hp
  231. textPos = "CENTER", -- Possible "TOP" "BOTTOM" "CENTER"
  232. reactionColoring = false,
  233. custom = {
  234. apply = false,
  235. color = { r = 1, g = 1, b = 0},
  236. },
  237. fontSize = 15,
  238. },
  239. },
  240.  
  241. -- Unitframes
  242. unitframes = {
  243. enable = true,
  244. player = {
  245. enable = true, -- Enable Player Frame Adjustments
  246. scale = 1.15, -- Player Frame Scale
  247. fontSize = 13, -- Stausbar Font Size
  248. fontSizepet = 10, -- Stausbar Font Size
  249. },
  250. target = {
  251. enable = true, -- Enable Target Frame Adjustments
  252. scale = 1.15, -- Target Frame Scale
  253. fontSize = 13, -- Stausbar Font Size
  254. },
  255. focus = {
  256. enable = true, -- Enable Focus Frame Adjustments
  257. scale = 1.15, -- Focus Frame Scale
  258. fontSize = 13, -- Stausbar Font Size
  259. },
  260. party = {
  261. enable = true,
  262. scale = 1.15,
  263. fontSize = 11, -- Stausbar Font Size
  264. position = {
  265. relAnchor = "TOPLEFT",
  266. offSetX = 10, -- Controls the X offset. (Left - Right)
  267. offSetY = -150, -- Controls the Y offset. (Up - Down)
  268. },
  269. },
  270. arena = {
  271. enable = true,
  272. scale = 1.5,
  273. fontSize = 11, -- Stausbar Font Size
  274. tracker = true,
  275. },
  276. boss = {
  277. enable = true,
  278. scale = 1.15,
  279. fontSize = 13, -- Stausbar Font Size
  280. position = {
  281. relAnchor = "TOPRIGHT",
  282. offSetX = -50, -- Controls the X offset. (Left - Right)
  283. offSetY = -250, -- Controls the Y offset. (Up - Down)
  284. },
  285. },
  286. },
  287. },
  288. }
  289.  
  290. function BasicUI:OnInitialize()
  291. -- Assuming the .toc says ## SavedVariables: MyAddonDB
  292. self.db = LibStub("AceDB-3.0"):New("BasicDB", defaults, true)
  293. end
  294.  
  295. function BasicUI:OnEnable()
  296. self:Actionbar()
  297. self:Buff()
  298. self.Castbars()
  299. self:Chat()
  300. self:Datapanel()
  301. self:Font()
  302. self:Merchant()
  303. self:Nameplates()
  304. self:Vellum()
  305. self:Tooltip()
  306. self:Unitframes()
  307. end
  308.  
  309. -------------
  310. -- CastBar --
  311. -------------
  312. function BasicUI:Castbars()
  313. local db = BasicUI.db.profile
  314. local ccolor = RAID_CLASS_COLORS[select(2, UnitClass("player"))]
  315. local m = 768/string.match(GetCVar("gxResolution"), "%d+x(%d+)")/min(2, max(.64, 768/string.match(({GetScreenResolutions()})[GetCurrentResolution()], "%d+x(%d+)")));
  316. local scale = function(v) return m * floor(v/m+.5) end;
  317.  
  318. if db.castbar.enable ~= true then return end
  319.  
  320. --[[
  321.  
  322. All Credit for Castbar.lua goes to thek.
  323. thek: Castbar = http://www.wowinterface.com/downloads/info11334-thekCastbar.html.
  324. Edited by Cokedriver.
  325.  
  326. ]]
  327.  
  328. local d = {};
  329. local find = string.find;
  330. local floor = math.floor;
  331.  
  332. local function Set(a, k)
  333. a:SetFrameLevel(_G[k]:GetFrameLevel() - 1);
  334. if find(k, "MirrorTimer") then
  335. _G[k.."StatusBar"]:SetStatusBarColor(ccolor.r, ccolor.g, ccolor.b);
  336. _G[k.."StatusBar"]:SetWidth(240);
  337. _G[k.."StatusBar"]:SetHeight(24);
  338. _G[k]:ClearAllPoints();
  339. _G[k]:SetPoint("TOPLEFT", a, "TOPLEFT", scale(_G[k].d.x), -scale(_G[k].d.y));
  340. _G[k.."StatusBar"]:ClearAllPoints();
  341. _G[k.."StatusBar"]:SetPoint("TOPLEFT", a, "TOPLEFT", scale(5), -scale(_G[k].d.y));
  342. else
  343. _G[k]:SetStatusBarColor(ccolor.r, ccolor.g, ccolor.b);
  344. _G[k]:SetWidth(240);
  345. _G[k]:SetHeight(24);
  346. _G[k]:ClearAllPoints();
  347. _G[k]:SetPoint("TOPLEFT", a, "TOPLEFT", scale(_G[k].d.x), -scale(_G[k].d.y))
  348. end;
  349. if db.castbar[k].enableLag then
  350. local d, u, l = GetNetStats();
  351. local min, max = _G[k]:GetMinMaxValues();
  352. local lv = ( l / 1000 ) / ( max - min );
  353. if ( lv < 0 ) then lv = 0; elseif ( lv > 1 ) then lv = 1 end;
  354. if ( _G[k].channeling ) then
  355. _G[k].lag:ClearAllPoints();
  356. _G[k].lag:SetPoint("LEFT", _G[k], "LEFT", 0, 0);
  357. else
  358. _G[k].lag:ClearAllPoints();
  359. _G[k].lag:SetPoint("RIGHT", _G[k], "RIGHT", 0, 0);
  360. end;
  361. _G[k].lag:SetWidth(_G[k]:GetWidth() * lv);
  362. end
  363. end;
  364.  
  365. if db.castbar["TargetFrameSpellBar"].enable then
  366. function Target_Spellbar_AdjustPosition()
  367. Set(_G["TargetFrameSpellBar"].df, "TargetFrameSpellBar");
  368. end;
  369. end;
  370. if db.castbar["FocusFrameSpellBar"].enable then
  371. function Focus_Spellbar_AdjustPosition()
  372. Set(_G["FocusFrameSpellBar"].df, "FocusFrameSpellBar");
  373. end;
  374. end
  375.  
  376. for k, _ in pairs(db.castbar) do
  377. if (k ~="enable" and db.castbar[k].enable) then
  378. local a = CreateFrame("Frame", "Castbar"..k, UIParent);
  379. d.w, d.h, d.x, d.y = nil, nil, nil, nil;
  380.  
  381. _G[k.."Border"]:SetTexture("");
  382. _G[k.."Text"]:ClearAllPoints("");
  383. _G[k.."Text"]:SetFont(db.fontNormal, db.castbar[k].fontSize, "");
  384.  
  385. if find(k, "MirrorTimer") then
  386. d.w = 240 + (5 * 2);
  387. d.h = 24 + (5 * 2);
  388. d.x = 5;
  389. d.y = 5;
  390.  
  391. _G[k.."Text"]:SetPoint("CENTER", k, -10, 2);
  392. _G[k.."StatusBar"]:SetStatusBarTexture(db.castbar.statusbar);
  393. else
  394. d.w = 240 + 24 + (5 * 2) + 5;
  395. d.h = 24 + (5 * 2);
  396. d.x = 24 + 5 + 5;
  397. d.y = 5;
  398.  
  399. _G[k.."Text"]:SetPoint(db.castbar[k].textPosition);
  400. _G[k]:SetStatusBarTexture(db.castbar.statusbar);
  401. _G[k.."Flash"].Show = _G[k.."Flash"].Hide;
  402. _G[k.."Spark"].Show = _G[k.."Spark"].Hide;
  403.  
  404. if _G[k.."BorderShield"] then
  405. _G[k.."BorderShield"].Show = _G[k.."BorderShield"].Hide;
  406. end;
  407.  
  408. if _G[k.."Icon"] then
  409. _G[k.."Icon"]:Show();
  410. _G[k.."Icon"]:ClearAllPoints();
  411. _G[k.."Icon"]:SetPoint("LEFT", _G[k], -27, 0);
  412. _G[k.."Icon"]:SetWidth(23);
  413. _G[k.."Icon"]:SetHeight(23);
  414. _G[k.."Icon"]:SetTexCoord(.08, .92, .08, .92);
  415. end;
  416.  
  417. _G[k]:HookScript("OnSizeChanged", function()
  418. _G[k].reset = true;
  419. end);
  420. _G[k]:HookScript("OnValueChanged", function(self)
  421. if self.reset and not self.reseting then
  422. self.reseting = true
  423. Set(a, k)
  424. self.reseting = nil
  425. self.reset = nil
  426. end
  427. end)
  428.  
  429. if db.castbar[k].enableLag then
  430. _G[k].lag = _G[k]:CreateTexture(nil, "BACKGROUND")
  431. _G[k].lag:SetHeight(24)
  432. _G[k].lag:SetWidth(0)
  433. _G[k].lag:SetPoint("RIGHT", _G[k], "RIGHT", 0, 0)
  434. _G[k].lag:SetTexture(1, 0, 0, 1)
  435. end;
  436. end;
  437.  
  438. if db.castbar[k].enableTimer then
  439. _G[k].timer = _G[k]:CreateFontString(nil);
  440. _G[k].timer:SetFont(db.fontNormal, db.fontSize, "");
  441. _G[k].timer:SetPoint("RIGHT", _G[k], "RIGHT", -5, 0);
  442. _G[k].update = .1;
  443. end;
  444.  
  445. a:SetPoint(db.castbar[k].relAnchor,"UIParent",db.castbar[k].selfAnchor, scale(db.castbar[k].offSetX),scale(db.castbar[k].offSetY))
  446.  
  447. a:SetWidth(d.w); a:SetHeight(d.h);
  448. a:SetBackdropColor(.1, .1, .1, .95);
  449. a:SetBackdrop({
  450. bgFile = db.castbar.background,
  451. edgeFile = db.castbar.border,
  452. tile = true, tileSize = 16, edgeSize = 15,
  453. insets = {left = 3, right = 3, top = 3, bottom = 3}
  454. })
  455. if db.classcolor == true then
  456. a:SetBackdropBorderColor(ccolor.r, ccolor.g, ccolor.b)
  457. end
  458. a:SetParent(_G[k]);
  459. a:SetMovable(true);
  460. a:EnableMouse(false);
  461. a:RegisterForDrag("LeftButton");
  462. a:SetScript("OnDragStart", function(self) self:StartMoving() end);
  463. a:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end);
  464. a.name = a:CreateFontString(nil, "OVERLAY");
  465. a.name:SetFont(db.fontNormal, db.fontSize, "");
  466. a.name:SetPoint("CENTER", a);
  467. _G[k].d = d; _G[k].df = a; _G[k].name = a.name; _G[k].l = true;
  468.  
  469. hooksecurefunc(_G[k], "Show", function() Set(a, k) end);
  470. end;
  471. end;
  472.  
  473. hooksecurefunc("CastingBarFrame_OnUpdate", function(self, elapsed)
  474. if not self.timer then return end
  475. if self.update and self.update < elapsed then
  476. if self.casting then
  477. self.timer:SetText(format("(%.1f)", max(self.maxValue - self.value, 0)))
  478. elseif self.channeling then
  479. self.timer:SetText(format("(%.1f)", max(self.value, 0)))
  480. else
  481. self.timer:SetText("")
  482. end
  483. self.update = .1
  484. else
  485. self.update = self.update - elapsed
  486. end
  487. end)
  488. UIPARENT_MANAGED_FRAME_POSITIONS["CastingBarFrame"] = nil;
  489. end
  490.  
  491. ---------------
  492. -- Actionbar --
  493. ---------------
  494. function BasicUI:Actionbar()
  495. local db = BasicUI.db.profile
  496. local ccolor = RAID_CLASS_COLORS[select(2, UnitClass("player"))]
  497. -- Hide Keybindings
  498. if db.buttons.showHotKeys ~= true then
  499. for i=1, 12 do
  500. _G["ActionButton"..i.."HotKey"]:SetAlpha(0) -- main bar
  501. _G["MultiBarBottomRightButton"..i.."HotKey"]:SetAlpha(0) -- bottom right bar
  502. _G["MultiBarBottomLeftButton"..i.."HotKey"]:SetAlpha(0) -- bottom left bar
  503. _G["MultiBarRightButton"..i.."HotKey"]:SetAlpha(0) -- right bar
  504. _G["MultiBarLeftButton"..i.."HotKey"]:SetAlpha(0) -- left bar
  505. end
  506. end
  507.  
  508. -- Hide Macros
  509. if db.buttons.showMacronames ~= true then
  510. for i=1, 12 do
  511. _G["ActionButton"..i.."Name"]:SetAlpha(0) -- main bar
  512. _G["MultiBarBottomRightButton"..i.."Name"]:SetAlpha(0) -- bottom right bar
  513. _G["MultiBarBottomLeftButton"..i.."Name"]:SetAlpha(0) -- bottom left bar
  514. _G["MultiBarRightButton"..i.."Name"]:SetAlpha(0) -- right bar
  515. _G["MultiBarLeftButton"..i.."Name"]:SetAlpha(0) -- left bar
  516. end
  517. end
  518.  
  519. hooksecurefunc('ActionButton_UpdateUsable', function(self)
  520. if (IsAddOnLoaded('RedRange') or IsAddOnLoaded('GreenRange') or IsAddOnLoaded('tullaRange') or IsAddOnLoaded('RangeColors')) then
  521. return
  522. end
  523.  
  524. local isUsable, notEnoughMana = IsUsableAction(self.action)
  525. if (isUsable) then
  526. _G[self:GetName()..'Icon']:SetVertexColor(1, 1, 1)
  527. elseif (notEnoughMana) then
  528. _G[self:GetName()..'Icon']:SetVertexColor(db.buttons.color.OutOfMana.r,db.buttons.color.OutOfMana.g,db.buttons.color.OutOfMana.b)
  529. else
  530. _G[self:GetName()..'Icon']:SetVertexColor(db.buttons.color.NotUsable.r, db.buttons.color.NotUsable.g, db.buttons.color.NotUsable.b)
  531. end
  532. end)
  533.  
  534. -- BetterBlizzardButtonBorder v1.1.1
  535. -- By Aprikot - http://aprikot.wowinterface.com
  536. -- Based upon functions within nMainbar by Neal, and thek: Buttonskin by thek
  537.  
  538. -- Functions
  539. hooksecurefunc("ActionButton_Update", function(self)
  540. if self:GetName():match("ExtraActionButton") then return end
  541. local bu = _G[self:GetName()]
  542. local ic = _G[self:GetName().."Icon"]
  543. local bo = _G[self:GetName().."NormalTexture"]
  544. bu:SetNormalTexture("Interface\\BUTTONS\\UI-Quickslot2")
  545. ic:SetTexCoord(.05, .95, .05, .95);
  546. ic:SetPoint("TOPLEFT", bu, 0, 0);
  547. ic:SetPoint("BOTTOMRIGHT", bu, 0, 0);
  548. bo:ClearAllPoints()
  549. bo:SetPoint("TOPLEFT", bu, -14, 14)
  550. bo:SetPoint("BOTTOMRIGHT", bu, 14, -14)
  551. if db.classcolor ~= true then
  552. bo:SetVertexColor(db.buttons.color.r, db.buttons.color.g, db.buttons.color.b)
  553. else
  554. bo:SetVertexColor((ccolor.r * 1.2), (ccolor.g * 1.2), (ccolor.b * 1.2))
  555. end
  556. end);
  557.  
  558. hooksecurefunc("ActionButton_UpdateUsable", function(self)
  559. if self:GetName():match("ExtraActionButton") then return end
  560. if db.classcolor ~= true then
  561. (_G[self:GetName().."NormalTexture"]):SetVertexColor(db.buttons.color.r, db.buttons.color.g, db.buttons.color.b)
  562. else
  563. (_G[self:GetName().."NormalTexture"]):SetVertexColor((ccolor.r * 1.2), (ccolor.g * 1.2), (ccolor.b * 1.2))
  564. end
  565. end);
  566.  
  567. hooksecurefunc("ActionButton_ShowGrid", function(self)
  568. if self:GetName():match("ExtraActionButton") then return end
  569. if db.classcolor ~= true then
  570. (_G[self:GetName().."NormalTexture"]):SetVertexColor(db.buttons.color.r, db.buttons.color.g, db.buttons.color.b)
  571. else
  572. (_G[self:GetName().."NormalTexture"]):SetVertexColor((ccolor.r * 1.2), (ccolor.g * 1.2), (ccolor.b * 1.2))
  573. end
  574. end);
  575.  
  576. hooksecurefunc("PetActionBar_Update", function()
  577. for i, v in pairs({"PetActionButton", "ShapeshiftButton", "PossessButton"}) do
  578. for i = 1, 12 do
  579. local bu = _G[v..i]
  580. if bu then
  581. bu:SetNormalTexture("Interface\\BUTTONS\\UI-Quickslot2")
  582. local ic = _G[v..i.."Icon"];
  583. ic:SetTexCoord(.05, .95, .05, .95);
  584. ic:SetPoint("TOPLEFT", bu, -1, 1);
  585. ic:SetPoint("BOTTOMRIGHT", bu, 1, -1);
  586. local bo = _G[v..i.."NormalTexture2"] or _G[v..i.."NormalTexture"]
  587. bo:ClearAllPoints()
  588. bo:SetPoint("TOPLEFT", bu, -15, 15)
  589. bo:SetPoint("BOTTOMRIGHT", bu, 15, -15)
  590. if db.classcolor ~= true then
  591. bo:SetVertexColor(db.buttons.color.r, db.buttons.color.g, db.buttons.color.b)
  592. else
  593. bo:SetVertexColor((ccolor.r * 1.2), (ccolor.g * 1.2), (ccolor.b * 1.2))
  594. end
  595. end
  596. end
  597. end
  598. end);
  599.  
  600. hooksecurefunc("AuraButton_Update", function(self, index)
  601. if db.buttons.auraborder then
  602. local bu = _G[self..index]
  603. local ic = _G[self..index.."Icon"]
  604. local bo = _G[self..index.."Border"]
  605. if ic then
  606. ic:SetTexCoord(.07, .93, .07, .93);
  607. end
  608. if bo then
  609. bo:SetTexture("Interface\\BUTTONS\\UI-Quickslot2")
  610. bo:ClearAllPoints()
  611. bo:SetPoint("TOPLEFT", bu, -12, 12)
  612. bo:SetPoint("BOTTOMRIGHT", bu, 12, -12)
  613. bo:SetTexCoord(0, 1, 0, 1)
  614. if db.classcolor ~= true then
  615. bo:SetVertexColor(db.color.r, db.color.g, db.color.b)
  616. else
  617. bo:SetVertexColor((ccolor.r * 1.2), (ccolor.g * 1.2), (ccolor.b * 1.2))
  618. end
  619. end
  620. if bu and not bo then
  621. nbo = bu:CreateTexture("$parentOverlay", "ARTWORK")
  622. nbo:SetParent(bu)
  623. nbo:SetTexture("Interface\\BUTTONS\\UI-Quickslot2")
  624. nbo:SetPoint("TOPLEFT", bu, -12, 12)
  625. nbo:SetPoint("BOTTOMRIGHT", bu, 12, -12)
  626. if db.classcolor ~= true then
  627. nbo:SetVertexColor(db.buttons.color.r, db.buttons.color.g, db.buttons.color.b)
  628. else
  629. nbo:SetVertexColor((ccolor.r * 1.2), (ccolor.g * 1.2), (ccolor.b * 1.2))
  630. end
  631. end
  632. end
  633. end);
  634.  
  635. function ActionButton_OnUpdate(self, elapsed)
  636. if (IsAddOnLoaded('RedRange') or IsAddOnLoaded('GreenRange') or IsAddOnLoaded('tullaRange') or IsAddOnLoaded('RangeColors')) then
  637. return
  638. end
  639.  
  640. if (ActionButton_IsFlashing(self)) then
  641. local flashtime = self.flashtime
  642. flashtime = flashtime - elapsed
  643.  
  644. if (flashtime <= 0) then
  645. local overtime = - flashtime
  646. if (overtime >= ATTACK_BUTTON_FLASH_TIME) then
  647. overtime = 0
  648. end
  649.  
  650. flashtime = ATTACK_BUTTON_FLASH_TIME - overtime
  651.  
  652. local flashTexture = _G[self:GetName()..'Flash']
  653. if (flashTexture:IsShown()) then
  654. flashTexture:Hide()
  655. else
  656. flashTexture:Show()
  657. end
  658. end
  659.  
  660. self.flashtime = flashtime
  661. end
  662.  
  663. local rangeTimer = self.rangeTimer
  664. if (rangeTimer) then
  665. rangeTimer = rangeTimer - elapsed
  666. if (rangeTimer <= 0.1) then
  667. local isInRange = false
  668. if (ActionHasRange(self.action) and IsActionInRange(self.action) == 0) then
  669. _G[self:GetName()..'Icon']:SetVertexColor(db.buttons.color.OutOfRange.r, db.buttons.color.OutOfRange.g, db.buttons.color.OutOfRange.b)
  670. isInRange = true
  671. end
  672.  
  673. if (self.isInRange ~= isInRange) then
  674. self.isInRange = isInRange
  675. ActionButton_UpdateUsable(self)
  676. end
  677.  
  678. rangeTimer = TOOLTIP_UPDATE_TIME
  679. end
  680.  
  681. self.rangeTimer = rangeTimer
  682. end
  683. end
  684. end
  685.  
  686. -----------
  687. -- Buffs --
  688. -----------
  689. function BasicUI:Buff()
  690. BuffFrame:ClearAllPoints()
  691. BuffFrame:SetScale(1.19)
  692. BuffFrame:SetPoint('TOPRIGHT', Minimap, 'TOPLEFT', -25, 0)
  693. end
  694.  
  695. ----------
  696. -- Chat --
  697. ----------
  698. function BasicUI:Chat()
  699. local db = BasicUI.db.profile
  700. local ccolor = RAID_CLASS_COLORS[select(2, UnitClass("player"))]
  701. -- Chat Message Groups
  702. ChatFrame_RemoveAllMessageGroups(ChatFrame1)
  703. ChatFrame_AddMessageGroup(ChatFrame1, "SAY")
  704. ChatFrame_AddMessageGroup(ChatFrame1, "EMOTE")
  705. ChatFrame_AddMessageGroup(ChatFrame1, "YELL")
  706. ChatFrame_AddMessageGroup(ChatFrame1, "GUILD")
  707. ChatFrame_AddMessageGroup(ChatFrame1, "OFFICER")
  708. ChatFrame_AddMessageGroup(ChatFrame1, "GUILD_ACHIEVEMENT")
  709. ChatFrame_AddMessageGroup(ChatFrame1, "MONSTER_SAY")
  710. ChatFrame_AddMessageGroup(ChatFrame1, "MONSTER_EMOTE")
  711. ChatFrame_AddMessageGroup(ChatFrame1, "MONSTER_YELL")
  712. ChatFrame_AddMessageGroup(ChatFrame1, "MONSTER_BOSS_EMOTE")
  713. ChatFrame_AddMessageGroup(ChatFrame1, "PARTY")
  714. ChatFrame_AddMessageGroup(ChatFrame1, "PARTY_LEADER")
  715. ChatFrame_AddMessageGroup(ChatFrame1, "RAID")
  716. ChatFrame_AddMessageGroup(ChatFrame1, "RAID_LEADER")
  717. ChatFrame_AddMessageGroup(ChatFrame1, "RAID_WARNING")
  718. ChatFrame_AddMessageGroup(ChatFrame1, "INSTANCE_CHAT")
  719. ChatFrame_AddMessageGroup(ChatFrame1, "INSTANCE_CHAT_LEADER")
  720. ChatFrame_AddMessageGroup(ChatFrame1, "BATTLEGROUND")
  721. ChatFrame_AddMessageGroup(ChatFrame1, "BATTLEGROUND_LEADER")
  722. ChatFrame_AddMessageGroup(ChatFrame1, "BG_HORDE")
  723. ChatFrame_AddMessageGroup(ChatFrame1, "BG_ALLIANCE")
  724. ChatFrame_AddMessageGroup(ChatFrame1, "BG_NEUTRAL")
  725. ChatFrame_AddMessageGroup(ChatFrame1, "SYSTEM")
  726. ChatFrame_AddMessageGroup(ChatFrame1, "ERRORS")
  727. ChatFrame_AddMessageGroup(ChatFrame1, "AFK")
  728. ChatFrame_AddMessageGroup(ChatFrame1, "DND")
  729. ChatFrame_AddMessageGroup(ChatFrame1, "IGNORED")
  730. ChatFrame_AddMessageGroup(ChatFrame1, "ACHIEVEMENT")
  731. ChatFrame_AddMessageGroup(ChatFrame1, "COMBAT_FACTION_CHANGE")
  732. ChatFrame_AddMessageGroup(ChatFrame1, "SKILL")
  733. ChatFrame_AddMessageGroup(ChatFrame1, "LOOT")
  734. ChatFrame_AddMessageGroup(ChatFrame1, "MONEY")
  735. ChatFrame_AddMessageGroup(ChatFrame1, "COMBAT_XP_GAIN")
  736. ChatFrame_AddMessageGroup(ChatFrame1, "COMBAT_HONOR_GAIN")
  737. ChatFrame_AddMessageGroup(ChatFrame1, "COMBAT_GUILD_XP_GAIN")
  738. ChatFrame_AddMessageGroup(ChatFrame1, "BN_INLINE_TOAST_ALERT")
  739.  
  740.  
  741. ChatFrame_RemoveAllMessageGroups(ChatFrame3)
  742. ChatFrame_AddMessageGroup(ChatFrame3, "WHISPER")
  743. ChatFrame_AddMessageGroup(ChatFrame3, "BN_WHISPER")
  744. ChatFrame_AddMessageGroup(ChatFrame3, "BN_CONVERSATION")
  745.  
  746.  
  747.  
  748. -- enable classcolor automatically on login and on each character without doing /configure each time.
  749. ToggleChatColorNamesByClassGroup(true, "SAY")
  750. ToggleChatColorNamesByClassGroup(true, "EMOTE")
  751. ToggleChatColorNamesByClassGroup(true, "YELL")
  752. ToggleChatColorNamesByClassGroup(true, "GUILD")
  753. ToggleChatColorNamesByClassGroup(true, "OFFICER")
  754. ToggleChatColorNamesByClassGroup(true, "GUILD_ACHIEVEMENT")
  755. ToggleChatColorNamesByClassGroup(true, "ACHIEVEMENT")
  756. ToggleChatColorNamesByClassGroup(true, "WHISPER")
  757. ToggleChatColorNamesByClassGroup(true, "PARTY")
  758. ToggleChatColorNamesByClassGroup(true, "PARTY_LEADER")
  759. ToggleChatColorNamesByClassGroup(true, "RAID")
  760. ToggleChatColorNamesByClassGroup(true, "RAID_LEADER")
  761. ToggleChatColorNamesByClassGroup(true, "RAID_WARNING")
  762. ToggleChatColorNamesByClassGroup(true, "BATTLEGROUND")
  763. ToggleChatColorNamesByClassGroup(true, "BATTLEGROUND_LEADER")
  764. ToggleChatColorNamesByClassGroup(true, "INSTANCE_CHAT")
  765. ToggleChatColorNamesByClassGroup(true, "INSTANCE_CHAT_LEADER")
  766. ToggleChatColorNamesByClassGroup(true, "CHANNEL1")
  767. ToggleChatColorNamesByClassGroup(true, "CHANNEL2")
  768. ToggleChatColorNamesByClassGroup(true, "CHANNEL3")
  769. ToggleChatColorNamesByClassGroup(true, "CHANNEL4")
  770. ToggleChatColorNamesByClassGroup(true, "CHANNEL5")
  771. ToggleChatColorNamesByClassGroup(true, "CHANNEL6")
  772. ToggleChatColorNamesByClassGroup(true, "CHANNEL7")
  773. ToggleChatColorNamesByClassGroup(true, "CHANNEL8")
  774. ToggleChatColorNamesByClassGroup(true, "CHANNEL9")
  775. ToggleChatColorNamesByClassGroup(true, "CHANNEL10")
  776. ToggleChatColorNamesByClassGroup(true, "CHANNEL11")
  777.  
  778. local _G = _G
  779. local type = type
  780. local select = select
  781. local unpack = unpack
  782. local tostring = tostring
  783. local concat = table.concat
  784. local find = string.find
  785.  
  786. local gsub = string.gsub
  787. local format = string.format
  788.  
  789.  
  790. _G.CHAT_FRAME_TAB_SELECTED_MOUSEOVER_ALPHA = 1
  791. _G.CHAT_FRAME_TAB_SELECTED_NOMOUSE_ALPHA = 0
  792.  
  793. _G.CHAT_FRAME_TAB_NORMAL_MOUSEOVER_ALPHA = 0.5
  794. _G.CHAT_FRAME_TAB_NORMAL_NOMOUSE_ALPHA = 0
  795.  
  796.  
  797. _G.CHAT_FONT_HEIGHTS = {
  798. [1] = 8,
  799. [2] = 9,
  800. [3] = 10,
  801. [4] = 11,
  802. [5] = 12,
  803. [6] = 13,
  804. [7] = 14,
  805. [8] = 15,
  806. [9] = 16,
  807. [10] = 17,
  808. [11] = 18,
  809. [12] = 19,
  810. [13] = 20,
  811. }
  812.  
  813.  
  814. _G.CHAT_FLAG_AFK = '[AFK] '
  815. _G.CHAT_FLAG_DND = '[DND] '
  816. _G.CHAT_FLAG_GM = '[GM] '
  817.  
  818. _G.CHAT_GUILD_GET = '(|Hchannel:Guild|hG|h) %s:\32'
  819. _G.CHAT_OFFICER_GET = '(|Hchannel:o|hO|h) %s:\32'
  820.  
  821. _G.CHAT_PARTY_GET = '(|Hchannel:party|hP|h) %s:\32'
  822. _G.CHAT_PARTY_LEADER_GET = '(|Hchannel:party|hPL|h) %s:\32'
  823. _G.CHAT_PARTY_GUIDE_GET = '(|Hchannel:party|hDG|h) %s:\32'
  824. _G.CHAT_MONSTER_PARTY_GET = '(|Hchannel:raid|hR|h) %s:\32'
  825.  
  826. _G.CHAT_RAID_GET = '(|Hchannel:raid|hR|h) %s:\32'
  827. _G.CHAT_RAID_WARNING_GET = '(RW!) %s:\32'
  828. _G.CHAT_RAID_LEADER_GET = '(|Hchannel:raid|hL|h) %s:\32'
  829.  
  830. _G.CHAT_BATTLEGROUND_GET = '(|Hchannel:Battleground|hBG|h) %s:\32'
  831. _G.CHAT_BATTLEGROUND_LEADER_GET = '(|Hchannel:Battleground|hBL|h) %s:\32'
  832.  
  833. _G.CHAT_INSTANCE_CHAT_GET = '|Hchannel:INSTANCE_CHAT|h[I]|h %s:\32';
  834. _G.CHAT_INSTANCE_CHAT_LEADER_GET = '|Hchannel:INSTANCE_CHAT|h[IL]|h %s:\32';
  835.  
  836.  
  837. local channelFormat
  838. do
  839. local a, b = '.*%[(.*)%].*', '%%[%1%%]'
  840. channelFormat = {
  841. [1] = {gsub(CHAT_BATTLEGROUND_GET, a, b), '[BG]'},
  842. [2] = {gsub(CHAT_BATTLEGROUND_LEADER_GET, a, b), '[BGL]'},
  843.  
  844. [3] = {gsub(CHAT_GUILD_GET, a, b), '[G]'},
  845. [4] = {gsub(CHAT_OFFICER_GET, a, b), '[O]'},
  846.  
  847. [5] = {gsub(CHAT_PARTY_GET, a, b), '[P]'},
  848. [6] = {gsub(CHAT_PARTY_LEADER_GET, a, b), '[PL]'},
  849. [7] = {gsub(CHAT_PARTY_GUIDE_GET, a, b), '[PL]'},
  850.  
  851. [8] = {gsub(CHAT_RAID_GET, a, b), '[R]'},
  852. [9] = {gsub(CHAT_RAID_LEADER_GET, a, b), '[RL]'},
  853. [10] = {gsub(CHAT_RAID_WARNING_GET, a, b), '[RW]'},
  854.  
  855. [11] = {gsub(CHAT_FLAG_AFK, a, b), '[AFK] '},
  856. [12] = {gsub(CHAT_FLAG_DND, a, b), '[DND] '},
  857. [13] = {gsub(CHAT_FLAG_GM, a, b), '[GM] '},
  858. }
  859. end
  860.  
  861.  
  862. local AddMessage = ChatFrame1.AddMessage
  863. local function FCF_AddMessage(self, text, ...)
  864. if (type(text) == 'string') then
  865. text = gsub(text, '(|HBNplayer.-|h)%[(.-)%]|h', '%1%2|h')
  866. text = gsub(text, '(|Hplayer.-|h)%[(.-)%]|h', '%1%2|h')
  867. text = gsub(text, '%[(%d0?)%. (.-)%]', '[%1]')
  868.  
  869.  
  870. for i = 1, #channelFormat do
  871. text = gsub(text, channelFormat[i][1], channelFormat[i][2])
  872. end
  873.  
  874. end
  875.  
  876. return AddMessage(self, text, ...)
  877. end
  878.  
  879. -- Modify the editbox
  880.  
  881. for k = 6, 11 do
  882. select(k, ChatFrame1EditBox:GetRegions()):SetTexture(nil)
  883. end
  884.  
  885. ChatFrame1EditBox:SetAltArrowKeyMode(false)
  886. ChatFrame1EditBox:ClearAllPoints()
  887. ChatFrame1EditBox:SetFont(db.fontNormal, db.fontSize)
  888. ChatFrame1EditBox:SetPoint('BOTTOMLEFT', ChatFrame1, 'TOPLEFT', 2, 33)
  889. ChatFrame1EditBox:SetPoint('BOTTOMRIGHT', ChatFrame1, 'TOPRIGHT', 0, 33)
  890. ChatFrame1EditBox:SetBackdrop({
  891. bgFile = db.chat.editboxbackground,
  892. edgeFile = db.chat.editboxborder,
  893. tile = true, tileSize = 16, edgeSize = 18,
  894. insets = {left = 3, right = 3, top = 2, bottom = 3},
  895. })
  896.  
  897.  
  898. ChatFrame1EditBox:SetBackdropColor(0, 0, 0, 0.5)
  899.  
  900. if (db.chat.enableBorderColoring) then
  901.  
  902. hooksecurefunc('ChatEdit_UpdateHeader', function(editBox)
  903. local type = editBox:GetAttribute('chatType')
  904. if (not type) then
  905. return
  906. end
  907.  
  908. local info = ChatTypeInfo[type]
  909. ChatFrame1EditBox:SetBackdropBorderColor(info.r, info.g, info.b)
  910. end)
  911. end
  912.  
  913. -- Hide the menu and friend button
  914.  
  915. FriendsMicroButton:SetAlpha(0)
  916. FriendsMicroButton:EnableMouse(false)
  917. FriendsMicroButton:UnregisterAllEvents()
  918.  
  919. ChatFrameMenuButton:SetAlpha(0)
  920. ChatFrameMenuButton:EnableMouse(false)
  921.  
  922. -- Tab text colors for the tabs
  923.  
  924. hooksecurefunc('FCFTab_UpdateColors', function(self, selected)
  925. if (selected) then
  926. self:GetFontString():SetTextColor(0, 0.75, 1)
  927. else
  928. self:GetFontString():SetTextColor(1, 1, 1)
  929. end
  930. end)
  931.  
  932. -- Tab text fadeout
  933.  
  934. local origFCF_FadeOutChatFrame = _G.FCF_FadeOutChatFrame
  935. local function FCF_FadeOutChatFrameHook(chatFrame)
  936. origFCF_FadeOutChatFrame(chatFrame)
  937.  
  938. local frameName = chatFrame:GetName()
  939. local chatTab = _G[frameName..'Tab']
  940. local tabGlow = _G[frameName..'TabGlow']
  941.  
  942. if (not tabGlow:IsShown()) then
  943. if (frameName.isDocked) then
  944. securecall('UIFrameFadeOut', chatTab, CHAT_FRAME_FADE_OUT_TIME, chatTab:GetAlpha(), CHAT_FRAME_TAB_NORMAL_NOMOUSE_ALPHA)
  945. else
  946. securecall('UIFrameFadeOut', chatTab, CHAT_FRAME_FADE_OUT_TIME, chatTab:GetAlpha(), CHAT_FRAME_TAB_NORMAL_NOMOUSE_ALPHA)
  947. end
  948. end
  949. end
  950. FCF_FadeOutChatFrame = FCF_FadeOutChatFrameHook
  951.  
  952. -- Improve mousewheel scrolling
  953.  
  954. hooksecurefunc('FloatingChatFrame_OnMouseScroll', function(self, direction)
  955. if (direction > 0) then
  956. if (IsShiftKeyDown()) then
  957. self:ScrollToTop()
  958. else
  959. self:ScrollUp()
  960. self:ScrollUp()
  961. end
  962. elseif (direction < 0) then
  963. if (IsShiftKeyDown()) then
  964. self:ScrollToBottom()
  965. else
  966. self:ScrollDown()
  967. self:ScrollDown()
  968. end
  969. end
  970.  
  971. if (db.chat.enableBottomButton) then
  972. local buttonBottom = _G[self:GetName() .. 'ButtonFrameBottomButton']
  973. if (self:AtBottom()) then
  974. buttonBottom:SetAlpha(0)
  975. buttonBottom:EnableMouse(false)
  976. else
  977. buttonBottom:SetAlpha(0.7)
  978. buttonBottom:EnableMouse(true)
  979. end
  980. end
  981. end)
  982.  
  983. -- Reposit toast frame
  984.  
  985. BNToastFrame:HookScript('OnShow', function(self)
  986. BNToastFrame:ClearAllPoints()
  987. BNToastFrame:SetPoint('BOTTOMLEFT', ChatFrame1EditBox, 'TOPLEFT', 0, 15)
  988. end)
  989.  
  990. -- Modify the chat tabs
  991.  
  992. function SkinTab(self)
  993. local chat = _G[self]
  994.  
  995. local tab = _G[self..'Tab']
  996. for i = 1, select('#', tab:GetRegions()) do
  997. local texture = select(i, tab:GetRegions())
  998. if (texture and texture:GetObjectType() == 'Texture') then
  999. texture:SetTexture(nil)
  1000. end
  1001. end
  1002.  
  1003. local tabText = _G[self..'TabText']
  1004. tabText:SetJustifyH('CENTER')
  1005. tabText:SetWidth(60)
  1006. if (db.chat.tab.fontOutline) then
  1007. tabText:SetFont(db.fontBold, db.fontSize, 'THINOUTLINE')
  1008. tabText:SetShadowOffset(0, 0)
  1009. else
  1010. tabText:SetFont(db.fontBold, db.fontLarge)
  1011. tabText:SetShadowOffset(1, -1)
  1012. end
  1013.  
  1014. local a1, a2, a3, a4, a5 = tabText:GetPoint()
  1015. tabText:SetPoint(a1, a2, a3, a4, 1)
  1016.  
  1017. local s1, s2, s3 = db.chat.tab.specialColor.r, db.chat.tab.specialColor.g, db.chat.tab.specialColor.b
  1018. local e1, e2, e3 = db.chat.tab.selectedColor.r, db.chat.tab.selectedColor.g, db.chat.tab.selectedColor.b
  1019. local n1, n2, n3 = db.chat.tab.normalColor.r, db.chat.tab.normalColor.g, db.chat.tab.normalColor.b
  1020.  
  1021. local tabGlow = _G[self..'TabGlow']
  1022. hooksecurefunc(tabGlow, 'Show', function()
  1023. tabText:SetTextColor(s1, s2, s3, CHAT_FRAME_TAB_NORMAL_MOUSEOVER_ALPHA)
  1024. end)
  1025.  
  1026. hooksecurefunc(tabGlow, 'Hide', function()
  1027. tabText:SetTextColor(n1, n2, n3)
  1028. end)
  1029.  
  1030. tab:SetScript('OnEnter', function()
  1031. tabText:SetTextColor(s1, s2, s3, tabText:GetAlpha())
  1032. end)
  1033.  
  1034. tab:SetScript('OnLeave', function()
  1035. local hasNofication = tabGlow:IsShown()
  1036.  
  1037. local r, g, b
  1038. if (_G[self] == SELECTED_CHAT_FRAME and chat.isDocked) then
  1039. r, g, b = e1, e2, e3
  1040. elseif (hasNofication) then
  1041. r, g, b = s1, s2, s3
  1042. else
  1043. r, g, b = n1, n2, n3
  1044. end
  1045.  
  1046. tabText:SetTextColor(r, g, b)
  1047. end)
  1048.  
  1049. hooksecurefunc(tab, 'Show', function()
  1050. if (not tab.wasShown) then
  1051. local hasNofication = tabGlow:IsShown()
  1052.  
  1053. if (chat:IsMouseOver()) then
  1054. tab:SetAlpha(CHAT_FRAME_TAB_NORMAL_MOUSEOVER_ALPHA)
  1055. else
  1056. tab:SetAlpha(CHAT_FRAME_TAB_NORMAL_NOMOUSE_ALPHA)
  1057. end
  1058.  
  1059. local r, g, b
  1060. if (_G[self] == SELECTED_CHAT_FRAME and chat.isDocked) then
  1061. r, g, b = e1, e2, e3
  1062. elseif (hasNofication) then
  1063. r, g, b = s1, s2, s3
  1064. else
  1065. r, g, b = n1, n2, n3
  1066. end
  1067.  
  1068. tabText:SetTextColor(r, g, b)
  1069.  
  1070. tab.wasShown = true
  1071. end
  1072. end)
  1073. end
  1074.  
  1075. local function ModChat(self)
  1076. local chat = _G[self]
  1077.  
  1078. if (not db.chat.chatOutline) then
  1079. chat:SetShadowOffset(1, -1)
  1080. end
  1081.  
  1082. if (db.chat.disableFade) then
  1083. chat:SetFading(false)
  1084. end
  1085.  
  1086. SkinTab(self)
  1087.  
  1088. local font, fontsize, fontflags = chat:GetFont()
  1089. chat:SetFont(db.fontNormal, fontsize, db.chat.chatOutline and 'THINOUTLINE' or fontflags)
  1090. chat:SetClampedToScreen(false)
  1091.  
  1092. chat:SetClampRectInsets(0, 0, 0, 0)
  1093. chat:SetMaxResize(UIParent:GetWidth(), UIParent:GetHeight())
  1094. chat:SetMinResize(150, 25)
  1095.  
  1096. if (self ~= 'ChatFrame2') then
  1097. chat.AddMessage = FCF_AddMessage
  1098. end
  1099.  
  1100. local buttonUp = _G[self..'ButtonFrameUpButton']
  1101. buttonUp:SetAlpha(0)
  1102. buttonUp:EnableMouse(false)
  1103.  
  1104. local buttonDown = _G[self..'ButtonFrameDownButton']
  1105. buttonDown:SetAlpha(0)
  1106. buttonDown:EnableMouse(false)
  1107.  
  1108. local buttonBottom = _G[self..'ButtonFrameBottomButton']
  1109. buttonBottom:SetAlpha(0)
  1110. buttonBottom:EnableMouse(false)
  1111.  
  1112. if (db.chat.enableBottomButton) then
  1113. buttonBottom:ClearAllPoints()
  1114. buttonBottom:SetPoint('BOTTOMRIGHT', chat, -1, -3)
  1115. buttonBottom:HookScript('OnClick', function(self)
  1116. self:SetAlpha(0)
  1117. self:EnableMouse(false)
  1118. end)
  1119. end
  1120.  
  1121. for _, texture in pairs({
  1122. 'ButtonFrameBackground',
  1123. 'ButtonFrameTopLeftTexture',
  1124. 'ButtonFrameBottomLeftTexture',
  1125. 'ButtonFrameTopRightTexture',
  1126. 'ButtonFrameBottomRightTexture',
  1127. 'ButtonFrameLeftTexture',
  1128. 'ButtonFrameRightTexture',
  1129. 'ButtonFrameBottomTexture',
  1130. 'ButtonFrameTopTexture',
  1131. }) do
  1132. _G[self..texture]:SetTexture(nil)
  1133. end
  1134. end
  1135.  
  1136. local function SetChatStyle()
  1137. for _, v in pairs(CHAT_FRAMES) do
  1138. local chat = _G[v]
  1139. if (chat and not chat.hasModification) then
  1140. ModChat(chat:GetName())
  1141.  
  1142. local convButton = _G[chat:GetName()..'ConversationButton']
  1143. if (convButton) then
  1144. convButton:SetAlpha(0)
  1145. convButton:EnableMouse(false)
  1146. end
  1147.  
  1148. local chatMinimize = _G[chat:GetName()..'ButtonFrameMinimizeButton']
  1149. if (chatMinimize) then
  1150. chatMinimize:SetAlpha(0)
  1151. chatMinimize:EnableMouse(0)
  1152. end
  1153.  
  1154. chat.hasModification = true
  1155. end
  1156. end
  1157. end
  1158. hooksecurefunc('FCF_OpenTemporaryWindow', SetChatStyle)
  1159. SetChatStyle()
  1160.  
  1161. -- Chat menu, just a middle click on the chatframe 1 tab
  1162.  
  1163. hooksecurefunc('ChatFrameMenu_UpdateAnchorPoint', function()
  1164. if (FCF_GetButtonSide(DEFAULT_CHAT_FRAME) == 'right') then
  1165. ChatMenu:ClearAllPoints()
  1166. ChatMenu:SetPoint('BOTTOMRIGHT', ChatFrame1Tab, 'TOPLEFT')
  1167. else
  1168. ChatMenu:ClearAllPoints()
  1169. ChatMenu:SetPoint('BOTTOMLEFT', ChatFrame1Tab, 'TOPRIGHT')
  1170. end
  1171. end)
  1172.  
  1173. ChatFrame1Tab:RegisterForClicks('AnyUp')
  1174. ChatFrame1Tab:HookScript('OnClick', function(self, button)
  1175. if (button == 'MiddleButton' or button == 'Button4' or button == 'Button5') then
  1176. if (ChatMenu:IsShown()) then
  1177. ChatMenu:Hide()
  1178. else
  1179. ChatMenu:Show()
  1180. end
  1181. else
  1182. ChatMenu:Hide()
  1183. end
  1184. end)
  1185.  
  1186. -- Modify the gm chatframe and add a sound notification on incoming whispers
  1187.  
  1188. local f = CreateFrame('Frame')
  1189. f:RegisterEvent('ADDON_LOADED')
  1190. f:RegisterEvent('CHAT_MSG_WHISPER')
  1191. f:RegisterEvent('CHAT_MSG_BN_WHISPER')
  1192. f:SetScript('OnEvent', function(_, event)
  1193. if (event == 'ADDON_LOADED' and arg1 == 'Blizzard_GMChatUI') then
  1194. GMChatFrame:EnableMouseWheel(true)
  1195. GMChatFrame:SetScript('OnMouseWheel', ChatFrame1:GetScript('OnMouseWheel'))
  1196. GMChatFrame:SetHeight(200)
  1197.  
  1198. GMChatFrameUpButton:SetAlpha(0)
  1199. GMChatFrameUpButton:EnableMouse(false)
  1200.  
  1201. GMChatFrameDownButton:SetAlpha(0)
  1202. GMChatFrameDownButton:EnableMouse(false)
  1203.  
  1204. GMChatFrameBottomButton:SetAlpha(0)
  1205. GMChatFrameBottomButton:EnableMouse(false)
  1206. end
  1207.  
  1208. if (event == 'CHAT_MSG_WHISPER' or event == 'CHAT_MSG_BN_WHISPER') then
  1209. PlaySoundFile(db.chat.sound)
  1210. end
  1211. end)
  1212.  
  1213. local combatLog = {
  1214. text = 'CombatLog',
  1215. colorCode = '|cffFFD100',
  1216. isNotRadio = true,
  1217.  
  1218. func = function()
  1219. if (not LoggingCombat()) then
  1220. LoggingCombat(true)
  1221. DEFAULT_CHAT_FRAME:AddMessage(COMBATLOGENABLED, 1, 1, 0)
  1222. else
  1223. LoggingCombat(false)
  1224. DEFAULT_CHAT_FRAME:AddMessage(COMBATLOGDISABLED, 1, 1, 0)
  1225. end
  1226. end,
  1227.  
  1228. checked = function()
  1229. if (LoggingCombat()) then
  1230. return true
  1231. else
  1232. return false
  1233. end
  1234. end
  1235. }
  1236.  
  1237. local chatLog = {
  1238. text = 'ChatLog',
  1239. colorCode = '|cffFFD100',
  1240. isNotRadio = true,
  1241.  
  1242. func = function()
  1243. if (not LoggingChat()) then
  1244. LoggingChat(true)
  1245. DEFAULT_CHAT_FRAME:AddMessage(CHATLOGENABLED, 1, 1, 0)
  1246. else
  1247. LoggingChat(false)
  1248. DEFAULT_CHAT_FRAME:AddMessage(CHATLOGDISABLED, 1, 1, 0)
  1249. end
  1250. end,
  1251.  
  1252. checked = function()
  1253. if (LoggingChat()) then
  1254. return true
  1255. else
  1256. return false
  1257. end
  1258. end
  1259. }
  1260.  
  1261. local origFCF_Tab_OnClick = _G.FCF_Tab_OnClick
  1262. local function FCF_Tab_OnClickHook(chatTab, ...)
  1263. origFCF_Tab_OnClick(chatTab, ...)
  1264.  
  1265. combatLog.arg1 = chatTab
  1266. UIDropDownMenu_AddButton(combatLog)
  1267.  
  1268. chatLog.arg1 = chatTab
  1269. UIDropDownMenu_AddButton(chatLog)
  1270. end
  1271. FCF_Tab_OnClick = FCF_Tab_OnClickHook
  1272.  
  1273.  
  1274. -- Chat Copy
  1275.  
  1276. local f = CreateFrame('Frame', nil, UIParent)
  1277. f:SetHeight(220)
  1278. f:SetBackdropColor(0, 0, 0, 1)
  1279. f:SetPoint('BOTTOMLEFT', ChatFrame1EditBox, 'TOPLEFT', 3, 10)
  1280. f:SetPoint('BOTTOMRIGHT', ChatFrame1EditBox, 'TOPRIGHT', -3, 10)
  1281. f:SetFrameStrata('DIALOG')
  1282. f:SetBackdrop({
  1283. bgFile = db.chat.background,
  1284. edgeFile = db.chat.border,
  1285. tile = true, tileSize = 16, edgeSize = 18,
  1286. insets = {left = 3, right = 3, top = 3, bottom = 3
  1287. }})
  1288. f:SetBackdropBorderColor(ccolor.r, ccolor.g, ccolor.b)
  1289. f:Hide()
  1290.  
  1291. f.t = f:CreateFontString(nil, 'OVERLAY')
  1292. f.t:SetFont(db.fontNormal, db.fontSize)
  1293. f.t:SetPoint('TOPLEFT', f, 8, -8)
  1294. f.t:SetTextColor(1, 1, 0)
  1295. f.t:SetShadowOffset(1, -1)
  1296. f.t:SetJustifyH('LEFT')
  1297.  
  1298. f.b = CreateFrame('EditBox', nil, f)
  1299. f.b:SetMultiLine(true)
  1300. f.b:SetMaxLetters(20000)
  1301. f.b:SetSize(450, 270)
  1302. f.b:SetScript('OnEscapePressed', function()
  1303. f:Hide()
  1304. end)
  1305.  
  1306. f.s = CreateFrame('ScrollFrame', '$parentScrollBar', f, 'UIPanelScrollFrameTemplate')
  1307. f.s:SetPoint('TOPLEFT', f, 'TOPLEFT', 8, -30)
  1308. f.s:SetPoint('BOTTOMRIGHT', f, 'BOTTOMRIGHT', -30, 8)
  1309. f.s:SetScrollChild(f.b)
  1310.  
  1311. f.c = CreateFrame('Button', nil, f, 'UIPanelCloseButton')
  1312. f.c:SetPoint('TOPRIGHT', f, 'TOPRIGHT', 0, -1)
  1313.  
  1314. local lines = {}
  1315. local function GetChatLines(...)
  1316. local count = 1
  1317. for i = select('#', ...), 1, -1 do
  1318. local region = select(i, ...)
  1319. if (region:GetObjectType() == 'FontString') then
  1320. lines[count] = tostring(region:GetText())
  1321. count = count + 1
  1322. end
  1323. end
  1324.  
  1325. return count - 1
  1326. end
  1327.  
  1328. local function copyChat(self)
  1329. local chat = _G[self:GetName()]
  1330. local _, fontSize = chat:GetFont()
  1331.  
  1332. FCF_SetChatWindowFontSize(self, chat, 0.1)
  1333. local lineCount = GetChatLines(chat:GetRegions())
  1334. FCF_SetChatWindowFontSize(self, chat, fontSize)
  1335.  
  1336. if (lineCount > 0) then
  1337. ToggleFrame(f)
  1338. f.t:SetText(chat:GetName())
  1339.  
  1340. local f1, f2, f3 = ChatFrame1:GetFont()
  1341. f.b:SetFont(f1, f2, f3)
  1342.  
  1343. local text = concat(lines, '\n', 1, lineCount)
  1344. f.b:SetText(text)
  1345. end
  1346. end
  1347.  
  1348. local function CreateCopyButton(self)
  1349. self.Copy = CreateFrame('Button', nil, _G[self:GetName()])
  1350. self.Copy:SetSize(20, 20)
  1351. self.Copy:SetPoint('TOPRIGHT', self, -5, -5)
  1352.  
  1353. self.Copy:SetNormalTexture'Interface\\AddOns\\BasicUI\\Media\\textureCopyNormal'
  1354. self.Copy:GetNormalTexture():SetSize(20, 20)
  1355.  
  1356. self.Copy:SetHighlightTexture'Interface\\AddOns\\BasicUI\\Media\\textureCopyHighlight'
  1357. self.Copy:GetHighlightTexture():SetAllPoints(self.Copy:GetNormalTexture())
  1358.  
  1359. local tab = _G[self:GetName()..'Tab']
  1360. hooksecurefunc(tab, 'SetAlpha', function()
  1361. self.Copy:SetAlpha(tab:GetAlpha()*0.55)
  1362. end)
  1363.  
  1364. self.Copy:SetScript('OnMouseDown', function(self)
  1365. self:GetNormalTexture():ClearAllPoints()
  1366. self:GetNormalTexture():SetPoint('CENTER', 1, -1)
  1367. end)
  1368.  
  1369. self.Copy:SetScript('OnMouseUp', function()
  1370. self.Copy:GetNormalTexture():ClearAllPoints()
  1371. self.Copy:GetNormalTexture():SetPoint('CENTER')
  1372.  
  1373. if (self.Copy:IsMouseOver()) then
  1374. copyChat(self)
  1375. end
  1376. end)
  1377. end
  1378.  
  1379. local function EnableCopyButton()
  1380. for _, v in pairs(CHAT_FRAMES) do
  1381. local chat = _G[v]
  1382. if (chat and not chat.Copy) then
  1383. CreateCopyButton(chat)
  1384. end
  1385. end
  1386. end
  1387. hooksecurefunc('FCF_OpenTemporaryWindow', EnableCopyButton)
  1388. EnableCopyButton()
  1389.  
  1390. -- Copy URL
  1391.  
  1392. local urlStyle = '|cffff00ff|Hurl:%1|h%1|h|r'
  1393. local urlPatterns = {
  1394. '(http://%S+)', -- http://xxx.com
  1395. '(www%.%S+)', -- www.xxx.com/site/index.php
  1396. '(%d+%.%d+%.%d+%.%d+:?%d*)', -- 192.168.1.1 / 192.168.1.1:1110
  1397. }
  1398.  
  1399. local messageTypes = {
  1400. 'CHAT_MSG_CHANNEL',
  1401. 'CHAT_MSG_GUILD',
  1402. 'CHAT_MSG_PARTY',
  1403. 'CHAT_MSG_RAID',
  1404. 'CHAT_MSG_SAY',
  1405. 'CHAT_MSG_WHISPER',
  1406. }
  1407.  
  1408. local function urlFilter(self, event, text, ...)
  1409. for _, pattern in ipairs(urlPatterns) do
  1410. local result, matches = gsub(text, pattern, urlStyle)
  1411.  
  1412. if (matches > 0) then
  1413. return false, result, ...
  1414. end
  1415. end
  1416. end
  1417.  
  1418. for _, event in ipairs(messageTypes) do
  1419. ChatFrame_AddMessageEventFilter(event, urlFilter)
  1420. end
  1421.  
  1422. local origSetItemRef = _G.SetItemRef
  1423. local currentLink
  1424. local SetItemRefHook = function(link, text, button)
  1425. if (link:sub(0, 3) == 'url') then
  1426. currentLink = link:sub(5)
  1427. StaticPopup_Show('UrlCopyDialog')
  1428. return
  1429. end
  1430.  
  1431. return origSetItemRef(link, text, button)
  1432. end
  1433.  
  1434. SetItemRef = SetItemRefHook
  1435.  
  1436. StaticPopupDialogs['UrlCopyDialog'] = {
  1437. text = 'URL',
  1438. button2 = CLOSE,
  1439. hasEditBox = 1,
  1440. editBoxWidth = 250,
  1441.  
  1442. OnShow = function(frame)
  1443. local editBox = _G[frame:GetName()..'EditBox']
  1444. if (editBox) then
  1445. editBox:SetText(currentLink)
  1446. editBox:SetFocus()
  1447. editBox:HighlightText(0)
  1448. end
  1449.  
  1450. local button = _G[frame:GetName()..'Button2']
  1451. if (button) then
  1452. button:ClearAllPoints()
  1453. button:SetWidth(100)
  1454. button:SetPoint('CENTER', editBox, 'CENTER', 0, -30)
  1455. end
  1456. end,
  1457.  
  1458. EditBoxOnEscapePressed = function(frame)
  1459. frame:GetParent():Hide()
  1460. end,
  1461.  
  1462. timeout = 0,
  1463. whileDead = 1,
  1464. hideOnEscape = 1,
  1465. maxLetters = 1024,
  1466. }
  1467.  
  1468. if db.chat.enableHyperlinkTooltip ~= true then return end
  1469.  
  1470. --[[
  1471.  
  1472. All Create for hyperlink.lua goes to Neal, ballagarba, and Tuks.
  1473. Neav UI = http://www.wowinterface.com/downloads/info13981-NeavUI.html.
  1474. Tukui = http://www.tukui.org/download.php.
  1475. Edited by Cokedriver.
  1476.  
  1477. ]]
  1478.  
  1479. local _G = getfenv(0)
  1480. local orig1, orig2 = {}, {}
  1481. local GameTooltip = GameTooltip
  1482.  
  1483. local linktypes = {
  1484. item = true,
  1485. enchant = true,
  1486. spell = true,
  1487. quest = true,
  1488. unit = true,
  1489. talent = true,
  1490. achievement = true,
  1491. glyph = true
  1492. }
  1493.  
  1494. local function OnHyperlinkEnter(frame, link, ...)
  1495. local linktype = link:match('^([^:]+)')
  1496. if (linktype and linktypes[linktype]) then
  1497. GameTooltip:SetOwner(ChatFrame1, 'ANCHOR_CURSOR', 0, 20)
  1498. GameTooltip:SetHyperlink(link)
  1499. GameTooltip:Show()
  1500. else
  1501. GameTooltip:Hide()
  1502. end
  1503.  
  1504. if (orig1[frame]) then
  1505. return orig1[frame](frame, link, ...)
  1506. end
  1507. end
  1508.  
  1509. local function OnHyperlinkLeave(frame, ...)
  1510. GameTooltip:Hide()
  1511.  
  1512. if (orig2[frame]) then
  1513. return orig2[frame](frame, ...)
  1514. end
  1515. end
  1516.  
  1517. local function EnableItemLinkTooltip()
  1518. for _, v in pairs(CHAT_FRAMES) do
  1519. local chat = _G[v]
  1520. if (chat and not chat.URLCopy) then
  1521. orig1[chat] = chat:GetScript('OnHyperlinkEnter')
  1522. chat:SetScript('OnHyperlinkEnter', OnHyperlinkEnter)
  1523.  
  1524. orig2[chat] = chat:GetScript('OnHyperlinkLeave')
  1525. chat:SetScript('OnHyperlinkLeave', OnHyperlinkLeave)
  1526. chat.URLCopy = true
  1527. end
  1528. end
  1529. end
  1530. hooksecurefunc('FCF_OpenTemporaryWindow', EnableItemLinkTooltip)
  1531. EnableItemLinkTooltip()
  1532.  
  1533. if db.chat.windowborder == true then
  1534. for i = 1, NUM_CHAT_WINDOWS do
  1535. local cf = _G['ChatFrame'..i]
  1536. local bg = CreateFrame("Frame", nil, cf);
  1537. bg:SetFrameStrata("BACKGROUND");
  1538.  
  1539. if i == 2 then
  1540. bg:SetPoint("TOPLEFT", -8, 32);
  1541. else
  1542. bg:SetPoint("TOPLEFT", -8, 8);
  1543. end
  1544. bg:SetPoint("BOTTOMRIGHT", 8, -12);
  1545. bg:SetBackdrop({
  1546. edgeFile = db.chat.border,
  1547. tile = true, tileSize = 16, edgeSize = 18,
  1548. })
  1549.  
  1550. bg:SetBackdropBorderColor(ccolor.r, ccolor.g, ccolor.b)
  1551.  
  1552.  
  1553. end
  1554. end
  1555.  
  1556. -- default position of chat
  1557. local function SetDefaultChatPosition(frame)
  1558. if frame then
  1559. local id = frame:GetID()
  1560. local name = FCF_GetChatWindowInfo(id)
  1561. local fontSize = select(2, frame:GetFont())
  1562.  
  1563. -- font size
  1564. if fontSize < 15 then
  1565. FCF_SetChatWindowFontSize(nil, frame, 15)
  1566. else
  1567. FCF_SetChatWindowFontSize(nil, frame, fontSize)
  1568. end
  1569.  
  1570. if id == 1 then
  1571. frame:ClearAllPoints()
  1572. frame:SetPoint("BOTTOMLEFT", UIParent, 50, 185)
  1573. end
  1574.  
  1575. -- lock them if unlocked
  1576. if not frame.isLocked then FCF_SetLocked(frame, 1) end
  1577. end
  1578. end
  1579. hooksecurefunc("FCF_RestorePositionAndDimensions", SetDefaultChatPosition)
  1580. end
  1581.  
  1582. ---------------
  1583. -- Datapanel --
  1584. ---------------
  1585. function BasicUI:Datapanel()
  1586. local db = BasicUI.db.profile
  1587. local ccolor = RAID_CLASS_COLORS[select(2, UnitClass("player"))]
  1588. local myclass = UnitClass("player")
  1589. local myname, _ = UnitName("player")
  1590. local myrealm = GetRealmName()
  1591. local getscreenwidth = tonumber(string.match(({GetScreenResolutions()})[GetCurrentResolution()], "(%d+)x+%d"))
  1592. local toc = select(4, GetBuildInfo())
  1593. local locale = GetLocale()
  1594. local currentFightDPS
  1595.  
  1596. PP = function(p, obj)
  1597.  
  1598. local left = PanelLeft
  1599. local center = PanelCenter
  1600. local right = PanelRight
  1601.  
  1602. -- Left Panel Data
  1603. if p == 1 then
  1604. obj:SetParent(left)
  1605. obj:SetHeight(left:GetHeight())
  1606. obj:SetPoint('LEFT', left, 30, 0)
  1607. obj:SetPoint('TOP', left)
  1608. obj:SetPoint('BOTTOM', left)
  1609. elseif p == 2 then
  1610. obj:SetParent(left)
  1611. obj:SetHeight(left:GetHeight())
  1612. obj:SetPoint('TOP', left)
  1613. obj:SetPoint('BOTTOM', left)
  1614. elseif p == 3 then
  1615. obj:SetParent(left)
  1616. obj:SetHeight(left:GetHeight())
  1617. obj:SetPoint('RIGHT', left, -30, 0)
  1618. obj:SetPoint('TOP', left)
  1619. obj:SetPoint('BOTTOM', left)
  1620.  
  1621. -- Center Panel Data
  1622. elseif p == 4 then
  1623. obj:SetParent(center)
  1624. obj:SetHeight(center:GetHeight())
  1625. obj:SetPoint('LEFT', center, 30, 0)
  1626. obj:SetPoint('TOP', center)
  1627. obj:SetPoint('BOTTOM', center)
  1628. elseif p == 5 then
  1629. obj:SetParent(center)
  1630. obj:SetHeight(center:GetHeight())
  1631. obj:SetPoint('TOP', center)
  1632. obj:SetPoint('BOTTOM', center)
  1633. elseif p == 6 then
  1634. obj:SetParent(center)
  1635. obj:SetHeight(center:GetHeight())
  1636. obj:SetPoint('RIGHT', center, -30, 0)
  1637. obj:SetPoint('TOP', center)
  1638. obj:SetPoint('BOTTOM', center)
  1639.  
  1640. -- Right Panel Data
  1641. elseif p == 7 then
  1642. obj:SetParent(right)
  1643. obj:SetHeight(right:GetHeight())
  1644. obj:SetPoint('LEFT', right, 30, 0)
  1645. obj:SetPoint('TOP', right)
  1646. obj:SetPoint('BOTTOM', right)
  1647. elseif p == 8 then
  1648. obj:SetParent(right)
  1649. obj:SetHeight(right:GetHeight())
  1650. obj:SetPoint('TOP', right)
  1651. obj:SetPoint('BOTTOM', right)
  1652. elseif p == 9 then
  1653. obj:SetParent(right)
  1654. obj:SetHeight(right:GetHeight())
  1655. obj:SetPoint('RIGHT', right, -30, 0)
  1656. obj:SetPoint('TOP', right)
  1657. obj:SetPoint('BOTTOM', right)
  1658. end
  1659.  
  1660. end
  1661.  
  1662. DataTextTooltipAnchor = function(self)
  1663. local panel = self:GetParent()
  1664. local anchor = 'GameTooltip'
  1665. local xoff = 1
  1666. local yoff = 3
  1667.  
  1668.  
  1669. for _, panel in pairs ({
  1670. PanelLeft,
  1671. PanelCenter,
  1672. PanelRight,
  1673. }) do
  1674. if db.datapanel.top == true then
  1675. anchor = 'ANCHOR_BOTTOM'
  1676. else
  1677. anchor = 'ANCHOR_TOP'
  1678. end
  1679. end
  1680. return anchor, panel, xoff, yoff
  1681. end
  1682.  
  1683. --Check Player's Role
  1684.  
  1685. local classRoles = {
  1686. PALADIN = {
  1687. [1] = "Caster",
  1688. [2] = "Tank",
  1689. [3] = "Melee",
  1690. },
  1691. PRIEST = "Caster",
  1692. WARLOCK = "Caster",
  1693. WARRIOR = {
  1694. [1] = "Melee",
  1695. [2] = "Melee",
  1696. [3] = "Tank",
  1697. },
  1698. HUNTER = "Melee",
  1699. SHAMAN = {
  1700. [1] = "Caster",
  1701. [2] = "Melee",
  1702. [3] = "Caster",
  1703. },
  1704. ROGUE = "Melee",
  1705. MAGE = "Caster",
  1706. DEATHKNIGHT = {
  1707. [1] = "Tank",
  1708. [2] = "Melee",
  1709. [3] = "Melee",
  1710. },
  1711. DRUID = {
  1712. [1] = "Caster",
  1713. [2] = "Melee",
  1714. [3] = "Tank",
  1715. [4] = "Caster"
  1716. },
  1717. MONK = {
  1718. [1] = "Tank",
  1719. [2] = "Caster",
  1720. [3] = "Melee",
  1721. },
  1722. }
  1723.  
  1724. local _, playerClass = UnitClass("player")
  1725. local Role
  1726. local function CheckRole()
  1727. local talentTree = GetSpecialization()
  1728.  
  1729. if(type(classRoles[playerClass]) == "string") then
  1730. Role = classRoles[playerClass]
  1731. elseif(talentTree) then
  1732. Role = classRoles[playerClass][talentTree]
  1733. end
  1734. end
  1735.  
  1736. local eventHandler = CreateFrame("Frame")
  1737. eventHandler:RegisterEvent("PLAYER_ENTERING_WORLD")
  1738. eventHandler:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
  1739. eventHandler:RegisterEvent("PLAYER_TALENT_UPDATE")
  1740. eventHandler:RegisterEvent("CHARACTER_POINTS_CHANGED")
  1741. eventHandler:SetScript("OnEvent", CheckRole)
  1742.  
  1743. SetFontString = function(parent, fontName, fontHeight, fontStyle)
  1744. local fs = parent:CreateFontString(nil, 'OVERLAY')
  1745. fs:SetFont(fontName, fontHeight, fontStyle)
  1746. fs:SetJustifyH('LEFT')
  1747. fs:SetShadowColor(0, 0, 0)
  1748. fs:SetShadowOffset(1.25, -1.25)
  1749. return fs
  1750. end
  1751.  
  1752. function RGBToHex(r, g, b)
  1753. r = r <= 1 and r >= 0 and r or 0
  1754. g = g <= 1 and g >= 0 and g or 0
  1755. b = b <= 1 and b >= 0 and b or 0
  1756. return string.format("|cff%02x%02x%02x", r*255, g*255, b*255)
  1757. end
  1758.  
  1759. ShortValue = function(v)
  1760. if v >= 1e6 then
  1761. return ("%.1fm"):format(v / 1e6):gsub("%.?0+([km])$", "%1")
  1762. elseif v >= 1e3 or v <= -1e3 then
  1763. return ("%.1fk"):format(v / 1e3):gsub("%.?0+([km])$", "%1")
  1764. else
  1765. return v
  1766. end
  1767. end
  1768.  
  1769. function HexToRGB(hex)
  1770. local rhex, ghex, bhex = string.sub(hex, 1, 2), string.sub(hex, 3, 4), string.sub(hex, 5, 6)
  1771. return tonumber(rhex, 16), tonumber(ghex, 16), tonumber(bhex, 16)
  1772. end
  1773.  
  1774. --------------
  1775. -- Data Panel
  1776. --------------
  1777. if db.datapanel.enable == true then
  1778.  
  1779. --[[
  1780. All Credit for Datapanel.lua goes to Tuks.
  1781. Tukui = http://www.tukui.org/download.php.
  1782. Edited by Cokedriver.
  1783. ]]
  1784.  
  1785. local DataPanel = CreateFrame('Frame', 'DataPanel', UIParent)
  1786. local PanelLeft = CreateFrame('Frame', 'PanelLeft', UIParent)
  1787. local PanelCenter = CreateFrame('Frame', 'PanelCenter', UIParent)
  1788. local PanelRight = CreateFrame('Frame', 'PanelRight', UIParent)
  1789. local BattleGroundPanel = CreateFrame('Frame', 'BattleGroundPanel', UIParent)
  1790.  
  1791. if db.datapanel.panel == "top" then
  1792. DataPanel:SetPoint('TOP', UIParent, 0, 0)
  1793. DataPanel:SetHeight(35)
  1794. DataPanel:SetWidth(getscreenwidth)
  1795. DataPanel:SetFrameStrata('LOW')
  1796. DataPanel:SetFrameLevel(0)
  1797. DataPanel:SetBackdrop({
  1798. bgFile = db.datapanel.background,
  1799. edgeFile = db.datapanel.border,
  1800. edgeSize = 25,
  1801. insets = {left = 5, right = 5, top = 5, bottom = 5}
  1802. })
  1803. DataPanel:SetBackdropColor(0, 0, 0, 1)
  1804.  
  1805.  
  1806. -- Left Panel
  1807. PanelLeft:SetPoint('LEFT', DataPanel, 5, 0)
  1808. PanelLeft:SetHeight(35)
  1809. PanelLeft:SetWidth(getscreenwidth / 3)
  1810. PanelLeft:SetFrameStrata('LOW')
  1811. PanelLeft:SetFrameLevel(1)
  1812.  
  1813. -- Center Panel
  1814. PanelCenter:SetPoint('CENTER', DataPanel, 0, 0)
  1815. PanelCenter:SetHeight(35)
  1816. PanelCenter:SetWidth(getscreenwidth / 3)
  1817. PanelCenter:SetFrameStrata('LOW')
  1818. PanelCenter:SetFrameLevel(1)
  1819.  
  1820. -- Right Panel
  1821. PanelRight:SetPoint('RIGHT', DataPanel, -5, 0)
  1822. PanelRight:SetHeight(35)
  1823. PanelRight:SetWidth(getscreenwidth / 3)
  1824. PanelRight:SetFrameStrata('LOW')
  1825. PanelRight:SetFrameLevel(1)
  1826.  
  1827. -- Battleground Panel
  1828. BattleGroundPanel:SetAllPoints(PanelLeft)
  1829. BattleGroundPanel:SetFrameStrata('LOW')
  1830. BattleGroundPanel:SetFrameLevel(1)
  1831.  
  1832. elseif db.datapanel.panel == "bottom" then
  1833. DataPanel:SetPoint('BOTTOM', UIParent, 0, 0)
  1834. DataPanel:SetHeight(35)
  1835. DataPanel:SetWidth(1200)
  1836. DataPanel:SetFrameStrata('LOW')
  1837. DataPanel:SetFrameLevel(0)
  1838. DataPanel:SetBackdrop({
  1839. bgFile = db.datapanel.background,
  1840. edgeFile = db.datapanel.border,
  1841. edgeSize = 25,
  1842. insets = {left = 5, right = 5, top = 5, bottom = 5}
  1843. })
  1844. DataPanel:SetBackdropColor(0, 0, 0, 1)
  1845.  
  1846.  
  1847. -- Left Panel
  1848. PanelLeft:SetPoint('LEFT', DataPanel, 5, 0)
  1849. PanelLeft:SetHeight(35)
  1850. PanelLeft:SetWidth(1200 / 3)
  1851. PanelLeft:SetFrameStrata('LOW')
  1852. PanelLeft:SetFrameLevel(1)
  1853.  
  1854. -- Center Panel
  1855. PanelCenter:SetPoint('CENTER', DataPanel, 0, 0)
  1856. PanelCenter:SetHeight(35)
  1857. PanelCenter:SetWidth(1200 / 3)
  1858. PanelCenter:SetFrameStrata('LOW')
  1859. PanelCenter:SetFrameLevel(1)
  1860.  
  1861. -- Right panel
  1862. PanelRight:SetPoint('RIGHT', DataPanel, -5, 0)
  1863. PanelRight:SetHeight(35)
  1864. PanelRight:SetWidth(1200 / 3)
  1865. PanelRight:SetFrameStrata('LOW')
  1866. PanelRight:SetFrameLevel(1)
  1867.  
  1868. -- Battleground Panel
  1869. BattleGroundPanel:SetAllPoints(PanelLeft)
  1870. BattleGroundPanel:SetFrameStrata('LOW')
  1871. BattleGroundPanel:SetFrameLevel(1)
  1872.  
  1873. elseif db.datapanel.panel == "shortbar" then
  1874. DataPanel:SetPoint('BOTTOM', UIParent, 0, 0)
  1875. DataPanel:SetHeight(35)
  1876. DataPanel:SetWidth(725)
  1877. DataPanel:SetFrameStrata('LOW')
  1878. DataPanel:SetFrameLevel(0)
  1879. DataPanel:SetBackdrop({
  1880. bgFile = db.datapanel.background,
  1881. edgeFile = db.datapanel.border,
  1882. edgeSize = 25,
  1883. insets = {left = 3, right = 3, top = 3, bottom = 3},
  1884. })
  1885. DataPanel:SetBackdropColor(0, 0, 0, 1)
  1886.  
  1887. -- Left Panel
  1888. PanelLeft:SetPoint('LEFT', DataPanel, 5, 0)
  1889. PanelLeft:SetHeight(35)
  1890. PanelLeft:SetWidth(725 / 2)
  1891. PanelLeft:SetFrameStrata('LOW')
  1892. PanelLeft:SetFrameLevel(1)
  1893.  
  1894. -- Right panel
  1895. PanelRight:SetPoint('RIGHT', DataPanel, -5, 0)
  1896. PanelRight:SetHeight(35)
  1897. PanelRight:SetWidth(725 / 2)
  1898. PanelRight:SetFrameStrata('LOW')
  1899. PanelRight:SetFrameLevel(1)
  1900.  
  1901. -- Battleground Panel
  1902. BattleGroundPanel:SetAllPoints(PanelLeft)
  1903. BattleGroundPanel:SetFrameStrata('LOW')
  1904. BattleGroundPanel:SetFrameLevel(1)
  1905.  
  1906. end
  1907.  
  1908.  
  1909.  
  1910.  
  1911. -- move some frames to make way for the datapanel
  1912. if db.datapanel.panel == "top" then
  1913.  
  1914. local top = function() end
  1915.  
  1916. -- Player Frame
  1917. PlayerFrame:ClearAllPoints()
  1918. PlayerFrame:SetPoint("TOPLEFT", -19, -20)
  1919. PlayerFrame.ClearAllPoints = top
  1920. PlayerFrame.SetPoint = top
  1921.  
  1922. -- Target Frame
  1923. TargetFrame:ClearAllPoints()
  1924. TargetFrame:SetPoint("TOPLEFT", 250, -20)
  1925. TargetFrame.ClearAllPoints = top
  1926. TargetFrame.SetPoint = top
  1927.  
  1928. -- Minimap Frame
  1929. MinimapCluster:ClearAllPoints()
  1930. MinimapCluster:SetPoint('TOPRIGHT', 0, -32)
  1931. MinimapCluster.ClearAllPoints = top
  1932. MinimapCluster.SetPoint = top
  1933.  
  1934. -- Buff Frame
  1935. BuffFrame:ClearAllPoints()
  1936. BuffFrame:SetPoint('TOP', MinimapCluster, -110, -2)
  1937. BuffFrame.ClearAllPoints = top
  1938. BuffFrame.SetPoint = top
  1939.  
  1940. -- PvP Frame
  1941. WorldStateAlwaysUpFrame:ClearAllPoints()
  1942. WorldStateAlwaysUpFrame:SetPoint('TOP', 0, -32)
  1943. WorldStateAlwaysUpFrame.ClearAllpoints = top
  1944. WorldStateAlwaysUpFrame.Setpoint = top
  1945.  
  1946.  
  1947. else
  1948.  
  1949. -- Move some stuff for the panel on bottom.
  1950.  
  1951. local bottom = function() end
  1952.  
  1953. -- Main Menu Bar
  1954. MainMenuBar:ClearAllPoints()
  1955. MainMenuBar:SetPoint("BOTTOM", DataPanel, "TOP", 0, -3)
  1956. MainMenuBar.ClearAllPoints = bottom
  1957. MainMenuBar.SetPoint = bottom
  1958.  
  1959. -- Vehicle Bar
  1960. OverrideActionBar:ClearAllPoints()
  1961. OverrideActionBar:SetPoint("BOTTOM", DataPanel, "TOP", 0, -3)
  1962. OverrideActionBar.ClearAllPoints = bottom
  1963. OverrideActionBar.SetPoint = bottom
  1964.  
  1965. -- Pet Battle Bar
  1966. PetBattleFrame.BottomFrame:ClearAllPoints()
  1967. PetBattleFrame.BottomFrame:SetPoint("BOTTOM", DataPanel, "TOP", 0, -3)
  1968. PetBattleFrame.BottomFrame.ClearAllPoints = bottom
  1969. PetBattleFrame.BottomFrame.SetPoint = bottom
  1970.  
  1971. -- World Status
  1972. WorldStateAlwaysUpFrame:ClearAllPoints()
  1973. WorldStateAlwaysUpFrame:SetPoint('TOP', -20, -40)
  1974. WorldStateAlwaysUpFrame.ClearAllpoints = bottom
  1975. WorldStateAlwaysUpFrame.Setpoint = bottom
  1976.  
  1977. -- Buff Frame
  1978. BuffFrame:ClearAllPoints()
  1979. BuffFrame:SetPoint('TOP', MinimapCluster, -110, -15)
  1980. BuffFrame.ClearAllPoints = bottom
  1981. BuffFrame.SetPoint = bottom
  1982.  
  1983.  
  1984. -- Move the tooltip above the Actionbar
  1985. hooksecurefunc('GameTooltip_SetDefaultAnchor', function(self)
  1986. self:SetPoint('BOTTOMRIGHT', UIParent, -95, 135)
  1987. end)
  1988.  
  1989.  
  1990. -- Move the Bags above the Actionbar
  1991. CONTAINER_WIDTH = 192;
  1992. CONTAINER_SPACING = 5;
  1993. VISIBLE_CONTAINER_SPACING = 3;
  1994. CONTAINER_OFFSET_Y = 70;
  1995. CONTAINER_OFFSET_X = 0;
  1996.  
  1997.  
  1998. function UpdateContainerFrameAnchors()
  1999. local _, xOffset, yOffset, _, _, _, _;
  2000. local containerScale = 1;
  2001. screenHeight = GetScreenHeight() / containerScale;
  2002. -- Adjust the start anchor for bags depending on the multibars
  2003. xOffset = CONTAINER_OFFSET_X / containerScale;
  2004. yOffset = CONTAINER_OFFSET_Y / containerScale + 25;
  2005. -- freeScreenHeight determines when to start a new column of bags
  2006. freeScreenHeight = screenHeight - yOffset;
  2007. column = 0;
  2008. for index, frameName in ipairs(ContainerFrame1.bags) do
  2009. frame = _G[frameName];
  2010. frame:SetScale(containerScale);
  2011. if ( index == 1 ) then
  2012. -- First bag
  2013. frame:SetPoint('BOTTOMRIGHT', frame:GetParent(), 'BOTTOMRIGHT', -xOffset, yOffset );
  2014. elseif ( freeScreenHeight < frame:GetHeight() ) then
  2015. -- Start a new column
  2016. column = column + 1;
  2017. freeScreenHeight = screenHeight - yOffset;
  2018. frame:SetPoint('BOTTOMRIGHT', frame:GetParent(), 'BOTTOMRIGHT', -(column * CONTAINER_WIDTH) - xOffset, yOffset );
  2019. else
  2020. -- Anchor to the previous bag
  2021. frame:SetPoint('BOTTOMRIGHT', ContainerFrame1.bags[index - 1], 'TOPRIGHT', 0, CONTAINER_SPACING);
  2022. end
  2023. freeScreenHeight = freeScreenHeight - frame:GetHeight() - VISIBLE_CONTAINER_SPACING;
  2024. end
  2025. end
  2026. end
  2027. end
  2028.  
  2029. ----------------
  2030. -- Color System
  2031. ----------------
  2032. if db.datapanel.color then
  2033.  
  2034. --[[
  2035.  
  2036. All Credit for Colors.lua goes to Tuks.
  2037. Tukui = http://www.tukui.org/download.php.
  2038. Edited by Cokedriver.
  2039.  
  2040. ]]
  2041.  
  2042. if db.datapanel.classcolor ~= true then
  2043. local r, g, b = db.datapanel.customcolor.r, db.datapanel.customcolor.g, db.datapanel.customcolor.b
  2044. hexa = ("|cff%.2x%.2x%.2x"):format(r * 255, g * 255, b * 255)
  2045. hexb = "|r"
  2046. else
  2047. hexa = ("|cff%.2x%.2x%.2x"):format(ccolor.r * 255, ccolor.g * 255, ccolor.b * 255)
  2048. hexb = "|r"
  2049. end
  2050. end
  2051.  
  2052. ----------------
  2053. -- Player Armor
  2054. ----------------
  2055. if db.datapanel.armor and db.datapanel.armor > 0 then
  2056. local effectiveArmor
  2057.  
  2058. local Stat = CreateFrame('Frame')
  2059. Stat:EnableMouse(true)
  2060. Stat:SetFrameStrata('BACKGROUND')
  2061. Stat:SetFrameLevel(3)
  2062.  
  2063. local Text = DataPanel:CreateFontString(nil, 'OVERLAY')
  2064. Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
  2065. PP(db.datapanel.armor, Text)
  2066.  
  2067. local function Update(self)
  2068. effectiveArmor = select(2, UnitArmor("player"))
  2069. Text:SetText(hexa.."Armor: "..hexb..(effectiveArmor))
  2070. --Setup Armor Tooltip
  2071. self:SetAllPoints(Text)
  2072. end
  2073.  
  2074. Stat:RegisterEvent("UNIT_INVENTORY_CHANGED")
  2075. Stat:RegisterEvent("UNIT_AURA")
  2076. Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
  2077. Stat:SetScript("OnMouseDown", function() ToggleCharacter("PaperDollFrame") end)
  2078. Stat:SetScript("OnEvent", Update)
  2079. Stat:SetScript("OnEnter", function(self)
  2080. if not InCombatLockdown() then
  2081. local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  2082. GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  2083. GameTooltip:ClearLines()
  2084. GameTooltip:AddLine("Mitigation By Level: ")
  2085. local lv = 83
  2086. local mitigation = (effectiveArmor/(effectiveArmor+(467.5*lv-22167.5)))
  2087. for i = 1, 4 do
  2088. local format = string.format
  2089. if mitigation > .75 then
  2090. mitigation = .75
  2091. end
  2092. GameTooltip:AddDoubleLine(lv,format("%.2f", mitigation*100) .. "%",1,1,1)
  2093. lv = lv - 1
  2094. end
  2095. if UnitLevel("target") > 0 and UnitLevel("target") < UnitLevel("player") then
  2096. if mitigation > .75 then
  2097. mitigation = .75
  2098. end
  2099. GameTooltip:AddDoubleLine(UnitLevel("target"),format("%.2f", mitigation*100) .. "%",1,1,1)
  2100. end
  2101. GameTooltip:Show()
  2102. end
  2103. end)
  2104. Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
  2105. end
  2106.  
  2107. --------------------
  2108. -- Player Avoidance
  2109. --------------------
  2110. if db.datapanel.avd and db.datapanel.avd > 0 then
  2111. local dodge, parry, block, avoidance, targetlv, playerlv, basemisschance, leveldifference
  2112. local Stat = CreateFrame('Frame')
  2113. Stat:EnableMouse(true)
  2114. Stat:SetFrameStrata('BACKGROUND')
  2115. Stat:SetFrameLevel(3)
  2116.  
  2117. local Text = DataPanel:CreateFontString(nil, 'OVERLAY')
  2118. Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
  2119. PP(db.datapanel.avd, Text)
  2120.  
  2121. local targetlv, playerlv
  2122.  
  2123. local function Update(self)
  2124. local format = string.format
  2125. targetlv, playerlv = UnitLevel("target"), UnitLevel("player")
  2126. local basemisschance, leveldifference, avoidance
  2127.  
  2128. if targetlv == -1 then
  2129. basemisschance = (5 - (3*.2)) --Boss Value
  2130. leveldifference = 3
  2131. elseif targetlv > playerlv then
  2132. basemisschance = (5 - ((targetlv - playerlv)*.2)) --Mobs above player level
  2133. leveldifference = (targetlv - playerlv)
  2134. elseif targetlv < playerlv and targetlv > 0 then
  2135. basemisschance = (5 + ((playerlv - targetlv)*.2)) --Mobs below player level
  2136. leveldifference = (targetlv - playerlv)
  2137. else
  2138. basemisschance = 5 --Sets miss chance of attacker level if no target exists, lv80=5, 81=4.2, 82=3.4, 83=2.6
  2139. leveldifference = 0
  2140. end
  2141.  
  2142. if myrace == "NightElf" then
  2143. basemisschance = basemisschance + 2
  2144. end
  2145.  
  2146. if leveldifference >= 0 then
  2147. dodge = (GetDodgeChance()-leveldifference*.2)
  2148. parry = (GetParryChance()-leveldifference*.2)
  2149. block = (GetBlockChance()-leveldifference*.2)
  2150. avoidance = (dodge+parry+block)
  2151. Text:SetText(hexa.."Avd: "..hexb..format("%.2f", avoidance).."|r")
  2152. else
  2153. dodge = (GetDodgeChance()+abs(leveldifference*.2))
  2154. parry = (GetParryChance()+abs(leveldifference*.2))
  2155. block = (GetBlockChance()+abs(leveldifference*.2))
  2156. avoidance = (dodge+parry+block)
  2157. Text:SetText(hexa.."Avd: "..hexb..format("%.2f", avoidance).."|r")
  2158. end
  2159.  
  2160. --Setup Avoidance Tooltip
  2161. self:SetAllPoints(Text)
  2162. end
  2163.  
  2164.  
  2165. Stat:RegisterEvent("UNIT_AURA")
  2166. Stat:RegisterEvent("UNIT_INVENTORY_CHANGED")
  2167. Stat:RegisterEvent("PLAYER_TARGET_CHANGED")
  2168. Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
  2169. Stat:SetScript("OnEvent", Update)
  2170. Stat:SetScript("OnEnter", function(self)
  2171. if not InCombatLockdown() then
  2172. local anchor, yoff = DataTextTooltipAnchor(Text)
  2173. GameTooltip:SetOwner(self, anchor, 0, yoff)
  2174. GameTooltip:ClearAllPoints()
  2175. GameTooltip:ClearLines()
  2176. if targetlv > 1 then
  2177. GameTooltip:AddDoubleLine("Avoidance Breakdown".." (".."lvl".." "..targetlv..")")
  2178. elseif targetlv == -1 then
  2179. GameTooltip:AddDoubleLine("Avoidance Breakdown".." (".."Boss"..")")
  2180. else
  2181. GameTooltip:AddDoubleLine("Avoidance Breakdown".." (".."lvl".." "..targetlv..")")
  2182. end
  2183. GameTooltip:AddDoubleLine("Dodge",format("%.2f",dodge) .. "%",1,1,1, 1,1,1)
  2184. GameTooltip:AddDoubleLine("Parry",format("%.2f",parry) .. "%",1,1,1, 1,1,1)
  2185. GameTooltip:AddDoubleLine("Block",format("%.2f",block) .. "%",1,1,1, 1,1,1)
  2186. GameTooltip:Show()
  2187. end
  2188. end)
  2189. Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
  2190. end
  2191.  
  2192. --------
  2193. -- Bags
  2194. --------
  2195.  
  2196. if db.datapanel.bags and db.datapanel.bags > 0 then
  2197. local Stat = CreateFrame('Frame')
  2198. Stat:EnableMouse(true)
  2199. Stat:SetFrameStrata('BACKGROUND')
  2200. Stat:SetFrameLevel(3)
  2201.  
  2202. local Text = DataPanel:CreateFontString(nil, 'OVERLAY')
  2203. Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
  2204. PP(db.datapanel.bags, Text)
  2205.  
  2206. local Profit = 0
  2207. local Spent = 0
  2208. local OldMoney = 0
  2209. local myPlayerRealm = GetRealmName();
  2210.  
  2211.  
  2212. local function formatMoney(c)
  2213. local str = ""
  2214. if not c or c < 0 then
  2215. return str
  2216. end
  2217.  
  2218. if c >= 10000 then
  2219. local g = math.floor(c/10000)
  2220. c = c - g*10000
  2221. str = str..g.."|cFFFFD800g|r "
  2222. end
  2223. if c >= 100 then
  2224. local s = math.floor(c/100)
  2225. c = c - s*100
  2226. str = str..s.."|cFFC7C7C7s|r "
  2227. end
  2228. if c >= 0 then
  2229. str = str..c.."|cFFEEA55Fc|r"
  2230. end
  2231.  
  2232. return str
  2233. end
  2234.  
  2235. local function FormatTooltipMoney(c)
  2236. if not c then return end
  2237. local str = ""
  2238. if not c or c < 0 then
  2239. return str
  2240. end
  2241.  
  2242. if c >= 10000 then
  2243. local g = math.floor(c/10000)
  2244. c = c - g*10000
  2245. str = str..g.."|cFFFFD800g|r "
  2246. end
  2247. if c >= 100 then
  2248. local s = math.floor(c/100)
  2249. c = c - s*100
  2250. str = str..s.."|cFFC7C7C7s|r "
  2251. end
  2252. if c >= 0 then
  2253. str = str..c.."|cFFEEA55Fc|r"
  2254. end
  2255.  
  2256. return str
  2257. end
  2258. local function OnEvent(self, event)
  2259. local totalSlots, freeSlots = 0, 0
  2260. local itemLink, subtype, isBag
  2261. for i = 0,NUM_BAG_SLOTS do
  2262. isBag = true
  2263. if i > 0 then
  2264. itemLink = GetInventoryItemLink('player', ContainerIDToInventoryID(i))
  2265. if itemLink then
  2266. subtype = select(7, GetItemInfo(itemLink))
  2267. if (subtype == 'Mining Bag') or (subtype == 'Gem Bag') or (subtype == 'Engineering Bag') or (subtype == 'Enchanting Bag') or (subtype == 'Herb Bag') or (subtype == 'Inscription Bag') or (subtype == 'Leatherworking Bag') or (subtype == 'Fishing Bag')then
  2268. isBag = false
  2269. end
  2270. end
  2271. end
  2272. if isBag then
  2273. totalSlots = totalSlots + GetContainerNumSlots(i)
  2274. freeSlots = freeSlots + GetContainerNumFreeSlots(i)
  2275. end
  2276. Text:SetText(hexa.."Bags: "..hexb.. freeSlots.. '/' ..totalSlots)
  2277. if freeSlots < 6 then
  2278. Text:SetTextColor(1,0,0)
  2279. elseif freeSlots < 10 then
  2280. Text:SetTextColor(1,0,0)
  2281. elseif freeSlots > 10 then
  2282. Text:SetTextColor(1,1,1)
  2283. end
  2284. self:SetAllPoints(Text)
  2285.  
  2286. end
  2287. if event == "PLAYER_ENTERING_WORLD" then
  2288. OldMoney = GetMoney()
  2289. end
  2290.  
  2291. local NewMoney = GetMoney()
  2292. local Change = NewMoney-OldMoney -- Positive if we gain money
  2293.  
  2294. if OldMoney>NewMoney then -- Lost Money
  2295. Spent = Spent - Change
  2296. else -- Gained Moeny
  2297. Profit = Profit + Change
  2298. end
  2299.  
  2300. --Text:SetText(formatMoney(NewMoney))
  2301. -- Setup Money Tooltip
  2302. self:SetAllPoints(Text)
  2303.  
  2304. local myPlayerName = UnitName("player")
  2305. if not BasicDB then BasicDB = {} end
  2306. if not BasicDB.gold then BasicDB.gold = {} end
  2307. if not BasicDB.gold[myPlayerRealm] then BasicDB.gold[myPlayerRealm]={} end
  2308. BasicDB.gold[myPlayerRealm][myPlayerName] = GetMoney()
  2309.  
  2310. OldMoney = NewMoney
  2311.  
  2312. end
  2313.  
  2314. Stat:RegisterEvent("PLAYER_MONEY")
  2315. Stat:RegisterEvent("SEND_MAIL_MONEY_CHANGED")
  2316. Stat:RegisterEvent("SEND_MAIL_COD_CHANGED")
  2317. Stat:RegisterEvent("PLAYER_TRADE_MONEY")
  2318. Stat:RegisterEvent("TRADE_MONEY_CHANGED")
  2319. Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
  2320. Stat:SetScript('OnMouseDown',
  2321. function()
  2322. if db.datapanel.bag ~= true then
  2323. ToggleAllBags()
  2324. else
  2325. ToggleBag(0)
  2326. end
  2327. end
  2328. )
  2329. Stat:SetScript('OnEvent', OnEvent)
  2330. Stat:SetScript("OnEnter", function(self)
  2331. if not InCombatLockdown() then
  2332. local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  2333. GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  2334. GameTooltip:ClearLines()
  2335. GameTooltip:AddLine(hexa..myname.."'s"..hexb.." Gold")
  2336. GameTooltip:AddLine' '
  2337. GameTooltip:AddLine("Session: ")
  2338. GameTooltip:AddDoubleLine("Earned:", formatMoney(Profit), 1, 1, 1, 1, 1, 1)
  2339. GameTooltip:AddDoubleLine("Spent:", formatMoney(Spent), 1, 1, 1, 1, 1, 1)
  2340. if Profit < Spent then
  2341. GameTooltip:AddDoubleLine("Deficit:", formatMoney(Profit-Spent), 1, 0, 0, 1, 1, 1)
  2342. elseif (Profit-Spent)>0 then
  2343. GameTooltip:AddDoubleLine("Profit:", formatMoney(Profit-Spent), 0, 1, 0, 1, 1, 1)
  2344. end
  2345. GameTooltip:AddLine' '
  2346.  
  2347. local totalGold = 0
  2348. GameTooltip:AddLine("Character: ")
  2349. local thisRealmList = BasicDB.gold[myPlayerRealm];
  2350. for k,v in pairs(thisRealmList) do
  2351. GameTooltip:AddDoubleLine(k, FormatTooltipMoney(v), 1, 1, 1, 1, 1, 1)
  2352. totalGold=totalGold+v;
  2353. end
  2354. GameTooltip:AddLine' '
  2355. GameTooltip:AddLine("Server: ")
  2356. GameTooltip:AddDoubleLine("Total: ", FormatTooltipMoney(totalGold), 1, 1, 1, 1, 1, 1)
  2357.  
  2358. for i = 1, GetNumWatchedTokens() do
  2359. local name, count, extraCurrencyType, icon, itemID = GetBackpackCurrencyInfo(i)
  2360. if name and i == 1 then
  2361. GameTooltip:AddLine(" ")
  2362. GameTooltip:AddLine(CURRENCY)
  2363. end
  2364. local r, g, b = 1,1,1
  2365. if itemID then r, g, b = GetItemQualityColor(select(3, GetItemInfo(itemID))) end
  2366. if name and count then GameTooltip:AddDoubleLine(name, count, r, g, b, 1, 1, 1) end
  2367. end
  2368. GameTooltip:AddLine' '
  2369. GameTooltip:AddLine("|cffeda55fClick|r to Open Bags")
  2370. GameTooltip:Show()
  2371. end
  2372. end)
  2373.  
  2374. Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
  2375. -- reset gold data
  2376. local function RESETGOLD()
  2377. local myPlayerRealm = GetRealmName();
  2378. local myPlayerName = UnitName("player");
  2379.  
  2380. BasicDB.gold = {}
  2381. BasicDB.gold[myPlayerRealm]={}
  2382. BasicDB.gold[myPlayerRealm][myPlayerName] = GetMoney();
  2383. end
  2384. SLASH_RESETGOLD1 = "/resetgold"
  2385. SlashCmdList["RESETGOLD"] = RESETGOLD
  2386.  
  2387. end
  2388.  
  2389. ----------------
  2390. -- Battleground
  2391. ----------------
  2392. if db.datapanel.battleground == true then
  2393.  
  2394. --Map IDs
  2395. local WSG = 443
  2396. local TP = 626
  2397. local AV = 401
  2398. local SOTA = 512
  2399. local IOC = 540
  2400. local EOTS = 482
  2401. local TBFG = 736
  2402. local AB = 461
  2403.  
  2404. local bgframe = BattleGroundPanel
  2405. bgframe:SetScript('OnEnter', function(self)
  2406. local numScores = GetNumBattlefieldScores()
  2407. for i=1, numScores do
  2408. local name, killingBlows, honorableKills, deaths, honorGained, faction, race, class, classToken, damageDone, healingDone, bgRating, ratingChange = GetBattlefieldScore(i)
  2409. if ( name ) then
  2410. if ( name == UnitName('player') ) then
  2411. GameTooltip:SetOwner(self, 'ANCHOR_TOPLEFT', 0, 4)
  2412. GameTooltip:ClearLines()
  2413. GameTooltip:SetPoint('BOTTOM', self, 'TOP', 0, 1)
  2414. GameTooltip:ClearLines()
  2415. GameTooltip:AddLine("Stats for : "..hexa..name..hexb)
  2416. GameTooltip:AddLine' '
  2417. GameTooltip:AddDoubleLine("Killing Blows:", killingBlows,1,1,1)
  2418. GameTooltip:AddDoubleLine("Honorable Kills:", honorableKills,1,1,1)
  2419. GameTooltip:AddDoubleLine("Deaths:", deaths,1,1,1)
  2420. GameTooltip:AddDoubleLine("Honor Gained:", format('%d', honorGained),1,1,1)
  2421. GameTooltip:AddDoubleLine("Damage Done:", damageDone,1,1,1)
  2422. GameTooltip:AddDoubleLine("Healing Done:", healingDone,1,1,1)
  2423. --Add extra statistics to watch based on what BG you are in.
  2424. if curmapid == WSG or curmapid == TP then
  2425. GameTooltip:AddDoubleLine("Flags Captured:",GetBattlefieldStatData(i, 1),1,1,1)
  2426. GameTooltip:AddDoubleLine("Flags Returned:",GetBattlefieldStatData(i, 2),1,1,1)
  2427. elseif curmapid == EOTS then
  2428. GameTooltip:AddDoubleLine("Flags Captured:",GetBattlefieldStatData(i, 1),1,1,1)
  2429. elseif curmapid == AV then
  2430. GameTooltip:AddDoubleLine("Graveyards Assaulted:",GetBattlefieldStatData(i, 1),1,1,1)
  2431. GameTooltip:AddDoubleLine("Graveyards Defended:",GetBattlefieldStatData(i, 2),1,1,1)
  2432. GameTooltip:AddDoubleLine("Towers Assaulted:",GetBattlefieldStatData(i, 3),1,1,1)
  2433. GameTooltip:AddDoubleLine("Towers Defended:",GetBattlefieldStatData(i, 4),1,1,1)
  2434. elseif curmapid == SOTA then
  2435. GameTooltip:AddDoubleLine("Demolishers Destroyed:",GetBattlefieldStatData(i, 1),1,1,1)
  2436. GameTooltip:AddDoubleLine("Gates Destroyed:",GetBattlefieldStatData(i, 2),1,1,1)
  2437. elseif curmapid == IOC or curmapid == TBFG or curmapid == AB then
  2438. GameTooltip:AddDoubleLine("Bases Assaulted:",GetBattlefieldStatData(i, 1),1,1,1)
  2439. GameTooltip:AddDoubleLine("Bases Defended:",GetBattlefieldStatData(i, 2),1,1,1)
  2440. end
  2441. GameTooltip:Show()
  2442. end
  2443. end
  2444. end
  2445. end)
  2446. bgframe:SetScript('OnLeave', function(self) GameTooltip:Hide() end)
  2447.  
  2448. local Stat = CreateFrame('Frame')
  2449. Stat:EnableMouse(true)
  2450.  
  2451. local Text1 = BattleGroundPanel:CreateFontString(nil, 'OVERLAY')
  2452. Text1:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
  2453. Text1:SetPoint('LEFT', BattleGroundPanel, 30, 0)
  2454. Text1:SetHeight(DataPanel:GetHeight())
  2455.  
  2456. local Text2 = BattleGroundPanel:CreateFontString(nil, 'OVERLAY')
  2457. Text2:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
  2458. Text2:SetPoint('CENTER', BattleGroundPanel, 0, 0)
  2459. Text2:SetHeight(DataPanel:GetHeight())
  2460.  
  2461. local Text3 = BattleGroundPanel:CreateFontString(nil, 'OVERLAY')
  2462. Text3:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
  2463. Text3:SetPoint('RIGHT', BattleGroundPanel, -30, 0)
  2464. Text3:SetHeight(DataPanel:GetHeight())
  2465.  
  2466. local int = 2
  2467. local function Update(self, t)
  2468. int = int - t
  2469. if int < 0 then
  2470. local dmgtxt
  2471. RequestBattlefieldScoreData()
  2472. local numScores = GetNumBattlefieldScores()
  2473. for i=1, numScores do
  2474. local name, killingBlows, honorableKills, deaths, honorGained, faction, race, class, classToken, damageDone, healingDone, bgRating, ratingChange = GetBattlefieldScore(i)
  2475. if healingDone > damageDone then
  2476. dmgtxt = ("Healing : "..hexa..healingDone..hexb)
  2477. else
  2478. dmgtxt = ("Damage : "..hexa..damageDone..hexb)
  2479. end
  2480. if ( name ) then
  2481. if ( name == myname ) then
  2482. Text2:SetText("Honor : "..hexa..format('%d', honorGained)..hexb)
  2483. Text1:SetText(dmgtxt)
  2484. Text3:SetText("Killing Blows : "..hexa..killingBlows..hexb)
  2485. end
  2486. end
  2487. end
  2488. int = 0
  2489. end
  2490. end
  2491.  
  2492. --hide text when not in an bg
  2493. local function OnEvent(self, event)
  2494. if event == 'PLAYER_ENTERING_WORLD' then
  2495. local inInstance, instanceType = IsInInstance()
  2496. if inInstance and (instanceType == 'pvp') then
  2497. bgframe:Show()
  2498. PanelLeft:Hide()
  2499. else
  2500. Text1:SetText('')
  2501. Text2:SetText('')
  2502. Text3:SetText('')
  2503. bgframe:Hide()
  2504. PanelLeft:Show()
  2505. end
  2506. end
  2507. end
  2508.  
  2509. Stat:RegisterEvent('PLAYER_ENTERING_WORLD')
  2510. Stat:SetScript('OnEvent', OnEvent)
  2511. Stat:SetScript('OnUpdate', Update)
  2512. Update(Stat, 10)
  2513. end
  2514.  
  2515. ----------------
  2516. -- Call To Arms
  2517. ----------------
  2518. if db.datapanel.calltoarms and db.datapanel.calltoarms > 0 then
  2519. local Stat = CreateFrame("Frame")
  2520. Stat:EnableMouse(true)
  2521. Stat:SetFrameStrata("MEDIUM")
  2522. Stat:SetFrameLevel(3)
  2523.  
  2524. local Text = DataPanel:CreateFontString(nil, "OVERLAY")
  2525. Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
  2526. PP(db.datapanel.calltoarms, Text)
  2527.  
  2528. local function MakeIconString(tank, healer, damage)
  2529. local str = ""
  2530. if tank then
  2531. str = str..'T'
  2532. end
  2533. if healer then
  2534. str = str..', H'
  2535. end
  2536. if damage then
  2537. str = str..', D'
  2538. end
  2539.  
  2540. return str
  2541. end
  2542.  
  2543. local function MakeString(tank, healer, damage)
  2544. local str = ""
  2545. if tank then
  2546. str = str..'Tank'
  2547. end
  2548. if healer then
  2549. str = str..', Healer'
  2550. end
  2551. if damage then
  2552. str = str..', DPS'
  2553. end
  2554.  
  2555. return str
  2556. end
  2557.  
  2558. local function OnEvent(self, event, ...)
  2559. local tankReward = false
  2560. local healerReward = false
  2561. local dpsReward = false
  2562. local unavailable = true
  2563. for i=1, GetNumRandomDungeons() do
  2564. local id, name = GetLFGRandomDungeonInfo(i)
  2565. for x = 1,LFG_ROLE_NUM_SHORTAGE_TYPES do
  2566. local eligible, forTank, forHealer, forDamage, itemCount = GetLFGRoleShortageRewards(id, x)
  2567. if eligible then unavailable = false end
  2568. if eligible and forTank and itemCount > 0 then tankReward = true end
  2569. if eligible and forHealer and itemCount > 0 then healerReward = true end
  2570. if eligible and forDamage and itemCount > 0 then dpsReward = true end
  2571. end
  2572. end
  2573.  
  2574. if unavailable then
  2575. Text:SetText(QUEUE_TIME_UNAVAILABLE)
  2576. else
  2577. Text:SetText(hexa..'C to A'..hexb.." : "..MakeIconString(tankReward, healerReward, dpsReward).." ")
  2578. end
  2579.  
  2580. self:SetAllPoints(Text)
  2581. end
  2582.  
  2583. local function OnEnter(self)
  2584. if InCombatLockdown() then return end
  2585.  
  2586. local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  2587. GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  2588. GameTooltip:ClearLines()
  2589. GameTooltip:AddLine(hexa..myname.."'s"..hexb.." Call to Arms")
  2590. GameTooltip:AddLine(' ')
  2591.  
  2592. local allUnavailable = true
  2593. local numCTA = 0
  2594. for i=1, GetNumRandomDungeons() do
  2595. local id, name = GetLFGRandomDungeonInfo(i)
  2596. local tankReward = false
  2597. local healerReward = false
  2598. local dpsReward = false
  2599. local unavailable = true
  2600. for x=1, LFG_ROLE_NUM_SHORTAGE_TYPES do
  2601. local eligible, forTank, forHealer, forDamage, itemCount = GetLFGRoleShortageRewards(id, x)
  2602. if eligible then unavailable = false end
  2603. if eligible and forTank and itemCount > 0 then tankReward = true end
  2604. if eligible and forHealer and itemCount > 0 then healerReward = true end
  2605. if eligible and forDamage and itemCount > 0 then dpsReward = true end
  2606. end
  2607. if not unavailable then
  2608. allUnavailable = false
  2609. local rolesString = MakeString(tankReward, healerReward, dpsReward)
  2610. if rolesString ~= "" then
  2611. GameTooltip:AddDoubleLine(name.." : ", rolesString..' ', 1, 1, 1)
  2612. end
  2613. if tankReward or healerReward or dpsReward then numCTA = numCTA + 1 end
  2614. end
  2615. end
  2616.  
  2617. if allUnavailable then
  2618. GameTooltip:AddLine("Could not get Call To Arms information.")
  2619. elseif numCTA == 0 then
  2620. GameTooltip:AddLine("Could not get Call To Arms information.")
  2621. end
  2622. GameTooltip:AddLine' '
  2623. GameTooltip:AddLine("|cffeda55fLeft Click|r to Open Dungeon Finder")
  2624. GameTooltip:AddLine("|cffeda55fRight Click|r to Open PvP Finder")
  2625. GameTooltip:Show()
  2626. end
  2627.  
  2628. Stat:RegisterEvent("LFG_UPDATE_RANDOM_INFO")
  2629. Stat:RegisterEvent("PLAYER_LOGIN")
  2630. Stat:SetScript("OnEvent", OnEvent)
  2631. Stat:SetScript("OnMouseDown", function(self, btn)
  2632. if btn == "LeftButton" then
  2633. ToggleLFDParentFrame(1)
  2634. elseif btn == "RightButton" then
  2635. TogglePVPUI(1)
  2636. end
  2637. end)
  2638. Stat:SetScript("OnEnter", OnEnter)
  2639. Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
  2640. end
  2641.  
  2642. ---------------
  2643. -- Coordinates
  2644. ---------------
  2645. if db.datapanel.coords and db.datapanel.coords > 0 then
  2646. local Stat = CreateFrame("Frame")
  2647. Stat:EnableMouse(true)
  2648. Stat:SetFrameStrata('BACKGROUND')
  2649. Stat:SetFrameLevel(3)
  2650.  
  2651. local Text = DataPanel:CreateFontString(nil, "OVERLAY")
  2652. Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
  2653. PP(db.datapanel.coords, Text)
  2654.  
  2655. local function Update(self)
  2656. local px,py=GetPlayerMapPosition("player")
  2657. Text:SetText(format(hexa.."Loc: "..hexb.."%i , %i",px*100,py*100))
  2658. end
  2659.  
  2660. Stat:SetScript("OnUpdate", Update)
  2661. Update(Stat, 10)
  2662. end
  2663.  
  2664. ---------------------
  2665. -- Damage Per Second
  2666. ---------------------
  2667. if db.datapanel.dps_text and db.datapanel.dps_text > 0 then
  2668. local events = {SWING_DAMAGE = true, RANGE_DAMAGE = true, SPELL_DAMAGE = true, SPELL_PERIODIC_DAMAGE = true, DAMAGE_SHIELD = true, DAMAGE_SPLIT = true, SPELL_EXTRA_ATTACKS = true}
  2669. local DPS_FEED = CreateFrame('Frame')
  2670. local player_id = UnitGUID('player')
  2671. local dmg_total, last_dmg_amount = 0, 0
  2672. local cmbt_time = 0
  2673.  
  2674. local pet_id = UnitGUID('pet')
  2675.  
  2676. local dText = DataPanel:CreateFontString(nil, 'OVERLAY')
  2677. dText:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
  2678. dText:SetText("DPS: ", '0')
  2679.  
  2680. PP(db.datapanel.dps_text, dText)
  2681.  
  2682. DPS_FEED:EnableMouse(true)
  2683. DPS_FEED:SetFrameStrata('BACKGROUND')
  2684. DPS_FEED:SetFrameLevel(3)
  2685. DPS_FEED:SetHeight(20)
  2686. DPS_FEED:SetWidth(100)
  2687. DPS_FEED:SetAllPoints(dText)
  2688.  
  2689. DPS_FEED:SetScript('OnEvent', function(self, event, ...) self[event](self, ...) end)
  2690. DPS_FEED:RegisterEvent('PLAYER_LOGIN')
  2691.  
  2692. DPS_FEED:SetScript('OnUpdate', function(self, elap)
  2693. if UnitAffectingCombat('player') then
  2694. cmbt_time = cmbt_time + elap
  2695. end
  2696.  
  2697. dText:SetText(getDPS())
  2698. end)
  2699.  
  2700. function DPS_FEED:PLAYER_LOGIN()
  2701. DPS_FEED:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
  2702. DPS_FEED:RegisterEvent('PLAYER_REGEN_ENABLED')
  2703. DPS_FEED:RegisterEvent('PLAYER_REGEN_DISABLED')
  2704. DPS_FEED:RegisterEvent('UNIT_PET')
  2705. player_id = UnitGUID('player')
  2706. DPS_FEED:UnregisterEvent('PLAYER_LOGIN')
  2707. end
  2708.  
  2709. function DPS_FEED:UNIT_PET(unit)
  2710. if unit == 'player' then
  2711. pet_id = UnitGUID('pet')
  2712. end
  2713. end
  2714.  
  2715. -- handler for the combat log. used http://www.wowwiki.com/API_COMBAT_LOG_EVENT for api
  2716. function DPS_FEED:COMBAT_LOG_EVENT_UNFILTERED(...)
  2717. -- filter for events we only care about. i.e heals
  2718. if not events[select(2, ...)] then return end
  2719.  
  2720. -- only use events from the player
  2721. local id = select(4, ...)
  2722.  
  2723. if id == player_id or id == pet_id then
  2724. if select(2, ...) == "SWING_DAMAGE" then
  2725. if toc < 40200 then
  2726. last_dmg_amount = select(10, ...)
  2727. else
  2728. last_dmg_amount = select(12, ...)
  2729. end
  2730. else
  2731. if toc < 40200 then
  2732. last_dmg_amount = select(13, ...)
  2733. else
  2734. last_dmg_amount = select(15, ...)
  2735. end
  2736. end
  2737. dmg_total = dmg_total + last_dmg_amount
  2738. end
  2739. end
  2740.  
  2741. function getDPS()
  2742. if (dmg_total == 0) then
  2743. return (hexa.."DPS"..hexb..' 0')
  2744. else
  2745. return string.format(hexa.."DPS: "..hexb..'%.1f ', (dmg_total or 0) / (cmbt_time or 1))
  2746. end
  2747. end
  2748.  
  2749. function DPS_FEED:PLAYER_REGEN_ENABLED()
  2750. dText:SetText(getDPS())
  2751. end
  2752.  
  2753. function DPS_FEED:PLAYER_REGEN_DISABLED()
  2754. cmbt_time = 0
  2755. dmg_total = 0
  2756. last_dmg_amount = 0
  2757. end
  2758.  
  2759. DPS_FEED:SetScript('OnMouseDown', function (self, button, down)
  2760. cmbt_time = 0
  2761. dmg_total = 0
  2762. last_dmg_amount = 0
  2763. end)
  2764. end
  2765.  
  2766. --------------
  2767. -- Durability
  2768. --------------
  2769. if db.datapanel.dur and db.datapanel.dur > 0 then
  2770.  
  2771. Slots = {
  2772. [1] = {1, "Head", 1000},
  2773. [2] = {3, "Shoulder", 1000},
  2774. [3] = {5, "Chest", 1000},
  2775. [4] = {6, "Waist", 1000},
  2776. [5] = {9, "Wrist", 1000},
  2777. [6] = {10, "Hands", 1000},
  2778. [7] = {7, "Legs", 1000},
  2779. [8] = {8, "Feet", 1000},
  2780. [9] = {16, "Main Hand", 1000},
  2781. [10] = {17, "Off Hand", 1000},
  2782. [11] = {18, "Ranged", 1000}
  2783. }
  2784.  
  2785.  
  2786. local Stat = CreateFrame("Frame")
  2787. Stat:EnableMouse(true)
  2788. Stat:SetFrameStrata("MEDIUM")
  2789. Stat:SetFrameLevel(3)
  2790.  
  2791. local Text = DataPanel:CreateFontString(nil, "OVERLAY")
  2792. Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
  2793. PP(db.datapanel.dur, Text)
  2794.  
  2795. local function OnEvent(self)
  2796. local Total = 0
  2797. local current, max
  2798.  
  2799. for i = 1, 11 do
  2800. if GetInventoryItemLink("player", Slots[i][1]) ~= nil then
  2801. current, max = GetInventoryItemDurability(Slots[i][1])
  2802. if current then
  2803. Slots[i][3] = current/max
  2804. Total = Total + 1
  2805. end
  2806. end
  2807. end
  2808. table.sort(Slots, function(a, b) return a[3] < b[3] end)
  2809.  
  2810. if Total > 0 then
  2811. Text:SetText(hexa.."Armor: "..hexb..floor(Slots[1][3]*100).."% |r")
  2812. else
  2813. Text:SetText(hexa.."Armor: "..hexb.."100% |r")
  2814. end
  2815. -- Setup Durability Tooltip
  2816. self:SetAllPoints(Text)
  2817. Total = 0
  2818. end
  2819.  
  2820. Stat:RegisterEvent("UPDATE_INVENTORY_DURABILITY")
  2821. Stat:RegisterEvent("MERCHANT_SHOW")
  2822. Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
  2823. Stat:SetScript("OnMouseDown", function() ToggleCharacter("PaperDollFrame") end)
  2824. Stat:SetScript("OnEvent", OnEvent)
  2825. Stat:SetScript("OnEnter", function(self)
  2826. if not InCombatLockdown() then
  2827. local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  2828. GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  2829. GameTooltip:ClearLines()
  2830. GameTooltip:AddLine(hexa..myname.."'s"..hexb.." Durability")
  2831. GameTooltip:AddLine' '
  2832. for i = 1, 11 do
  2833. if Slots[i][3] ~= 1000 then
  2834. local green, red
  2835. green = Slots[i][3]*2
  2836. red = 1 - green
  2837. GameTooltip:AddDoubleLine(Slots[i][2], floor(Slots[i][3]*100).."%",1 ,1 , 1, red + 1, green, 0)
  2838. end
  2839. end
  2840. GameTooltip:AddLine(" ")
  2841. GameTooltip:AddLine("|cffeda55fClick|r to Show Character Panel")
  2842. GameTooltip:Show()
  2843. end
  2844. end)
  2845. Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
  2846.  
  2847. end
  2848.  
  2849. ------------
  2850. -- Friends
  2851. ------------
  2852. if db.datapanel.friends and db.datapanel.friends > 0 then
  2853.  
  2854. -- create a popup
  2855. StaticPopupDialogs["SET_BN_BROADCAST"] = {
  2856. text = BN_BROADCAST_TOOLTIP,
  2857. button1 = ACCEPT,
  2858. button2 = CANCEL,
  2859. hasEditBox = 1,
  2860. editBoxWidth = 350,
  2861. maxLetters = 127,
  2862. OnAccept = function(self) BNSetCustomMessage(self.editBox:GetText()) end,
  2863. OnShow = function(self) self.editBox:SetText(select(3, BNGetInfo()) ) self.editBox:SetFocus() end,
  2864. OnHide = ChatEdit_FocusActiveWindow,
  2865. EditBoxOnEnterPressed = function(self) BNSetCustomMessage(self:GetText()) self:GetParent():Hide() end,
  2866. EditBoxOnEscapePressed = function(self) self:GetParent():Hide() end,
  2867. timeout = 0,
  2868. exclusive = 1,
  2869. whileDead = 1,
  2870. hideOnEscape = 1
  2871. }
  2872.  
  2873. --[[ localized references for global functions (about 50% faster)
  2874. local join = string.join
  2875. local find = string.find
  2876. local format = string.format
  2877. local split = string.split
  2878. local sort = table.sort
  2879. local insert = table.insert
  2880. local sizeof = table.getn
  2881.  
  2882. -- for datatext display
  2883. local displayString = join("", hexa.."%s: "..hexb, "|cffffffff", "%d|r")]]
  2884.  
  2885. local Stat = CreateFrame("Frame")
  2886. Stat:EnableMouse(true)
  2887. Stat:SetFrameStrata("MEDIUM")
  2888. Stat:SetFrameLevel(3)
  2889.  
  2890. local Text = DataPanel:CreateFontString(nil, "OVERLAY")
  2891. Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
  2892. PP(db.datapanel.friends, Text)
  2893.  
  2894.  
  2895. local menuFrame = CreateFrame("Frame", "TukuiFriendRightClickMenu", UIParent, "UIDropDownMenuTemplate")
  2896. local menuList = {
  2897. { text = OPTIONS_MENU, isTitle = true,notCheckable=true},
  2898. { text = INVITE, hasArrow = true,notCheckable=true, },
  2899. { text = CHAT_MSG_WHISPER_INFORM, hasArrow = true,notCheckable=true, },
  2900. { text = PLAYER_STATUS, hasArrow = true, notCheckable=true,
  2901. menuList = {
  2902. { text = "|cff2BC226"..AVAILABLE.."|r", notCheckable=true, func = function() if IsChatAFK() then SendChatMessage("", "AFK") elseif IsChatDND() then SendChatMessage("", "DND") end end },
  2903. { text = "|cffE7E716"..DND.."|r", notCheckable=true, func = function() if not IsChatDND() then SendChatMessage("", "DND") end end },
  2904. { text = "|cffFF0000"..AFK.."|r", notCheckable=true, func = function() if not IsChatAFK() then SendChatMessage("", "AFK") end end },
  2905. },
  2906. },
  2907. { text = BN_BROADCAST_TOOLTIP, notCheckable=true, func = function() T.ShowPopup("TUKUI_SET_BN_BROADCAST") end },
  2908. }
  2909.  
  2910. local function GetTableIndex(table, fieldIndex, value)
  2911. for k,v in ipairs(table) do
  2912. if v[fieldIndex] == value then return k end
  2913. end
  2914. return -1
  2915. end
  2916.  
  2917. local function inviteClick(self, arg1, arg2, checked)
  2918. menuFrame:Hide()
  2919. if type(arg1) ~= 'number' then
  2920. InviteUnit(arg1)
  2921. else
  2922. BNInviteFriend(arg1);
  2923. end
  2924. end
  2925.  
  2926. local function whisperClick(self,name,bnet)
  2927. menuFrame:Hide()
  2928. if bnet then
  2929. ChatFrame_SendSmartTell(name)
  2930. else
  2931. SetItemRef( "player:"..name, ("|Hplayer:%1$s|h[%1$s]|h"):format(name), "LeftButton" )
  2932. end
  2933. end
  2934.  
  2935. local levelNameString = "|cff%02x%02x%02x%d|r |cff%02x%02x%02x%s|r"
  2936. local clientLevelNameString = "%s (|cff%02x%02x%02x%d|r |cff%02x%02x%02x%s|r%s) |cff%02x%02x%02x%s|r"
  2937. local levelNameClassString = "|cff%02x%02x%02x%d|r %s%s%s"
  2938. local worldOfWarcraftString = "World of Warcraft"
  2939. local battleNetString = "Battle.NET"
  2940. local wowString = "WoW"
  2941. local totalOnlineString = "Online: " .. "%s/%s"
  2942. local tthead, ttsubh, ttoff = {r=0.4, g=0.78, b=1}, {r=0.75, g=0.9, b=1}, {r=.3,g=1,b=.3}
  2943. local activezone, inactivezone = {r=0.3, g=1.0, b=0.3}, {r=0.65, g=0.65, b=0.65}
  2944. local displayString = string.join("", hexa.."%s: "..hexb, "|cffffffff", "%d|r")
  2945. local statusTable = { "|cffff0000[AFK]|r", "|cffff0000[DND]|r", "" }
  2946. local groupedTable = { "|cffaaaaaa*|r", "" }
  2947. local friendTable, BNTable = {}, {}
  2948. local totalOnline, BNTotalOnline = 0, 0
  2949.  
  2950. local function BuildFriendTable(total)
  2951. totalOnline = 0
  2952. wipe(friendTable)
  2953. local name, level, class, area, connected, status, note
  2954. for i = 1, total do
  2955. name, level, class, area, connected, status, note = GetFriendInfo(i)
  2956. for k,v in pairs(LOCALIZED_CLASS_NAMES_MALE) do if class == v then class = k end end
  2957.  
  2958. if status == "<"..AFK..">" then
  2959. status = "|cffff0000[AFK]|r"
  2960. elseif status == "<"..DND..">" then
  2961. status = "|cffff0000[DND]|r"
  2962. end
  2963.  
  2964. friendTable[i] = { name, level, class, area, connected, status, note }
  2965. if connected then totalOnline = totalOnline + 1 end
  2966. end
  2967. end
  2968.  
  2969. local function UpdateFriendTable(total)
  2970. totalOnline = 0
  2971. local name, level, class, area, connected, status, note
  2972. for i = 1, #friendTable do
  2973. name, level, class, area, connected, status, note = GetFriendInfo(i)
  2974. for k,v in pairs(LOCALIZED_CLASS_NAMES_MALE) do if class == v then class = k end end
  2975.  
  2976. -- get the correct index in our table
  2977. local index = GetTableIndex(friendTable, 1, name)
  2978. -- we cannot find a friend in our table, so rebuild it
  2979. if index == -1 then
  2980. BuildFriendTable(total)
  2981. break
  2982. end
  2983. -- update on-line status for all members
  2984. friendTable[index][5] = connected
  2985. -- update information only for on-line members
  2986. if connected then
  2987. friendTable[index][2] = level
  2988. friendTable[index][3] = class
  2989. friendTable[index][4] = area
  2990. friendTable[index][6] = status
  2991. friendTable[index][7] = note
  2992. totalOnline = totalOnline + 1
  2993. end
  2994. end
  2995. end
  2996.  
  2997. local function BuildBNTable(total)
  2998. BNTotalOnline = 0
  2999. wipe(BNTable)
  3000.  
  3001. for i = 1, total do
  3002. local presenceID, presenceName, battleTag, isBattleTagPresence, toonName, toonID, client, isOnline, lastOnline, isAFK, isDND, messageText, noteText, isRIDFriend, messageTime, canSoR = BNGetFriendInfo(i)
  3003. local hasFocus, _, _, realmName, realmID, faction, race, class, guild, zoneName, level, gameText = BNGetToonInfo(presenceID)
  3004.  
  3005. for k,v in pairs(LOCALIZED_CLASS_NAMES_MALE) do if class == v then class = k end end
  3006.  
  3007. BNTable[i] = { presenceID, presenceName, battleTag, toonName, toonID, client, isOnline, isAFK, isDND, noteText, realmName, faction, race, class, zoneName, level }
  3008. if isOnline then BNTotalOnline = BNTotalOnline + 1 end
  3009. end
  3010. end
  3011.  
  3012. local function UpdateBNTable(total)
  3013. BNTotalOnline = 0
  3014. for i = 1, #BNTable do
  3015. -- get guild roster information
  3016. local presenceID, presenceName, battleTag, isBattleTagPresence, toonName, toonID, client, isOnline, lastOnline, isAFK, isDND, messageText, noteText, isRIDFriend, messageTime, canSoR = BNGetFriendInfo(i)
  3017. local hasFocus, _, _, realmName, realmID, faction, race, class, guild, zoneName, level, gameText = BNGetToonInfo(presenceID)
  3018.  
  3019. for k,v in pairs(LOCALIZED_CLASS_NAMES_MALE) do if class == v then class = k end end
  3020.  
  3021. -- get the correct index in our table
  3022. local index = GetTableIndex(BNTable, 1, presenceID)
  3023. -- we cannot find a BN member in our table, so rebuild it
  3024. if index == -1 then
  3025. BuildBNTable(total)
  3026. return
  3027. end
  3028. -- update on-line status for all members
  3029. BNTable[index][7] = isOnline
  3030. -- update information only for on-line members
  3031. if isOnline then
  3032. BNTable[index][2] = presenceName
  3033. BNTable[index][3] = battleTag
  3034. BNTable[index][4] = toonName
  3035. BNTable[index][5] = toonID
  3036. BNTable[index][6] = client
  3037. BNTable[index][8] = isAFK
  3038. BNTable[index][9] = isDND
  3039. BNTable[index][10] = noteText
  3040. BNTable[index][11] = realmName
  3041. BNTable[index][12] = faction
  3042. BNTable[index][13] = race
  3043. BNTable[index][14] = class
  3044. BNTable[index][15] = zoneName
  3045. BNTable[index][16] = level
  3046.  
  3047. BNTotalOnline = BNTotalOnline + 1
  3048. end
  3049. end
  3050. end
  3051.  
  3052. Stat:SetScript("OnMouseUp", function(self, btn)
  3053. if btn ~= "RightButton" then return end
  3054.  
  3055. GameTooltip:Hide()
  3056.  
  3057. local menuCountWhispers = 0
  3058. local menuCountInvites = 0
  3059. local classc, levelc
  3060.  
  3061. menuList[2].menuList = {}
  3062. menuList[3].menuList = {}
  3063.  
  3064. if totalOnline > 0 then
  3065. for i = 1, #friendTable do
  3066. if (friendTable[i][5]) then
  3067. menuCountInvites = menuCountInvites + 1
  3068. menuCountWhispers = menuCountWhispers + 1
  3069.  
  3070. classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[friendTable[i][3]], GetQuestDifficultyColor(friendTable[i][2])
  3071. if classc == nil then classc = GetQuestDifficultyColor(friendTable[i][2]) end
  3072.  
  3073. menuList[2].menuList[menuCountInvites] = {text = format(levelNameString,levelc.r*255,levelc.g*255,levelc.b*255,friendTable[i][2],classc.r*255,classc.g*255,classc.b*255,friendTable[i][1]), arg1 = friendTable[i][1],notCheckable=true, func = inviteClick}
  3074. menuList[3].menuList[menuCountWhispers] = {text = format(levelNameString,levelc.r*255,levelc.g*255,levelc.b*255,friendTable[i][2],classc.r*255,classc.g*255,classc.b*255,friendTable[i][1]), arg1 = friendTable[i][1],notCheckable=true, func = whisperClick}
  3075. end
  3076. end
  3077. end
  3078.  
  3079. if BNTotalOnline > 0 then
  3080. local realID, grouped
  3081. for i = 1, #BNTable do
  3082. if (BNTable[i][7]) then
  3083. realID = BNTable[i][2]
  3084. menuCountWhispers = menuCountWhispers + 1
  3085. menuList[3].menuList[menuCountWhispers] = {text = realID, arg1 = realID, arg2 = true, notCheckable=true, func = whisperClick}
  3086.  
  3087. if BNTable[i][6] == wowString and UnitFactionGroup("player") == BNTable[i][12] then
  3088. classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[BNTable[i][14]], GetQuestDifficultyColor(BNTable[i][16])
  3089. if classc == nil then classc = GetQuestDifficultyColor(BNTable[i][16]) end
  3090.  
  3091. if UnitInParty(BNTable[i][4]) or UnitInRaid(BNTable[i][4]) then grouped = 1 else grouped = 2 end
  3092. menuCountInvites = menuCountInvites + 1
  3093. menuList[2].menuList[menuCountInvites] = {text = format(levelNameString,levelc.r*255,levelc.g*255,levelc.b*255,BNTable[i][16],classc.r*255,classc.g*255,classc.b*255,BNTable[i][4]), arg1 = BNTable[i][5],notCheckable=true, func = inviteClick}
  3094. end
  3095. end
  3096. end
  3097. end
  3098.  
  3099. EasyMenu(menuList, menuFrame, "cursor", 0, 0, "MENU", 2)
  3100. end)
  3101.  
  3102. local function Update(self, event)
  3103. if event == "BN_FRIEND_INFO_CHANGED" or "BN_FRIEND_ACCOUNT_ONLINE" or "BN_FRIEND_ACCOUNT_OFFLINE" or "BN_TOON_NAME_UPDATED"
  3104. or "BN_FRIEND_TOON_ONLINE" or "BN_FRIEND_TOON_OFFLINE" or "PLAYER_ENTERING_WORLD" then
  3105. local BNTotal = BNGetNumFriends()
  3106. if BNTotal == #BNTable then
  3107. UpdateBNTable(BNTotal)
  3108. else
  3109. BuildBNTable(BNTotal)
  3110. end
  3111. end
  3112.  
  3113. if event == "FRIENDLIST_UPDATE" or "PLAYER_ENTERING_WORLD" then
  3114. local total = GetNumFriends()
  3115. if total == #friendTable then
  3116. UpdateFriendTable(total)
  3117. else
  3118. BuildFriendTable(total)
  3119. end
  3120. end
  3121.  
  3122. Text:SetFormattedText(displayString, "Friends", totalOnline + BNTotalOnline)
  3123. self:SetAllPoints(Text)
  3124. end
  3125.  
  3126. Stat:SetScript("OnMouseDown", function(self, btn) if btn == "LeftButton" then ToggleFriendsFrame() end end)
  3127. Stat:SetScript("OnEnter", function(self)
  3128. if InCombatLockdown() then return end
  3129.  
  3130. local totalonline = totalOnline + BNTotalOnline
  3131. local totalfriends = #friendTable + #BNTable
  3132. local zonec, classc, levelc, realmc, grouped
  3133. if totalonline > 0 then
  3134. local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  3135. GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  3136. GameTooltip:ClearLines()
  3137. GameTooltip:AddDoubleLine("Friends list:", format(totalOnlineString, totalonline, totalfriends),tthead.r,tthead.g,tthead.b,tthead.r,tthead.g,tthead.b)
  3138. if totalOnline > 0 then
  3139. GameTooltip:AddLine(' ')
  3140. GameTooltip:AddLine(worldOfWarcraftString)
  3141. for i = 1, #friendTable do
  3142. if friendTable[i][5] then
  3143. if GetRealZoneText() == friendTable[i][4] then zonec = activezone else zonec = inactivezone end
  3144. classc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[friendTable[i][3]]
  3145. if classc == nil then classc = GetQuestDifficultyColor(friendTable[i][2]) end
  3146.  
  3147. if friendTable[i][2] ~= '' then
  3148. levelc = GetQuestDifficultyColor(friendTable[i][2])
  3149. else
  3150. levelc = RAID_CLASS_COLORS["PRIEST"]
  3151. classc = RAID_CLASS_COLORS["PRIEST"]
  3152. end
  3153.  
  3154. if UnitInParty(friendTable[i][1]) or UnitInRaid(friendTable[i][1]) then grouped = 1 else grouped = 2 end
  3155. GameTooltip:AddDoubleLine(format(levelNameClassString,levelc.r*255,levelc.g*255,levelc.b*255,friendTable[i][2],friendTable[i][1],groupedTable[grouped]," "..friendTable[i][6]),friendTable[i][4],classc.r,classc.g,classc.b,zonec.r,zonec.g,zonec.b)
  3156. end
  3157. end
  3158. end
  3159. if BNTotalOnline > 0 then
  3160. GameTooltip:AddLine(' ')
  3161. GameTooltip:AddLine(battleNetString)
  3162.  
  3163. local status = 0
  3164. for i = 1, #BNTable do
  3165. if BNTable[i][7] then
  3166. if BNTable[i][6] == wowString then
  3167. if (BNTable[i][8] == true) then status = 1 elseif (BNTable[i][9] == true) then status = 2 else status = 3 end
  3168.  
  3169. classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[BNTable[i][14]], GetQuestDifficultyColor(BNTable[i][16])
  3170. if classc == nil then classc = GetQuestDifficultyColor(BNTable[i][16]) end
  3171.  
  3172. if UnitInParty(BNTable[i][4]) or UnitInRaid(BNTable[i][4]) then grouped = 1 else grouped = 2 end
  3173. GameTooltip:AddDoubleLine(format(clientLevelNameString, BNTable[i][6],levelc.r*255,levelc.g*255,levelc.b*255,BNTable[i][16],classc.r*255,classc.g*255,classc.b*255,BNTable[i][4],groupedTable[grouped], 255, 0, 0, statusTable[status]),BNTable[i][2],238,238,238,238,238,238)
  3174. if IsShiftKeyDown() then
  3175. if GetRealZoneText() == BNTable[i][15] then zonec = activezone else zonec = inactivezone end
  3176. if GetRealmName() == BNTable[i][11] then realmc = activezone else realmc = inactivezone end
  3177. GameTooltip:AddDoubleLine(" "..BNTable[i][15], BNTable[i][11], zonec.r, zonec.g, zonec.b, realmc.r, realmc.g, realmc.b)
  3178. end
  3179. else
  3180. GameTooltip:AddDoubleLine("|cffeeeeee"..BNTable[i][6].." ("..BNTable[i][4]..")|r", "|cffeeeeee"..BNTable[i][2].."|r")
  3181. end
  3182. end
  3183. end
  3184. end
  3185. GameTooltip:Show()
  3186. else
  3187. GameTooltip:Hide()
  3188. end
  3189. end)
  3190.  
  3191. Stat:RegisterEvent("BN_FRIEND_ACCOUNT_ONLINE")
  3192. Stat:RegisterEvent("BN_FRIEND_ACCOUNT_OFFLINE")
  3193. Stat:RegisterEvent("BN_FRIEND_INFO_CHANGED")
  3194. Stat:RegisterEvent("BN_FRIEND_TOON_ONLINE")
  3195. Stat:RegisterEvent("BN_FRIEND_TOON_OFFLINE")
  3196. Stat:RegisterEvent("BN_TOON_NAME_UPDATED")
  3197. Stat:RegisterEvent("FRIENDLIST_UPDATE")
  3198. Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
  3199.  
  3200. Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
  3201. Stat:SetScript("OnEvent", Update)
  3202. end
  3203.  
  3204. ---------
  3205. -- Guild
  3206. ---------
  3207. if db.datapanel.guild and db.datapanel.guild > 0 then
  3208.  
  3209. local Stat = CreateFrame("Frame")
  3210. Stat:EnableMouse(true)
  3211. Stat:SetFrameStrata("MEDIUM")
  3212. Stat:SetFrameLevel(3)
  3213.  
  3214. local Text = DataPanel:CreateFontString(nil, "OVERLAY")
  3215. Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
  3216. PP(db.datapanel.guild, Text)
  3217.  
  3218. local tthead, ttsubh, ttoff = {r=0.4, g=0.78, b=1}, {r=0.75, g=0.9, b=1}, {r=.3,g=1,b=.3}
  3219. local activezone, inactivezone = {r=0.3, g=1.0, b=0.3}, {r=0.65, g=0.65, b=0.65}
  3220. local displayString = string.join("", hexa.."%s: "..hexb, "|cffffffff", "%d|r")
  3221. local guildInfoString0 = "%s"
  3222. local guildInfoString1 = "%s [%d]"
  3223. local guildInfoString2 = "%s: %d/%d"
  3224. local guildMotDString = "%s |cffaaaaaa- |cffffffff%s"
  3225. local levelNameString = "|cff%02x%02x%02x%d|r |cff%02x%02x%02x%s|r %s"
  3226. local levelNameStatusString = "|cff%02x%02x%02x%d|r %s %s"
  3227. local nameRankString = "%s |cff999999-|cffffffff %s"
  3228. local noteString = " '%s'"
  3229. local officerNoteString = " o: '%s'"
  3230.  
  3231. local guildTable, guildXP, guildMotD = {}, {}, ""
  3232. local totalOnline = 0
  3233.  
  3234.  
  3235. local function BuildGuildTable()
  3236. totalOnline = 0
  3237. wipe(guildTable)
  3238. local _, name, rank, level, zone, note, officernote, connected, status, class, isMobile
  3239. for i = 1, GetNumGuildMembers() do
  3240. name, rank, _, level, _, zone, note, officernote, connected, status, class, _, _, isMobile = GetGuildRosterInfo(i)
  3241.  
  3242. if status == 1 then
  3243. status = "|cffff0000["..AFK.."]|r"
  3244. elseif status == 2 then
  3245. status = "|cffff0000["..DND.."]|r"
  3246. else
  3247. status = ""
  3248. end
  3249.  
  3250. guildTable[i] = { name, rank, level, zone, note, officernote, connected, status, class, isMobile }
  3251. if connected then totalOnline = totalOnline + 1 end
  3252. end
  3253. table.sort(guildTable, function(a, b)
  3254. if a and b then
  3255. return a[1] < b[1]
  3256. end
  3257. end)
  3258. end
  3259.  
  3260. local function UpdateGuildXP()
  3261. local currentXP, remainingXP = UnitGetGuildXP("player")
  3262. local nextLevelXP = currentXP + remainingXP
  3263.  
  3264. -- prevent 4.3 division / 0
  3265. if nextLevelXP == 0 or maxDailyXP == 0 then return end
  3266.  
  3267. local percentTotal = tostring(math.ceil((currentXP / nextLevelXP) * 100))
  3268.  
  3269. guildXP[0] = { currentXP, nextLevelXP, percentTotal }
  3270. end
  3271.  
  3272. local function UpdateGuildMessage()
  3273. guildMotD = GetGuildRosterMOTD()
  3274. end
  3275.  
  3276. local function Update(self, event, ...)
  3277. if event == "PLAYER_ENTERING_WORLD" then
  3278. self:UnregisterEvent("PLAYER_ENTERING_WORLD")
  3279. if IsInGuild() and not GuildFrame then LoadAddOn("Blizzard_GuildUI") end
  3280. end
  3281.  
  3282. if IsInGuild() then
  3283. totalOnline = 0
  3284. local name, rank, level, zone, note, officernote, connected, status, class
  3285. for i = 1, GetNumGuildMembers() do
  3286. local connected = select(9, GetGuildRosterInfo(i))
  3287. if connected then totalOnline = totalOnline + 1 end
  3288. end
  3289. Text:SetFormattedText(displayString, "Guild", totalOnline)
  3290. else
  3291. Text:SetText("No Guild")
  3292. end
  3293.  
  3294. self:SetAllPoints(Text)
  3295. end
  3296.  
  3297. local menuFrame = CreateFrame("Frame", "GuildRightClickMenu", UIParent, "UIDropDownMenuTemplate")
  3298. local menuList = {
  3299. { text = OPTIONS_MENU, isTitle = true,notCheckable=true},
  3300. { text = INVITE, hasArrow = true,notCheckable=true,},
  3301. { text = CHAT_MSG_WHISPER_INFORM, hasArrow = true,notCheckable=true,}
  3302. }
  3303.  
  3304. local function inviteClick(self, arg1, arg2, checked)
  3305. menuFrame:Hide()
  3306. InviteUnit(arg1)
  3307. end
  3308.  
  3309. local function whisperClick(self,arg1,arg2,checked)
  3310. menuFrame:Hide()
  3311. SetItemRef( "player:"..arg1, ("|Hplayer:%1$s|h[%1$s]|h"):format(arg1), "LeftButton" )
  3312. end
  3313.  
  3314. local function ToggleGuildFrame()
  3315. if IsInGuild() then
  3316. if not GuildFrame then LoadAddOn("Blizzard_GuildUI") end
  3317. GuildFrame_Toggle()
  3318. GuildFrame_TabClicked(GuildFrameTab2)
  3319. else
  3320. if not LookingForGuildFrame then LoadAddOn("Blizzard_LookingForGuildUI") end
  3321. LookingForGuildFrame_Toggle()
  3322. end
  3323. end
  3324.  
  3325. Stat:SetScript("OnMouseUp", function(self, btn)
  3326. if btn ~= "RightButton" or not IsInGuild() then return end
  3327.  
  3328. GameTooltip:Hide()
  3329.  
  3330. local classc, levelc, grouped
  3331. local menuCountWhispers = 0
  3332. local menuCountInvites = 0
  3333.  
  3334. menuList[2].menuList = {}
  3335. menuList[3].menuList = {}
  3336.  
  3337. for i = 1, #guildTable do
  3338. if (guildTable[i][7] and guildTable[i][1] ~= nDatamyname) then
  3339. local classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[guildTable[i][9]], GetQuestDifficultyColor(guildTable[i][3])
  3340.  
  3341. if UnitInParty(guildTable[i][1]) or UnitInRaid(guildTable[i][1]) then
  3342. grouped = "|cffaaaaaa*|r"
  3343. else
  3344. grouped = ""
  3345. if not guildTable[i][10] then
  3346. menuCountInvites = menuCountInvites + 1
  3347. menuList[2].menuList[menuCountInvites] = {text = string.format(levelNameString, levelc.r*255,levelc.g*255,levelc.b*255, guildTable[i][3], classc.r*255,classc.g*255,classc.b*255, guildTable[i][1], ""), arg1 = guildTable[i][1],notCheckable=true, func = inviteClick}
  3348. end
  3349. end
  3350. menuCountWhispers = menuCountWhispers + 1
  3351. menuList[3].menuList[menuCountWhispers] = {text = string.format(levelNameString, levelc.r*255,levelc.g*255,levelc.b*255, guildTable[i][3], classc.r*255,classc.g*255,classc.b*255, guildTable[i][1], grouped), arg1 = guildTable[i][1],notCheckable=true, func = whisperClick}
  3352. end
  3353. end
  3354.  
  3355. EasyMenu(menuList, menuFrame, "cursor", 0, 0, "MENU", 2)
  3356. end)
  3357.  
  3358. Stat:SetScript("OnEnter", function(self)
  3359. if InCombatLockdown() or not IsInGuild() then return end
  3360.  
  3361. GuildRoster()
  3362. UpdateGuildMessage()
  3363. BuildGuildTable()
  3364.  
  3365. local name, rank, level, zone, note, officernote, connected, status, class, isMobile
  3366. local zonec, classc, levelc
  3367. local online = totalOnline
  3368. local guildName, guildRankName, guildRankIndex = GetGuildInfo("player");
  3369. local GuildInfo = GetGuildInfo('player')
  3370. local GuildLevel = GetGuildLevel()
  3371.  
  3372. local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  3373. GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  3374. GameTooltip:ClearLines()
  3375. GameTooltip:AddLine(hexa..myname.."'s"..hexb.." Guild")
  3376. if GuildInfo then
  3377. GameTooltip:AddDoubleLine(string.format(guildInfoString0, GuildInfo), string.format(guildInfoString1, "Guild Level:", GuildLevel),tthead.r,tthead.g,tthead.b,tthead.r,tthead.g,tthead.b)
  3378. end
  3379. GameTooltip:AddLine' '
  3380. if GuildLevel then
  3381. GameTooltip:AddLine( string.format(guildInfoString2, "Member's Online", online, #guildTable),tthead.r,tthead.g,tthead.b)
  3382. end
  3383.  
  3384. if guildMotD ~= "" then GameTooltip:AddLine(' ')
  3385. GameTooltip:AddLine(string.format(guildMotDString, GUILD_MOTD, guildMotD), ttsubh.r, ttsubh.g, ttsubh.b, 1)
  3386. end
  3387.  
  3388. local col = RGBToHex(ttsubh.r, ttsubh.g, ttsubh.b)
  3389. GameTooltip:AddLine' '
  3390. if GuildLevel and GuildLevel ~= 25 then
  3391. --UpdateGuildXP()
  3392.  
  3393. if guildXP[0] then
  3394. local currentXP, nextLevelXP, percentTotal = unpack(guildXP[0])
  3395.  
  3396. GameTooltip:AddLine(string.format(col..GUILD_EXPERIENCE_CURRENT, "|r |cFFFFFFFF"..ShortValue(currentXP), ShortValue(nextLevelXP), percentTotal))
  3397. end
  3398. end
  3399.  
  3400. local _, _, standingID, barMin, barMax, barValue = GetGuildFactionInfo()
  3401. if standingID ~= 8 then -- Not Max Rep
  3402. barMax = barMax - barMin
  3403. barValue = barValue - barMin
  3404. barMin = 0
  3405. GameTooltip:AddLine(string.format("%s:|r |cFFFFFFFF%s/%s (%s%%)",col..COMBAT_FACTION_CHANGE, ShortValue(barValue), ShortValue(barMax), math.ceil((barValue / barMax) * 100)))
  3406. end
  3407.  
  3408. if online > 1 then
  3409. GameTooltip:AddLine(' ')
  3410. for i = 1, #guildTable do
  3411. if online <= 1 then
  3412. if online > 1 then GameTooltip:AddLine(format("+ %d More...", online - modules.Guild.maxguild),ttsubh.r,ttsubh.g,ttsubh.b) end
  3413. break
  3414. end
  3415.  
  3416. name, rank, level, zone, note, officernote, connected, status, class, isMobile = unpack(guildTable[i])
  3417. if connected and name ~= nDatamyname then
  3418. if GetRealZoneText() == zone then zonec = activezone else zonec = inactivezone end
  3419. classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class], GetQuestDifficultyColor(level)
  3420.  
  3421. if isMobile then zone = "" end
  3422.  
  3423. if IsShiftKeyDown() then
  3424. GameTooltip:AddDoubleLine(string.format(nameRankString, name, rank), zone, classc.r, classc.g, classc.b, zonec.r, zonec.g, zonec.b)
  3425. if note ~= "" then GameTooltip:AddLine(string.format(noteString, note), ttsubh.r, ttsubh.g, ttsubh.b, 1) end
  3426. if officernote ~= "" then GameTooltip:AddLine(string.format(officerNoteString, officernote), ttoff.r, ttoff.g, ttoff.b ,1) end
  3427. else
  3428. GameTooltip:AddDoubleLine(string.format(levelNameStatusString, levelc.r*255, levelc.g*255, levelc.b*255, level, name, status), zone, classc.r,classc.g,classc.b, zonec.r,zonec.g,zonec.b)
  3429. end
  3430. end
  3431. end
  3432. end
  3433. GameTooltip:AddLine' '
  3434. GameTooltip:AddLine("|cffeda55fLeft Click|r to Open Guild Roster")
  3435. GameTooltip:AddLine("|cffeda55fHold Shift & Mouseover|r to See Guild and Officer Note's")
  3436. GameTooltip:AddLine("|cffeda55fRight Click|r to open Options Menu")
  3437. GameTooltip:Show()
  3438. end)
  3439.  
  3440. Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
  3441. Stat:SetScript("OnMouseDown", function(self, btn)
  3442. if btn ~= "LeftButton" then return end
  3443. ToggleGuildFrame()
  3444. end)
  3445.  
  3446. Stat:RegisterEvent("GUILD_ROSTER_SHOW")
  3447. Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
  3448. Stat:RegisterEvent("GUILD_ROSTER_UPDATE")
  3449. Stat:RegisterEvent("PLAYER_GUILD_UPDATE")
  3450. Stat:SetScript("OnEvent", Update)
  3451. end
  3452.  
  3453. ----------------
  3454. -- Player Haste
  3455. ----------------
  3456. if db.datapanel.haste and db.datapanel.haste > 0 then
  3457. local Stat = CreateFrame('Frame')
  3458. Stat:EnableMouse(true)
  3459. Stat:SetFrameStrata('BACKGROUND')
  3460. Stat:SetFrameLevel(3)
  3461.  
  3462. local Text = DataPanel:CreateFontString(nil, 'OVERLAY')
  3463. Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
  3464. PP(db.datapanel.haste, Text)
  3465.  
  3466. local int = 1
  3467.  
  3468. local function Update(self, t)
  3469. local spellhaste = GetCombatRating(CR_HASTE_SPELL)
  3470. local rangedhaste = GetCombatRating(CR_HASTE_RANGED)
  3471. local attackhaste = GetCombatRating(CR_HASTE_MELEE)
  3472.  
  3473. if attackhaste > spellhaste and select(2, UnitClass("Player")) ~= "HUNTER" then
  3474. haste = attackhaste
  3475. elseif select(2, UnitClass("Player")) == "HUNTER" then
  3476. haste = rangedhaste
  3477. else
  3478. haste = spellhaste
  3479. end
  3480.  
  3481. int = int - t
  3482. if int < 0 then
  3483. Text:SetText(hexa.."Haste: "..hexb..haste)
  3484. int = 1
  3485. end
  3486. end
  3487.  
  3488. Stat:SetScript("OnUpdate", Update)
  3489. Update(Stat, 10)
  3490. end
  3491.  
  3492. --------------------
  3493. -- Heals Per Second
  3494. --------------------
  3495. if db.datapanel.hps_text and db.datapanel.hps_text > 0 then
  3496. local events = {SPELL_HEAL = true, SPELL_PERIODIC_HEAL = true}
  3497. local HPS_FEED = CreateFrame('Frame')
  3498. local player_id = UnitGUID('player')
  3499. local actual_heals_total, cmbt_time = 0
  3500.  
  3501. local hText = DataPanel:CreateFontString(nil, 'OVERLAY')
  3502. hText:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
  3503. hText:SetText("HPS: ", '0')
  3504.  
  3505. PP(db.datapanel.hps_text, hText)
  3506.  
  3507. HPS_FEED:EnableMouse(true)
  3508. HPS_FEED:SetFrameStrata('BACKGROUND')
  3509. HPS_FEED:SetFrameLevel(3)
  3510. HPS_FEED:SetHeight(20)
  3511. HPS_FEED:SetWidth(100)
  3512. HPS_FEED:SetAllPoints(hText)
  3513.  
  3514. HPS_FEED:SetScript('OnEvent', function(self, event, ...) self[event](self, ...) end)
  3515. HPS_FEED:RegisterEvent('PLAYER_LOGIN')
  3516.  
  3517. HPS_FEED:SetScript('OnUpdate', function(self, elap)
  3518. if UnitAffectingCombat('player') then
  3519. HPS_FEED:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
  3520. cmbt_time = cmbt_time + elap
  3521. else
  3522. HPS_FEED:UnregisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
  3523. end
  3524. hText:SetText(get_hps())
  3525. end)
  3526.  
  3527. function HPS_FEED:PLAYER_LOGIN()
  3528. HPS_FEED:RegisterEvent('PLAYER_REGEN_ENABLED')
  3529. HPS_FEED:RegisterEvent('PLAYER_REGEN_DISABLED')
  3530. player_id = UnitGUID('player')
  3531. HPS_FEED:UnregisterEvent('PLAYER_LOGIN')
  3532. end
  3533.  
  3534. -- handler for the combat log. used http://www.wowwiki.com/API_COMBAT_LOG_EVENT for api
  3535. function HPS_FEED:COMBAT_LOG_EVENT_UNFILTERED(...)
  3536. -- filter for events we only care about. i.e heals
  3537. if not events[select(2, ...)] then return end
  3538. if event == 'PLAYER_REGEN_DISABLED' then return end
  3539.  
  3540. -- only use events from the player
  3541. local id = select(4, ...)
  3542. if id == player_id then
  3543. if toc < 40200 then
  3544. amount_healed = select(13, ...)
  3545. amount_over_healed = select(14, ...)
  3546. else
  3547. amount_healed = select(15, ...)
  3548. amount_over_healed = select(16, ...)
  3549. end
  3550. -- add to the total the healed amount subtracting the overhealed amount
  3551. actual_heals_total = actual_heals_total + math.max(0, amount_healed - amount_over_healed)
  3552. end
  3553. end
  3554.  
  3555. function get_hps()
  3556. if (actual_heals_total == 0) then
  3557. return (hexa.."HPS: "..hexb..'0' )
  3558. else
  3559. return string.format('%.1f '..hexa.."HPS"..hexb, (actual_heals_total or 0) / (cmbt_time or 1))
  3560. end
  3561. end
  3562.  
  3563. function HPS_FEED:PLAYER_REGEN_ENABLED()
  3564. hText:SetText(get_hps)
  3565. end
  3566.  
  3567. function HPS_FEED:PLAYER_REGEN_DISABLED()
  3568. cmbt_time = 0
  3569. actual_heals_total = 0
  3570. end
  3571.  
  3572. HPS_FEED:SetScript('OnMouseDown', function (self, button, down)
  3573. cmbt_time = 0
  3574. actual_heals_total = 0
  3575. end)
  3576.  
  3577. end
  3578.  
  3579. ---------------
  3580. -- Professions
  3581. ---------------
  3582. if db.datapanel.pro and db.datapanel.pro > 0 then
  3583.  
  3584. local Stat = CreateFrame('Button')
  3585. Stat:RegisterEvent('PLAYER_ENTERING_WORLD')
  3586. Stat:SetFrameStrata('BACKGROUND')
  3587. Stat:SetFrameLevel(3)
  3588. Stat:EnableMouse(true)
  3589. Stat.tooltip = false
  3590.  
  3591. local Text = DataPanel:CreateFontString(nil, 'OVERLAY')
  3592. Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
  3593. PP(db.datapanel.pro, Text)
  3594.  
  3595. local function Update(self)
  3596. for i = 1, select("#", GetProfessions()) do
  3597. local v = select(i, GetProfessions());
  3598. if v ~= nil then
  3599. local name, texture, rank, maxRank = GetProfessionInfo(v)
  3600. Text:SetFormattedText(hexa.."Professions"..hexb)
  3601. end
  3602. end
  3603. self:SetAllPoints(Text)
  3604. end
  3605.  
  3606. Stat:SetScript('OnEnter', function()
  3607. if InCombatLockdown() then return end
  3608. local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  3609. GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  3610. GameTooltip:ClearLines()
  3611. GameTooltip:AddLine(hexa..myname.."'s"..hexb.." Professions")
  3612. GameTooltip:AddLine' '
  3613. for i = 1, select("#", GetProfessions()) do
  3614. local v = select(i, GetProfessions());
  3615. if v ~= nil then
  3616. local name, texture, rank, maxRank = GetProfessionInfo(v)
  3617. GameTooltip:AddDoubleLine(name, rank..' / '..maxRank,.75,.9,1,.3,1,.3)
  3618. end
  3619. end
  3620. GameTooltip:AddLine' '
  3621. GameTooltip:AddLine("|cffeda55fLeft Click|r to Open Profession #1")
  3622. GameTooltip:AddLine("|cffeda55fMiddle Click|r to Open Spell Book")
  3623. GameTooltip:AddLine("|cffeda55fRight Click|r to Open Profession #2")
  3624.  
  3625. GameTooltip:Show()
  3626. end)
  3627.  
  3628.  
  3629. Stat:SetScript("OnClick",function(self,btn)
  3630. local prof1, prof2 = GetProfessions()
  3631. if btn == "LeftButton" then
  3632. if prof1 then
  3633. if (GetProfessionInfo(prof1) == ('Herbalism')) then
  3634. print('|cff00B4FFBasic|rUI: |cffFF0000Herbalism has no options!|r')
  3635. elseif(GetProfessionInfo(prof1) == ('Skinning')) then
  3636. print('|cff00B4FFBasic|rUI: |cffFF0000Skinning has no options!|r')
  3637. elseif(GetProfessionInfo(prof1) == ('Mining')) then
  3638. CastSpellByName("Smelting")
  3639. else
  3640. CastSpellByName((GetProfessionInfo(prof1)))
  3641. end
  3642. else
  3643. print('|cff00B4FFBasic|rUI: |cffFF0000No Profession Found!|r')
  3644. end
  3645. elseif btn == 'MiddleButton' then
  3646. ToggleSpellBook(BOOKTYPE_PROFESSION);
  3647. elseif btn == "RightButton" then
  3648. if prof2 then
  3649. if (GetProfessionInfo(prof2) == ('Herbalism')) then
  3650. print('|cff00B4FFBasic|rUI: |cffFF0000Herbalism has no options!|r')
  3651. elseif(GetProfessionInfo(prof2) == ('Skinning')) then
  3652. print('|cff00B4FFBasic|rUI: |cffFF0000Skinning has no options!|r')
  3653. elseif(GetProfessionInfo(prof2) == ('Mining')) then
  3654. CastSpellByName("Smelting")
  3655. else
  3656. CastSpellByName((GetProfessionInfo(prof2)))
  3657. end
  3658. else
  3659. print('|cff00B4FFBasic|rUI: |cffFF0000No Profession Found!|r')
  3660. end
  3661. end
  3662. end)
  3663.  
  3664.  
  3665. Stat:RegisterForClicks("AnyUp")
  3666. Stat:SetScript('OnUpdate', Update)
  3667. Stat:SetScript('OnLeave', function() GameTooltip:Hide() end)
  3668. end
  3669.  
  3670.  
  3671. -----------
  3672. -- Recount
  3673. -----------
  3674. if db.datapanel.recount and db.datapanel.recount > 0 then
  3675.  
  3676. local RecountDPS = CreateFrame("Frame")
  3677. RecountDPS:EnableMouse(true)
  3678. RecountDPS:SetFrameStrata("MEDIUM")
  3679. RecountDPS:SetFrameLevel(3)
  3680.  
  3681. local Text = DataPanel:CreateFontString(nil, "OVERLAY")
  3682. Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
  3683. PP(db.datapanel.recount, Text)
  3684. RecountDPS:SetAllPoints(Text)
  3685.  
  3686. function OnEvent(self, event, ...)
  3687. if event == "PLAYER_LOGIN" then
  3688. if IsAddOnLoaded("Recount") then
  3689. RecountDPS:RegisterEvent("PLAYER_REGEN_ENABLED")
  3690. RecountDPS:RegisterEvent("PLAYER_REGEN_DISABLED")
  3691. myname = UnitName("player")
  3692. currentFightDPS = 0
  3693. else
  3694. return
  3695. end
  3696. RecountDPS:UnregisterEvent("PLAYER_LOGIN")
  3697. elseif event == "PLAYER_ENTERING_WORLD" then
  3698. self.updateDPS()
  3699. RecountDPS:UnregisterEvent("PLAYER_ENTERING_WORLD")
  3700. end
  3701. end
  3702.  
  3703. function RecountDPS:RecountHook_UpdateText()
  3704. self:updateDPS()
  3705. end
  3706.  
  3707. function RecountDPS:updateDPS()
  3708. Text:SetText(hexa.."DPS: "..hexb.. RecountDPS.getDPS() .. "|r")
  3709. end
  3710.  
  3711. function RecountDPS:getDPS()
  3712. if not IsAddOnLoaded("Recount") then return "N/A" end
  3713. if db.datapanel.recountraiddps == true then
  3714. -- show raid dps
  3715. _, dps = RecountDPS:getRaidValuePerSecond(Recount.db.profile.CurDataSet)
  3716. return dps
  3717. else
  3718. return RecountDPS.getValuePerSecond()
  3719. end
  3720. end
  3721.  
  3722. -- quick dps calculation from recount's data
  3723. function RecountDPS:getValuePerSecond()
  3724. local _, dps = Recount:MergedPetDamageDPS(Recount.db2.combatants[myname], Recount.db.profile.CurDataSet)
  3725. return math.floor(10 * dps + 0.5) / 10
  3726. end
  3727.  
  3728. function RecountDPS:getRaidValuePerSecond(tablename)
  3729. local dps, curdps, data, damage, temp = 0, 0, nil, 0, 0
  3730. for _,data in pairs(Recount.db2.combatants) do
  3731. if data.Fights and data.Fights[tablename] and (data.type=="Self" or data.type=="Grouped" or data.type=="Pet" or data.type=="Ungrouped") then
  3732. temp, curdps = Recount:MergedPetDamageDPS(data,tablename)
  3733. if data.type ~= "Pet" or (not Recount.db.profile.MergePets and data.Owner and (Recount.db2.combatants[data.Owner].type=="Self" or Recount.db2.combatants[data.Owner].type=="Grouped" or Recount.db2.combatants[data.Owner].type=="Ungrouped")) or (not Recount.db.profile.MergePets and data.Name and data.GUID and self:matchUnitGUID(data.Name, data.GUID)) then
  3734. dps = dps + 10 * curdps
  3735. damage = damage + temp
  3736. end
  3737. end
  3738. end
  3739. return math.floor(damage + 0.5) / 10, math.floor(dps + 0.5)/10
  3740. end
  3741.  
  3742. -- tracked events
  3743. RecountDPS:RegisterEvent("PLAYER_LOGIN")
  3744. RecountDPS:RegisterEvent("PLAYER_ENTERING_WORLD")
  3745.  
  3746. -- scripts
  3747. RecountDPS:SetScript("OnEnter", function(self)
  3748. if InCombatLockdown() then return end
  3749.  
  3750. local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  3751. GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  3752. GameTooltip:ClearLines()
  3753. GameTooltip:AddLine(hexa..myname.."'s"..hexb.." Damage")
  3754. GameTooltip:AddLine' '
  3755. if IsAddOnLoaded("Recount") then
  3756. local damage, dps = Recount:MergedPetDamageDPS(Recount.db2.combatants[myname], Recount.db.profile.CurDataSet)
  3757. local raid_damage, raid_dps = RecountDPS:getRaidValuePerSecond(Recount.db.profile.CurDataSet)
  3758. -- format the number
  3759. dps = math.floor(10 * dps + 0.5) / 10
  3760. GameTooltip:AddLine("Recount")
  3761. GameTooltip:AddDoubleLine("Personal Damage:", damage, 1, 1, 1, 0.8, 0.8, 0.8)
  3762. GameTooltip:AddDoubleLine("Personal DPS:", dps, 1, 1, 1, 0.8, 0.8, 0.8)
  3763. GameTooltip:AddLine(" ")
  3764. GameTooltip:AddDoubleLine("Raid Damage:", raid_damage, 1, 1, 1, 0.8, 0.8, 0.8)
  3765. GameTooltip:AddDoubleLine("Raid DPS:", raid_dps, 1, 1, 1, 0.8, 0.8, 0.8)
  3766. GameTooltip:AddLine(" ")
  3767. GameTooltip:AddLine("|cffeda55fLeft Click|r to toggle Recount")
  3768. GameTooltip:AddLine("|cffeda55fRight Click|r to reset data")
  3769. GameTooltip:AddLine("|cffeda55fShift + Right Click|r to open config")
  3770. else
  3771. GameTooltip:AddLine("Recount is not loaded.", 255, 0, 0)
  3772. GameTooltip:AddLine("Enable Recount and reload your UI.")
  3773. end
  3774. GameTooltip:Show()
  3775. end)
  3776. RecountDPS:SetScript("OnMouseUp", function(self, button)
  3777. if button == "RightButton" then
  3778. if not IsShiftKeyDown() then
  3779. Recount:ShowReset()
  3780. else
  3781. Recount:ShowConfig()
  3782. end
  3783. elseif button == "LeftButton" then
  3784. if Recount.MainWindow:IsShown() then
  3785. Recount.MainWindow:Hide()
  3786. else
  3787. Recount.MainWindow:Show()
  3788. Recount:RefreshMainWindow()
  3789. end
  3790. end
  3791. end)
  3792. RecountDPS:SetScript("OnEvent", OnEvent)
  3793. RecountDPS:SetScript("OnLeave", function() GameTooltip:Hide() end)
  3794. RecountDPS:SetScript("OnUpdate", function(self, t)
  3795. local int = -1
  3796. int = int - t
  3797. if int < 0 then
  3798. self.updateDPS()
  3799. int = 1
  3800. end
  3801. end)
  3802. end
  3803.  
  3804. --------------------
  3805. -- Talent Spec Swap
  3806. --------------------
  3807. if db.datapanel.spec and db.datapanel.spec > 0 then
  3808.  
  3809. local Stat = CreateFrame('Frame')
  3810. Stat:EnableMouse(true)
  3811. Stat:SetFrameStrata('BACKGROUND')
  3812. Stat:SetFrameLevel(3)
  3813.  
  3814. local Text = DataPanel:CreateFontString(nil, 'OVERLAY')
  3815. Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
  3816. PP(db.datapanel.spec, Text)
  3817.  
  3818. local talent = {}
  3819. local active
  3820. local talentString = string.join('', '|cffFFFFFF%s|r ')
  3821. local activeString = string.join('', '|cff00FF00' , ACTIVE_PETS, '|r')
  3822. local inactiveString = string.join('', '|cffFF0000', FACTION_INACTIVE, '|r')
  3823.  
  3824.  
  3825.  
  3826. local function LoadTalentTrees()
  3827. for i = 1, GetNumSpecGroups(false, false) do
  3828. talent[i] = {} -- init talent group table
  3829. for j = 1, GetNumSpecializations(false, false) do
  3830. talent[i][j] = select(5, GetSpecializationInfo(j, false, false, i))
  3831. end
  3832. end
  3833. end
  3834.  
  3835. local int = 1
  3836. local function Update(self, t)
  3837. int = int - t
  3838. if int > 0 or not GetSpecialization() then return end
  3839.  
  3840. active = GetActiveSpecGroup(false, false)
  3841. Text:SetFormattedText(talentString, hexa..select(2, GetSpecializationInfo(GetSpecialization(false, false, active)))..hexb)
  3842. int = 1
  3843.  
  3844. -- disable script
  3845. self:SetScript('OnUpdate', nil)
  3846. end
  3847.  
  3848.  
  3849. Stat:SetScript('OnEnter', function(self)
  3850. if InCombatLockdown() then return end
  3851.  
  3852. local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  3853. GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  3854.  
  3855. GameTooltip:ClearLines()
  3856. GameTooltip:AddLine(hexa..myname.."'s"..hexb.." Spec")
  3857. GameTooltip:AddLine' '
  3858. for i = 1, GetNumSpecGroups() do
  3859. if GetSpecialization(false, false, i) then
  3860. GameTooltip:AddLine(string.join('- ', string.format(talentString, select(2, GetSpecializationInfo(GetSpecialization(false, false, i)))), (i == active and activeString or inactiveString)),1,1,1)
  3861. end
  3862. end
  3863.  
  3864. GameTooltip:AddLine' '
  3865. GameTooltip:AddLine("|cffeda55fLeft Click|r to Switch Spec's")
  3866. GameTooltip:AddLine("|cffeda55fRight Click|r to Open Talent Tree")
  3867. GameTooltip:Show()
  3868. end)
  3869.  
  3870. Stat:SetScript('OnLeave', function() GameTooltip:Hide() end)
  3871.  
  3872. local function OnEvent(self, event, ...)
  3873. if event == 'PLAYER_ENTERING_WORLD' then
  3874. self:UnregisterEvent('PLAYER_ENTERING_WORLD')
  3875. end
  3876.  
  3877. -- load talent information
  3878. LoadTalentTrees()
  3879.  
  3880. -- Setup Talents Tooltip
  3881. self:SetAllPoints(Text)
  3882.  
  3883. -- update datatext
  3884. if event ~= 'PLAYER_ENTERING_WORLD' then
  3885. self:SetScript('OnUpdate', Update)
  3886. end
  3887. end
  3888.  
  3889.  
  3890.  
  3891. Stat:RegisterEvent('PLAYER_ENTERING_WORLD');
  3892. Stat:RegisterEvent('CHARACTER_POINTS_CHANGED');
  3893. Stat:RegisterEvent('PLAYER_TALENT_UPDATE');
  3894. Stat:RegisterEvent('ACTIVE_TALENT_GROUP_CHANGED')
  3895. Stat:RegisterEvent("EQUIPMENT_SETS_CHANGED")
  3896. Stat:SetScript('OnEvent', OnEvent)
  3897. Stat:SetScript('OnUpdate', Update)
  3898.  
  3899. Stat:SetScript("OnMouseDown", function(self, button)
  3900. if button == "LeftButton" then
  3901. SetActiveSpecGroup (active == 1 and 2 or 1)
  3902. elseif button == "RightButton" then
  3903. ToggleTalentFrame()
  3904. end
  3905. end)
  3906. end
  3907.  
  3908. -----------------
  3909. -- Statistics #1
  3910. -----------------
  3911. if db.datapanel.stat1 and db.datapanel.stat1 > 0 then
  3912.  
  3913. local Stat = CreateFrame("Frame")
  3914. Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
  3915. Stat:SetFrameStrata("BACKGROUND")
  3916. Stat:SetFrameLevel(3)
  3917. Stat:EnableMouse(true)
  3918.  
  3919. local Text = DataPanel:CreateFontString(nil, "OVERLAY")
  3920. Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
  3921. PP(db.datapanel.stat1, Text)
  3922.  
  3923. local format = string.format
  3924. local targetlv, playerlv = UnitLevel("target"), UnitLevel("player")
  3925. local basemisschance, leveldifference, dodge, parry, block
  3926. local chanceString = "%.2f%%"
  3927. local modifierString = string.join("", "%d (+", chanceString, ")")
  3928. local manaRegenString = "%d / %d"
  3929. local displayNumberString = string.join("", "%s", "%d|r")
  3930. local displayFloatString = string.join("", "%s", "%.2f%%|r")
  3931. local spellpwr, avoidance, pwr
  3932. local haste, hasteBonus
  3933. local level = UnitLevel("player")
  3934.  
  3935. local function ShowTooltip(self)
  3936. if InCombatLockdown() then return end
  3937.  
  3938. local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  3939. GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  3940. GameTooltip:ClearLines()
  3941. GameTooltip:AddLine(hexa..myname.."'s"..hexb.." Statistics")
  3942. GameTooltip:AddLine' '
  3943.  
  3944. if Role == "Tank" then
  3945. if targetlv > 1 then
  3946. GameTooltip:AddDoubleLine("Avoidance Breakdown", string.join("", " (", "lvl", " ", targetlv, ")"))
  3947. elseif targetlv == -1 then
  3948. GameTooltip:AddDoubleLine("Avoidance Breakdown", string.join("", " (", "Boss", ")"))
  3949. else
  3950. GameTooltip:AddDoubleLine("Avoidance Breakdown", string.join("", " (", "lvl", " ", playerlv, ")"))
  3951. end
  3952. GameTooltip:AddLine' '
  3953. GameTooltip:AddDoubleLine(DODGE_CHANCE, format(chanceString, dodge),1,1,1)
  3954. GameTooltip:AddDoubleLine(PARRY_CHANCE, format(chanceString, parry),1,1,1)
  3955. GameTooltip:AddDoubleLine(BLOCK_CHANCE, format(chanceString, block),1,1,1)
  3956. GameTooltip:AddDoubleLine(MISS_CHANCE, format(chanceString, basemisschance),1,1,1)
  3957. elseif Role == "Caster" then
  3958. GameTooltip:AddDoubleLine(STAT_HIT_CHANCE, format(modifierString, GetCombatRating(CR_HIT_SPELL), GetCombatRatingBonus(CR_HIT_SPELL)), 1, 1, 1)
  3959. GameTooltip:AddDoubleLine(STAT_HASTE, format(modifierString, GetCombatRating(CR_HASTE_SPELL), GetCombatRatingBonus(CR_HASTE_SPELL)), 1, 1, 1)
  3960. local base, combat = GetManaRegen()
  3961. GameTooltip:AddDoubleLine(MANA_REGEN, format(manaRegenString, base * 5, combat * 5), 1, 1, 1)
  3962. elseif Role == "Melee" then
  3963. local hit = myclass == "HUNTER" and GetCombatRating(CR_HIT_RANGED) or GetCombatRating(CR_HIT_MELEE)
  3964. local hitBonus = myclass == "HUNTER" and GetCombatRatingBonus(CR_HIT_RANGED) or GetCombatRatingBonus(CR_HIT_MELEE)
  3965.  
  3966. GameTooltip:AddDoubleLine(STAT_HIT_CHANCE, format(modifierString, hit, hitBonus), 1, 1, 1)
  3967.  
  3968. local haste = myclass == "HUNTER" and GetCombatRating(CR_HASTE_RANGED) or GetCombatRating(CR_HASTE_MELEE)
  3969. local hasteBonus = myclass == "HUNTER" and GetCombatRatingBonus(CR_HASTE_RANGED) or GetCombatRatingBonus(CR_HASTE_MELEE)
  3970.  
  3971. GameTooltip:AddDoubleLine(STAT_HASTE, format(modifierString, haste, hasteBonus), 1, 1, 1)
  3972. end
  3973.  
  3974. local masteryspell
  3975. if GetCombatRating(CR_MASTERY) ~= 0 and GetSpecialization() then
  3976. if myclass == "DRUID" then
  3977. if Role == "Melee" then
  3978. masteryspell = select(2, GetSpecializationMasterySpells(GetSpecialization()))
  3979. elseif Role == "Tank" then
  3980. masteryspell = select(1, GetSpecializationMasterySpells(GetSpecialization()))
  3981. else
  3982. masteryspell = GetSpecializationMasterySpells(GetSpecialization())
  3983. end
  3984. else
  3985. masteryspell = GetSpecializationMasterySpells(GetSpecialization())
  3986. end
  3987.  
  3988.  
  3989.  
  3990. local masteryName, _, _, _, _, _, _, _, _ = GetSpellInfo(masteryspell)
  3991. if masteryName then
  3992. GameTooltip:AddLine' '
  3993. GameTooltip:AddDoubleLine(masteryName, format(modifierString, GetCombatRating(CR_MASTERY), GetCombatRatingBonus(CR_MASTERY)), 1, 1, 1)
  3994. end
  3995. end
  3996.  
  3997. GameTooltip:Show()
  3998. end
  3999.  
  4000. local function UpdateTank(self)
  4001.  
  4002. -- the 5 is for base miss chance
  4003. if targetlv == -1 then
  4004. basemisschance = (5 - (3*.2))
  4005. leveldifference = 3
  4006. elseif targetlv > playerlv then
  4007. basemisschance = (5 - ((targetlv - playerlv)*.2))
  4008. leveldifference = (targetlv - playerlv)
  4009. elseif targetlv < playerlv and targetlv > 0 then
  4010. basemisschance = (5 + ((playerlv - targetlv)*.2))
  4011. leveldifference = (targetlv - playerlv)
  4012. else
  4013. basemisschance = 5
  4014. leveldifference = 0
  4015. end
  4016.  
  4017. if select(2, UnitRace("player")) == "NightElf" then basemisschance = basemisschance + 2 end
  4018.  
  4019. if leveldifference >= 0 then
  4020. dodge = (GetDodgeChance()-leveldifference*.2)
  4021. parry = (GetParryChance()-leveldifference*.2)
  4022. block = (GetBlockChance()-leveldifference*.2)
  4023. else
  4024. dodge = (GetDodgeChance()+abs(leveldifference*.2))
  4025. parry = (GetParryChance()+abs(leveldifference*.2))
  4026. block = (GetBlockChance()+abs(leveldifference*.2))
  4027. end
  4028.  
  4029. if dodge <= 0 then dodge = 0 end
  4030. if parry <= 0 then parry = 0 end
  4031. if block <= 0 then block = 0 end
  4032.  
  4033. if myclass == "DRUID" then
  4034. parry = 0
  4035. block = 0
  4036. elseif myclass == "DEATHKNIGHT" then
  4037. block = 0
  4038. end
  4039. avoidance = (dodge+parry+block+basemisschance)
  4040.  
  4041. Text:SetFormattedText(displayFloatString, hexa.."AVD: "..hexb, avoidance)
  4042. --Setup Tooltip
  4043. self:SetAllPoints(Text)
  4044. end
  4045.  
  4046. local function UpdateCaster(self)
  4047. if GetSpellBonusHealing() > GetSpellBonusDamage(7) then
  4048. spellpwr = GetSpellBonusHealing()
  4049. else
  4050. spellpwr = GetSpellBonusDamage(7)
  4051. end
  4052.  
  4053. Text:SetFormattedText(displayNumberString, hexa.."SP: "..hexb, spellpwr)
  4054. --Setup Tooltip
  4055. self:SetAllPoints(Text)
  4056. end
  4057.  
  4058. local function UpdateMelee(self)
  4059. local base, posBuff, negBuff = UnitAttackPower("player");
  4060. local effective = base + posBuff + negBuff;
  4061. local Rbase, RposBuff, RnegBuff = UnitRangedAttackPower("player");
  4062. local Reffective = Rbase + RposBuff + RnegBuff;
  4063.  
  4064. if myclass == "HUNTER" then
  4065. pwr = Reffective
  4066. else
  4067. pwr = effective
  4068. end
  4069.  
  4070. Text:SetFormattedText(displayNumberString, hexa.."AP: "..hexb, pwr)
  4071. --Setup Tooltip
  4072. self:SetAllPoints(Text)
  4073. end
  4074.  
  4075. -- initial delay for update (let the ui load)
  4076. local int = 5
  4077. local function Update(self, t)
  4078. int = int - t
  4079. if int > 0 then return end
  4080. if Role == "Tank" then
  4081. UpdateTank(self)
  4082. elseif Role == "Caster" then
  4083. UpdateCaster(self)
  4084. elseif Role == "Melee" then
  4085. UpdateMelee(self)
  4086. end
  4087. int = 2
  4088. end
  4089.  
  4090. Stat:SetScript("OnEnter", function() ShowTooltip(Stat) end)
  4091. Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
  4092. Stat:SetScript("OnUpdate", Update)
  4093. Update(Stat, 10)
  4094. end
  4095.  
  4096. -----------------
  4097. -- Statistics #2
  4098. -----------------
  4099. if db.datapanel.stat2 and db.datapanel.stat2 > 0 then
  4100.  
  4101. local Stat = CreateFrame("Frame")
  4102. Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
  4103. Stat:SetFrameStrata("BACKGROUND")
  4104. Stat:SetFrameLevel(3)
  4105. Stat:EnableMouse(true)
  4106.  
  4107. local Text = DataPanel:CreateFontString(nil, "OVERLAY")
  4108. Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
  4109. PP(db.datapanel.stat2, Text)
  4110.  
  4111. local _G = getfenv(0)
  4112. local format = string.format
  4113. local chanceString = "%.2f%%"
  4114. local armorString = hexa..ARMOR..hexb..": "
  4115. local modifierString = string.join("", "%d (+", chanceString, ")")
  4116. local baseArmor, effectiveArmor, armor, posBuff, negBuff
  4117. local displayNumberString = string.join("", "%s", "%d|r")
  4118. local displayFloatString = string.join("", "%s", "%.2f%%|r")
  4119. local level = UnitLevel("player")
  4120.  
  4121.  
  4122. local function CalculateMitigation(level, effective)
  4123. local mitigation
  4124.  
  4125. if not effective then
  4126. _, effective, _, _, _ = UnitArmor("player")
  4127. end
  4128.  
  4129. if level < 60 then
  4130. mitigation = (effective/(effective + 400 + (85 * level)));
  4131. else
  4132. mitigation = (effective/(effective + (467.5 * level - 22167.5)));
  4133. end
  4134. if mitigation > .75 then
  4135. mitigation = .75
  4136. end
  4137. return mitigation
  4138. end
  4139.  
  4140. local function AddTooltipHeader(description)
  4141. GameTooltip:AddLine(description)
  4142. GameTooltip:AddLine(' ')
  4143. end
  4144.  
  4145. local function ShowTooltip(self)
  4146. if InCombatLockdown() then return end
  4147.  
  4148. local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  4149. GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  4150. GameTooltip:ClearLines()
  4151. GameTooltip:AddLine(hexa..myname.."'s"..hexb.." Statistics")
  4152. GameTooltip:AddLine' '
  4153.  
  4154. if Role == "Tank" then
  4155. AddTooltipHeader("Mitigation By Level: ")
  4156. local lv = level +3
  4157. for i = 1, 4 do
  4158. GameTooltip:AddDoubleLine(lv,format(chanceString, CalculateMitigation(lv, effectiveArmor) * 100),1,1,1)
  4159. lv = lv - 1
  4160. end
  4161. lv = UnitLevel("target")
  4162. if lv and lv > 0 and (lv > level + 3 or lv < level) then
  4163. GameTooltip:AddDoubleLine(lv, format(chanceString, CalculateMitigation(lv, effectiveArmor) * 100),1,1,1)
  4164. end
  4165. elseif Role == "Caster" or Role == "Melee" then
  4166. AddTooltipHeader(MAGIC_RESISTANCES_COLON)
  4167.  
  4168. local baseResistance, effectiveResistance, posResitance, negResistance
  4169. for i = 2, 6 do
  4170. baseResistance, effectiveResistance, posResitance, negResistance = UnitResistance("player", i)
  4171. GameTooltip:AddDoubleLine(_G["DAMAGE_SCHOOL"..(i+1)], format(chanceString, (effectiveResistance / (effectiveResistance + (500 + level + 2.5))) * 100),1,1,1)
  4172. end
  4173.  
  4174. local spellpen = GetSpellPenetration()
  4175. if (myclass == "SHAMAN" or Role == "Caster") and spellpen > 0 then
  4176. GameTooltip:AddLine' '
  4177. GameTooltip:AddDoubleLine(ITEM_MOD_SPELL_PENETRATION_SHORT, spellpen,1,1,1)
  4178. end
  4179. end
  4180. GameTooltip:Show()
  4181. end
  4182.  
  4183. local function UpdateTank(self)
  4184. baseArmor, effectiveArmor, armor, posBuff, negBuff = UnitArmor("player");
  4185.  
  4186. Text:SetFormattedText(displayNumberString, armorString, effectiveArmor)
  4187. --Setup Tooltip
  4188. self:SetAllPoints(Text)
  4189. end
  4190.  
  4191. local function UpdateCaster(self)
  4192. local spellcrit = GetSpellCritChance(1)
  4193.  
  4194. Text:SetFormattedText(displayFloatString, hexa.."Crit: "..hexb, spellcrit)
  4195. --Setup Tooltip
  4196. self:SetAllPoints(Text)
  4197. end
  4198.  
  4199. local function UpdateMelee(self)
  4200. local meleecrit = GetCritChance()
  4201. local rangedcrit = GetRangedCritChance()
  4202. local critChance
  4203.  
  4204. if myclass == "HUNTER" then
  4205. critChance = rangedcrit
  4206. else
  4207. critChance = meleecrit
  4208. end
  4209.  
  4210. Text:SetFormattedText(displayFloatString, hexa.."Crit: "..hexb, critChance)
  4211. --Setup Tooltip
  4212. self:SetAllPoints(Text)
  4213. end
  4214.  
  4215. -- initial delay for update (let the ui load)
  4216. local int = 5
  4217. local function Update(self, t)
  4218. int = int - t
  4219. if int > 0 then return end
  4220.  
  4221. if Role == "Tank" then
  4222. UpdateTank(self)
  4223. elseif Role == "Caster" then
  4224. UpdateCaster(self)
  4225. elseif Role == "Melee" then
  4226. UpdateMelee(self)
  4227. end
  4228. int = 2
  4229. end
  4230.  
  4231. Stat:SetScript("OnEnter", function() ShowTooltip(Stat) end)
  4232. Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
  4233. Stat:SetScript("OnUpdate", Update)
  4234. Update(Stat, 10)
  4235. end
  4236.  
  4237. -------------------
  4238. -- System Settings
  4239. -------------------
  4240. if db.datapanel.system and db.datapanel.system > 0 then
  4241.  
  4242. local Stat = CreateFrame("Frame")
  4243. Stat:RegisterEvent("PLAYER_ENTERING_WORLD")
  4244. Stat:SetFrameStrata("BACKGROUND")
  4245. Stat:SetFrameLevel(3)
  4246. Stat:EnableMouse(true)
  4247. Stat.tooltip = false
  4248.  
  4249. local Text = DataPanel:CreateFontString(nil, "OVERLAY")
  4250. Text:SetFont(db.fontNormal, db.fontSize,'THINOUTLINE')
  4251. PP(db.datapanel.system, Text)
  4252.  
  4253. local bandwidthString = "%.2f Mbps"
  4254. local percentageString = "%.2f%%"
  4255. local homeLatencyString = "%d ms"
  4256. local worldLatencyString = "%d ms"
  4257. local kiloByteString = "%d kb"
  4258. local megaByteString = "%.2f mb"
  4259.  
  4260. local function formatMem(memory)
  4261. local mult = 10^1
  4262. if memory > 999 then
  4263. local mem = ((memory/1024) * mult) / mult
  4264. return string.format(megaByteString, mem)
  4265. else
  4266. local mem = (memory * mult) / mult
  4267. return string.format(kiloByteString, mem)
  4268. end
  4269. end
  4270.  
  4271. local memoryTable = {}
  4272.  
  4273. local function RebuildAddonList(self)
  4274. local addOnCount = GetNumAddOns()
  4275. if (addOnCount == #memoryTable) or self.tooltip == true then return end
  4276.  
  4277. -- Number of loaded addons changed, create new memoryTable for all addons
  4278. memoryTable = {}
  4279. for i = 1, addOnCount do
  4280. memoryTable[i] = { i, select(2, GetAddOnInfo(i)), 0, IsAddOnLoaded(i) }
  4281. end
  4282. self:SetAllPoints(Text)
  4283. end
  4284.  
  4285. local function UpdateMemory()
  4286. -- Update the memory usages of the addons
  4287. UpdateAddOnMemoryUsage()
  4288. -- Load memory usage in table
  4289. local addOnMem = 0
  4290. local totalMemory = 0
  4291. for i = 1, #memoryTable do
  4292. addOnMem = GetAddOnMemoryUsage(memoryTable[i][1])
  4293. memoryTable[i][3] = addOnMem
  4294. totalMemory = totalMemory + addOnMem
  4295. end
  4296. -- Sort the table to put the largest addon on top
  4297. table.sort(memoryTable, function(a, b)
  4298. if a and b then
  4299. return a[3] > b[3]
  4300. end
  4301. end)
  4302.  
  4303. return totalMemory
  4304. end
  4305.  
  4306. -- initial delay for update (let the ui load)
  4307. local int, int2 = 6, 5
  4308. local statusColors = {
  4309. "|cff0CD809",
  4310. "|cffE8DA0F",
  4311. "|cffFF9000",
  4312. "|cffD80909"
  4313. }
  4314.  
  4315. local function Update(self, t)
  4316. int = int - t
  4317. int2 = int2 - t
  4318.  
  4319. if int < 0 then
  4320. RebuildAddonList(self)
  4321. int = 10
  4322. end
  4323. if int2 < 0 then
  4324. local framerate = floor(GetFramerate())
  4325. local fpscolor = 4
  4326. local latency = select(4, GetNetStats())
  4327. local latencycolor = 4
  4328.  
  4329. if latency < 150 then
  4330. latencycolor = 1
  4331. elseif latency >= 150 and latency < 300 then
  4332. latencycolor = 2
  4333. elseif latency >= 300 and latency < 500 then
  4334. latencycolor = 3
  4335. end
  4336. if framerate >= 30 then
  4337. fpscolor = 1
  4338. elseif framerate >= 20 and framerate < 30 then
  4339. fpscolor = 2
  4340. elseif framerate >= 10 and framerate < 20 then
  4341. fpscolor = 3
  4342. end
  4343. local displayFormat = string.join("", hexa.."FPS: "..hexb, statusColors[fpscolor], "%d|r", hexa.." MS: "..hexb, statusColors[latencycolor], "%d|r")
  4344. Text:SetFormattedText(displayFormat, framerate, latency)
  4345. int2 = 1
  4346. end
  4347. end
  4348. Stat:SetScript("OnMouseDown", function () collectgarbage("collect") Update(Stat, 20) end)
  4349. Stat:SetScript("OnEnter", function(self)
  4350. if InCombatLockdown() then return end
  4351. local bandwidth = GetAvailableBandwidth()
  4352. local _, _, latencyHome, latencyWorld = GetNetStats()
  4353. local anchor, panel, xoff, yoff = DataTextTooltipAnchor(Text)
  4354. GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  4355. GameTooltip:ClearLines()
  4356. GameTooltip:AddLine(hexa..myname.."'s"..hexb.." Latency")
  4357. GameTooltip:AddLine' '
  4358. GameTooltip:AddDoubleLine("Home Latency: ", string.format(homeLatencyString, latencyHome), 0.80, 0.31, 0.31,0.84, 0.75, 0.65)
  4359. GameTooltip:AddDoubleLine("World Latency: ", string.format(worldLatencyString, latencyWorld), 0.80, 0.31, 0.31,0.84, 0.75, 0.65)
  4360.  
  4361. if bandwidth ~= 0 then
  4362. GameTooltip:AddDoubleLine(L.datatext_bandwidth , string.format(bandwidthString, bandwidth),0.69, 0.31, 0.31,0.84, 0.75, 0.65)
  4363. GameTooltip:AddDoubleLine("Download: " , string.format(percentageString, GetDownloadedPercentage() *100),0.69, 0.31, 0.31, 0.84, 0.75, 0.65)
  4364. GameTooltip:AddLine(" ")
  4365. end
  4366. local totalMemory = UpdateMemory()
  4367. GameTooltip:AddDoubleLine("Total Memory Usage:", formatMem(totalMemory), 0.69, 0.31, 0.31,0.84, 0.75, 0.65)
  4368. GameTooltip:AddLine(" ")
  4369. for i = 1, #memoryTable do
  4370. if (memoryTable[i][4]) then
  4371. local red = memoryTable[i][3] / totalMemory
  4372. local green = 1 - red
  4373. GameTooltip:AddDoubleLine(memoryTable[i][2], formatMem(memoryTable[i][3]), 1, 1, 1, red, green + .5, 0)
  4374. end
  4375. end
  4376. GameTooltip:Show()
  4377. end)
  4378. Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)
  4379. Stat:SetScript("OnUpdate", Update)
  4380. Update(Stat, 10)
  4381. end
  4382. end
  4383.  
  4384. ----------
  4385. -- Font --
  4386. ----------
  4387. function BasicUI:Font()
  4388. local db = BasicUI.db.profile
  4389. -- Credit Game Font goes to Elv for his ElvUI project.
  4390. -- You can find his Addon at http://tukui.org/dl.php
  4391. -- Editied by Cokedriver
  4392.  
  4393. if db.fontEnable == true then
  4394.  
  4395. local function SetFont(obj, font, size, style, r, g, b, sr, sg, sb, sox, soy)
  4396. obj:SetFont(font, size, style)
  4397. if sr and sg and sb then obj:SetShadowColor(sr, sg, sb) end
  4398. if sox and soy then obj:SetShadowOffset(sox, soy) end
  4399. if r and g and b then obj:SetTextColor(r, g, b)
  4400. elseif r then obj:SetAlpha(r) end
  4401. end
  4402.  
  4403. local NORMAL = db.fontNormal
  4404. local BOLD = db.fontBold
  4405. local BOLDITALIC = db.fontBoldItalic
  4406. local ITALIC = db.fontItalic
  4407. local NUMBER = db.fontNormal
  4408.  
  4409. UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT = 15
  4410. CHAT_FONT_HEIGHTS = {7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}
  4411.  
  4412. UNIT_NAME_FONT = NORMAL
  4413. DAMAGE_TEXT_FONT = NUMBER
  4414. STANDARD_TEXT_FONT = NORMAL
  4415.  
  4416. -- Base fonts
  4417. SetFont(AchievementFont_Small, BOLD, db.fontSize)
  4418. SetFont(FriendsFont_Large, NORMAL, db.fontSize, nil, nil, nil, nil, 0, 0, 0, 1, -1)
  4419. SetFont(FriendsFont_Normal, NORMAL, db.fontSize, nil, nil, nil, nil, 0, 0, 0, 1, -1)
  4420. SetFont(FriendsFont_Small, NORMAL, db.fontSize, nil, nil, nil, nil, 0, 0, 0, 1, -1)
  4421. SetFont(FriendsFont_UserText, NUMBER, db.fontSize, nil, nil, nil, nil, 0, 0, 0, 1, -1)
  4422. SetFont(GameTooltipHeader, BOLD, db.fontSize, "OUTLINE")
  4423. SetFont(GameFont_Gigantic, BOLD, 32, nil, nil, nil, nil, 0, 0, 0, 1, -1)
  4424. SetFont(InvoiceFont_Med, ITALIC, db.fontSize, nil, 0.15, 0.09, 0.04)
  4425. SetFont(InvoiceFont_Small, ITALIC, db.fontSize, nil, 0.15, 0.09, 0.04)
  4426. SetFont(MailFont_Large, ITALIC, db.fontSize, nil, 0.15, 0.09, 0.04, 0.54, 0.4, 0.1, 1, -1)
  4427. SetFont(NumberFont_OutlineThick_Mono_Small, NUMBER, db.fontSize, "OUTLINE")
  4428. SetFont(NumberFont_Outline_Huge, NUMBER, 30, "THICKOUTLINE", 30)
  4429. SetFont(NumberFont_Outline_Large, NUMBER, 17, "OUTLINE")
  4430. SetFont(NumberFont_Outline_Med, NUMBER, db.fontSize, "OUTLINE")
  4431. SetFont(NumberFont_Shadow_Med, NORMAL, db.fontSize)
  4432. SetFont(NumberFont_Shadow_Small, NORMAL, db.fontSize)
  4433. SetFont(QuestFont_Shadow_Small, NORMAL, 16)
  4434. SetFont(QuestFont_Large, NORMAL, 16)
  4435. SetFont(QuestFont_Shadow_Huge, BOLD, 19, nil, nil, nil, nil, 0.54, 0.4, 0.1)
  4436. SetFont(QuestFont_Super_Huge, BOLD, 24)
  4437. SetFont(ReputationDetailFont, BOLD, db.fontSize, nil, nil, nil, nil, 0, 0, 0, 1, -1)
  4438. SetFont(SpellFont_Small, BOLD, db.fontSize)
  4439. SetFont(SystemFont_InverseShadow_Small, BOLD, db.fontSize)
  4440. SetFont(SystemFont_Large, NORMAL, 17)
  4441. SetFont(SystemFont_Med1, NORMAL, db.fontSize)
  4442. SetFont(SystemFont_Med2, ITALIC, db.fontSize, nil, 0.15, 0.09, 0.04)
  4443. SetFont(SystemFont_Med3, NORMAL, db.fontSize)
  4444. SetFont(SystemFont_OutlineThick_Huge2, NORMAL, 22, "THICKOUTLINE")
  4445. SetFont(SystemFont_OutlineThick_Huge4, BOLDITALIC, 27, "THICKOUTLINE")
  4446. SetFont(SystemFont_OutlineThick_WTF, BOLDITALIC, 31, "THICKOUTLINE", nil, nil, nil, 0, 0, 0, 1, -1)
  4447. SetFont(SystemFont_Outline_Small, NUMBER, db.fontSize, "OUTLINE")
  4448. SetFont(SystemFont_Shadow_Huge1, BOLD, 20)
  4449. SetFont(SystemFont_Shadow_Huge3, BOLD, 25)
  4450. SetFont(SystemFont_Shadow_Large, NORMAL, 17)
  4451. SetFont(SystemFont_Shadow_Med1, NORMAL, db.fontSize)
  4452. SetFont(SystemFont_Shadow_Med2, NORMAL, db.fontSize)
  4453. SetFont(SystemFont_Shadow_Med3, NORMAL, db.fontSize)
  4454. SetFont(SystemFont_Shadow_Outline_Huge2, NORMAL, 22, "OUTLINE")
  4455. SetFont(SystemFont_Shadow_Small, BOLD, db.fontSize)
  4456. SetFont(SystemFont_Small, NORMAL, db.fontSize)
  4457. SetFont(SystemFont_Tiny, NORMAL, db.fontSize)
  4458. SetFont(ChatBubbleFont, NORMAL, db.fontSize)
  4459.  
  4460.  
  4461. -- Derived fonts
  4462. SetFont(BossEmoteNormalHuge, BOLDITALIC, 27, "THICKOUTLINE")
  4463. SetFont(CombatTextFont, NORMAL, 26)
  4464. SetFont(ErrorFont, ITALIC, 16, nil, 60)
  4465. SetFont(QuestFontNormalSmall, BOLD, db.fontSize, nil, nil, nil, nil, 0.54, 0.4, 0.1)
  4466. SetFont(WorldMapTextFont, BOLDITALIC, 31, "THICKOUTLINE", 40, nil, nil, 0, 0, 0, 1, -1)
  4467.  
  4468. end
  4469. end
  4470.  
  4471. --------------
  4472. -- Merchant --
  4473. --------------
  4474. function BasicUI:Merchant()
  4475. local db = BasicUI.db.profile
  4476. -- Credit for Merchant goes to Tuks for his Tukui project.
  4477. -- You can find his Addon at http://tukui.org/dl.php
  4478. -- Editied by Cokedriver
  4479.  
  4480. if db.merchant.enable then
  4481.  
  4482. local filter = {
  4483. [6289] = true, -- Raw Longjaw Mud Snapper
  4484. [6291] = true, -- Raw Brilliant Smallfish
  4485. [6308] = true, -- Raw Bristle Whisker Catfish
  4486. [6309] = true, -- 17 Pound Catfish
  4487. [6310] = true, -- 19 Pound Catfish
  4488. [41808] = true, -- Bonescale Snapper
  4489. [42336] = true, -- Bloodstone Band
  4490. [42337] = true, -- Sun Rock Ring
  4491. [43244] = true, -- Crystal Citrine Necklace
  4492. [43571] = true, -- Sewer Carp
  4493. [43572] = true, -- Magic Eater
  4494. }
  4495.  
  4496. local f = CreateFrame("Frame")
  4497. f:SetScript("OnEvent", function()
  4498. if db.merchant.autoSellGrey or db.merchant.sellMisc then
  4499. local c = 0
  4500. for b=0,4 do
  4501. for s=1,GetContainerNumSlots(b) do
  4502. local l,lid = GetContainerItemLink(b, s), GetContainerItemID(b, s)
  4503. if l and lid then
  4504. local p = select(11, GetItemInfo(l))*select(2, GetContainerItemInfo(b, s))
  4505. if db.merchant.autoSellGrey and select(3, GetItemInfo(l))==0 then
  4506. UseContainerItem(b, s)
  4507. PickupMerchantItem()
  4508. c = c+p
  4509. end
  4510. if db.merchant.sellMisc and filter[ lid ] then
  4511. UseContainerItem(b, s)
  4512. PickupMerchantItem()
  4513. c = c+p
  4514. end
  4515. end
  4516. end
  4517. end
  4518. if c>0 then
  4519. local g, s, c = math.floor(c/10000) or 0, math.floor((c%10000)/100) or 0, c%100
  4520. DEFAULT_CHAT_FRAME:AddMessage("Your grey item's have been sold for".." |cffffffff"..g.."|cffffd700g|r".." |cffffffff"..s.."|cffc7c7cfs|r".." |cffffffff"..c.."|cffeda55fc|r"..".",255,255,0)
  4521. end
  4522. end
  4523. if not IsShiftKeyDown() then
  4524. if CanMerchantRepair() and db.merchant.autoRepair then
  4525. guildRepairFlag = 0
  4526. local cost, possible = GetRepairAllCost()
  4527. -- additional checks for guild repairs
  4528. if (IsInGuild()) and (CanGuildBankRepair()) then
  4529. if cost <= GetGuildBankWithdrawMoney() then
  4530. guildRepairFlag = 1
  4531. end
  4532. end
  4533. if cost>0 then
  4534. if (possible or guildRepairFlag) then
  4535. RepairAllItems(guildRepairFlag)
  4536. local c = cost%100
  4537. local s = math.floor((cost%10000)/100)
  4538. local g = math.floor(cost/10000)
  4539. if db.merchant.gpay == "true" and guildRepairFlag == 1 then
  4540. DEFAULT_CHAT_FRAME:AddMessage("Your guild payed".." |cffffffff"..g.."|cffffd700g|r".." |cffffffff"..s.."|cffc7c7cfs|r".." |cffffffff"..c.."|cffeda55fc|r".." to repair your gear.",255,255,0)
  4541. else
  4542. DEFAULT_CHAT_FRAME:AddMessage("You payed".." |cffffffff"..g.."|cffffd700g|r".." |cffffffff"..s.."|cffc7c7cfs|r".." |cffffffff"..c.."|cffeda55fc|r".." to repair your gear.",255,255,0)
  4543. end
  4544. else
  4545. DEFAULT_CHAT_FRAME:AddMessage("You don't have enough money for repair!",255,0,0)
  4546. end
  4547. end
  4548. end
  4549. end
  4550. end)
  4551. f:RegisterEvent("MERCHANT_SHOW")
  4552.  
  4553. end
  4554. end
  4555.  
  4556. ---------------
  4557. -- Nameplates --
  4558. ---------------
  4559. function BasicUI:Nameplates()
  4560. local db = BasicUI.db.profile
  4561.  
  4562. local len = string.len
  4563. local find = string.find
  4564. local gsub = string.gsub
  4565.  
  4566. local select = select
  4567. local tonumber = tonumber
  4568.  
  4569. local UnitName = UnitName
  4570. local UnitCastingInfo = UnitCastingInfo
  4571. local UnitChannelInfo = UnitChannelInfo
  4572.  
  4573. local borderColor = {0.47, 0.47, 0.47}
  4574. local noThreatColor = {0, 1, 0}
  4575.  
  4576. local glowTexture = 'Interface\\AddOns\\BasicUI\\Media\\NameplateNewGlow_LessGlow'
  4577. local overlayTexture = 'Interface\\AddOns\\BasicUI\\Media\\NameplateOverlay'
  4578. local whiteOverlay = 'Interface\\AddOns\\BasicUI\\Media\\NameplateIconOverlay'
  4579.  
  4580. local f = CreateFrame('Frame', nil, UIParent)
  4581.  
  4582. f.elapsed = 0
  4583. f.elapsedLong = 0
  4584.  
  4585. -- Totem data and functions
  4586.  
  4587. local function TotemName(SpellID)
  4588. local name = GetSpellInfo(SpellID)
  4589. return name
  4590. end
  4591.  
  4592. local function TotemIcon(SpellID)
  4593. local _, _, icon = GetSpellInfo(SpellID)
  4594. return icon
  4595. end
  4596.  
  4597. local totemData = {
  4598. -- Air
  4599. [TotemName(8177)] = {TotemIcon(8177)}, -- Grounding Totem
  4600. [TotemName(108269)] = {TotemIcon(108269)}, -- Capacitor Totem
  4601. [TotemName(120668)] = {TotemIcon(120668)}, -- Stormlash Totem
  4602. [TotemName(98009)] = {TotemIcon(98008)}, -- Spirit Link Totem
  4603.  
  4604. -- Earth
  4605. [TotemName(2062)] = {TotemIcon(2062)}, -- Earth Elemental Totem
  4606. [TotemName(2484)] = {TotemIcon(2484)}, -- Earthbind Totem
  4607. [TotemName(8143)] = {TotemIcon(8143)}, -- Tremor Totem
  4608.  
  4609. -- Fire
  4610. [TotemName(2894)] = {TotemIcon(2894)}, -- Fire Elemental Totem
  4611. [TotemName(8190)] = {TotemIcon(8190)}, -- Magma Totem
  4612. [TotemName(3599)] = {TotemIcon(3599)}, -- Searing Totem
  4613.  
  4614. -- Water
  4615. [TotemName(16190)] = {TotemIcon(16190)}, -- Mana Tide Totem
  4616. [TotemName(5394)] = {TotemIcon(5394)}, -- Healing Stream Totem
  4617. }
  4618.  
  4619. -- Some general functions
  4620.  
  4621. local function FormatValue(number)
  4622. if (number >= 1e6) then
  4623. return tonumber(format('%.1f', number/1e6))..'m'
  4624. elseif (number >= 1e3) then
  4625. return tonumber(format('%.1f', number/1e3))..'k'
  4626. else
  4627. return number
  4628. end
  4629. end
  4630.  
  4631. local function RGBHex(r, g, b)
  4632. if (type(r) == 'table') then
  4633. if (r.r) then
  4634. r, g, b = r.r, r.g, r.b
  4635. else
  4636. r, g, b = unpack(r)
  4637. end
  4638. end
  4639.  
  4640. return ('|cff%02x%02x%02x'):format(r * 255, g * 255, b * 255)
  4641. end
  4642.  
  4643. -- The plate functions
  4644.  
  4645. local function GetUnitReaction(r, g, b)
  4646. if (g + b == 0) then
  4647. return true
  4648. end
  4649.  
  4650. return false
  4651. end
  4652.  
  4653. local function GetUnitCombatStatus(r, g, b)
  4654. if (r >= 0.98) then
  4655. return true
  4656. end
  4657.  
  4658. return false
  4659. end
  4660.  
  4661. local function IsTarget(self)
  4662. local targetExists = UnitExists('target')
  4663. if (not targetExists) then
  4664. return false
  4665. end
  4666.  
  4667. local targetName = UnitName('target')
  4668. if (targetName == self.Name:GetText() and self:GetAlpha() >= 0.99) then
  4669. return true
  4670. else
  4671. return false
  4672. end
  4673. end
  4674.  
  4675. local function CanHaveThreat(r, g, b)
  4676. if (r < .01 and b < .01 and g > .99) then
  4677. return false
  4678. elseif (r < .01 and b > .99 and g < .01) then
  4679. return false
  4680. elseif (r > .99 and b < .01 and g > .99) then
  4681. return false
  4682. elseif (r > .99 and b < .01 and g < .01) then
  4683. return true
  4684. else
  4685. return true
  4686. end
  4687. end
  4688.  
  4689. local function UpdateTotemIcon(self)
  4690. if (totemData[self.Name:GetText()]) then
  4691. if (not self.Icon) then
  4692. self.Icon = CreateFrame('Frame', nil, self)
  4693. self.Icon:EnableMouse(false)
  4694. self.Icon:SetSize(24, 24)
  4695. self.Icon:SetPoint('BOTTOM', self.NewName, 'TOP', 0, 1)
  4696. end
  4697.  
  4698. local icon = totemData[self.Name:GetText()]
  4699. self.Icon:SetBackdrop({
  4700. bgFile = icon[1],
  4701. edgeFile = 'Interface\\Buttons\\WHITE8x8',
  4702. tile = true, tileSize = 16, edgeSize = 18,
  4703. insets = { top = -0, left = -0, bottom = -0, right = -0 },
  4704. })
  4705.  
  4706. local r, g, b = self.Health:GetStatusBarColor()
  4707. self.Icon:SetBackdropBorderColor(r, g, b, 1)
  4708. self.Icon:Show()
  4709. else
  4710. if (self.Icon) then
  4711. self.Icon:SetBackdrop(nil)
  4712. self.Icon:Hide()
  4713. self.Icon = nil
  4714. end
  4715. end
  4716. end
  4717.  
  4718. local function UpdateThreatColor(self)
  4719. local r, g, b
  4720. local playerInfight = InCombatLockdown()
  4721. local unitInfight = GetUnitCombatStatus(self.Name:GetTextColor())
  4722. local lowThreat = unitInfight and playerInfight
  4723. local isEnemy = GetUnitReaction(self.Health:GetStatusBarColor())
  4724.  
  4725. if (lowThreat and not self.Glow:IsVisible() and isEnemy and db.nameplates.enableTankMode) then
  4726. r, g, b = unpack(noThreatColor)
  4727. self.NewGlow:SetVertexColor(r, g, b)
  4728.  
  4729. if (not self.NewGlow:IsVisible()) then
  4730. self.NewGlow:Show()
  4731. end
  4732.  
  4733. if (db.nameplates.colorNameWithThreat) then
  4734. self.NewName:SetTextColor(r * 0.7, g * 0.7, b * 0.7)
  4735. end
  4736. elseif (self.Glow:IsVisible()) then
  4737. r, g, b = self.Glow:GetVertexColor()
  4738. self.NewGlow:SetVertexColor(r, g, b)
  4739.  
  4740. if (not self.NewGlow:IsVisible()) then
  4741. self.NewGlow:Show()
  4742. end
  4743.  
  4744. if (db.nameplates.colorNameWithThreat) then
  4745. self.NewName:SetTextColor(r, g, b)
  4746. end
  4747. else
  4748. if (self.NewGlow:IsVisible()) then
  4749. self.NewGlow:Hide()
  4750.  
  4751. if (db.nameplates.colorNameWithThreat) then
  4752. self.NewName:SetTextColor(1, 1, 1)
  4753. end
  4754. end
  4755. end
  4756. end
  4757.  
  4758. local function UpdateHealthText(self)
  4759. local min, max = self.Health:GetMinMaxValues()
  4760. local currentValue = self.Health:GetValue()
  4761. local perc = (currentValue/max)*100
  4762.  
  4763. if (perc >= 100 and currentValue > 5 and db.nameplates.showFullHP) then
  4764. self.Health.Value:SetFormattedText('%s', FormatValue(currentValue))
  4765. elseif (perc < 100 and currentValue > 5) then
  4766. self.Health.Value:SetFormattedText('%s - %.0f%%', FormatValue(currentValue), perc-0.5)
  4767. else
  4768. self.Health.Value:SetText('')
  4769. end
  4770. end
  4771.  
  4772. local function UpdateHealthColor(self)
  4773. local r, g, b = self.Health:GetStatusBarColor()
  4774. if (r + g == 0) then
  4775. self.Health:SetStatusBarColor(0, 0.35, 1)
  4776. return
  4777. end
  4778. end
  4779.  
  4780. local function UpdateCastbarValue(self, curValue)
  4781. local _, maxValue = self:GetMinMaxValues()
  4782. local cast = UnitCastingInfo('target')
  4783. local channel = UnitChannelInfo('target')
  4784.  
  4785. if (self.Shield:IsShown()) then
  4786. self.Overlay:SetVertexColor(1, 0, 1, 1)
  4787. self.Overlay:Show()
  4788. else
  4789. local r, g, b = unpack(borderColor)
  4790. self.Overlay:SetVertexColor(r, g, b, 1 )
  4791. end
  4792.  
  4793. if (channel) then
  4794. self.CastTime:SetFormattedText('%.1fs', curValue)
  4795. else
  4796. self.CastTime:SetFormattedText('%.1fs', maxValue - curValue)
  4797. end
  4798.  
  4799. self.Name:SetText(cast or channel)
  4800. end
  4801.  
  4802. local function UpdateNameL(self)
  4803. local newName = self.Name:GetText()
  4804. if (db.nameplates.abbrevLongNames) then
  4805. newName = (len(newName) > 20) and gsub(newName, '%s?(.[\128-\191]*)%S+%s', '%1. ') or newName
  4806. end
  4807.  
  4808. self.NewName:SetTextColor(1, 1, 1)
  4809. if (db.nameplates.showLevel) then
  4810. local levelText = self.Level:GetText() or ''
  4811. local levelColor = RGBHex(self.Level:GetTextColor())
  4812. local eliteTexture = self.EliteIcon:IsVisible()
  4813.  
  4814. if (self.BossIcon:IsVisible()) then
  4815. self.NewName:SetText('|cffff0000??|r '..newName)
  4816. elseif (eliteTexture) then
  4817. self.NewName:SetText('|cffffff00+|r'..levelColor..levelText..'|r '..newName)
  4818. else
  4819. self.NewName:SetText(levelColor..levelText..'|r '..newName)
  4820. end
  4821. else
  4822. self.NewName:SetText(newName)
  4823. end
  4824. end
  4825.  
  4826. local function UpdateEliteTexture(self)
  4827. local r, g, b = unpack(borderColor)
  4828. if (self.BossIcon:IsVisible() or self.EliteIcon:IsVisible()) then
  4829. self.Overlay:SetGradientAlpha('HORIZONTAL', r, g, b, 1, 1, 1, 0, 1)
  4830. else
  4831. self.Overlay:SetVertexColor(r, g, b, 1)
  4832. end
  4833. end
  4834.  
  4835. local function UpdatePlate(self)
  4836. if (self.Level) then
  4837. UpdateNameL(self)
  4838. end
  4839.  
  4840. if (db.nameplates.showEliteBorder) then
  4841. UpdateEliteTexture(self)
  4842. else
  4843. local r, g, b = unpack(borderColor)
  4844. self.Overlay:SetVertexColor(r, g, b, 1)
  4845. end
  4846.  
  4847. if (db.nameplates.showTotemIcon) then
  4848. UpdateTotemIcon(self)
  4849. end
  4850.  
  4851. UpdateHealthText(self)
  4852. UpdateHealthColor(self)
  4853. UpdateThreatColor(self)
  4854.  
  4855. self.Highlight:ClearAllPoints()
  4856. self.Highlight:SetAllPoints(self.Health)
  4857.  
  4858. if (self.Castbar:IsVisible()) then
  4859. self.Castbar:Hide()
  4860. end
  4861.  
  4862. local r, g, b = self.Health:GetStatusBarColor()
  4863. self.Castbar.IconOverlay:SetVertexColor(r, g, b)
  4864. end
  4865.  
  4866. local function SkinPlate(self, nameFrame)
  4867. self.Health, self.Castbar = self:GetChildren()
  4868. _, self.Castbar.Overlay, self.Castbar.Shield, self.Castbar.Icon = self.Castbar:GetRegions()
  4869. self.Glow, self.Overlay, self.Highlight, self.Level, self.BossIcon, self.RaidIcon, self.EliteIcon = self:GetRegions()
  4870. self.Name = nameFrame:GetRegions()
  4871.  
  4872. -- Hide some nameplate objects
  4873.  
  4874. self.Glow:SetTexCoord(0, 0, 0, 0)
  4875. self.BossIcon:SetTexCoord(0, 0, 0, 0)
  4876. self.EliteIcon:SetTexCoord(0, 0, 0, 0)
  4877. self.Castbar.Shield:SetTexCoord(0, 0, 0, 0)
  4878.  
  4879. self.Name:SetWidth(0.001)
  4880. self.Level:SetWidth(0.0001)
  4881.  
  4882. -- Modify the overlay
  4883.  
  4884. self.Overlay:SetTexCoord(0, 1, 0, 1)
  4885. self.Overlay:ClearAllPoints()
  4886. self.Overlay:SetPoint('TOPRIGHT', self.Health, 35.66666667, 5.66666667)
  4887. self.Overlay:SetPoint('BOTTOMLEFT', self.Health, -36.66666667, -5.66666667)
  4888. --self.Overlay:SetPoint('TOPRIGHT', self.Health, 29.66666667, 4.66666667)
  4889. --self.Overlay:SetPoint('BOTTOMLEFT', self.Health, -31.66666667, -4.66666667)
  4890. self.Overlay:SetDrawLayer('BORDER')
  4891. self.Overlay:SetTexture(overlayTexture)
  4892.  
  4893. -- Healtbar and background
  4894.  
  4895. self.Health:SetBackdrop({
  4896. bgFile = 'Interface\\Buttons\\WHITE8x8',
  4897. insets = { left = -1, right = -1, top = -1, bottom = -1 }
  4898. })
  4899. self.Health:SetBackdropColor(0, 0, 0, 0.55)
  4900.  
  4901. self.Health:SetScript('OnValueChanged', function()
  4902. UpdateHealthText(self)
  4903. UpdateHealthColor(self)
  4904. end)
  4905.  
  4906. -- Create health value font string
  4907.  
  4908. if (not self.Health.Value) then
  4909. self.Health.Value = self.Health:CreateFontString(nil, 'OVERLAY')
  4910. self.Health.Value:SetPoint('CENTER', self.Health, 0, 0)
  4911. self.Health.Value:SetFont(db.fontNormal, 12)
  4912. self.Health.Value:SetShadowOffset(1, -1)
  4913. end
  4914.  
  4915. if (not self.NewName) then
  4916. self.NewName = self:CreateFontString(nil, 'ARTWORK')
  4917. self.NewName:SetFont(db.fontNormal, 15, 'THINOUTLINE')
  4918. self.NewName:SetShadowOffset(0, 0)
  4919. -- self.NewName:SetPoint('CENTER', self.Health, 'CENTER', 0, 9)
  4920. self.NewName:SetPoint('BOTTOM', self.Health, 'TOP', 0, 2)
  4921. self.NewName:SetSize(110, 13)
  4922. end
  4923.  
  4924. if (not self.NewGlow) then
  4925. self.NewGlow = self.Health:CreateTexture(nil, 'BACKGROUND')
  4926. self.NewGlow:SetTexture(glowTexture)
  4927. self.NewGlow:SetAllPoints(self.Overlay)
  4928. self.NewGlow:Hide()
  4929. end
  4930.  
  4931. -- Castbar
  4932.  
  4933. self.Castbar:SetBackdrop({
  4934. bgFile = 'Interface\\Buttons\\WHITE8x8',
  4935. insets = { left = -1, right = -1, top = -1, bottom = -1 }
  4936. })
  4937. self.Castbar:SetBackdropColor(0.2, 0.2, 0.2, 0.5)
  4938.  
  4939. self.Castbar:ClearAllPoints()
  4940. self.Castbar:SetPoint('TOPRIGHT', self.Health, 'BOTTOMRIGHT', 0, -9)
  4941. self.Castbar:SetPoint('BOTTOMLEFT', self.Health, 'BOTTOMLEFT', 0, -20)
  4942.  
  4943. self.Castbar:HookScript('OnValueChanged', UpdateCastbarValue)
  4944.  
  4945. self.Castbar.Overlay:SetTexCoord(0, 1, 0, 1)
  4946. self.Castbar.Overlay:SetDrawLayer('BORDER')
  4947. self.Castbar.Overlay:SetTexture(overlayTexture)
  4948. self.Castbar.Overlay:ClearAllPoints()
  4949. self.Castbar.Overlay:SetPoint('TOPRIGHT', self.Castbar, 35.66666667, 5.66666667)
  4950. self.Castbar.Overlay:SetPoint('BOTTOMLEFT', self.Castbar, -36.66666667, -5.66666667)
  4951.  
  4952. -- Castbar casttime font string
  4953.  
  4954. if (not self.Castbar.CastTime) then
  4955. self.Castbar.CastTime = self.Castbar:CreateFontString(nil, 'OVERLAY')
  4956. self.Castbar.CastTime:SetPoint('RIGHT', self.Castbar, 1.6666667, 0)
  4957. self.Castbar.CastTime:SetFont(db.fontNormal, 16) -- , 'THINOUTLINE')
  4958. self.Castbar.CastTime:SetTextColor(1, 1, 1)
  4959. self.Castbar.CastTime:SetShadowOffset(1, -1)
  4960. end
  4961.  
  4962. -- Castbar castname font string
  4963.  
  4964. if (not self.Castbar.Name) then
  4965. self.Castbar.Name = self.Castbar:CreateFontString(nil, 'OVERLAY')
  4966. self.Castbar.Name:SetPoint('LEFT', self.Castbar, 1.5, 0)
  4967. self.Castbar.Name:SetPoint('RIGHT', self.Castbar.CastTime, 'LEFT', -6, 0)
  4968. self.Castbar.Name:SetFont(db.fontNormal, 10)
  4969. self.Castbar.Name:SetTextColor(1, 1, 1)
  4970. self.Castbar.Name:SetShadowOffset(1, -1)
  4971. self.Castbar.Name:SetJustifyH('LEFT')
  4972. end
  4973.  
  4974. -- Castbar spellicon and overlay
  4975.  
  4976. self.Castbar.Icon:SetParent(self.Castbar)
  4977. self.Castbar.Icon:ClearAllPoints()
  4978. self.Castbar.Icon:SetPoint('BOTTOMLEFT', self.Castbar, 'BOTTOMRIGHT', 7, 3)
  4979. self.Castbar.Icon:SetSize(24, 24)
  4980. self.Castbar.Icon:SetTexCoord(0.08, 0.92, 0.08, 0.92)
  4981. self.Castbar.Icon:SetDrawLayer('BACKGROUND')
  4982.  
  4983. if (not self.Castbar.IconOverlay) then
  4984. self.Castbar.IconOverlay = self.Castbar:CreateTexture(nil, 'OVERLAY')
  4985. self.Castbar.IconOverlay:SetPoint('TOPLEFT', self.Castbar.Icon, -1, 1)
  4986. self.Castbar.IconOverlay:SetPoint('BOTTOMRIGHT', self.Castbar.Icon, 1, -1)
  4987. self.Castbar.IconOverlay:SetTexture(whiteOverlay)
  4988. end
  4989.  
  4990. -- Mouseover highlight
  4991.  
  4992. self.Highlight:SetTexture(1, 1, 1, 0.2)
  4993.  
  4994. -- Raidicons
  4995.  
  4996. self.RaidIcon:ClearAllPoints()
  4997. self.RaidIcon:SetDrawLayer('OVERLAY')
  4998. self.RaidIcon:SetPoint('CENTER', self.Health, 'TOP', 0, 12)
  4999. self.RaidIcon:SetSize(16, 16)
  5000.  
  5001. -- Nameplates like cookies
  5002.  
  5003. UpdatePlate(self)
  5004.  
  5005. self:SetScript('OnUpdate', nil)
  5006. self:SetScript('OnShow', UpdatePlate)
  5007.  
  5008. self:SetScript('OnHide', function(self)
  5009. self.Highlight:Hide()
  5010. end)
  5011.  
  5012. self:SetScript('OnUpdate', function(_, elapsed)
  5013. f.elapsed = f.elapsed + elapsed
  5014. if (f.elapsed >= 0.1) then
  5015. if ((CanHaveThreat(self.Health:GetStatusBarColor()) and InCombatLockdown()) or self.NewGlow:IsShown()) then
  5016. UpdateThreatColor(self)
  5017. end
  5018.  
  5019. if (db.nameplates.showTargetBorder) then
  5020. if (IsTarget(self)) then
  5021. if (not self.TargetHighlight) then
  5022. self.TargetHighlight = self:CreateTexture(nil, 'ARTWORK')
  5023. self.TargetHighlight:SetAllPoints(self.Overlay)
  5024. self.TargetHighlight:SetTexture(overlayTexture)
  5025. self.TargetHighlight:Hide()
  5026. end
  5027.  
  5028. if (not self.TargetHighlight:IsVisible()) then
  5029. self.TargetHighlight:Show()
  5030. end
  5031. else
  5032. if (self.TargetHighlight and self.TargetHighlight:IsVisible()) then
  5033. self.TargetHighlight:Hide()
  5034. end
  5035. end
  5036. end
  5037.  
  5038. f.elapsed = 0
  5039. end
  5040.  
  5041. f.elapsedLong = f.elapsedLong + elapsed
  5042. if (f.elapsedLong >= 0.49) then
  5043. UpdateHealthColor(self)
  5044.  
  5045. f.elapsedLong = 0
  5046. end
  5047.  
  5048. end)
  5049. end
  5050.  
  5051. -- Scan the worldframe for nameplates
  5052.  
  5053. local numFrames = 0
  5054. local lastUpdate = 0
  5055. local index = 1
  5056. f:SetScript('OnUpdate', function(self, elapsed)
  5057. lastUpdate = lastUpdate + elapsed
  5058.  
  5059. if (lastUpdate > 0.1) then
  5060. local newNumFrames = WorldFrame:GetNumChildren()
  5061.  
  5062. if (newNumFrames ~= numFrames) then
  5063. numFrames = newNumFrames
  5064.  
  5065. for i = index, numFrames do
  5066. local frame = select(i, WorldFrame:GetChildren())
  5067. local frameName = frame:GetName()
  5068.  
  5069. if (frameName and frameName:find('NamePlate') and not frame.NewName) then
  5070. SkinPlate(frame:GetChildren())
  5071. index = i
  5072. end
  5073. end
  5074. end
  5075.  
  5076. lastUpdate = 0
  5077. end
  5078. end)
  5079. end
  5080.  
  5081. -----------
  5082. -- Quest --
  5083. -----------
  5084. function BasicUI:Quest()
  5085. local db = BasicUI.db.profile
  5086. -- Credit for Quest goes to nightcracker for his ncQuest addon.
  5087. -- You can find his addon at http://www.wowinterface.com/downloads/info14972-ncQuest.html
  5088. -- Editied by Cokedriver
  5089.  
  5090. if db.quest.enable then
  5091.  
  5092. local f = CreateFrame("Frame")
  5093.  
  5094. local function MostValueable()
  5095. local bestp, besti = 0
  5096. for i=1,GetNumQuestChoices() do
  5097. local link, name, _, qty = GetQuestItemLink("choice", i), GetQuestItemInfo("choice", i)
  5098. local price = link and select(11, GetItemInfo(link))
  5099. if not price then
  5100. return
  5101. elseif (price * (qty or 1)) > bestp then
  5102. bestp, besti = (price * (qty or 1)), i
  5103. end
  5104. end
  5105. if besti then
  5106. local btn = _G["QuestInfoItem"..besti]
  5107. if (btn.type == "choice") then
  5108. btn:GetScript("OnClick")(btn)
  5109. end
  5110. end
  5111. end
  5112.  
  5113. f:RegisterEvent("QUEST_ITEM_UPDATE")
  5114. f:RegisterEvent("GET_ITEM_INFO_RECEIVED")
  5115. f:RegisterEvent("QUEST_ACCEPT_CONFIRM")
  5116. f:RegisterEvent("QUEST_DETAIL")
  5117. f:RegisterEvent("QUEST_COMPLETE")
  5118. f:SetScript("OnEvent", function(self, event, ...)
  5119. if db.quest.autocomplete ~= false then
  5120. if (event == "QUEST_DETAIL") then
  5121. AcceptQuest()
  5122. CompleteQuest()
  5123. elseif (event == "QUEST_COMPLETE") then
  5124. if (GetNumQuestChoices() and GetNumQuestChoices() < 1) then
  5125. GetQuestReward()
  5126. else
  5127. MostValueable()
  5128. end
  5129. elseif (event == "QUEST_ACCEPT_CONFIRM") then
  5130. ConfirmAcceptQuest()
  5131. end
  5132. else
  5133. if (event == "QUEST_COMPLETE") then
  5134. if (GetNumQuestChoices() and GetNumQuestChoices() < 1) then
  5135. GetQuestReward()
  5136. else
  5137. MostValueable()
  5138. end
  5139. end
  5140. end
  5141. end)
  5142.  
  5143. end
  5144.  
  5145.  
  5146. if db.vendor.enable then
  5147.  
  5148. local timeout = CreateFrame("Frame")
  5149. timeout:Hide()
  5150.  
  5151. local f = LibStub("tekShiner").new(QuestRewardScrollChildFrame)
  5152. f:Hide()
  5153.  
  5154.  
  5155. f:RegisterEvent("QUEST_COMPLETE")
  5156. f:RegisterEvent("QUEST_ITEM_UPDATE")
  5157. f:RegisterEvent("GET_ITEM_INFO_RECEIVED")
  5158. f:SetScript("OnEvent", function(self, ...)
  5159. self:Hide()
  5160. local bestp, besti = 0
  5161. for i=1,GetNumQuestChoices() do
  5162. local link, name, _, qty = GetQuestItemLink("choice", i), GetQuestItemInfo("choice", i)
  5163. if not link then
  5164. timeout:Show()
  5165. return
  5166. end
  5167. local price = link and select(11, GetItemInfo(link))
  5168. if not price then return
  5169. elseif (price * (qty or 1)) > bestp then bestp, besti = (price * (qty or 1)), i end
  5170. end
  5171.  
  5172. if besti then
  5173. self:ClearAllPoints()
  5174. self:SetAllPoints("QuestInfoItem"..besti.."IconTexture")
  5175. self:Show()
  5176. end
  5177. end)
  5178.  
  5179.  
  5180. local elapsed
  5181. timeout:SetScript("OnShow", function() elapsed = 0 end)
  5182. timeout:SetScript("OnHide", function() f:GetScript("OnEvent")(f) end)
  5183. timeout:SetScript("OnUpdate", function(self, elap)
  5184. elapsed = elapsed + elap
  5185. if elapsed < 1 then return end
  5186. self:Hide()
  5187. end)
  5188.  
  5189. if QuestInfoItem1:IsVisible() then f:GetScript("OnEvent")(f) end
  5190.  
  5191. end
  5192. end
  5193.  
  5194. -----------------
  5195. -- Velluminous --
  5196. -----------------
  5197. function BasicUI:Vellum()
  5198. local db = BasicUI.db.profile
  5199.  
  5200. if db.vellum.enable then
  5201. if not TradeSkillFrame then
  5202. print("What the fuck? Velluminous cannot initialize. BAIL! BAIL! BAIL!")
  5203. return
  5204. end
  5205.  
  5206.  
  5207. local butt = CreateFrame("Button", nil, TradeSkillCreateButton, "SecureActionButtonTemplate")
  5208. butt:SetAttribute("type", "macro")
  5209. butt:SetAttribute("macrotext", "/click TradeSkillCreateButton\n/use item:38682")
  5210.  
  5211. butt:SetText("Vellum")
  5212.  
  5213. butt:SetPoint("RIGHT", TradeSkillCreateButton, "LEFT")
  5214.  
  5215. butt:SetWidth(80) butt:SetHeight(22)
  5216.  
  5217. -- Fonts --
  5218. butt:SetDisabledFontObject(GameFontDisable)
  5219. butt:SetHighlightFontObject(GameFontHighlight)
  5220. butt:SetNormalFontObject(GameFontNormal)
  5221.  
  5222. -- Textures --
  5223. butt:SetNormalTexture("Interface\\Buttons\\UI-Panel-Button-Up")
  5224. butt:SetPushedTexture("Interface\\Buttons\\UI-Panel-Button-Down")
  5225. butt:SetHighlightTexture("Interface\\Buttons\\UI-Panel-Button-Highlight")
  5226. butt:SetDisabledTexture("Interface\\Buttons\\UI-Panel-Button-Disabled")
  5227. butt:GetNormalTexture():SetTexCoord(0, 0.625, 0, 0.6875)
  5228. butt:GetPushedTexture():SetTexCoord(0, 0.625, 0, 0.6875)
  5229. butt:GetHighlightTexture():SetTexCoord(0, 0.625, 0, 0.6875)
  5230. butt:GetDisabledTexture():SetTexCoord(0, 0.625, 0, 0.6875)
  5231. butt:GetHighlightTexture():SetBlendMode("ADD")
  5232.  
  5233. local hider = CreateFrame("Frame", nil, TradeSkillCreateAllButton)
  5234. hider:SetScript("OnShow", function() butt:Hide() end)
  5235. hider:SetScript("OnHide", function() butt:Show() end)
  5236. end
  5237. end
  5238.  
  5239. -------------
  5240. -- Tooltip --
  5241. -------------
  5242. function BasicUI:Tooltip()
  5243. local db = BasicUI.db.profile
  5244.  
  5245. if db.tooltip.enable then
  5246.  
  5247.  
  5248. --[[
  5249.  
  5250. All Credit for Tooltip.lua goes to Neal and ballagarba.
  5251. Neav UI = http://www.wowinterface.com/downloads/info13981-NeavUI.html.
  5252. Edited by Cokedriver.
  5253.  
  5254. ]]
  5255.  
  5256. local _G = _G
  5257. local select = select
  5258. local format = string.format
  5259.  
  5260. local UnitName = UnitName
  5261. local UnitLevel = UnitLevel
  5262. local UnitExists = UnitExists
  5263. local UnitIsDead = UnitIsDead
  5264. local UnitIsGhost = UnitIsGhost
  5265. local UnitFactionGroup = UnitFactionGroup
  5266. local UnitCreatureType = UnitCreatureType
  5267. local GetQuestDifficultyColor = GetQuestDifficultyColor
  5268.  
  5269. local tankIcon = '|TInterface\\LFGFrame\\UI-LFG-ICON-PORTRAITROLES.blp:13:13:0:0:64:64:0:19:22:41|t'
  5270. local healIcon = '|TInterface\\LFGFrame\\UI-LFG-ICON-PORTRAITROLES.blp:13:13:0:0:64:64:20:39:1:20|t'
  5271. local damagerIcon = '|TInterface\\LFGFrame\\UI-LFG-ICON-PORTRAITROLES.blp:13:13:0:0:64:64:20:39:22:41|t'
  5272.  
  5273. local symbiosis = {
  5274. gain = {
  5275. ['DEATHKNIGHT'] = { ['DK_BLOOD'] = 113072, ['DK_FROST'] = 113516, ['DK_UNHOLY'] = 113516, },
  5276. ['HUNTER'] = { ['HUNTER_BM'] = 113073, ['HUNTER_MM'] = 113073, ['HUNTER_SV'] = 113073, },
  5277. ['MAGE'] = { ['MAGE_ARCANE'] = 113074, ['MAGE_FIRE'] = 113074, ['MAGE_FROST'] = 113074, },
  5278. ['MONK'] = { ['MONK_BREW'] = 113306, ['MONK_MIST'] = 127361, ['MONK_WIND'] = 113275, },
  5279. ['PALADIN'] = { ['PALADIN_HOLY'] = 113269, ['PALADIN_PROT'] = 122287, ['PALADIN_RET'] = 113075, },
  5280. ['PRIEST'] = { ['PRIEST_DISC'] = 113506, ['PRIEST_HOLY'] = 113506, ['PRIEST_SHADOW'] = 113277, },
  5281. ['ROGUE'] = { ['ROGUE_ASS'] = 113613, ['ROGUE_COMBAT'] = 113613, ['ROGUE_SUB'] = 113613, },
  5282. ['SHAMAN'] = { ['SHAMAN_ELE'] = 113286, ['SHAMAN_ENHANCE'] = 113286, ['SHAMAN_RESTO'] = 113289, },
  5283. ['WARLOCK'] = { ['WARLOCK_AFFLICTION'] = 113295, ['WARLOCK_DEMO'] = 113295, ['WARLOCK_DESTRO'] = 113295, },
  5284. ['WARRIOR'] = { ['WARRIOR_ARMS'] = 122294, ['WARRIOR_FURY'] = 122294, ['WARRIOR_PROT'] = 122286, },
  5285. },
  5286. grant = {
  5287. ['DEATHKNIGHT'] = { ['DRUID_BALANCE'] = 110570, ['DRUID_FERAL'] = 122282, ['DRUID_GUARDIAN'] = 122285, ['DRUID_RESTO'] = 110575, },
  5288. ['HUNTER'] = { ['DRUID_BALANCE'] = 110588, ['DRUID_FERAL'] = 110597, ['DRUID_GUARDIAN'] = 110600, ['DRUID_RESTO'] = 19263, },
  5289. ['MAGE'] = { ['DRUID_BALANCE'] = 110621, ['DRUID_FERAL'] = 110693, ['DRUID_GUARDIAN'] = 110694, ['DRUID_RESTO'] = 110696, },
  5290. ['MONK'] = { ['DRUID_BALANCE'] = 126458, ['DRUID_FERAL'] = 128844, ['DRUID_GUARDIAN'] = 126453, ['DRUID_RESTO'] = 126456, },
  5291. ['PALADIN'] = { ['DRUID_BALANCE'] = 110698, ['DRUID_FERAL'] = 110700, ['DRUID_GUARDIAN'] = 110701, ['DRUID_RESTO'] = 122288, },
  5292. ['PRIEST'] = { ['DRUID_BALANCE'] = 110707, ['DRUID_FERAL'] = 110715, ['DRUID_GUARDIAN'] = 110717, ['DRUID_RESTO'] = 110718, },
  5293. ['ROGUE'] = { ['DRUID_BALANCE'] = 110788, ['DRUID_FERAL'] = 110730, ['DRUID_GUARDIAN'] = 122289, ['DRUID_RESTO'] = 110791, },
  5294. ['SHAMAN'] = { ['DRUID_BALANCE'] = 110802, ['DRUID_FERAL'] = 110807, ['DRUID_GUARDIAN'] = 110803, ['DRUID_RESTO'] = 110806, },
  5295. ['WARLOCK'] = { ['DRUID_BALANCE'] = 122291, ['DRUID_FERAL'] = 110810, ['DRUID_GUARDIAN'] = 122290, ['DRUID_RESTO'] = 112970, },
  5296. ['WARRIOR'] = { ['DRUID_BALANCE'] = 122292, ['DRUID_FERAL'] = 112997, ['DRUID_GUARDIAN'] = 113002, ['DRUID_RESTO'] = 113004, },
  5297. }
  5298. }
  5299.  
  5300. -- _G.TOOLTIP_DEFAULT_BACKGROUND_COLOR = {r = 0, g = 0, b = 0}
  5301.  
  5302. -- Some tooltip changes
  5303.  
  5304. if (db.tooltip.fontOutline) then
  5305. GameTooltipHeaderText:SetFont(db.fontBold, (db.tooltip.fontSize + 2), 'THINOUTLINE')
  5306. GameTooltipHeaderText:SetShadowOffset(0, 0)
  5307.  
  5308. GameTooltipText:SetFont(db.fontNormal, (db.tooltip.fontSize), 'THINOUTLINE')
  5309. GameTooltipText:SetShadowOffset(0, 0)
  5310.  
  5311. GameTooltipTextSmall:SetFont(db.fontNormal, (db.tooltip.fontSize), 'THINOUTLINE')
  5312. GameTooltipTextSmall:SetShadowOffset(0, 0)
  5313. else
  5314. GameTooltipHeaderText:SetFont(db.fontBold, (db.tooltip.fontSize + 2))
  5315. GameTooltipText:SetFont(db.fontNormal, (db.tooltip.fontSize))
  5316. GameTooltipTextSmall:SetFont(db.fontNormal, (db.tooltip.fontSize))
  5317. end
  5318.  
  5319. GameTooltipStatusBar:SetHeight(7)
  5320. GameTooltipStatusBar:SetBackdrop({bgFile = 'Interface\\Buttons\\WHITE8x8'})
  5321. GameTooltipStatusBar:SetBackdropColor(0, 1, 0, 0.3)
  5322.  
  5323.  
  5324. function GameTooltip_UnitColor(unit)
  5325. local r, g, b
  5326.  
  5327. if (UnitIsDead(unit) or UnitIsGhost(unit) or UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit)) then
  5328. r = 0.5
  5329. g = 0.5
  5330. b = 0.5
  5331. elseif (UnitIsPlayer(unit)) then
  5332. if (UnitIsFriend(unit, 'player')) then
  5333. local _, class = UnitClass(unit)
  5334. r = RAID_CLASS_COLORS[class].r
  5335. g = RAID_CLASS_COLORS[class].g
  5336. b = RAID_CLASS_COLORS[class].b
  5337. elseif (not UnitIsFriend(unit, 'player')) then
  5338. r = 1
  5339. g = 0
  5340. b = 0
  5341. end
  5342. elseif (UnitPlayerControlled(unit)) then
  5343. if (UnitCanAttack(unit, 'player')) then
  5344. if (not UnitCanAttack('player', unit)) then
  5345. r = 157/255
  5346. g = 197/255
  5347. b = 255/255
  5348. else
  5349. r = 1
  5350. g = 0
  5351. b = 0
  5352. end
  5353. elseif (UnitCanAttack('player', unit)) then
  5354. r = 1
  5355. g = 1
  5356. b = 0
  5357. elseif (UnitIsPVP(unit)) then
  5358. r = 0
  5359. g = 1
  5360. b = 0
  5361. else
  5362. r = 157/255
  5363. g = 197/255
  5364. b = 255/255
  5365. end
  5366. else
  5367. local reaction = UnitReaction(unit, 'player')
  5368.  
  5369. if (reaction) then
  5370. r = FACTION_BAR_COLORS[reaction].r
  5371. g = FACTION_BAR_COLORS[reaction].g
  5372. b = FACTION_BAR_COLORS[reaction].b
  5373. else
  5374. r = 157/255
  5375. g = 197/255
  5376. b = 255/255
  5377. end
  5378. end
  5379.  
  5380. return r, g, b
  5381. end
  5382.  
  5383. UnitSelectionColor = GameTooltip_UnitColor
  5384.  
  5385. local function ApplyTooltipStyle(self)
  5386. local bgsize, bsize
  5387. if (self == ConsolidatedBuffsTooltip) then
  5388. bgsize = 1
  5389. bsize = 8
  5390. elseif (self == FriendsTooltip) then
  5391. FriendsTooltip:SetScale(1.1)
  5392.  
  5393. bgsize = 1
  5394. bsize = 9
  5395. else
  5396. bgsize = 3
  5397. bsize = 12
  5398. end
  5399.  
  5400. self:SetBackdrop({
  5401. bgFile = db.tooltip.background, -- 'Interface\\Tooltips\\UI-Tooltip-Background',
  5402. edgeFile = db.tooltip.border,
  5403. tile = true, tileSize = 16, edgeSize = 18,
  5404.  
  5405. insets = {
  5406. left = bgsize, right = bgsize, top = bgsize, bottom = bgsize
  5407. }
  5408. })
  5409. end
  5410.  
  5411. for _, tooltip in pairs({
  5412. GameTooltip,
  5413. ItemRefTooltip,
  5414.  
  5415. ShoppingTooltip1,
  5416. ShoppingTooltip2,
  5417. ShoppingTooltip3,
  5418.  
  5419. WorldMapTooltip,
  5420.  
  5421. DropDownList1MenuBackdrop,
  5422. DropDownList2MenuBackdrop,
  5423.  
  5424. ConsolidatedBuffsTooltip,
  5425.  
  5426. ChatMenu,
  5427. EmoteMenu,
  5428. LanguageMenu,
  5429. VoiceMacroMenu,
  5430.  
  5431. FriendsTooltip,
  5432. }) do
  5433. ApplyTooltipStyle(tooltip)
  5434. end
  5435.  
  5436. -- Itemquaility border
  5437.  
  5438. if (db.tooltip.itemqualityBorderColor) then
  5439. for _, tooltip in pairs({
  5440. GameTooltip,
  5441. ItemRefTooltip,
  5442.  
  5443. ShoppingTooltip1,
  5444. ShoppingTooltip2,
  5445. ShoppingTooltip3,
  5446. }) do
  5447. tooltip:HookScript('OnTooltipSetItem', function(self)
  5448. local name, item = self:GetItem()
  5449. if (item) then
  5450. local quality = select(3, GetItemInfo(item))
  5451. if (quality) then
  5452. local r, g, b = GetItemQualityColor(quality)
  5453. self:SetBackdropBorderColor(r, g, b)
  5454. end
  5455. end
  5456. end)
  5457.  
  5458. tooltip:HookScript('OnTooltipCleared', function(self)
  5459. self:SetBackdropBorderColor(1, 1, 1)
  5460. end)
  5461. end
  5462. end
  5463.  
  5464. -- Itemlvl (by Gsuz) - http://www.tukui.org/forums/topic.php?id=10151
  5465.  
  5466. local function GetItemLevel(unit)
  5467. local total, item = 0, 0
  5468. for i, v in pairs({
  5469. 'Head',
  5470. 'Neck',
  5471. 'Shoulder',
  5472. 'Back',
  5473. 'Chest',
  5474. 'Wrist',
  5475. 'Hands',
  5476. 'Waist',
  5477. 'Legs',
  5478. 'Feet',
  5479. 'Finger0',
  5480. 'Finger1',
  5481. 'Trinket0',
  5482. 'Trinket1',
  5483. 'MainHand',
  5484. 'SecondaryHand',
  5485. }) do
  5486. local slot = GetInventoryItemLink(unit, GetInventorySlotInfo(v..'Slot'))
  5487. if (slot ~= nil) then
  5488. item = item + 1
  5489. total = total + select(4, GetItemInfo(slot))
  5490. end
  5491. end
  5492.  
  5493. if (item > 0) then
  5494. return floor(total / item + 0.5)
  5495. end
  5496.  
  5497. return 0
  5498. end
  5499.  
  5500. -- Make sure we get a correct unit
  5501.  
  5502. local function GetRealUnit(self)
  5503. if (GetMouseFocus() and not GetMouseFocus():GetAttribute('unit') and GetMouseFocus() ~= WorldFrame) then
  5504. return select(2, self:GetUnit())
  5505. elseif (GetMouseFocus() and GetMouseFocus():GetAttribute('unit')) then
  5506. return GetMouseFocus():GetAttribute('unit')
  5507. elseif (select(2, self:GetUnit())) then
  5508. return select(2, self:GetUnit())
  5509. else
  5510. return 'mouseover'
  5511. end
  5512. end
  5513.  
  5514. local function GetFormattedUnitType(unit)
  5515. local creaturetype = UnitCreatureType(unit)
  5516. if (creaturetype) then
  5517. return creaturetype
  5518. else
  5519. return ''
  5520. end
  5521. end
  5522.  
  5523. local function GetFormattedUnitClassification(unit)
  5524. local class = UnitClassification(unit)
  5525. if (class == 'worldboss') then
  5526. return '|cffFF0000'..BOSS..'|r '
  5527. elseif (class == 'rareelite') then
  5528. return '|cffFF66CCRare|r |cffFFFF00'..ELITE..'|r '
  5529. elseif (class == 'rare') then
  5530. return '|cffFF66CCRare|r '
  5531. elseif (class == 'elite') then
  5532. return '|cffFFFF00'..ELITE..'|r '
  5533. else
  5534. return ''
  5535. end
  5536. end
  5537.  
  5538. local function GetFormattedUnitLevel(unit)
  5539. local diff = GetQuestDifficultyColor(UnitLevel(unit))
  5540. if (UnitLevel(unit) == -1) then
  5541. return '|cffff0000??|r '
  5542. elseif (UnitLevel(unit) == 0) then
  5543. return '? '
  5544. else
  5545. return format('|cff%02x%02x%02x%s|r ', diff.r*255, diff.g*255, diff.b*255, UnitLevel(unit))
  5546. end
  5547. end
  5548.  
  5549. local function GetFormattedUnitClass(unit)
  5550. local color = RAID_CLASS_COLORS[select(2, UnitClass(unit))]
  5551. if (color) then
  5552. return format(' |cff%02x%02x%02x%s|r', color.r*255, color.g*255, color.b*255, UnitClass(unit))
  5553. end
  5554. end
  5555.  
  5556. local function GetFormattedUnitString(unit, specIcon)
  5557. if (UnitIsPlayer(unit)) then
  5558. if (not UnitRace(unit)) then
  5559. return nil
  5560. end
  5561. return GetFormattedUnitLevel(unit)..UnitRace(unit)..GetFormattedUnitClass(unit)..(db.tooltip.showSpecializationIcon and specIcon or '')
  5562. else
  5563. return GetFormattedUnitLevel(unit)..GetFormattedUnitClassification(unit)..GetFormattedUnitType(unit)
  5564. end
  5565. end
  5566.  
  5567. local function GetUnitRoleString(unit)
  5568. local role = UnitGroupRolesAssigned(unit)
  5569. local roleList = nil
  5570.  
  5571. if (role == 'TANK') then
  5572. roleList = ' '..tankIcon..' '..TANK
  5573. elseif (role == 'HEALER') then
  5574. roleList = ' '..healIcon..' '..HEALER
  5575. elseif (role == 'DAMAGER') then
  5576. roleList = ' '..damagerIcon..' '..DAMAGER
  5577. end
  5578.  
  5579. return roleList
  5580. end
  5581.  
  5582. -- Healthbar coloring funtion
  5583.  
  5584. local function SetHealthBarColor(unit)
  5585. local r, g, b
  5586. if (db.tooltip.healthbar.custom.apply and not db.tooltip.healthbar.reactionColoring) then
  5587. r, g, b = db.tooltip.healthbar.custom.color.r, db.tooltip.healthbar.custom.color.g, db.tooltip.healthbar.custom.color.b
  5588. elseif (db.tooltip.healthbar.reactionColoring and unit) then
  5589. r, g, b = UnitSelectionColor(unit)
  5590. else
  5591. r, g, b = 0, 1, 0
  5592. end
  5593.  
  5594. GameTooltipStatusBar:SetStatusBarColor(r, g, b)
  5595. GameTooltipStatusBar:SetBackdropColor(r, g, b, 0.3)
  5596. end
  5597.  
  5598. local function GetUnitRaidIcon(unit)
  5599. local index = GetRaidTargetIndex(unit)
  5600.  
  5601. if (index) then
  5602. if (UnitIsPVP(unit) and db.tooltip.showPVPIcons) then
  5603. return ICON_LIST[index]..'11|t'
  5604. else
  5605. return ICON_LIST[index]..'11|t '
  5606. end
  5607. else
  5608. return ''
  5609. end
  5610. end
  5611.  
  5612. local function GetUnitPVPIcon(unit)
  5613. local factionGroup = UnitFactionGroup(unit)
  5614.  
  5615. if (UnitIsPVPFreeForAll(unit)) then
  5616. if (db.tooltip.showPVPIcons) then
  5617. return '|TInterface\\AddOns\\MyCore\\Media\\UI-PVP-FFA:12|t'
  5618. else
  5619. return '|cffFF0000# |r'
  5620. end
  5621. elseif (factionGroup and UnitIsPVP(unit)) then
  5622. if (db.tooltip.showPVPIcons) then
  5623. return '|TInterface\\AddOns\\MyCore\\Media\\UI-PVP-'..factionGroup..':12|t'
  5624. else
  5625. return '|cff00FF00# |r'
  5626. end
  5627. else
  5628. return ''
  5629. end
  5630. end
  5631.  
  5632. local function AddMouseoverTarget(self, unit)
  5633. local unitTargetName = UnitName(unit..'target')
  5634. local unitTargetClassColor = RAID_CLASS_COLORS[select(2, UnitClass(unit..'target'))] or { r = 1, g = 0, b = 1 }
  5635. local unitTargetReactionColor = {
  5636. r = select(1, UnitSelectionColor(unit..'target')),
  5637. g = select(2, UnitSelectionColor(unit..'target')),
  5638. b = select(3, UnitSelectionColor(unit..'target'))
  5639. }
  5640.  
  5641. if (UnitExists(unit..'target')) then
  5642. if (UnitName('player') == unitTargetName) then
  5643. self:AddLine(format('|cffFFFF00Target|r: '..GetUnitRaidIcon(unit..'target')..'|cffff00ff%s|r', string.upper("** YOU **")), 1, 1, 1)
  5644. else
  5645. if (UnitIsPlayer(unit..'target')) then
  5646. self:AddLine(format('|cffFFFF00Target|r: '..GetUnitRaidIcon(unit..'target')..'|cff%02x%02x%02x%s|r', unitTargetClassColor.r*255, unitTargetClassColor.g*255, unitTargetClassColor.b*255, unitTargetName:sub(1, 40)), 1, 1, 1)
  5647. else
  5648. self:AddLine(format('|cffFFFF00Target|r: '..GetUnitRaidIcon(unit..'target')..'|cff%02x%02x%02x%s|r', unitTargetReactionColor.r*255, unitTargetReactionColor.g*255, unitTargetReactionColor.b*255, unitTargetName:sub(1, 40)), 1, 1, 1)
  5649. end
  5650. end
  5651. end
  5652. end
  5653.  
  5654. GameTooltip.inspectCache = {}
  5655.  
  5656. GameTooltip:HookScript('OnTooltipSetUnit', function(self, ...)
  5657. local unit = GetRealUnit(self)
  5658.  
  5659. if (db.tooltip.hideInCombat and InCombatLockdown()) then
  5660. self:Hide()
  5661. return
  5662. end
  5663.  
  5664. if (UnitExists(unit) and UnitName(unit) ~= UNKNOWN) then
  5665.  
  5666. local ilvl = 0
  5667. local specIcon = ''
  5668. local lastUpdate = 30
  5669. for index, _ in pairs(self.inspectCache) do
  5670. local inspectCache = self.inspectCache[index]
  5671. if (inspectCache.GUID == UnitGUID(unit)) then
  5672. ilvl = inspectCache.itemLevel or 0
  5673. specIcon = inspectCache.specIcon or ''
  5674. lastUpdate = inspectCache.lastUpdate and math.abs(inspectCache.lastUpdate - math.floor(GetTime())) or 30
  5675. end
  5676. end
  5677.  
  5678. -- Fetch inspect information (ilvl and spec)
  5679.  
  5680. if (unit and CanInspect(unit)) then
  5681. if (not self.inspectRefresh and lastUpdate >= 30 and not self.blockInspectRequests) then
  5682. if (not self.blockInspectRequests) then
  5683. self.inspectRequestSent = true
  5684. NotifyInspect(unit)
  5685. end
  5686. end
  5687. end
  5688.  
  5689. self.inspectRefresh = false
  5690.  
  5691. local name, realm = UnitName(unit)
  5692.  
  5693. -- Hide player titles
  5694.  
  5695. if (db.tooltip.showPlayerTitles) then
  5696. if (UnitPVPName(unit)) then
  5697. name = UnitPVPName(unit)
  5698. end
  5699. end
  5700.  
  5701. GameTooltipTextLeft1:SetText(name)
  5702.  
  5703. -- Color guildnames
  5704.  
  5705. if (GetGuildInfo(unit)) then
  5706. if (GetGuildInfo(unit) == GetGuildInfo('player') and IsInGuild('player')) then
  5707. GameTooltipTextLeft2:SetText('|cffFF66CC'..GameTooltipTextLeft2:GetText()..'|r')
  5708. end
  5709. end
  5710.  
  5711. -- Tooltip level text
  5712.  
  5713. for i = 2, GameTooltip:NumLines() do
  5714. if (_G['GameTooltipTextLeft'..i]:GetText():find('^'..TOOLTIP_UNIT_LEVEL:gsub('%%s', '.+'))) then
  5715. _G['GameTooltipTextLeft'..i]:SetText(GetFormattedUnitString(unit, specIcon))
  5716. end
  5717. end
  5718.  
  5719. -- Role text
  5720.  
  5721. if (db.tooltip.showUnitRole) then
  5722. self:AddLine(GetUnitRoleString(unit), 1, 1, 1)
  5723. end
  5724.  
  5725. -- Mouse over target with raidicon support
  5726.  
  5727. if (db.tooltip.showMouseoverTarget) then
  5728. AddMouseoverTarget(self, unit)
  5729. end
  5730.  
  5731. -- Pvp flag prefix
  5732.  
  5733. for i = 3, GameTooltip:NumLines() do
  5734. if (_G['GameTooltipTextLeft'..i]:GetText():find(PVP_ENABLED)) then
  5735. _G['GameTooltipTextLeft'..i]:SetText(nil)
  5736. GameTooltipTextLeft1:SetText(GetUnitPVPIcon(unit)..GameTooltipTextLeft1:GetText())
  5737. end
  5738. end
  5739.  
  5740. -- Raid icon, want to see the raidicon on the left
  5741.  
  5742. GameTooltipTextLeft1:SetText(GetUnitRaidIcon(unit)..GameTooltipTextLeft1:GetText())
  5743.  
  5744. -- Afk and dnd prefix
  5745.  
  5746. if (UnitIsAFK(unit)) then
  5747. self:AppendText('|cff00ff00 <AFK>|r')
  5748. elseif (UnitIsDND(unit)) then
  5749. self:AppendText('|cff00ff00 <DND>|r')
  5750. end
  5751.  
  5752. -- Player realm names
  5753.  
  5754. if (realm and realm ~= '') then
  5755. if (db.tooltip.abbrevRealmNames) then
  5756. self:AppendText(' (*)')
  5757. else
  5758. self:AppendText(' - '..realm)
  5759. end
  5760. end
  5761.  
  5762. -- Move the healthbar inside the tooltip
  5763.  
  5764. self:AddLine(' ')
  5765. GameTooltipStatusBar:ClearAllPoints()
  5766. GameTooltipStatusBar:SetPoint('LEFT', self:GetName()..'TextLeft'..self:NumLines(), 1, -3)
  5767. GameTooltipStatusBar:SetPoint('RIGHT', self, -10, 0)
  5768.  
  5769. -- Border coloring
  5770.  
  5771. if (db.tooltip.reactionBorderColor) then
  5772. local r, g, b = UnitSelectionColor(unit)
  5773. self:SetBackdropBorderColor(r, g, b)
  5774. end
  5775.  
  5776. -- Dead or ghost recoloring
  5777.  
  5778. if (UnitIsDead(unit) or UnitIsGhost(unit)) then
  5779. GameTooltipStatusBar:SetBackdropColor(0.5, 0.5, 0.5, 0.3)
  5780. else
  5781. if (not db.tooltip.healthbar.custom.apply and not db.tooltip.healthbar.reactionColoring) then
  5782. GameTooltipStatusBar:SetBackdropColor(27/255, 243/255, 27/255, 0.3)
  5783. else
  5784. SetHealthBarColor(unit)
  5785. end
  5786. end
  5787.  
  5788. -- Custom healthbar coloring
  5789.  
  5790. if (db.tooltip.healthbar.reactionColoring or db.tooltip.healthbar.custom.apply) then
  5791. GameTooltipStatusBar:HookScript('OnValueChanged', function()
  5792. SetHealthBarColor(unit)
  5793. end)
  5794. end
  5795.  
  5796. -- Show player item lvl
  5797.  
  5798. if (db.tooltip.showItemLevel and ilvl > 1) then
  5799. GameTooltip:AddLine(STAT_AVERAGE_ITEM_LEVEL .. ': ' .. '|cffFFFFFF'..ilvl..'|r')
  5800. end
  5801.  
  5802. -- Symbiosis
  5803.  
  5804. if (UnitIsPlayer(unit) and not UnitIsEnemy(unit, 'player')) then
  5805. local hasSymbiosisBuff = false
  5806. for i = 1, 40 do
  5807. if select(11, UnitAura(unit, i, 'HELPFUL')) == 110309 then
  5808. hasSymbiosisBuff = true
  5809. break
  5810. end
  5811. end
  5812.  
  5813. local _, playerClass = UnitClass('player')
  5814. local _, unitClass = UnitClass(unit)
  5815. local spec = SPEC_CORE_ABILITY_TEXT[GetSpecializationInfo(GetSpecialization() or 1)]
  5816. local spellID = (playerClass == 'DRUID' and unitClass ~= 'DRUID') and symbiosis.grant[unitClass][spec] or (playerClass ~= 'DRUID' and unitClass == 'DRUID') and symbiosis.grant[playerClass][spec]
  5817. local name, _, icon = GetSpellInfo(spellID)
  5818.  
  5819. if (hasSymbiosisBuff) then
  5820. GameTooltip:AddLine(' ')
  5821. GameTooltip:AddLine('|cff3eea23'..GetSpellInfo(110309)..' already buffed|r')
  5822. end
  5823.  
  5824. if (icon) then
  5825. GameTooltip:AddLine(' ')
  5826. GameTooltip:AddDoubleLine('|T'..icon..':16:16:0:0:64:64:4:60:4:60|t '..name, '|cff3eea23'..GetSpellInfo(110309)..'|r')
  5827. end
  5828. end
  5829. end
  5830. end)
  5831.  
  5832. GameTooltip:HookScript('OnTooltipCleared', function(self)
  5833. GameTooltipStatusBar:ClearAllPoints()
  5834. GameTooltipStatusBar:SetPoint('BOTTOMLEFT', self, 'TOPLEFT', 0.5, 3)
  5835. GameTooltipStatusBar:SetPoint('BOTTOMRIGHT', self, 'TOPRIGHT', -1, 3)
  5836. GameTooltipStatusBar:SetBackdropColor(0, 1, 0, 0.3)
  5837.  
  5838. if (db.tooltip.reactionBorderColor) then
  5839. self:SetBackdropColor(1, 1, 1)
  5840. end
  5841. end)
  5842.  
  5843.  
  5844. -- Hide coalesced/interactive realm information
  5845.  
  5846. if (db.tooltip.hideRealmText) then
  5847. local COALESCED_REALM_TOOLTIP1 = string.split(FOREIGN_SERVER_LABEL, COALESCED_REALM_TOOLTIP)
  5848. local INTERACTIVE_REALM_TOOLTIP1 = string.split(INTERACTIVE_SERVER_LABEL, INTERACTIVE_REALM_TOOLTIP)
  5849. -- Dirty checking of the coalesced realm text because it's added
  5850. -- after the initial OnShow
  5851. GameTooltip:HookScript('OnUpdate', function(self)
  5852. for i = 3, self:NumLines() do
  5853. local row = _G['GameTooltipTextLeft'..i]
  5854. local rowText = row:GetText()
  5855.  
  5856. if (rowText) then
  5857. if (rowText:find(COALESCED_REALM_TOOLTIP1) or rowText:find(INTERACTIVE_REALM_TOOLTIP1)) then
  5858. row:SetText(nil)
  5859. row:Hide()
  5860.  
  5861. local previousRow = _G['GameTooltipTextLeft'..(i - 1)]
  5862. previousRow:SetText(nil)
  5863. previousRow:Hide()
  5864.  
  5865. self:Show()
  5866. end
  5867. end
  5868. end
  5869. end)
  5870. end
  5871.  
  5872. hooksecurefunc('GameTooltip_SetDefaultAnchor', function(self, parent)
  5873. if (db.tooltip.showOnMouseover) then
  5874. self:SetOwner(parent, 'ANCHOR_CURSOR')
  5875. end
  5876. end)
  5877.  
  5878.  
  5879. GameTooltip:RegisterEvent('INSPECT_READY')
  5880. GameTooltip:SetScript('OnEvent', function(self, event, GUID)
  5881. if (not self:IsShown()) then
  5882. return
  5883. end
  5884.  
  5885. local _, unit = self:GetUnit()
  5886.  
  5887. if (not unit) then
  5888. return
  5889. end
  5890.  
  5891. if (self.blockInspectRequests) then
  5892. self.inspectRequestSent = false
  5893. end
  5894.  
  5895. if (UnitGUID(unit) ~= GUID or not self.inspectRequestSent) then
  5896. if (not self.blockInspectRequests) then
  5897. ClearInspectPlayer()
  5898. end
  5899. return
  5900. end
  5901.  
  5902. local _, _, _, icon = GetSpecializationInfoByID(GetInspectSpecialization(unit))
  5903. local ilvl = GetItemLevel(unit)
  5904. local now = GetTime()
  5905.  
  5906. local matchFound
  5907. for index, _ in pairs(self.inspectCache) do
  5908. local inspectCache = self.inspectCache[index]
  5909. if (inspectCache.GUID == GUID) then
  5910. inspectCache.itemLevel = ilvl
  5911. inspectCache.specIcon = icon and ' |T'..icon..':0|t' or ''
  5912. inspectCache.lastUpdate = math.floor(now)
  5913. matchFound = true
  5914. end
  5915. end
  5916.  
  5917. if not matchFound then
  5918. local GUIDInfo = {
  5919. ['GUID'] = GUID,
  5920. ['itemLevel'] = ilvl,
  5921. ['specIcon'] = icon and ' |T'..icon..':0|t' or '',
  5922. ['lastUpdate'] = math.floor(now)
  5923. }
  5924. table.insert(self.inspectCache, GUIDInfo)
  5925. end
  5926.  
  5927. if (#self.inspectCache > 30) then
  5928. table.remove(self.inspectCache, 1)
  5929. end
  5930.  
  5931. self.inspectRefresh = true
  5932. GameTooltip:SetUnit('mouseover')
  5933.  
  5934. if (not self.blockInspectRequests) then
  5935. ClearInspectPlayer()
  5936. end
  5937. self.inspectRequestSent = false
  5938. end)
  5939.  
  5940. local f = CreateFrame('Frame')
  5941. f:RegisterEvent('ADDON_LOADED')
  5942. f:SetScript('OnEvent', function(self, event)
  5943. if IsAddOnLoaded('Blizzard_InspectUI') then
  5944. hooksecurefunc('InspectFrame_Show', function(unit)
  5945. GameTooltip.blockInspectRequests = true
  5946. end)
  5947.  
  5948. InspectFrame:HookScript('OnHide', function()
  5949. GameTooltip.blockInspectRequests = false
  5950. end)
  5951.  
  5952. self:UnregisterEvent('ADDON_LOADED')
  5953. end
  5954. end)
  5955.  
  5956. local select = select
  5957. local tonumber = tonumber
  5958.  
  5959. local modf = math.modf
  5960. local gsub = string.gsub
  5961. local format = string.format
  5962.  
  5963. local bar = GameTooltipStatusBar
  5964. bar.Text = bar:CreateFontString(nil, 'OVERLAY')
  5965. bar.Text:SetPoint('CENTER', bar, db.tooltip.healthbar.textPos, 0, 1)
  5966.  
  5967. if (db.tooltip.healthbar.showOutline) then
  5968. bar.Text:SetFont(db.fontNormal, db.tooltip.healthbar.fontSize, 'THINOUTLINE')
  5969. bar.Text:SetShadowOffset(0, 0)
  5970. else
  5971. bar.Text:SetFont(db.fontNormal, db.tooltip.healthbar.fontSize)
  5972. bar.Text:SetShadowOffset(1, -1)
  5973. end
  5974.  
  5975. local function ColorGradient(perc, ...)
  5976. if (perc >= 1) then
  5977. local r, g, b = select(select('#', ...) - 2, ...)
  5978. return r, g, b
  5979. elseif (perc <= 0) then
  5980. local r, g, b = ...
  5981. return r, g, b
  5982. end
  5983.  
  5984. local num = select('#', ...) / 3
  5985.  
  5986. local segment, relperc = modf(perc*(num-1))
  5987. local r1, g1, b1, r2, g2, b2 = select((segment*3)+1, ...)
  5988.  
  5989. return r1 + (r2-r1)*relperc, g1 + (g2-g1)*relperc, b1 + (b2-b1)*relperc
  5990. end
  5991.  
  5992. local function FormatValue(value)
  5993. if (value >= 1e6) then
  5994. return tonumber(format('%.1f', value/1e6))..'m'
  5995. elseif (value >= 1e3) then
  5996. return tonumber(format('%.1f', value/1e3))..'k'
  5997. else
  5998. return value
  5999. end
  6000. end
  6001.  
  6002. local function DeficitValue(value)
  6003. if (value == 0) then
  6004. return ''
  6005. else
  6006. return '-'..FormatValue(value)
  6007. end
  6008. end
  6009.  
  6010. local function GetHealthTag(text, cur, max)
  6011. local perc = format('%d', (cur/max)*100)
  6012.  
  6013. if (max == 1) then
  6014. return perc
  6015. end
  6016.  
  6017. local r, g, b = ColorGradient(cur/max, 1, 0, 0, 1, 1, 0, 0, 1, 0)
  6018. text = gsub(text, '$cur', format('%s', FormatValue(cur)))
  6019. text = gsub(text, '$max', format('%s', FormatValue(max)))
  6020. text = gsub(text, '$deficit', format('%s', DeficitValue(max-cur)))
  6021. text = gsub(text, '$perc', format('%d', perc)..'%%')
  6022. text = gsub(text, '$smartperc', format('%d', perc))
  6023. text = gsub(text, '$smartcolorperc', format('|cff%02x%02x%02x%d|r', r*255, g*255, b*255, perc))
  6024. text = gsub(text, '$colorperc', format('|cff%02x%02x%02x%d', r*255, g*255, b*255, perc)..'%%|r')
  6025.  
  6026. return text
  6027. end
  6028.  
  6029. GameTooltipStatusBar:HookScript('OnValueChanged', function(self, value)
  6030. if (self.Text) then
  6031. self.Text:SetText('')
  6032. end
  6033.  
  6034. if (not value) then
  6035. return
  6036. end
  6037.  
  6038. local min, max = self:GetMinMaxValues()
  6039.  
  6040. if ((value < min) or (value > max) or (value == 0) or (value == 1)) then
  6041. return
  6042. end
  6043.  
  6044. if (not self.Text) then
  6045. CreateHealthString(self)
  6046. end
  6047.  
  6048. local fullString = GetHealthTag(db.tooltip.healthbar.healthFullFormat, value, max)
  6049. local normalString = GetHealthTag(db.tooltip.healthbar.healthFormat, value, max)
  6050.  
  6051. local perc = (value/max)*100
  6052. if (perc >= 100 and currentValue ~= 1) then
  6053. self.Text:SetText(fullString)
  6054. elseif (perc < 100 and currentValue ~= 1) then
  6055. self.Text:SetText(normalString)
  6056. else
  6057. self.Text:SetText('')
  6058. end
  6059. end)
  6060.  
  6061. local ccolor = RAID_CLASS_COLORS[select(2, UnitClass("player"))]
  6062. local watchFrame = _G['WatchFrame']
  6063. watchFrame:SetHeight(400)
  6064. watchFrame:ClearAllPoints()
  6065. watchFrame.ClearAllPoints = function() end
  6066. watchFrame:SetPoint('TOPRIGHT', UIParent, -100, -250)
  6067. watchFrame:SetClampedToScreen(true)
  6068. watchFrame:SetMovable(true)
  6069. watchFrame:SetUserPlaced(true)
  6070. watchFrame.SetPoint = function() end
  6071. watchFrame:SetScale(1.01)
  6072.  
  6073. local watchHead = _G['WatchFrameHeader']
  6074. watchHead:EnableMouse(true)
  6075. watchHead:RegisterForDrag('LeftButton')
  6076. watchHead:SetHitRectInsets(-15, 0, -5, -5)
  6077. watchHead:SetScript('OnDragStart', function(self)
  6078. if (IsShiftKeyDown()) then
  6079. self:GetParent():StartMoving()
  6080. end
  6081. end)
  6082.  
  6083. watchHead:SetScript('OnDragStop', function(self)
  6084. self:GetParent():StopMovingOrSizing()
  6085. end)
  6086.  
  6087. watchHead:SetScript('OnEnter', function()
  6088. if InCombatLockdown() then return end
  6089. GameTooltip:SetOwner(watchHead, "ANCHOR_TOPLEFT")
  6090. GameTooltip:ClearLines()
  6091. GameTooltip:AddLine("|cffeda55fShift+Left Click|r to Drag")
  6092. GameTooltip:Show()
  6093. end)
  6094. watchHead:SetScript('OnLeave', function() GameTooltip:Hide() end)
  6095.  
  6096. local watchHeadTitle = _G['WatchFrameTitle']
  6097. watchHeadTitle:SetFont(db.fontBold, 15)
  6098. if db.classcolor == true then
  6099. watchHeadTitle:SetTextColor(ccolor.r, ccolor.g, ccolor.b)
  6100. end
  6101. end
  6102. end
  6103.  
  6104. ----------------
  6105. -- Unitframes --
  6106. ----------------
  6107. function BasicUI:Unitframes()
  6108. local db = BasicUI.db.profile
  6109.  
  6110. if db.unitframes.enable then
  6111. -- Player Frame
  6112. if db.unitframes.player.enable then
  6113. if PlayerFrame then
  6114. PlayerFrame:SetScale(db.unitframes.player.scale);
  6115. PlayerFrameHealthBarText:SetFont(db.fontNormal, db.unitframes.player.fontSize,"THINOUTLINE");
  6116. PlayerFrameManaBarText:SetFont(db.fontNormal, db.unitframes.player.fontSize, "THINOUTLINE");
  6117. PlayerFrameAlternateManaBarText:SetFont(db.fontNormal, db.unitframes.player.fontSize, "THINOUTLINE");
  6118. PetFrameHealthBarText:SetFont(db.fontNormal, db.unitframes.player.fontSizepet,"THINOUTLINE");
  6119. PetFrameManaBarText:SetFont(db.fontNormal, db.unitframes.player.fontSizepet, "THINOUTLINE");
  6120. end
  6121. end
  6122.  
  6123. -- Target Frame
  6124. if db.unitframes.target.enable then
  6125. if TargetFrame then
  6126. TargetFrame:SetScale(db.unitframes.target.scale);
  6127. TargetFrameTextureFrameHealthBarText:SetFont(db.fontNormal, db.unitframes.target.fontSize, "THINOUTLINE");
  6128. TargetFrameTextureFrameManaBarText:SetFont(db.fontNormal, db.unitframes.target.fontSize, "THINOUTLINE");
  6129. end;
  6130. end;
  6131.  
  6132. -- Focus Frame
  6133. if db.unitframes.focus.enable then
  6134. if FocusFrame then
  6135. FocusFrame:SetScale(db.unitframes.focus.scale)
  6136. FocusFrameTextureFrameHealthBarText:SetFont(db.fontNormal, db.unitframes.focus.fontSize,"THINOUTLINE")
  6137. FocusFrameTextureFrameManaBarText:SetFont(db.fontNormal, db.unitframes.focus.fontSize,"THINOUTLINE")
  6138. end;
  6139. end;
  6140.  
  6141.  
  6142. -- Party Frames --
  6143. if db.unitframes.party.enable then
  6144. for i = 1, MAX_PARTY_MEMBERS do
  6145. local partyFrame = "PartyMemberFrame"..i
  6146. _G[partyFrame]:SetScale(db.unitframes.party.scale);
  6147. _G[partyFrame.."HealthBarText"]:SetFont(db.fontNormal, db.unitframes.party.fontSize, "THINOUTLINE");
  6148. _G[partyFrame.."ManaBarText"]:SetFont(db.fontNormal, db.unitframes.party.fontSize, "THINOUTLINE");
  6149. end
  6150.  
  6151. end;
  6152.  
  6153. -- Arena Frames
  6154. if db.unitframes.arena.enable then
  6155. hooksecurefunc("Arena_LoadUI", function()
  6156. for i = 1, MAX_ARENA_ENEMIES do
  6157. arenaFrame = "ArenaEnemyFrame"..i
  6158. _G[arenaFrame]:SetScale(db.unitframes.arena.scale);
  6159. _G[arenaFrame.."HealthBarText"]:SetFont(db.fontNormal, db.unitframes.arena.fontSize,"THINOUTLINE");
  6160. _G[arenaFrame.."ManaBarText"]:SetFont(db.fontNormal, db.unitframes.arena.fontSize, "THINOUTLINE");
  6161. end
  6162. end)
  6163. end;
  6164.  
  6165. -- Boss Frames
  6166. if db.unitframes.boss.enable then
  6167. for i = 1, MAX_BOSS_FRAMES do
  6168. local bossFrame = "Boss"..i.."TargetFrame"
  6169. _G[bossFrame]:SetScale(db.unitframes.boss.scale);
  6170. end;
  6171. end;
  6172.  
  6173. -- Font Style / Color thanks to Phanx from WoWinterface.
  6174.  
  6175. -- Font Style
  6176. local shorts = {
  6177. { 1e10, 1e9, "%.0fB" }, -- 10b+ as 12b
  6178. { 1e9, 1e9, "%.1fB" }, -- 1b+ as 8.3b
  6179. { 1e7, 1e6, "%.0fM" }, -- 10m+ as 14m
  6180. { 1e6, 1e6, "%.1fM" }, -- 1m+ as 7.4m
  6181. { 1e5, 1e3, "%.0fK" }, -- 100k+ as 840k
  6182. { 1e3, 1e3, "%.1fK" }, -- 1k+ as 2.5k
  6183. { 0, 1, "%d" }, -- < 1k as 974
  6184. }
  6185. for i = 1, #shorts do
  6186. shorts[i][4] = shorts[i][3] .. " (%.0f%%)"
  6187. end
  6188.  
  6189. hooksecurefunc("TextStatusBar_UpdateTextStringWithValues", function(statusBar, fontString, value, valueMin, valueMax)
  6190. if value == 0 then
  6191. return fontString:SetText("")
  6192. end
  6193.  
  6194. local style = GetCVar("statusTextDisplay")
  6195. if style == "PERCENT" then
  6196. return fontString:SetFormattedText("%.0f%%", value / valueMax * 100)
  6197. end
  6198. for i = 1, #shorts do
  6199. local t = shorts[i]
  6200. if value >= t[1] then
  6201. if style == "BOTH" then
  6202. return fontString:SetFormattedText(t[4], value / t[2], value / valueMax * 100)
  6203. else
  6204. if value < valueMax then
  6205. for j = 1, #shorts do
  6206. local v = shorts[j]
  6207. if valueMax >= v[1] then
  6208. return fontString:SetFormattedText(t[3] .. " / " .. v[3], value / t[2], valueMax / v[2])
  6209. end
  6210. end
  6211. end
  6212. return fontString:SetFormattedText(t[3], value / t[2])
  6213. end
  6214. end
  6215. end
  6216. end)
  6217. -- Font Color
  6218. hooksecurefunc("UnitFrame_Update", function(self)
  6219. if not self.name then return end
  6220.  
  6221. local PET_COLOR = { r = 157/255, g = 197/255, b = 255/255 }
  6222. local unit, color = self.unit
  6223. if UnitPlayerControlled(unit) then
  6224. if UnitIsPlayer(unit) then
  6225. local _, class = UnitClass(unit)
  6226. color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
  6227. else
  6228. color = PET_COLOR
  6229. end
  6230. elseif UnitIsDead(unit) or UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit) then
  6231. color = GRAY_FONT_COLOR
  6232. else
  6233. color = FACTION_BAR_COLORS[UnitIsEnemy(unit, "player") and 1 or UnitReaction(unit, "player") or 5]
  6234. end
  6235.  
  6236. if not color then
  6237. color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)["PRIEST"]
  6238. end
  6239.  
  6240. self.name:SetTextColor(color.r, color.g, color.b)
  6241. end)
  6242.  
  6243. local frame = CreateFrame("FRAME")
  6244. frame:RegisterEvent("GROUP_ROSTER_UPDATE")
  6245. frame:RegisterEvent("PLAYER_TARGET_CHANGED")
  6246. frame:RegisterEvent("PLAYER_FOCUS_CHANGED")
  6247. frame:RegisterEvent("UNIT_FACTION")
  6248.  
  6249. local unitRegions = {
  6250. target = TargetFrameNameBackground,
  6251. focus = FocusFrameNameBackground,
  6252. boss1 = Boss1TargetFrameNameBackground,
  6253. boss2 = Boss2TargetFrameNameBackground,
  6254. boss3 = Boss3TargetFrameNameBackground,
  6255. boss4 = Boss4TargetFrameNameBackground,
  6256. }
  6257.  
  6258. frame:SetScript("OnEvent", function(self, event, ...)
  6259. for unit, region in pairs(unitRegions) do
  6260. if UnitIsPlayer(unit) then
  6261. region:SetTexture('Interface\\DialogFrame\\UI-DialogBox-Background')
  6262. end
  6263. end
  6264. end)
  6265.  
  6266. -- Disable healing/damage spam over player/pet frame:
  6267. PlayerHitIndicator:SetText(nil)
  6268. PlayerHitIndicator.SetText = function() end
  6269. PetHitIndicator:SetText(nil)
  6270. PetHitIndicator.SetText = function() end
  6271. end
  6272. end
Add Comment
Please, Sign In to add comment