Quantcast

Parses a hidden tooltip for the stats instead of reading GameTooltip directly

Kevin Lyles [09-19-09 - 08:55]
Parses a hidden tooltip for the stats instead of reading GameTooltip directly

Removed marking of unrecognized lines (we'd be marking a hidden tooltip)
Filename
HiddenTooltip.xml
WeightsWatcher.lua
WeightsWatcher.toc
diff --git a/HiddenTooltip.xml b/HiddenTooltip.xml
new file mode 100644
index 0000000..9c3018f
--- /dev/null
+++ b/HiddenTooltip.xml
@@ -0,0 +1,10 @@
+<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+		xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">
+	<GameTooltip name="WeightsWatcherHiddenTooltip" inherits="GameTooltipTemplate">
+		<Scripts>
+			<Onload>
+				self:SetOwner(WorldFrame, "ANCHOR_NONE");
+			</Onload>
+		</Scripts>
+	</GameTooltip>
+</Ui>
diff --git a/WeightsWatcher.lua b/WeightsWatcher.lua
index 58551af..7b19d85 100644
--- a/WeightsWatcher.lua
+++ b/WeightsWatcher.lua
@@ -77,7 +77,7 @@ function WeightsWatcher:displayItemStats(tooltip, ttname)

 	_, _, _, _, _, itemType, _, stackSize = GetItemInfo(link)
 	if (IsEquippableItem(link) and itemType ~= "Container" and itemType ~= "Quiver") or (itemType == "Gem" and stackSize == 1) or (itemType == "Consumable") or (itemType == "Recipe") then
-		normalStats, socketBonusStat = WeightsWatcher:getItemStats(link, tooltip, ttname)
+		normalStats, socketBonusStat = WeightsWatcher:getItemStats(link)
 		for _, stat in pairs(normalStats) do
 			tooltip:AddDoubleLine(unpack(stat))
 		end
@@ -97,20 +97,24 @@ function WeightsWatcher:displayItemStats(tooltip, ttname)
 	end
 end

-function WeightsWatcher:getItemStats(link, tooltip, ttname)
+function WeightsWatcher:getItemStats(link)
 	local ttleft, ttright, origTextL, textL, textR, pattern, func, start
 	local normalStats, socketBonusStat = {}

+	-- Populate hidden tooltip
+	WeightsWatcherHiddenTooltip:ClearLines()
+	WeightsWatcherHiddenTooltip:SetHyperlink(link)
+
 	-- Skip item name and "currently equipped"
-	if getglobal(ttname .. "TextLeft1"):GetText() == CURRENTLY_EQUIPPED then
+	if WeightsWatcherHiddenTooltipTextLeft1:GetText() == CURRENTLY_EQUIPPED then
 		start = 3
 	else
 		start = 2
 	end

-	for i = start, tooltip:NumLines() do
-		ttleft = getglobal(ttname .. "TextLeft" .. i)
-		ttright = getglobal(ttname .. "TextRight" .. i)
+	for i = start, WeightsWatcherHiddenTooltip:NumLines() do
+		ttleft = getglobal("WeightsWatcherHiddenTooltipTextLeft" .. i)
+		ttright = getglobal("WeightsWatcherHiddenTooltipTextRight" .. i)
 		origTextL = ttleft:GetText()
 		textR = ttright:GetText()
 		textL = WeightsWatcher:preprocess(origTextL)
@@ -163,8 +167,6 @@ function WeightsWatcher:getItemStats(link, tooltip, ttname)
 							stat = WeightsWatcher:singleStat(textL)
 							if stat then
 								table.insert(normalStats, stat)
-							else
-								ttleft:SetText(origTextL .. " *")
 							end
 						end
 					end
diff --git a/WeightsWatcher.toc b/WeightsWatcher.toc
index ae29aa9..fddfbde 100644
--- a/WeightsWatcher.toc
+++ b/WeightsWatcher.toc
@@ -15,5 +15,6 @@ Libs\AceEvent-2.0\AceEvent-2.0.lua
 Libs\AceHook-2.1\AceHook-2.1.lua

 Regexps.lua
+HiddenTooltip.xml
 WeightsWatcher.lua
 WeightsWatcher.xml