更新配置相关显示等
This commit is contained in:
181
Tooltip.lua
181
Tooltip.lua
@@ -822,9 +822,18 @@ local function IC_AddSellPrice(tooltip, link, count)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
local function IC_AppendItemId(tooltip, link)
|
||||
if SFramesDB and SFramesDB.showTooltipIDs == false then return end
|
||||
local itemId = IC_GetItemIdFromLink(link)
|
||||
if itemId then
|
||||
tooltip:AddLine("物品ID: " .. itemId, 0.55, 0.55, 0.70)
|
||||
end
|
||||
end
|
||||
|
||||
local function IC_EnhanceTooltip(tooltip, link, count, skipSellPrice)
|
||||
if not link then return end
|
||||
IC_AppendItemLevel(tooltip, link)
|
||||
IC_AppendItemId(tooltip, link)
|
||||
if not SFramesDB or SFramesDB.itemCompare ~= false then
|
||||
local lib = IC_GetLib()
|
||||
if lib then
|
||||
@@ -1174,8 +1183,180 @@ function IC:HookTooltips()
|
||||
SetTooltipMoney(ItemRefTooltip, price)
|
||||
ItemRefTooltip:Show()
|
||||
end
|
||||
if itemId then
|
||||
ItemRefTooltip:AddLine("物品ID: " .. itemId, 0.55, 0.55, 0.70)
|
||||
ItemRefTooltip:Show()
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
-- Spell ID display
|
||||
---------------------------------------------------------------------------
|
||||
local spellIdCache = {}
|
||||
|
||||
local function TT_AddSpellIdLine(tooltip, sid)
|
||||
if not tooltip or not sid then return end
|
||||
if SFramesDB and SFramesDB.showTooltipIDs == false then return end
|
||||
tooltip:AddLine("法术ID: " .. sid, 0.55, 0.55, 0.70)
|
||||
tooltip:Show()
|
||||
end
|
||||
|
||||
local function TT_ExtractSpellId(link)
|
||||
if not link then return nil end
|
||||
local _, _, id = string.find(link, "spell:(%d+)")
|
||||
return id
|
||||
end
|
||||
|
||||
local function TT_CleanName(text)
|
||||
if not text then return nil end
|
||||
text = string.gsub(text, "|c%x%x%x%x%x%x%x%x", "")
|
||||
text = string.gsub(text, "|r", "")
|
||||
text = string.gsub(text, "|H.-|h", "")
|
||||
text = string.gsub(text, "|h", "")
|
||||
text = string.gsub(text, "^%s+", "")
|
||||
text = string.gsub(text, "%s+$", "")
|
||||
return text
|
||||
end
|
||||
|
||||
local function TT_BuildSpellCache()
|
||||
spellIdCache = {}
|
||||
local function ScanBook(bookType, count)
|
||||
if not GetSpellLink or count == 0 then return end
|
||||
for i = 1, count do
|
||||
local name, rank = GetSpellName(i, bookType)
|
||||
if name then
|
||||
local link = GetSpellLink(i, bookType)
|
||||
local sid = TT_ExtractSpellId(link)
|
||||
if sid then
|
||||
spellIdCache[name] = sid
|
||||
local clean = TT_CleanName(name)
|
||||
if clean and clean ~= name then
|
||||
spellIdCache[clean] = sid
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local bookType = BOOKTYPE_SPELL or "spell"
|
||||
local numTabs = GetNumSpellTabs and GetNumSpellTabs() or 0
|
||||
local total = 0
|
||||
for t = 1, numTabs do
|
||||
local _, _, _, count = GetSpellTabInfo(t)
|
||||
total = total + (count or 0)
|
||||
end
|
||||
ScanBook(bookType, total)
|
||||
|
||||
if HasPetSpells then
|
||||
local numPet = HasPetSpells() or 0
|
||||
if numPet > 0 then
|
||||
ScanBook(BOOKTYPE_PET or "pet", numPet)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local spellCacheFrame = CreateFrame("Frame")
|
||||
spellCacheFrame:RegisterEvent("SPELLS_CHANGED")
|
||||
spellCacheFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
spellCacheFrame:RegisterEvent("LEARNED_SPELL_IN_TAB")
|
||||
spellCacheFrame:RegisterEvent("PET_BAR_UPDATE")
|
||||
spellCacheFrame:SetScript("OnEvent", function()
|
||||
TT_BuildSpellCache()
|
||||
end)
|
||||
|
||||
local function TT_LookupSpellId(spellBookIdx, bookType)
|
||||
if GetSpellLink then
|
||||
local link = GetSpellLink(spellBookIdx, bookType)
|
||||
local sid = TT_ExtractSpellId(link)
|
||||
if sid then return sid end
|
||||
end
|
||||
local name = GetSpellName(spellBookIdx, bookType)
|
||||
if name then
|
||||
if spellIdCache[name] then return spellIdCache[name] end
|
||||
local clean = TT_CleanName(name)
|
||||
if clean and spellIdCache[clean] then return spellIdCache[clean] end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local function TT_LookupByTooltipName(tooltip)
|
||||
local ttName = tooltip and tooltip:GetName()
|
||||
if not ttName then return nil end
|
||||
local left1 = _G[ttName .. "TextLeft1"]
|
||||
if not left1 then return nil end
|
||||
local raw = left1:GetText()
|
||||
if not raw or raw == "" then return nil end
|
||||
|
||||
if spellIdCache[raw] then return spellIdCache[raw] end
|
||||
|
||||
local clean = TT_CleanName(raw)
|
||||
if clean and spellIdCache[clean] then return spellIdCache[clean] end
|
||||
|
||||
local noRank = string.gsub(clean or raw, "%s*%(.-%)%s*$", "")
|
||||
if noRank ~= (clean or raw) and spellIdCache[noRank] then
|
||||
return spellIdCache[noRank]
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
local orig_SetSpell = GameTooltip.SetSpell
|
||||
if orig_SetSpell then
|
||||
GameTooltip.SetSpell = function(self, id, bookType)
|
||||
orig_SetSpell(self, id, bookType)
|
||||
pcall(function()
|
||||
local sid = TT_LookupSpellId(id, bookType)
|
||||
if sid then
|
||||
TT_AddSpellIdLine(self, sid)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
local orig_SetUnitBuff = GameTooltip.SetUnitBuff
|
||||
if orig_SetUnitBuff then
|
||||
GameTooltip.SetUnitBuff = function(self, unit, idx, filter)
|
||||
orig_SetUnitBuff(self, unit, idx, filter)
|
||||
pcall(function()
|
||||
local sid = TT_LookupByTooltipName(self)
|
||||
if sid then TT_AddSpellIdLine(self, sid) end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
local orig_SetUnitDebuff = GameTooltip.SetUnitDebuff
|
||||
if orig_SetUnitDebuff then
|
||||
GameTooltip.SetUnitDebuff = function(self, unit, idx, filter)
|
||||
orig_SetUnitDebuff(self, unit, idx, filter)
|
||||
pcall(function()
|
||||
local sid = TT_LookupByTooltipName(self)
|
||||
if sid then TT_AddSpellIdLine(self, sid) end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
local orig_SetCraftSpell = GameTooltip.SetCraftSpell
|
||||
if orig_SetCraftSpell then
|
||||
GameTooltip.SetCraftSpell = function(self, idx)
|
||||
orig_SetCraftSpell(self, idx)
|
||||
pcall(function()
|
||||
local sid = TT_LookupByTooltipName(self)
|
||||
if sid then TT_AddSpellIdLine(self, sid) end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
local orig_SetTrackingSpell = GameTooltip.SetTrackingSpell
|
||||
if orig_SetTrackingSpell then
|
||||
GameTooltip.SetTrackingSpell = function(self)
|
||||
orig_SetTrackingSpell(self)
|
||||
pcall(function()
|
||||
local sid = TT_LookupByTooltipName(self)
|
||||
if sid then TT_AddSpellIdLine(self, sid) end
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user