From 5cbe664d1308cdad4ff781a2f5180eaca5422dbc Mon Sep 17 00:00:00 2001 From: Kevin Lyles Date: Sat, 12 Sep 2009 05:00:53 -0500 Subject: [PATCH] Obtains basic stats, marks lines it doesn't process Still need to check the proper tooltip for non-primary tooltips Still double-parsing --- Regexps.lua | 14 +++++++++++++- WeightsWatcher.lua | 30 +++++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/Regexps.lua b/Regexps.lua index e5aa0ab..4d7c520 100644 --- a/Regexps.lua +++ b/Regexps.lua @@ -4,5 +4,17 @@ Preprocess = { } ProcessedLines = { - "%+(%d+) (%a[%a ]+)" + {"^%+?(%d+) (%a[%a ]+)", + function(text, pattern) + local start, name, value + start, _, value, name = string.find(text, pattern) + if start then + return {name, value} + end + end}, + "^(%a[%a ]+) (%d+)", + "^Equip: Increases (%a[%a ]+) by (%d+)%.", + "^Soulbound$", + "^Durability %d+ / %d+$", + "^<.+>$", } diff --git a/WeightsWatcher.lua b/WeightsWatcher.lua index c6124c3..5c643c9 100644 --- a/WeightsWatcher.lua +++ b/WeightsWatcher.lua @@ -66,8 +66,8 @@ function WeightsWatcher:OnDisable() end function DisplayItemInfo(tooltip, ttname) + local itemType, ttline, origText, text, pattern, func, stat, start, name, value local _, link = tooltip:GetItem() - local itemType, text, start, name, value if link == nil then return @@ -82,14 +82,34 @@ function DisplayItemInfo(tooltip, ttname) start = 2 end for i = start, tooltip:NumLines() do - text = WeightsWatcher:preprocess(getglobal(ttname .. "TextLeft" .. i):GetText()) + ttline = getglobal(ttname .. "TextLeft" .. i) + origText = ttline:GetText() + text = WeightsWatcher:preprocess(origText) + matched = false for _, regex in pairs(ProcessedLines) do - start, _, value, name = string.find(text, regex) - if start then - tooltip:AddDoubleLine(name, value) + if type(regex) == "table" then + pattern, func = unpack(regex) + if string.find(text, pattern) then + stat = func(text, pattern) + if stat then + tooltip:AddDoubleLine(unpack(stat)) + matched = true + break + end + end + else + start, _, name, value = string.find(text, regex) + if start then + tooltip:AddDoubleLine(name, value) + matched = true + break + end end end + if not matched then + ttline:SetText(origText .. " *") + end end tooltip:Show() end -- 1.7.9.5