Загрузить файлы в «/»
This commit is contained in:
+67
@@ -0,0 +1,67 @@
|
||||
-- Ade Alts: tooltip (recipe items show which of your alts can learn them)
|
||||
local AA = AdeAlts
|
||||
|
||||
local PREFIX = { Pattern = 1, Recipe = 1, Plans = 1, Formula = 1, Schematic = 1, Manual = 1, Design = 1, Book = 1, Technique = 1 }
|
||||
|
||||
function AA.EnhanceTooltip(tt)
|
||||
if not AA.db or not AA.RIndex or tt.adeDone then return end
|
||||
local l1 = getglobal(tt:GetName() .. "TextLeft1")
|
||||
local txt = l1 and l1:GetText()
|
||||
if not txt then return end
|
||||
local _, _, pre, nm = string.find(txt, "^(%a+): (.+)$")
|
||||
if not pre or not PREFIX[pre] then return end
|
||||
local hits = AA.RIndex().byAny[string.lower(nm)]
|
||||
if not hits then return end
|
||||
tt.adeDone = true
|
||||
local key = string.lower(nm)
|
||||
local added = false
|
||||
for _, h in ipairs(hits) do
|
||||
for _, k in ipairs(AA.SortedAlts()) do
|
||||
local ch = AA.db.chars[k]
|
||||
local p = ch and ch.prof and ch.prof[h.prof]
|
||||
if p then
|
||||
if not added then
|
||||
tt:AddLine(" ")
|
||||
tt:AddLine("Ade Alts", 0.2, 1, 0.8)
|
||||
added = true
|
||||
end
|
||||
local col = "|cff" .. AA.ClassHex(ch.class)
|
||||
local label
|
||||
if not p.rec then
|
||||
label = "|cff808080" .. h.prof .. " recipes not scanned|r"
|
||||
else
|
||||
local has = false
|
||||
for _, n in ipairs(p.rec) do
|
||||
if string.lower(n) == key then has = true; break end
|
||||
end
|
||||
if has then
|
||||
label = "|cff808080already known|r"
|
||||
elseif h.c[3] > (p.r or 0) then
|
||||
label = "|cffff6060needs " .. h.prof .. " " .. h.c[3] .. " (has " .. (p.r or 0) .. ")|r"
|
||||
else
|
||||
label = "|cff40ff40can learn now|r"
|
||||
end
|
||||
end
|
||||
tt:AddDoubleLine(col .. ch.name .. "|r", label)
|
||||
end
|
||||
end
|
||||
end
|
||||
if added then tt:Show() end
|
||||
end
|
||||
|
||||
local function Hook(tt)
|
||||
if not tt then return end
|
||||
local oldShow = tt:GetScript("OnShow")
|
||||
tt:SetScript("OnShow", function()
|
||||
if oldShow then oldShow() end
|
||||
AA.EnhanceTooltip(this)
|
||||
end)
|
||||
local oldHide = tt:GetScript("OnHide")
|
||||
tt:SetScript("OnHide", function()
|
||||
this.adeDone = nil
|
||||
if oldHide then oldHide() end
|
||||
end)
|
||||
end
|
||||
|
||||
Hook(GameTooltip)
|
||||
Hook(ItemRefTooltip)
|
||||
Reference in New Issue
Block a user