Quantcast

fix tooltip

rawoil [01-21-22 - 02:57]
fix tooltip
Filename
rTooltip/core.lua
diff --git a/rTooltip/core.lua b/rTooltip/core.lua
index 23e0d79..c664b26 100644
--- a/rTooltip/core.lua
+++ b/rTooltip/core.lua
@@ -56,6 +56,13 @@ cfg.pos = "ANCHOR_NONE" --"ANCHOR_CURSOR"
 -- Functions
 -----------------------------

+-- Tooltip skin
+local fakeBg = CreateFrame("Frame", nil, UIParent, "BackdropTemplate")
+fakeBg:SetBackdrop({ bgFile = cfg.backdrop.bgFile, edgeFile = cfg.backdrop.bgFile, edgeSize = 1 })
+local function __GetBackdrop() return fakeBg:GetBackdrop() end
+local function __GetBackdropColor() return 0, 0, 0, .7 end
+local function __GetBackdropBorderColor() return 0, 0, 0 end
+
 local function GetHexColor(color)
   if color.r then
     return ("%.2x%.2x%.2x"):format(color.r*255, color.g*255, color.b*255)
@@ -343,19 +350,41 @@ local function SetCompareItemBorderColor(anchorFrame)
 	end
 end

+local function HideBackdrop(frame)
+  if frame.NineSlice then frame.NineSlice:SetAlpha(0) end
+  if frame.SetBackdrop then frame:SetBackdrop(nil) end
+end
+
 local function SkinTooltip(self)
 	if self:IsForbidden() then
 		return
 	end

 	if (not self.isSkinned) then
+    HideBackdrop(self)
+    self:DisableDrawLayer("BACKGROUND")
 		StripTextures(self)
 		CreateBackdrop(self)

+    if self.GetBackdrop then
+			self.GetBackdrop = __GetBackdrop
+			self.GetBackdropColor = __GetBackdropColor
+			self.GetBackdropBorderColor = __GetBackdropBorderColor
+		end
+
 		self.isSkinned = true
 	end
 end

+local function OnTooltipCleared(self)
+	if self:IsForbidden() then return end
+
+	GameTooltip_ClearMoney(self)
+	GameTooltip_ClearStatusBars(self)
+	GameTooltip_ClearProgressBars(self)
+	GameTooltip_ClearWidgetSet(self)
+end
+
 -----------------------------
 -- Init
 -----------------------------
@@ -388,8 +417,8 @@ Tooltip_Small:SetShadowColor(0,0,0,0.75)

 --gametooltip statusbar
 GameTooltipStatusBar:ClearAllPoints()
-GameTooltipStatusBar:SetPoint("LEFT",3,0)
-GameTooltipStatusBar:SetPoint("RIGHT",-3,0)
+GameTooltipStatusBar:SetPoint("LEFT",5,0)
+GameTooltipStatusBar:SetPoint("RIGHT",-5, 0)
 GameTooltipStatusBar:SetPoint("TOP",0,-2.5)
 GameTooltipStatusBar:SetHeight(4)
 --gametooltip statusbar bg
@@ -421,16 +450,18 @@ local tooltips = { GameTooltip,ShoppingTooltip1,ShoppingTooltip2,ItemRefTooltip,
 WorldMapCompareTooltip1,WorldMapCompareTooltip2,SmallTextTooltip,EmbeddedItemTooltip }
 for i, tooltip in next, tooltips do
   tooltip:SetScale(cfg.scale)
-  -- if tooltip:HasScript("OnTooltipCleared") then
-  --   tooltip:HookScript("OnTooltipCleared", SetBackdropStyle)
-  -- end
+  SkinTooltip(tooltip)
+  if tooltip:HasScript("OnTooltipCleared") then
+    -- tooltip:HookScript("OnTooltipCleared", SetBackdropStyle)
+    tooltip:HookScript("OnTooltipCleared", OnTooltipCleared)
+  end
 end

-SkinTooltip(GameTooltip)
-SkinTooltip(ItemRefTooltip)
-SkinTooltip(EmbeddedItemTooltip)
-SkinTooltip(ShoppingTooltip1)
-SkinTooltip(ShoppingTooltip2)
+-- SkinTooltip(GameTooltip)
+-- SkinTooltip(ItemRefTooltip)
+-- SkinTooltip(EmbeddedItemTooltip)
+-- SkinTooltip(ShoppingTooltip1)
+-- SkinTooltip(ShoppingTooltip2)

 --loop over menues
 local menues = {