Bring in tip scanner external
This commit is contained in:
parent
c831f921ab
commit
f39146ffb0
|
@ -11,7 +11,7 @@
|
|||
## X-LoadOn-InterfaceOptions: GnomishVendorShrinker
|
||||
|
||||
externals\itemid.lua
|
||||
externals\ptr.lua
|
||||
externals\tooltip_scanner.lua
|
||||
|
||||
tekFunks\gsc.lua
|
||||
tekKonfig\tekKonfig.xml
|
||||
|
|
|
@ -1,31 +1,28 @@
|
|||
|
||||
local myname, ns = ...
|
||||
|
||||
local tip = CreateFrame("GameTooltip")
|
||||
tip:SetOwner(WorldFrame, "ANCHOR_NONE")
|
||||
|
||||
local lcache = {}
|
||||
for i=1,40 do
|
||||
lcache[i] = tip:CreateFontString()
|
||||
tip:AddFontStrings(lcache[i], tip:CreateFontString())
|
||||
local function HasHeirloom(id)
|
||||
return C_Heirloom.IsItemHeirloom(id) and C_Heirloom.PlayerHasHeirloom(id)
|
||||
end
|
||||
|
||||
ns.knowns = setmetatable({}, {__index = function(t, i)
|
||||
|
||||
local function IsKnown(link)
|
||||
ns.scantip:SetHyperlink(link)
|
||||
for i=1,ns.scantip:NumLines() do
|
||||
if ns.scantip.L[i] == ITEM_SPELL_KNOWN then return true end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
ns.knowns = setmetatable({}, {
|
||||
__index = function(t, i)
|
||||
local id = ns.ids[i]
|
||||
if not id then return end
|
||||
|
||||
if C_Heirloom.IsItemHeirloom(id) and C_Heirloom.PlayerHasHeirloom(id) then
|
||||
t[i] = true
|
||||
return true
|
||||
end
|
||||
|
||||
tip:ClearLines()
|
||||
if not tip:IsOwned(WorldFrame) then tip:SetOwner(WorldFrame, "ANCHOR_NONE") end
|
||||
tip:SetHyperlink(i)
|
||||
for i=1,tip:NumLines() do
|
||||
if lcache[i]:GetText() == ITEM_SPELL_KNOWN then
|
||||
if HasHeirloom(id) or IsKnown(i) then
|
||||
t[i] = true
|
||||
return true
|
||||
end
|
||||
end
|
||||
end})
|
||||
})
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
itemid.lua
|
||||
tooltip_scanner.lua
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
|
||||
local myname, ns = ...
|
||||
|
||||
|
||||
local tip = CreateFrame("GameTooltip")
|
||||
tip:SetOwner(WorldFrame, "ANCHOR_NONE")
|
||||
|
||||
ns.scantip = tip
|
||||
|
||||
|
||||
local lcache, rcache = {}, {}
|
||||
for i=1,30 do
|
||||
lcache[i], rcache[i] = tip:CreateFontString(), tip:CreateFontString()
|
||||
lcache[i]:SetFontObject(GameFontNormal)
|
||||
rcache[i]:SetFontObject(GameFontNormal)
|
||||
tip:AddFontStrings(lcache[i], rcache[i])
|
||||
end
|
||||
|
||||
|
||||
-- GetText cache tables, provide fast access to the tooltip's text
|
||||
tip.L = setmetatable({}, {
|
||||
__index = function(t, key)
|
||||
if tip:NumLines() >= key and lcache[key] then
|
||||
local v = lcache[key]:GetText()
|
||||
t[key] = v
|
||||
return v
|
||||
end
|
||||
return nil
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
tip.R = setmetatable({}, {
|
||||
__index = function(t, key)
|
||||
if tip:NumLines() >= key and rcache[key] then
|
||||
local v = rcache[key]:GetText()
|
||||
t[key] = v
|
||||
return v
|
||||
end
|
||||
return nil
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
-- Performes a "full" erase of the tooltip
|
||||
tip.Erase = function(self)
|
||||
self:ClearLines() -- Ensures tooltip's NumLines is reset
|
||||
for i in pairs(self.L) do self.L[i] = nil end -- Flush the metatable cache
|
||||
for i in pairs(self.R) do
|
||||
self.rcache[i]:SetText() -- Clear text from right side (ClearLines only hides them)
|
||||
self.R[i] = nil -- Flush the metatable cache
|
||||
end
|
||||
if not self:IsOwned(WorldFrame) then
|
||||
self:SetOwner(WorldFrame, "ANCHOR_NONE")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Hooks the Set* methods to force a full erase beforehand
|
||||
local methods = {"SetMerchantCostItem", "SetBagItem", "SetAction",
|
||||
"SetAuctionItem", "SetAuctionSellItem", "SetBuybackItem", "SetCraftItem",
|
||||
"SetCraftSpell", "SetHyperlink", "SetInboxItem", "SetInventoryItem",
|
||||
"SetLootItem", "SetLootRollItem", "SetMerchantItem", "SetPetAction",
|
||||
"SetPlayerBuff", "SetQuestItem", "SetQuestLogItem", "SetQuestRewardSpell",
|
||||
"SetSendMailItem", "SetShapeshift", "SetSpell", "SetTalent",
|
||||
"SetTrackingSpell", "SetTradePlayerItem", "SetTradeSkillItem",
|
||||
"SetTradeTargetItem", "SetTrainerService", "SetUnit", "SetUnitBuff",
|
||||
"SetUnitDebuff"}
|
||||
for _,m in pairs(methods) do
|
||||
local orig = tip[m]
|
||||
tip[m] = function(self, ...)
|
||||
self:Erase()
|
||||
return orig(self, ...)
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue