📄 tooltip.lua
字号:
hideTooltip() if (HideObj and HideObj == "ItemRefTooltip") then -- closing chatreferenceTT? self.oldChatItem = nil -- remove old chatlink data elseif self.oldChatItem then -- closing another tooltip -- redisplay old chatlinkdata, if it was not embeded if not self.oldChatItem.embed then doHyperlink(self.oldChatItem.reference, self.oldChatItem.link, self.oldChatItem.button) end end endendfunction linkType(link) if type(link) ~= "string" then return end local _, _, linktype = string.find(link, "|H(%a+):") return linktypeendfunction nameFromLink(link) local name if( not link ) then return end _, _, name = string.find(link, "|c%x+|Hitem:%d+:%d+:%d+:%d+|h%[(.-)%]|h|r"); if (name) then return name; end returnendfunction hyperlinkFromLink(link) if( not link ) then return end _, _, hyperlink = string.find(link, "|H([^|]+)|h"); if (hyperlink) then return hyperlink; endendfunction baselinkFromLink(link) if( not link ) then return end _, _, baselink = string.find(link, "|Hitem:(%d+:%d+:%d+):%d+|h"); if (baselink) then return baselink; endendfunction qualityFromLink(link) if (not link) then return end local _, _, color = string.find(link, "(|c%x+)|Hitem:%d+:%d+:%d+:%d+|h%[.-%]|h|r"); if color then for i = 0, 6 do local _, _, _, hex = GetItemQualityColor(i) if color == hex then return i end end end return -1endfunction fakeLink(hyperlink, quality, name) -- make this function nilSafe, as it's a global one and might be used by external addons if not hyperlink then return end local sName, sLink, iQuality = GetItemInfo(hyperlink) if (quality == nil) then quality = iQuality or -1 end if (name == nil) then name = sName or "unknown" end local _, _, _, color = GetItemQualityColor(quality) return color.. "|H"..hyperlink.."|h["..name.."]|h|r"endfunction tooltipCall(frame, name, link, quality, count, price, forcePopup, hyperlink) self.currentGametip = frame self.hideTime = 0 local itemSig = frame:GetName() if (link) then itemSig = itemSig..link end if (count) then itemSig = itemSig..count end if (price) then itemSig = itemSig..price end if (self.currentItem and self.currentItem == itemSig) then -- We are already showing this... No point doing it again. showTooltip(self.currentGametip) return end self.currentItem = itemSig if (quality==nil or quality==-1) then local linkQuality = qualityFromLink(link) if (linkQuality and linkQuality > -1) then quality = linkQuality else quality = -1 end end if (hyperlink == nil) then hyperlink = link end local extract = hyperlinkFromLink(hyperlink) if (extract) then hyperlink = extract end local showTip = true local popupKeyPressed = ( (self.forcePopupKey == "ctrl" and IsControlKeyDown()) or (self.forcePopupKey == "alt" and IsAltKeyDown()) or (self.forcePopupKey == "shift" and IsShiftKeyDown()) ) if ((forcePopup == true) or ((forcePopup == nil) and (popupKeyPressed))) then local popupTest = checkPopup(name, link, quality, count, price, hyperlink) if (popupTest) then showTip = false end end if (showTip) then clearTooltip() self.showIgnore = true EnhTooltip.AddTooltip(frame, name, link, quality, count, price) self.showIgnore = false showTooltip(frame) self.currentItem = itemSig return true else frame:Hide() hideTooltip() return false endend-------------------------- Hook calling functions------------------------function callCheckPopup(name, link, quality, count, price, hyperlink) if (EnhTooltip.CheckPopup(name, link, quality, count, price, hyperlink)) then return true; end return falseendfunction merchantScanner() local npcName = UnitName("NPC") local numMerchantItems = GetMerchantNumItems() local link, quality, name, texture, price, quantity, numAvailable, isUsable for i=1, numMerchantItems, 1 do link = GetMerchantItemLink(i) quality = qualityFromLink(link) name, texture, price, quantity, numAvailable, isUsable = GetMerchantItemInfo(i) EnhTooltip.MerchantHook(npcName, i, name, link, quality, quantity, price, numAvailable) endendfunction callBankHook() if not (BankFrame and BankFrame:IsVisible()) then return end EnhTooltip.BankHook(0)endfunction callBagHook(funcVars, event, bagNumber) if (bagNumber >= 5) and (bagNumber < 10) then if not (BankFrame and BankFrame:IsVisible()) then return end EnhTooltip.BankHook(bagNumber) else EnhTooltip.BagHook(bagNumber) endendfunction callTradeHook(funcVars, event, selID) EnhTooltip.TradeHook(funcVars[1], selID)end-------------------------- Tooltip functions that we have hooked------------------------function chatHookOnHyperlinkShow(funcArgs, retVal, reference, link, button) if (IsAltKeyDown()) and AuctionFrame and (AuctionFrame:IsVisible()) then AuctionFrameTab_OnClick(1) local itemID = breakLink(link) if (itemID) then local itemName = GetItemInfo(tostring(itemID)) if (itemName) then BrowseName:SetText(itemName) BrowseMinLevel:SetText("") BrowseMaxLevel:SetText("") AuctionFrameBrowse.selectedInvtype = nil AuctionFrameBrowse.selectedInvtypeIndex = nil AuctionFrameBrowse.selectedClass = nil AuctionFrameBrowse.selectedClassIndex = nil AuctionFrameBrowse.selectedSubclass = nil AuctionFrameBrowse.selectedSubclassIndex = nil AuctionFrameFilters_Update() IsUsableCheckButton:SetChecked(0) UIDropDownMenu_SetSelectedValue(BrowseDropDown, -1) AuctionFrameBrowse_Search() BrowseNoResultsText:SetText(BROWSE_NO_RESULTS) ItemRefTooltip:Hide() end end return end doHyperlink(reference, link, button)endfunction afHookOnEnter(funcArgs, retVal, type, index) local link = GetAuctionItemLink(type, index) if (link) then local name = nameFromLink(link) if (name) then local aiName, aiTexture, aiCount, aiQuality, aiCanUse, aiLevel, aiMinBid, aiMinIncrement, aiBuyoutPrice, aiBidAmount, aiHighBidder, aiOwner = GetAuctionItemInfo(type, index) tooltipCall(GameTooltip, name, link, aiQuality, aiCount) end endendfunction cfHookUpdate(funcArgs, retVal, frame) local frameID = frame:GetID() local frameName = frame:GetName() local iButton for iButton = 1, frame.size do local button = getglobal(frameName.."Item"..iButton) if (GameTooltip:IsOwned(button)) then local buttonID = button:GetID() local link = GetContainerItemLink(frameID, buttonID) local name = nameFromLink(link) if (name) then local texture, itemCount, locked, quality, readable = GetContainerItemInfo(frameID, buttonID) if (quality == nil) then quality = qualityFromLink(link) end tooltipCall(GameTooltip, name, link, quality, itemCount) end end endendfunction gtHookSetLootItem(funcArgs, retVal, frame, slot) local link = GetLootSlotLink(slot) local name = nameFromLink(link) if (name) then local texture, item, quantity, quality = GetLootSlotInfo(slot) if (quality == nil) then quality = qualityFromLink(link) end tooltipCall(GameTooltip, name, link, quality, quantity) endendfunction gtHookSetQuestItem(funcArgs, retVal, frame, qtype, slot) local link = GetQuestItemLink(qtype, slot) if (link) then local name, texture, quantity, quality, usable = GetQuestItemInfo(qtype, slot) tooltipCall(GameTooltip, name, link, quality, quantity) endendfunction gtHookSetQuestLogItem(funcArgs, retVal, frame, qtype, slot) local link = GetQuestLogItemLink(qtype, slot) if (link) then local name, texture, quantity, quality, usable = GetQuestLogRewardInfo(slot) if (name == nil) then name = nameFromLink(link) end quality = qualityFromLink(link) -- I don't trust the quality returned from the above function. tooltipCall(GameTooltip, name, link, quality, quantity) endendfunction gtHookSetBagItem(funcArgs, retVal, frame, frameID, buttonID) local link = GetContainerItemLink(frameID, buttonID) local name = nameFromLink(link) if (name) then local texture, itemCount, locked, quality, readable = GetContainerItemInfo(frameID, buttonID) if (quality==nil or quality==-1) then quality = qualityFromLink(link) end tooltipCall(GameTooltip, name, link, quality, itemCount) endendfunction gtHookSetInboxItem(funcArgs, retVal, frame, index) local inboxItemName, itemTexture, inboxItemCount, inboxItemQuality = GetInboxItem(index) local itemName, hyperLink, itemQuality, itemLink for itemID = 1, 30000 do itemName, hyperLink, itemQuality = GetItemInfo(itemID) if (itemName and itemName == inboxItemName) then local _, _, _, hex = GetItemQualityColor(tonumber(itemQuality)) itemLink = hex.. "|H"..hyperLink.."|h["..itemName.."]|h|r" tooltipCall(GameTooltip, inboxItemName, itemLink, inboxItemQuality, inboxItemCount) break end end endfunction gtHookSetInventoryItem(funcArgs, retVal, frame, unit, slot) local link = GetInventoryItemLink(unit, slot) if (link) then local name = nameFromLink(link) local quantity if (slot >= 20 and slot <= 23) then -- Workaround for bag slots. Quiver slots report the number of -- arrows in there instead of 1 for the actual bag. -- And well, bags aren't stackable anyway, so here you go: quantity = 1 else -- Should be 1 for anything but quivers, because even empty slots -- return 1.. but who knows what crazy stuff Blizzard will add ;) quantity = GetInventoryItemCount(unit, slot) end local quality = GetInventoryItemQuality(unit, slot) if (quality == nil) then quality = qualityFromLink(link) end tooltipCall(GameTooltip, name, link, quality, quantity) endendfunction gtHookSetMerchantItem(funcArgs, retVal, frame, slot) local link = GetMerchantItemLink(slot) if (link) then local name, texture, price, quantity, numAvailable, isUsable = GetMerchantItemInfo(slot) local quality = qualityFromLink(link) tooltipCall(GameTooltip, name, link, quality, quantity, price) endendfunction gtHookSetCraftItem(funcArgs, retVal, frame, skill, slot) local link if (slot) then link = GetCraftReagentItemLink(skill, slot) if (link) then local name, texture, quantity, quantityHave = GetCraftReagentInfo(skill, slot) local quality = qualityFromLink(link) tooltipCall(GameTooltip, name, link, quality, quantity, 0) end else link = GetCraftItemLink(skill) if (link) then local name = nameFromLink(link) local quality = qualityFromLink(link) tooltipCall(GameTooltip, name, link, quality, 1, 0) end endendfunction gtHookSetCraftSpell(funcArgs, retVal, frame, slot) local name = GetCraftInfo(slot) local link = GetCraftItemLink(slot) if name and link then tooltipCall(GameTooltip, name, link) endendfunction gtHookSetTradeSkillItem(funcArgs, retVal, frame, skill, slot) local link if (slot) then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -