Advertisement
Guest User

tiptop.lua

a guest
Nov 19th, 2021
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.24 KB | None | 0 0
  1. --update for level increases from expansions
  2. local hugeLevel = 150
  3.  
  4. local ttName, TipTop = ...
  5.  
  6. --CREATE & ASSIGN FRAMES--
  7. local evfr = CreateFrame("Frame", nil, self, BackdropTemplateMixin and "BackdropTemplate")
  8. local tt = GameTooltip
  9. local ttSBar = GameTooltipStatusBar
  10. local ttSBarBG = CreateFrame("Frame", nil, ttSBar, "BackdropTemplate")
  11. local ttHealth = ttSBar:CreateFontString("ttHealth", "OVERLAY")
  12. ttHealth:SetPoint("CENTER")
  13. local raidIcon = ttSBar:CreateTexture(nil, "OVERLAY")
  14.  
  15. --OTHER LOCALS--
  16. local LSM = LibStub("LibSharedMedia-3.0")
  17. local player = UnitName("player")
  18. local server = GetRealmName()
  19. local _, db, color, font, classif, talentsGUID, factionIcon, factionTable, ttStyle
  20. local specializationText = SPECIALIZATION..":"
  21. local tooltips = { GameTooltip,
  22. ItemRefTooltip,
  23. ShoppingTooltip1,
  24. ShoppingTooltip2,
  25. ItemRefShoppingTooltip1,
  26. ItemRefShoppingTooltip2,
  27. --WorldMapTooltip,
  28. WorldMapCompareTooltip1,
  29. WorldMapCompareTooltip2,
  30. AdventureMap_MissionPinTooltip,}
  31.  
  32. --UPVALUES--
  33. local table_sort = _G.table.sort
  34. local GetItemInfo = _G.GetItemInfo
  35. local GetRaidTargetIndex = _G.GetRaidTargetIndex
  36. local SetRaidTargetIconTexture = _G.SetRaidTargetIconTexture
  37. local UnitClass = _G.UnitClass
  38. local UnitClassification = _G.UnitClassification
  39. local UnitExists = _G.UnitExists
  40. local UnitHealth = _G.UnitHealth
  41. local UnitIsAFK = _G.UnitIsAFK
  42. local UnitIsConnected = _G.UnitIsConnected
  43. local UnitIsDead = _G.UnitIsDead
  44. local UnitIsDND = _G.UnitIsDND
  45. local UnitIsTapDenied = _G.UnitIsTapDenied
  46. local UnitIsFriend = _G.UnitIsFriend
  47. local UnitLevel = _G.UnitLevel
  48. local UnitHealthMax = _G.UnitHealthMax
  49. local UnitName = _G.UnitName
  50. local UnitFactionGroup = _G.UnitFactionGroup
  51. local UnitPlayerControlled = _G.UnitPlayerControlled
  52. local GameTooltipTextLeft1 = GameTooltipTextLeft1
  53. local qualityColor = ITEM_QUALITY_COLORS
  54. local GetQuestDifficultyColor = _G.GetQuestDifficultyColor
  55. local GetInspectSpecialization = _G.GetInspectSpecialization
  56. local GetSpecializationInfoByID = _G.GetSpecializationInfoByID
  57. local GetGuildInfo = _G.GetGuildInfo
  58. local strsplit = strsplit
  59. local SetBorderColor = evfr.SetBackdropBorderColor
  60.  
  61.  
  62. function TipTop:SetBackgrounds()
  63. local backdrop = { bgFile = LSM:Fetch("background", db.bg),
  64. insets = {left=db.inset, right=db.inset, top=db.inset, bottom=db.inset},
  65. edgeFile = LSM:Fetch("border", db.border),
  66. edgeSize = db.borderWidth }
  67. for i = 1, #tooltips do
  68. tooltips[i]:SetScale(db.scale)
  69. tooltips[i]:SetBackdrop(backdrop)
  70. tooltips[i]:SetBackdropColor(db.bgColor.r, db.bgColor.g, db.bgColor.b, db.alpha)
  71. SetBorderColor(tooltips[i], db.borderColor.r, db.borderColor.g, db.borderColor.b, db.borderColor.a)
  72. end
  73. --copy our style to default style (can't just do ttStyle = backdrop because there's other stuff in there)
  74. -- ttStyle.bgFile = backdrop.bgFile
  75. -- ttStyle.insets = backdrop.insets
  76. -- ttStyle.edgeFile = backdrop.edgeFile
  77. -- ttStyle.edgeSize = backdrop.edgeSize
  78. -- ttStyle.tile = false
  79. -- ttStyle.tileEdge = false
  80. -- ttStyle.backdropColor:SetRGBA(db.bgColor.r, db.bgColor.g, db.bgColor.b, db.alpha)
  81. -- ttStyle.backdropBorderColor:SetRGBA(db.borderColor.r, db.borderColor.g, db.borderColor.b, db.borderColor.a)
  82. end
  83.  
  84. function TipTop:SetFonts()
  85. font = LSM:Fetch("font", db.font)
  86. local size = db.fontSize
  87. if db.diffFont then
  88. ttHealth:SetFont(LSM:Fetch("font", db.healthFont), db.healthSize, "OUTLINE")
  89. else
  90. ttHealth:SetFont(font, db.healthSize, "OUTLINE")
  91. end
  92. GameTooltipHeaderText:SetFont(font, size + 2, db.fontFlag)
  93. GameTooltipText:SetFont(font, size, db.fontFlag)
  94. GameTooltipTextSmall:SetFont(font, size - 2, db.fontFlag)
  95. ShoppingTooltip1TextLeft1:SetFont(font, size -2, db.fontFlag)
  96. ShoppingTooltip1TextLeft2:SetFont(font, size, db.fontFlag)
  97. ShoppingTooltip1TextLeft3:SetFont(font, size -2, db.fontFlag)
  98. ShoppingTooltip2TextLeft1:SetFont(font, size -2, db.fontFlag)
  99. ShoppingTooltip2TextLeft2:SetFont(font, size, db.fontFlag)
  100. ShoppingTooltip2TextLeft3:SetFont(font, size -2, db.fontFlag)
  101. for i = 1, ShoppingTooltip1:NumLines() do
  102. _G["ShoppingTooltip1TextRight"..i]:SetFont(font, size -2, db.fontFlag)
  103. end
  104. for i = 1, ShoppingTooltip2:NumLines() do
  105. _G["ShoppingTooltip2TextRight"..i]:SetFont(font, size -2, db.fontFlag)
  106. end
  107. if GameTooltipMoneyFrame1 then
  108. GameTooltipMoneyFrame1PrefixText:SetFont(font, size, db.fontFlag)
  109. GameTooltipMoneyFrame1SuffixText:SetFont(font, size, db.fontFlag)
  110. GameTooltipMoneyFrame1CopperButtonText:SetFont(font, size, db.fontFlag)
  111. GameTooltipMoneyFrame1SilverButtonText:SetFont(font, size, db.fontFlag)
  112. GameTooltipMoneyFrame1GoldButtonText:SetFont(font, size, db.fontFlag)
  113. end
  114. end
  115.  
  116. local SetSBarColor = ttSBar.SetStatusBarColor
  117. ttSBar.SetStatusBarColor = function() return end
  118. function TipTop:SBarCustom()
  119. ttSBar:SetStatusBarTexture(LSM:Fetch("statusbar", db.healthBar))
  120. SetSBarColor(ttSBar, db.sbarcolor.r, db.sbarcolor.g, db.sbarcolor.b, db.sbarcolor.a)
  121. ttSBarBG:SetAllPoints()
  122. ttSBarBG:SetFrameLevel(ttSBar:GetFrameLevel() - 1)
  123. ttSBarBG:SetBackdrop({bgFile = LSM:Fetch("statusbar", db.sbarbg)})
  124. ttSBarBG:SetBackdropColor(db.sbarbgcolor.r, db.sbarbgcolor.g, db.sbarbgcolor.b, db.sbarbgcolor.a)
  125. end
  126.  
  127. function TipTop:SBPosition() --call on load and when setting changed
  128. if db.insideBar then
  129. if db.topBar then
  130. ttSBar:ClearAllPoints()
  131. ttSBar:SetPoint("TOPLEFT", 7, -7)
  132. ttSBar:SetPoint("TOPRIGHT", -7, -7)
  133. else
  134. ttSBar:ClearAllPoints()
  135. ttSBar:SetPoint("BOTTOMLEFT", 7, 7)
  136. ttSBar:SetPoint("BOTTOMRIGHT", -7, 7)
  137. end
  138. else
  139. if db.topBar then
  140. ttSBar:ClearAllPoints()
  141. ttSBar:SetPoint("BOTTOMLEFT", tt, "TOPLEFT", 2, 1)
  142. ttSBar:SetPoint("BOTTOMRIGHT", tt, "TOPRIGHT", -2, 1)
  143. else
  144. ttSBar:ClearAllPoints()
  145. ttSBar:SetPoint("TOPLEFT", tt, "BOTTOMLEFT", 2, -1)
  146. ttSBar:SetPoint("TOPRIGHT", tt, "BOTTOMRIGHT", -2, -1)
  147. end
  148. end
  149. end
  150.  
  151. local function AdjustTooltipBG() --call when unit is set to tooltip
  152. if db.insideBar then
  153. if db.topBar then
  154. GameTooltipTextLeft1:ClearAllPoints()
  155. GameTooltipTextLeft1:SetPoint("TOPLEFT", 10, -23)
  156. tt:SetHeight(tt:GetHeight() + 13)
  157. else
  158. tt:SetHeight(tt:GetHeight() + 10)
  159. end
  160. end
  161. end
  162.  
  163. function TipTop:FactionIcon()
  164. if not factionIcon then
  165. factionIcon = ttSBar:CreateTexture(nil, "OVERLAY")
  166. factionTable = {
  167. ["Alliance"] = "Interface\\Timer\\Alliance-Logo",
  168. ["Horde"] = "Interface\\Timer\\Horde-Logo",
  169. ["Neutral"] = "Interface\\Timer\\Panda-Logo",
  170. }
  171. end
  172. factionIcon:SetWidth(db.factionIconSize)
  173. factionIcon:SetHeight(db.factionIconSize)
  174. factionIcon:SetPoint("CENTER", tt, db.factionIconPosition, db.factionIconX, db.factionIconY)
  175. factionIcon:Hide()
  176. end
  177.  
  178. local function FactionIconUpdate()
  179. if UnitPlayerControlled("mouseover") then
  180. factionIcon:SetTexture(factionTable[UnitFactionGroup("mouseover")])
  181. factionIcon:Show()
  182. else
  183. factionIcon:Hide()
  184. end
  185. end
  186.  
  187. function TipTop:RaidIcon()
  188. raidIcon:SetWidth(db.raidIconSize)
  189. raidIcon:SetHeight(db.raidIconSize)
  190. raidIcon:SetTexture("Interface\\TARGETINGFRAME\\UI-RaidTargetingIcons")
  191. raidIcon:SetPoint("CENTER", tt, db.raidIconPosition, db.raidIconX, db.raidIconY)
  192. raidIcon:Hide()
  193. end
  194.  
  195. local function RaidIconUpdate()
  196. local icon = GetRaidTargetIndex("mouseover")
  197. if icon and icon < 9 then
  198. SetRaidTargetIconTexture(raidIcon, icon)
  199. raidIcon:Show()
  200. else
  201. raidIcon:Hide()
  202. end
  203. end
  204.  
  205. local function FadedTip() --grays out tooltip if unit is tapped or dead
  206. local tapped = false
  207. if not UnitPlayerControlled("mouseover") then
  208. if UnitIsTapDenied("mouseover") then
  209. tapped = true
  210. end
  211. end
  212. if UnitIsDead("mouseover") or tapped or not UnitIsConnected("mouseover") then
  213. local borderColor = db.borderColor
  214. SetBorderColor(tt, borderColor.r, borderColor.g, borderColor.b, borderColor.a)
  215. local bgColor = db.bgColor
  216. tt:SetBackdropColor(bgColor.r + .2, bgColor.g +.2, bgColor.b + .2, db.alpha-.1)
  217. end
  218. end
  219.  
  220. local function Appendices() --appends info to the name/guild of the unit - ALSO sets elite graphic
  221. classif = UnitClassification("mouseover")
  222. if db.elite then
  223. if not elitetexture then
  224. elitetexture = ttSBar:CreateTexture(nil, "OVERLAY")
  225. elitetexture:SetHeight(70)
  226. elitetexture:SetWidth(70)
  227. elitetexture:SetPoint("CENTER", tt, "TOPLEFT", 8, -18)
  228. end
  229. elitetexture:Hide()
  230. end
  231.  
  232. if classif == "rare" or classif == "rareelite" then
  233. tt:AppendText(" (Rare)")
  234. if db.elite and classif == "rareelite" then
  235. elitetexture:SetTexture("Interface\\AddOns\\TipTop\\media\\rare_graphic")
  236. elitetexture:Show()
  237. end
  238. elseif classif == "elite" or classif == "worldboss" or classif == "boss" then
  239. if db.elite then
  240. elitetexture:SetTexture("Interface\\AddOns\\TipTop\\media\\elite_graphic")
  241. elitetexture:Show()
  242. end
  243. end
  244.  
  245. if UnitIsAFK("mouseover") then
  246. tt:AppendText(" (AFK)")
  247. elseif UnitIsDND("mouseover") then
  248. tt:AppendText(" (DND)")
  249. end
  250.  
  251. if db.guildRank then
  252. local guild, rank, _, realm = GetGuildInfo("mouseover")
  253. if guild then
  254. local text = nil
  255. text = GameTooltipTextLeft2:GetText()
  256. if text then
  257. if realm then
  258. text = strsplit("-", text)
  259. end
  260. if text == guild then
  261. GameTooltipTextLeft2:SetFormattedText("%s (%s)", text, rank)
  262. end
  263. end
  264. end
  265. end
  266. end
  267.  
  268. local function ColorBy() --colors tip border, statusbar, name, and adds class icon
  269. local _,class = UnitClass("mouseover")
  270. local isNPC = not UnitIsPlayer("mouseover")
  271. local level = UnitLevel("mouseover")
  272.  
  273. --name by class
  274. if db.className and class and not isNPC then
  275. GameTooltipTextLeft1:SetTextColor(color[class].r, color[class].g, color[class].b)
  276. end
  277.  
  278. --border colors
  279. if db.diffColor and level then --if coloring by difficulty
  280. if db.classColor and class and UnitIsFriend("player", "mouseover") and ((isNPC and db.npcClassColor) or not isNPC) then --if class enabled, too, use that if unit is friendly
  281. SetBorderColor(tt, color[class].r, color[class].g, color[class].b, db.borderColor.a)
  282. else --all else, color by difficulty
  283. if level == -1 then --where a skull might show instead of a level # (account for bosses and elites being harder)
  284. level = hugeLevel
  285. elseif classif == "elite" or classif == "rareelite" then
  286. level = level + 3
  287. elseif classif == "boss" or classif == "worldboss" then
  288. level = level + 5
  289. end
  290. local levelColor = GetQuestDifficultyColor(level)
  291. SetBorderColor(tt, levelColor.r - .1, levelColor.g - .1, levelColor.b - .1, db.borderColor.a)
  292. end
  293. elseif db.classColor and class and ((isNPC and db.npcClassColor) or not isNPC) then --if just coloring by class
  294. SetBorderColor(tt, color[class].r, color[class].g, color[class].b, db.borderColor.a)
  295. else --default border color
  296. local borderColor = db.borderColor
  297. SetBorderColor(tt, borderColor.r, borderColor.g, borderColor.b, borderColor.a)
  298. end
  299.  
  300. --class icon
  301. if db.classIcon and class and ((isNPC and db.npcClassIcon) or not isNPC)then
  302. local text = nil --reset text var so as to not get a repeating icon issue...
  303. text = GameTooltipTextLeft1:GetText()
  304. if text then
  305. local path
  306. if db.classIconStyle == "Default UI" then
  307. path = "Interface\\TARGETINGFRAME\\UI-Classes-Circles"
  308. else
  309. path = "Interface\\AddOns\\TipTop\\media\\ClassIcons\\"..db.classIconStyle
  310. end
  311. local x1, x2, y1, y2 = unpack(CLASS_ICON_TCOORDS[class])
  312. GameTooltipTextLeft1:SetFormattedText("|T%s:22:22:0:0:256:256:%d:%d:%d:%d|t %s", path, x1*256, x2*256, y1*256, y2*256, text)
  313. end
  314. end
  315.  
  316. --statusbar by class
  317. if db.sbarclass and class then
  318. SetSBarColor(ttSBar, color[class].r, color[class].g, color[class].b)
  319. end
  320. end
  321.  
  322. local function ItemQualityBorder(tip) --colors tip border by item quality
  323. if db.itemColor then
  324. local _,item = tip:GetItem()
  325. if item then
  326. local _,_,quality = GetItemInfo(item)
  327. if quality then
  328. local r, g, b = GetItemQualityColor(quality)
  329. if r and g and b then
  330. SetBorderColor(tip, r - .2, g - .2, b - .2, db.borderColor.a)
  331. end
  332. end
  333. end
  334. else
  335. if tip == ItemRefTooltip then
  336. SetBorderColor(tip, db.borderColor.r, db.borderColor.g, db.borderColor.b, db.borderColor.a)
  337. end
  338. end
  339. end
  340.  
  341. local function CalcHealth(_,hp) --sets health text on status bar
  342. if db.healthText then
  343. local per, hpmult, hpdiv, maxhpmult, maxhpdiv, hpformat, maxhpformat --upvalues
  344. local maxhp = UnitHealthMax("mouseover")
  345. if maxhp == 0 then --mouseover unit no longer exists
  346. return
  347. end
  348. local hp = hp or UnitHealth("mouseover")
  349. if db.textformat == "100/100" then
  350. hp = tostring(hp) --needed to store huge health numbers as strings in WoD
  351. maxhp = tostring(maxhp)
  352. ttHealth:SetFormattedText("%s / %s", hp, maxhp)
  353. elseif db.textformat == "100%" then
  354. per = (hp/maxhp) * 100
  355. if per <= 100 then
  356. ttHealth:SetFormattedText("%d%%", per)
  357. end
  358. elseif db.textformat == "100/100 (100%)" then
  359. per = (hp/maxhp) * 100
  360. if per <= 100 then
  361. hp = tostring(hp)
  362. maxhp = tostring(maxhp)
  363. ttHealth:SetFormattedText("%s / %s (%d%%)", hp, maxhp, per)
  364. end
  365. elseif db.textformat == "1.2k/1.2k" or db.textformat == "1.2k/1.2k (100%)" then
  366. hpformat, maxhpformat = "%.1f", "%.1f"
  367. if hp >= 1000000 then
  368. hpmult, hpdiv = "m", 1000000
  369. elseif hp >= 1000 then
  370. hpmult, hpdiv = "k", 1000
  371. else
  372. hpmult, hpdiv = "", 1
  373. hpformat = "%d"
  374. end
  375. if maxhp >= 1000000 then
  376. maxhpmult, maxhpdiv = "m", 1000000
  377. elseif hp >= 1000 then
  378. maxhpmult, maxhpdiv = "k", 1000
  379. else
  380. maxhpmult, maxhpdiv = "", 1
  381. maxhpformat = "%d"
  382. end
  383. if db.textformat == "1.2k/1.2k" then
  384. ttHealth:SetFormattedText(hpformat.."%s / "..maxhpformat.."%s", hp/hpdiv, hpmult, maxhp/maxhpdiv, maxhpmult)
  385. else
  386. ttHealth:SetFormattedText(hpformat.."%s / "..maxhpformat.."%s (%d%%)", hp/hpdiv, hpmult, maxhp/maxhpdiv, maxhpmult, hp/maxhp*100)
  387. end
  388. end
  389. end
  390. end
  391.  
  392. local function TargetTextUpdate() --shows and updates target text
  393. if db.showTargetText then
  394. local target, tserver = UnitName("mouseovertarget")
  395. local _,tclass = UnitClass("mouseovertarget")
  396. if target and target ~= UNKNOWN and tclass then
  397. local targetLine
  398. for i=1, GameTooltip:NumLines() do --scan tip to see if Target line is already added
  399. local left, right, leftText, rightText
  400. left = _G[GameTooltip:GetName().."TextLeft"..i]
  401. leftText = left:GetText()
  402. right = _G[GameTooltip:GetName().."TextRight"..i]
  403. if leftText == "Target:" then --if already present, then just update it
  404. if db.you and target == player and (tserver == nil or tserver == server) then
  405. right:SetText("<<YOU>>")
  406. right:SetTextColor(.9, 0, .1)
  407. else
  408. right:SetText(target)
  409. right:SetTextColor(color[tclass].r,color[tclass].g,color[tclass].b)
  410. end
  411. tt:Show()
  412. AdjustTooltipBG()
  413. targetLine = true
  414. end
  415. end
  416. if targetLine ~= true then --if not present, then add it
  417. if db.you and target == player and (tserver == nil or tserver == server) then
  418. tt:AddDoubleLine("Target:", "<<YOU>>", nil, nil, nil, .9, 0, .1)
  419. else
  420. local tcolor = color[tclass]
  421. if tcolor then
  422. tt:AddDoubleLine("Target:", target, nil,nil,nil,tcolor.r,tcolor.g,tcolor.b)
  423. end
  424. end
  425. tt:Show()
  426. AdjustTooltipBG()
  427. else
  428. targetLine = false
  429. end
  430. end
  431. end
  432. end
  433.  
  434. local function TalentQuery() --send request for talent info
  435. if CanInspect("mouseover") and db.showTalentText then
  436. if UnitName("mouseover") ~= player and UnitLevel("mouseover") > 9 then
  437. local talentline = false
  438. for i=1, tt:NumLines() do
  439. local left, leftText
  440. left = _G["GameTooltipTextLeft"..i]
  441. leftText = left:GetText()
  442. if leftText == specializationText then
  443. talentline = true
  444. break
  445. end
  446. end
  447. if not talentline then
  448. if InspectFrame and InspectFrame:IsShown() then --to not step on default UI's toes
  449. tt:AddDoubleLine(specializationText, "Inspect Frame is open", nil,nil,nil, 1,0,0)
  450. elseif Examiner and Examiner:IsShown() then --same thing with Examiner
  451. tt:AddDoubleLine(specializationText, "Examiner frame is open", nil,nil,nil, 1,0,0)
  452. else
  453. talentsGUID = UnitGUID("mouseover")
  454. NotifyInspect("mouseover")
  455. evfr:RegisterEvent("INSPECT_READY")
  456. tt:AddDoubleLine(specializationText, "...") --adds the Talents line with a placeholder for info
  457. end
  458. end
  459. end
  460. end
  461. end
  462.  
  463. local maxtree,left,leftText
  464. local function TalentText()
  465. if UnitExists("mouseover") then
  466. maxtree = GetInspectSpecialization("mouseover")
  467. if maxtree and maxtree > 0 then
  468. for i=1, tt:NumLines() do
  469. left = _G[GameTooltip:GetName().."TextLeft"..i]
  470. leftText = left:GetText()
  471. if leftText == specializationText then --finds the Talents line and updates with info
  472. _G[GameTooltip:GetName().."TextRight"..i]:SetText(select(2,GetSpecializationInfoByID(maxtree)))
  473. break
  474. end
  475. end
  476. end
  477. end
  478. evfr:UnregisterEvent("INSPECT_READY")
  479. maxtree = nil --reset this variable
  480. end
  481.  
  482. local ttWidth
  483. local function MouseoverTargetUpdate() --do this stuff whenever the mouseover unit is changed
  484. if ttSBar:IsShown() then --interactable objects register as units
  485. if db.shortName then
  486. GameTooltipTextLeft1:SetText(UnitName("mouseover"))
  487. end
  488. Appendices()
  489. ColorBy()
  490. CalcHealth()
  491. RaidIconUpdate()
  492. TalentQuery()
  493. FadedTip()
  494. tt:Show()
  495. AdjustTooltipBG()
  496. if db.factionIcon then
  497. FactionIconUpdate()
  498. end
  499. --sets min size for aesthetics and for extended health text
  500. ttWidth = tt:GetWidth()
  501. if ttWidth < 175 and db.healthText and db.textformat == "100/100 (100%)" then
  502. tt:SetWidth(200)
  503. elseif ttWidth < 125 then
  504. tt:SetWidth(125)
  505. end
  506. end
  507. end
  508.  
  509. local function PlayerLogin()
  510. if TipTopPCDB.charSpec then
  511. db = TipTopPCDB
  512. else
  513. db = TipTopDB
  514. end
  515.  
  516. --make sure all tooltips have a Backdrop Object
  517. for i = 1, #tooltips do
  518. Mixin(tooltips[i], BackdropTemplateMixin)
  519. end
  520.  
  521. --set the default style to ours
  522. ttStyle = TOOLTIP_BACKDROP_STYLE_DEFAULT
  523.  
  524. --totally ugly chunk of code to ensure tooltip style and colors are consistent
  525. -- ttStyle.backdropColor.GetRGB = ColorMixin.GetRGBA;
  526. -- ttStyle.backdropBorderColor.GetRGB = ColorMixin.GetRGBA
  527. tt:HookScript("OnTooltipCleared", function(self)
  528. if not self:GetUnit() and not self:GetItem() then
  529. local borderColor = db.borderColor
  530. SetBorderColor(self, borderColor.r, borderColor.g, borderColor.b, borderColor.a)
  531. end
  532. end)
  533. tt:HookScript("OnShow", function(self) --stupid world tips
  534. if self:IsOwned(UIParent) and not self:GetUnit() then
  535. tt:SetBackdropColor(db.bgColor.r, db.bgColor.g, db.bgColor.b, db.alpha)
  536. end
  537. end)
  538. --hooksecurefunc("GameTooltip_SetBackdropStyle", function(self)
  539. hooksecurefunc("SharedTooltip_SetBackdropStyle", function(self)
  540. SetBorderColor(self, db.borderColor.r, db.borderColor.g, db.borderColor.b, db.borderColor.a)
  541. end)
  542. --[[WorldMapTooltip:HookScript("OnShow", function(self)
  543. SetBorderColor(self, db.borderColor.r, db.borderColor.g, db.borderColor.b, db.borderColor.a)
  544. end)]]
  545. QuestScrollFrame.StoryTooltip:HookScript("OnShow", function(self)
  546. self:SetBackdrop(ttStyle)
  547. SetBorderColor(self, db.borderColor.r, db.borderColor.g, db.borderColor.b, db.borderColor.a)
  548. self:SetBackdropColor(db.bgColor.r, db.bgColor.g, db.bgColor.b, db.alpha)
  549. end)
  550. --[[QuestScrollFrame.WarCampaignTooltip:HookScript("OnShow", function(self)
  551. self:SetBackdrop(ttStyle)
  552. SetBorderColor(self, db.borderColor.r, db.borderColor.g, db.borderColor.b, db.borderColor.a)
  553. self:SetBackdropColor(db.bgColor.r, db.bgColor.g, db.bgColor.b, db.alpha)
  554. end)]]
  555.  
  556. TipTop:SetBackgrounds()
  557. TipTop:SBarCustom()
  558. TipTop:SBPosition()
  559. TipTop:SetFonts()
  560. TipTop:RaidIcon()
  561. if db.factionIcon then
  562. TipTop:FactionIcon()
  563. end
  564.  
  565. color = CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS --support for CUSTOM_CLASS_COLORS addons
  566. if CUSTOM_CLASS_COLORS then
  567. CUSTOM_CLASS_COLORS:RegisterCallback(function() color = CUSTOM_CLASS_COLORS end)
  568. end
  569.  
  570. --moves tooltip
  571. local mover = TipTop.mover
  572. hooksecurefunc("GameTooltip_SetDefaultAnchor", function (tooltip, parent)
  573. if db.onCursor then
  574. tooltip:SetOwner(parent, "ANCHOR_CURSOR")
  575. else
  576. tooltip:SetOwner(parent, "ANCHOR_NONE")
  577. tooltip:ClearAllPoints()
  578. tooltip:SetPoint(db.anchor, mover)
  579. end
  580. end)
  581.  
  582. --set item tooltip hook
  583. local moneyfontset
  584. for i=1,#tooltips do
  585. if tooltips[i]:GetScript("OnTooltipSetItem") then
  586. tooltips[i]:HookScript("OnTooltipSetItem", function(tip)
  587. ItemQualityBorder(tip)
  588. --the vendor price strings don't exist until the first time they're needed
  589. if GameTooltipMoneyFrame1 and not moneyfontset then
  590. TipTop:SetFonts()
  591. moneyfontset = true
  592. end
  593. end)
  594. end
  595. tooltips[i].SetBackdropBorderColor = function() end
  596. end
  597.  
  598. --sb text updates
  599. ttSBar:HookScript("OnValueChanged", CalcHealth)
  600. ttSBar:HookScript("OnUpdate", TargetTextUpdate)
  601.  
  602. evfr:UnregisterEvent("PLAYER_LOGIN")
  603. evfr:RegisterEvent("UPDATE_MOUSEOVER_UNIT")
  604. evfr:SetScript("OnEvent", function(_, event, arg)
  605. if event == "UPDATE_MOUSEOVER_UNIT" then
  606. MouseoverTargetUpdate()
  607. elseif event == "INSPECT_READY" then
  608. if talentsGUID == arg then --only gather information about the unit we requested
  609. TalentText()
  610. end
  611. end
  612. end)
  613.  
  614. PlayerLogin = nil --let this function be garbage collected
  615. end
  616.  
  617. evfr:RegisterEvent("PLAYER_LOGIN")
  618. evfr:SetScript("OnEvent", PlayerLogin)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement