聊天重做前缓存
This commit is contained in:
72
Tooltip.lua
72
Tooltip.lua
@@ -115,6 +115,23 @@ local function TT_DifficultyColor(unitLevel)
|
||||
end
|
||||
end
|
||||
|
||||
local function TT_GetClassificationText(unit)
|
||||
if not UnitExists(unit) then return nil end
|
||||
|
||||
local classif = UnitClassification(unit)
|
||||
if classif == "rareelite" then
|
||||
return "|cffc57cff[稀有 精英]|r"
|
||||
elseif classif == "rare" then
|
||||
return "|cffc57cff[稀有]|r"
|
||||
elseif classif == "elite" then
|
||||
return "|cffffa500[精英]|r"
|
||||
elseif classif == "worldboss" then
|
||||
return "|cffff4040[首领]|r"
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Initialize
|
||||
--------------------------------------------------------------------------------
|
||||
@@ -680,6 +697,29 @@ function SFrames.FloatingTooltip:FormatLines(tooltip)
|
||||
GameTooltipStatusBar._origSetColor(GameTooltipStatusBar, color.r, color.g, color.b)
|
||||
end
|
||||
end
|
||||
|
||||
local classificationText = TT_GetClassificationText(unit)
|
||||
if classificationText then
|
||||
local numLines = tooltip:NumLines()
|
||||
local appended = false
|
||||
for i = 2, numLines do
|
||||
local left = getglobal("GameTooltipTextLeft" .. i)
|
||||
if left then
|
||||
local txt = left:GetText()
|
||||
if txt and (string.find(txt, "^Level ") or string.find(txt, "^等级 ")) then
|
||||
if not string.find(txt, "%[") then
|
||||
left:SetText(txt .. " " .. classificationText)
|
||||
end
|
||||
appended = true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not appended then
|
||||
tooltip:AddLine(classificationText)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------
|
||||
@@ -1268,27 +1308,27 @@ function IC:HookTooltips()
|
||||
---------------------------------------------------------------------------
|
||||
-- SetItemRef (chat item links)
|
||||
---------------------------------------------------------------------------
|
||||
local orig_SetItemRef = SetItemRef
|
||||
if orig_SetItemRef then
|
||||
SetItemRef = function(link, text, button)
|
||||
orig_SetItemRef(link, text, button)
|
||||
if IsAltKeyDown() or IsShiftKeyDown() or IsControlKeyDown() then return end
|
||||
if ItemRefTooltip and ItemRefTooltip.SetHyperlink then
|
||||
local orig_ItemRef_SetHyperlink = ItemRefTooltip.SetHyperlink
|
||||
ItemRefTooltip.SetHyperlink = function(self, link)
|
||||
self._nanamiSellPriceAdded = nil
|
||||
self._gsScoreAdded = nil
|
||||
|
||||
local r1, r2, r3, r4 = orig_ItemRef_SetHyperlink(self, link)
|
||||
|
||||
if IsAltKeyDown() or IsShiftKeyDown() or IsControlKeyDown() then
|
||||
return r1, r2, r3, r4
|
||||
end
|
||||
|
||||
pcall(function()
|
||||
local _, _, itemStr = string.find(link or "", "(item:[%-?%d:]+)")
|
||||
if itemStr then
|
||||
ItemRefTooltip._nanamiSellPriceAdded = nil
|
||||
local itemId = IC_GetItemIdFromLink(itemStr)
|
||||
local price = IC_QueryAndLearnPrice(itemStr)
|
||||
if price and price > 0 and not ItemRefTooltip.hasMoney then
|
||||
SetTooltipMoney(ItemRefTooltip, price)
|
||||
ItemRefTooltip:Show()
|
||||
end
|
||||
if itemId then
|
||||
ItemRefTooltip:AddLine("物品ID: " .. itemId, 0.55, 0.55, 0.70)
|
||||
ItemRefTooltip:Show()
|
||||
end
|
||||
local moneyAlreadyShown = self.hasMoney
|
||||
IC_EnhanceTooltip(self, itemStr, nil, moneyAlreadyShown)
|
||||
end
|
||||
end)
|
||||
|
||||
return r1, r2, r3, r4
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user