Quantcast

Add tooltipMain:FadeOut to mimic GameTooltip's own fading.

Scott Sibley [07-08-11 - 05:00]
Add tooltipMain:FadeOut to mimic GameTooltip's own fading.
Filename
.pkgmeta
Modules/Fade/Fade.lua
StarTip.lua
embeds.xml
diff --git a/.pkgmeta b/.pkgmeta
index 015d3f7..ce11243 100644
--- a/.pkgmeta
+++ b/.pkgmeta
@@ -51,6 +51,8 @@ externals:
         tag: v1.1.4
     Libs/LibScriptable-1.0:
         url: svn://svn.wowace.com/wow/libscriptable-1-0/mainline/trunk
+    Libs/LibFlash:
+        url: svn://svn.wowace.com/wow/libflash/mainline/trunk

 move-folders:
     StarTip/Modules/Appearance: StarTip_Appearance
diff --git a/Modules/Fade/Fade.lua b/Modules/Fade/Fade.lua
index 5337153..ac79d7f 100644
--- a/Modules/Fade/Fade.lua
+++ b/Modules/Fade/Fade.lua
@@ -78,13 +78,7 @@ function mod:OnEnable()
 end

 function mod:OnDisable()
-	self:Unhook(GameTooltip, "FadeOut")
-	self:Unhook(GameTooltip, "Hide")
 	StarTip:SetOptionsDisabled(options, true)
-	if timer then
-		self:CancelTimer(timer)
-		timer = nil
-	end
 end

 function mod:GetOptions()
@@ -106,7 +100,7 @@ local checkExistence = function()
 		end
 		if kind == 2 then
 			GameTooltip:FadeOut()
-			StarTip.tooltipMain:Hide()
+			StarTip.tooltipMain:FadeOut()
 		else
 			GameTooltip:Hide()
 			StarTip.tooltipMain:Hide()
@@ -125,8 +119,10 @@ local checkTooltipAlpha = function()
 		end
 		if kind == 2 then
 			GameTooltip:FadeOut()
+			StarTip.tooltipMain:FadeOut()
 		else
 			GameTooltip:Hide()
+			StarTip.tooltipMain:Hide()
 		end
 	end
 end
@@ -164,6 +160,7 @@ function mod:OnFadeOut(this, ...)
 	else
 		self.justHide = true
 		GameTooltip:Hide()
+		StarTip.tooltipMain:Hide()
 	end

 end
@@ -191,6 +188,7 @@ function mod:GameTooltipHide(this, ...)
 	if kind == 2 then
 		self.justFade = true
 		GameTooltip:FadeOut()
+		StarTip.tooltipMain:FadeOut()
 	else
 		return true
 	end
diff --git a/StarTip.lua b/StarTip.lua
index 1493ffc..561dc35 100644
--- a/StarTip.lua
+++ b/StarTip.lua
@@ -9,6 +9,7 @@ local L = LibStub("AceLocale-3.0"):GetLocale("StarTip")
 StarTip.L = L
 local LQT = LibStub:GetLibrary("LibQTip-1.0-fix")
 StarTip.LQT = LQT
+local LibFlash = LibStub("LibFlash")


 local LibCore = LibStub("LibScriptableLCDCoreLite-1.0")
@@ -495,6 +496,21 @@ StarTip.tooltipMain:SetParent(UIParent)
 _G["StarTipQTipMain"] = StarTip.tooltipMain
 StarTip.tooltipMain:ClearAllPoints()
 StarTip.tooltipMain:SetPoint("CENTER")
+StarTip.tooltipMain.flash = LibFlash:New(StarTip.tooltipMain)
+StarTip.tooltipMain.ShowReal = StarTip.tooltipMain.Show
+StarTip.tooltipMain.Show = function()
+	StarTip.tooltipMain.flash:Stop()
+	StarTip.tooltipMain:ShowReal()
+	StarTip.tooltipMain:SetAlpha(1)
+end
+StarTip.tooltipMain.HideReal = StarTip.tooltipMain.Hide
+StarTip.tooltipMain.Hide = function()
+	StarTip.tooltipMain.flash:Stop()
+	StarTip.tooltipMain:HideReal()
+end
+StarTip.tooltipMain.FadeOut = function()
+	StarTip.tooltipMain.flash:FadeOut(1, 1, 0)
+end

 local trunk = {}
 local trunkLines = 1
@@ -696,6 +712,7 @@ function StarTip:OpenConfig()
 	AceConfigDialog:Open("StarTip-Addon")
 end

+--[[
 function StarTip:HideTooltip()
 	GameTooltip:Hide()
 	self.tooltipHidden = true
@@ -709,6 +726,7 @@ function StarTip:ShowTooltip(unit)
 	GameTooltip:SetUnit(unit)
 	GameTooltip:Show()
 end
+]]

 function StarTip.GameTooltipAddLine(...)
 end
@@ -731,13 +749,13 @@ function StarTip.OnTooltipSetUnit(...)

 	local _, unit = GameTooltip:GetUnit()

-	if not unit or StarTip.tooltipHidden then GameTooltip:Hide() return end
+	if not unit then return end

-	environment.unit = unit

 	StarTip:TrunkClear()
 	trunkLines = GameTooltip:NumLines()

+--[[
 	hideTimer = hideTimer or LibTimer:New("StarTip.Hide", 100, false, hideTooltip, nil, StarTip.db.profile.errorLevel)
 	hideTimer:Start()

@@ -748,13 +766,13 @@ function StarTip.OnTooltipSetUnit(...)
 		return
 	end
 	lastTime = GetTime()
-
+]]
 	if unit ~= "mouseover" and UnitIsUnit(unit, "mouseover") then
 		unit = "mouseover"
 	end

-	--StarTip.fading = false
 	StarTip.unit = unit
+	environment.unit = unit

 	if not StarTip.justSetUnit then
 		for k, v in StarTip:IterateModules() do
@@ -764,7 +782,6 @@ function StarTip.OnTooltipSetUnit(...)

 	StarTip.justSetUnit = false

-	--checkTooltipAlphaFrame:SetScript("OnUpdate", checkTooltipAlpha)
 	StarTip.tooltipMain:Show()
 	StarTip.trunkTimer:Start()
 end
@@ -808,7 +825,6 @@ function StarTip:GameTooltipHide(...)
 	end
 	]]

-	self.tooltipMain:Hide()
 	if hide then
 		StarTip.hooks[GameTooltip].Hide(...)
 	end
@@ -921,7 +937,6 @@ function StarTip:GameTooltipFadeOut(...)
 	if fadeOut then
 		StarTip.hooks[GameTooltip].FadeOut(...)
 	end
-	self.tooltipMain:Hide()
 end

 function StarTip:GetLSMIndexByName(category, name)
diff --git a/embeds.xml b/embeds.xml
index 16032c1..14c9500 100644
--- a/embeds.xml
+++ b/embeds.xml
@@ -14,6 +14,7 @@
 <Include file = "Libs\AceComm-3.0\AceComm-3.0.xml"/>
 <Include file = "Libs\AceSerializer-3.0\AceSerializer-3.0.xml"/>
 <Include file = "Libs\AceLocale-3.0\AceLocale-3.0.xml"/>
+<Script file = "Libs\LibFlash\LibFlash.lua"/>
 <Script file = "LibQTip-1.0.lua"/>

 <Include file = "Libs\LibSharedMedia-3.0\lib.xml"/>