From fd5dfb9e5fe5e6465a5c30df47c4925aa6e78a4f Mon Sep 17 00:00:00 2001 From: Kevin Lyles Date: Sat, 12 Sep 2009 02:46:32 -0500 Subject: [PATCH] Detects and prints simple stats at the bottom of the tooltip Seems to do it twice for some reason --- Regexps.lua | 3 +++ WeightsWatcher.lua | 12 ++++++++++-- WeightsWatcher.toc | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 Regexps.lua diff --git a/Regexps.lua b/Regexps.lua new file mode 100644 index 0000000..290a4f3 --- /dev/null +++ b/Regexps.lua @@ -0,0 +1,3 @@ +ProcessedLines = { + "%+(%d+) (%a[%a ]+)" +} diff --git a/WeightsWatcher.lua b/WeightsWatcher.lua index b01f6ba..8e23599 100644 --- a/WeightsWatcher.lua +++ b/WeightsWatcher.lua @@ -67,7 +67,7 @@ end function DisplayItemInfo(tooltip, ttname) local _, link = tooltip:GetItem() - local itemType + local itemType, text, start, name, value if link == nil then return @@ -75,7 +75,15 @@ function DisplayItemInfo(tooltip, ttname) _, _, _, _, _, itemType, _, stackSize = GetItemInfo(link) if IsEquippableItem(link) or (itemType == "Gem" and stackSize == 1) then - tooltip:AddLine("Weights needed here") + for i = 1, tooltip:NumLines() do + text = getglobal(ttname .. "TextLeft" .. i):GetText() + for _, regex in pairs(ProcessedLines) do + start, _, value, name = string.find(text, regex) + if start then + tooltip:AddDoubleLine(name, value) + end + end + end tooltip:Show() end end diff --git a/WeightsWatcher.toc b/WeightsWatcher.toc index ab78fb3..ae29aa9 100644 --- a/WeightsWatcher.toc +++ b/WeightsWatcher.toc @@ -14,5 +14,6 @@ Libs\AceAddon-2.0\AceAddon-2.0.lua Libs\AceEvent-2.0\AceEvent-2.0.lua Libs\AceHook-2.1\AceHook-2.1.lua +Regexps.lua WeightsWatcher.lua WeightsWatcher.xml -- 1.7.9.5