From 1d071108a5a3cca64fdf432f622af91c2409403b Mon Sep 17 00:00:00 2001 From: shagu Date: Sun, 17 Mar 2019 16:22:58 +0100 Subject: [PATCH] libtipscan: add method to parse tooltips into strings --- libs/libtipscan.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/libs/libtipscan.lua b/libs/libtipscan.lua index 72d11a9b..4df96a9b 100644 --- a/libs/libtipscan.lua +++ b/libs/libtipscan.lua @@ -42,6 +42,24 @@ local extra_methods = { "Find", "Line", "Text", "List", } +local getFontString = function(obj) + local name = obj:GetName() + local r, g, b, color + local text, segment + + for i=1, obj:NumLines() do + local left = _G[string.format("%sTextLeft%d",name,i)] + segment = left and left:IsVisible() and left:GetText() + segment = segment and segment ~= "" and segment or nil + if segment then + r, g, b, a = left:GetTextColor() + segment = "|c" .. string.format("ff%02x%02x%02x", r*255, g*255, b*255) .. segment .. "|r" + text = text and text .. "\n" .. segment or segment + end + end + return text +end + local getText = function(obj) local name = obj:GetName() local text = {} @@ -132,6 +150,9 @@ libtipscan._registry = setmetatable({},{__index = function(t,k) function v:Text() return getText(self) end + function v:FontString() + return getFontString(self) + end function v:Find(text, exact) return findText(self, text, exact) end