⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tooltip.lua

📁 时间太紧了
💻 LUA
📖 第 1 页 / 共 4 页
字号:
		link = GetTradeSkillReagentItemLink(skill, slot)		if (link) then			local name, texture, quantity, quantityHave = GetTradeSkillReagentInfo(skill, slot)			local quality = qualityFromLink(link)			tooltipCall(GameTooltip, name, link, quality, quantity, 0)		end	else		link = GetTradeSkillItemLink(skill)		if (link) then			local name = nameFromLink(link)			local quality = qualityFromLink(link)			tooltipCall(GameTooltip, name, link, quality, 1, 0)		end	endend-- Given a Blizzard item link, breaks it into it's itemID, randomProperty, enchantProperty, uniqueness and namefunction breakLink(link)	if (type(link) ~= 'string') then return end	local i,j, itemID, enchant, randomProp, uniqID, name = string.find(link, "|Hitem:(%d+):(%d+):(%d+):(%d+)|h[[]([^]]+)[]]|h")	return tonumber(itemID or 0), tonumber(randomProp or 0), tonumber(enchant or 0), tonumber(uniqID or 0), nameendfunction findItemInBags(findName)	for bag = 0, 4, 1 do		size = GetContainerNumSlots(bag)		if (size) then			for slot = size, 1, -1 do				local link = GetContainerItemLink(bag, slot)				if (link) then					local itemID, randomProp, enchant, uniqID, itemName = breakLink(link)					if (itemName == findName) then						return bag, slot, itemID, randomProp, enchant, uniqID					end				end			end		end	endendfunction gtHookSetAuctionSellItem(funcArgs, retVal, frame)	local name, texture, quantity, quality, canUse, price = GetAuctionSellItemInfo()	if (name) then		local bag, slot = findItemInBags(name)		if (bag) then			local link = GetContainerItemLink(bag, slot)			if (link) then				tooltipCall(GameTooltip, name, link, quality, quantity, price)			end		end	endendfunction gtHookSetText(funcArgs, retval, frame, text, r, g, b, a, textWrap)	-- Nothing to do for plain text	if (self.currentGametip == frame) then		clearTooltip()	endendfunction gtHookAppendText(funcArgs, retVal, frame)	if (self.currentGametip and self.currentItem and self.currentItem ~= "") then		showTooltip(self.currentGametip, true)	endendfunction gtHookShow(funcArgs, retVal, frame)	if (self.hookRecursion) then		return;	end	if (self.currentGametip and self.currentItem and self.currentItem ~= "") then		self.hookRecursion = true;		showTooltip(self.currentGametip, true)		self.hookRecursion = nil;	endendfunction imiHookOnEnter()	if(not IM_InvList) then return end	local id = this:GetID()	if(id == 0) then		id = this:GetParent():GetID()	end	local offset = FauxScrollFrame_GetOffset(ItemsMatrix_IC_ScrollFrame)	local item = IM_InvList[id + offset]	if (not item) then return end	local imlink = ItemsMatrix_GetHyperlink(item.name)	local link = fakeLink(imlink, item.quality, item.name)	if (link) then		tooltipCall(GameTooltip, item.name, link, item.quality, item.count, 0)	endendfunction imHookOnEnter()	local imlink = ItemsMatrix_GetHyperlink(this:GetText())	if (imlink) then		local name = this:GetText()		local link = fakeLink(imlink, -1, name)		tooltipCall(GameTooltip, name, link, -1, 1, 0)	endendfunction getLootLinkServer()	return LootLinkState.ServerNamesToIndices[GetCVar("realmName")]endfunction getLootLinkLink(name)	local itemLink = ItemLinks[name]	if (itemLink and itemLink.c and itemLink.i and LootLink_CheckItemServer(itemLink, getLootLinkServer())) then		local item = string.gsub(itemLink.i, "(%d+):(%d+):(%d+):(%d+)", "%1:0:%3:%4")		local link = "|c"..itemLink.c.."|Hitem:"..item.."|h["..name.."]|h|r"		return link	end	returnendfunction llHookOnEnter()	local name = this:GetText()	local link = getLootLinkLink(name)	if (link) then		local quality = qualityFromLink(link)		tooltipCall(LootLinkTooltip, name, link, quality, 1, 0)	endendfunction gtHookSetOwner(funcArgs, retVal, frame, owner, anchor)	frame.owner = owner	frame.anchor = anchorend-------------------------- Operation functions------------------------function setElapsed(elapsed)	if (elapsed) then		self.eventTimer = self.eventTimer + elapsed	end	checkHide()	return self.eventTimerendfunction setMoneySpacing(spacing)	if (spacing ~= nil) then self.moneySpacing = spacing end	return self.moneySpacingendfunction setPopupKey(key)	if (key ~= nil) then self.forcePopupKey = key end	return self.forcePopupKeyend-------------------------- Debug functions------------------------local function dump(...)	local out = "";	for i = 1, arg.n, 1 do		local d = arg[i];		local t = type(d);		if (t == "table") then			out = out .. "{";			local first = true;			if (d) then				for k, v in pairs(d) do					if (not first) then out = out .. ", "; end					first = false;					out = out .. dump(k);					out = out .. " = ";					out = out .. dump(v);				end			end			out = out .. "}";		elseif (t == "nil") then			out = out .. "NIL";		elseif (t == "number") then			out = out .. d;		elseif (t == "string") then			out = out .. "\"" .. d .. "\"";		elseif (t == "boolean") then			if (d) then				out = out .. "true";			else				out = out .. "false";			end		else			out = out .. string.upper(t) .. "??";		end		if (i < arg.n) then out = out .. ", "; end	end	return out;endfunction debugPrint(...)	local debugWin = 0;	local name, shown;	for i=1, NUM_CHAT_WINDOWS do		name,_,_,_,_,_,shown = GetChatWindowInfo(i);		if (string.lower(name) == "ettdebug") then debugWin = i; break; end	end	if (debugWin == 0) then return end	local out = "";	for i = 1, arg.n, 1 do		if (i > 1) then out = out .. ", "; end		local t = type(arg[i]);		if (t == "string") then			out = out .. '"'..arg[i]..'"';		elseif (t == "number") then			out = out .. arg[i];		else			out = out .. dump(arg[i]);		end	end	getglobal("ChatFrame"..debugWin):AddMessage(out, 1.0, 1.0, 0.3);end-------------------------- Load and initialization functions--------------------------The new blizzard addons are called:--	Blizzard_TrainerUI,		Blizzard_MacroUI,		Blizzard_RaidUI,		Blizzard_TradeSkillUI,--	Blizzard_InspectUI,		Blizzard_BattlefieldMinimap,	Blizzard_TalentUI,--	Blizzard_AuctionUI,		Blizzard_BindingUI,		Blizzard_CraftUI-- Hook in alternative Auctionhouse tooltip codelocal function hookAuctionHouse()	Stubby.RegisterFunctionHook("AuctionFrameItem_OnEnter", 200, afHookOnEnter)end-- Hook the ItemsMatrix tooltip functionslocal function hookItemsMatrix()	Stubby.RegisterFunctionHook("IMInv_ItemButton_OnEnter", 200, imiHookOnEnter)	Stubby.RegisterFunctionHook("ItemsMatrixItemButton_OnEnter", 200, imHookOnEnter)end-- Hook the LootLink tooltip functionlocal function hookLootLink()	Stubby.RegisterFunctionHook("LootLinkItemButton_OnEnter", 200, llHookOnEnter)end-- Hook tradeskill functionslocal function hookTradeskill()	Stubby.RegisterFunctionHook("TradeSkillFrame_Update", 200, callTradeHook, "trade", "")	Stubby.RegisterFunctionHook("TradeSkillFrame_SetSelection", 200, callTradeHook, "trade", "")end-- Hook craft functionslocal function hookCraft()	Stubby.RegisterFunctionHook("CraftFrame_Update", 200, callTradeHook, "craft", "");	Stubby.RegisterFunctionHook("CraftFrame_SetSelection", 200, callTradeHook, "craft", "");endfunction ttInitialize()	----  Establish hooks to all the game tooltips.	-- Hook in alternative Chat/Hyperlinking code	Stubby.RegisterFunctionHook("ChatFrame_OnHyperlinkShow", 200, chatHookOnHyperlinkShow)	-- Container frame linking	Stubby.RegisterFunctionHook("ContainerFrame_Update", 200, cfHookUpdate)	-- Game tooltips	Stubby.RegisterFunctionHook("GameTooltip.SetLootItem", 200, gtHookSetLootItem);	Stubby.RegisterFunctionHook("GameTooltip.SetQuestItem", 200, gtHookSetQuestItem);	Stubby.RegisterFunctionHook("GameTooltip.SetQuestLogItem", 200, gtHookSetQuestLogItem);	Stubby.RegisterFunctionHook("GameTooltip.SetInboxItem", 200, gtHookSetInboxItem);	Stubby.RegisterFunctionHook("GameTooltip.SetInventoryItem", 200, gtHookSetInventoryItem);	Stubby.RegisterFunctionHook("GameTooltip.SetBagItem", 200, gtHookSetBagItem);	Stubby.RegisterFunctionHook("GameTooltip.SetMerchantItem", 200, gtHookSetMerchantItem);	Stubby.RegisterFunctionHook("GameTooltip.SetCraftItem", 200, gtHookSetCraftItem);	Stubby.RegisterFunctionHook("GameTooltip.SetCraftSpell", 200, gtHookSetCraftSpell);	Stubby.RegisterFunctionHook("GameTooltip.SetTradeSkillItem", 200, gtHookSetTradeSkillItem);	Stubby.RegisterFunctionHook("GameTooltip.SetAuctionSellItem", 200, gtHookSetAuctionSellItem);	Stubby.RegisterFunctionHook("GameTooltip.SetText", 200, gtHookSetText);	Stubby.RegisterFunctionHook("GameTooltip.AppendText", 200, gtHookAppendText);	Stubby.RegisterFunctionHook("GameTooltip.SetOwner", 200, gtHookSetOwner);	Stubby.RegisterFunctionHook("GameTooltip.Show", 200, gtHookShow);	Stubby.RegisterFunctionHook("GameTooltip_OnHide", 200, gtHookOnHide);	-- Establish hooks for us to use.	Stubby.RegisterAddOnHook("Blizzard_AuctionUI", "EnhTooltip", hookAuctionHouse)	Stubby.RegisterAddOnHook("ItemsMatrix", "EnhTooltip", hookItemsMatrix)	Stubby.RegisterAddOnHook("LootLink", "EnhTooltip", hookLootLink)	Stubby.RegisterAddOnHook("Blizzard_TradeSkillUI", "EnhTooltip", hookTradeskill)	Stubby.RegisterAddOnHook("Blizzard_CraftUI", "EnhTooltip", hookCraft)	-- Register event notification	Stubby.RegisterEventHook("MERCHANT_SHOW", "EnhTooltip", merchantScanner);	Stubby.RegisterEventHook("TRADE_SKILL_SHOW", "EnhTooltip", callTradeHook, 'trade');	Stubby.RegisterEventHook("TRADE_SKILL_CLOSE", "EnhTooltip", callTradeHook, 'trade');	Stubby.RegisterEventHook("CRAFT_SHOW", "EnhTooltip", callTradeHook, 'craft');	Stubby.RegisterEventHook("CRAFT_CLOSE", "EnhTooltip", callTradeHook, 'craft');	Stubby.RegisterEventHook("BANKFRAME_OPENED", "EnhTooltip", callBankHook);	Stubby.RegisterEventHook("PLAYERBANKSLOTS_CHANGED", "EnhTooltip", callBankHook);	Stubby.RegisterEventHook("BAG_UPDATE", "EnhTooltip", callBagHook);end-- =============== EVENT HANDLERS =============== --function TT_OnLoad()	EnhancedTooltip:SetBackdropColor(0,0,0)	clearTooltip()	ttInitialize()endfunction TT_OnUpdate(elapsed)	setElapsed(elapsed)end-- =============== DEFINE ACCESS OBJECT =============== ---- Global objectEnhTooltip = {	AddTooltip			= addTooltip,	CheckPopup			= checkPopup,	MerchantHook		= merchantHook,	TradeHook			= tradeHook,	BankHook			= bankHook,	BagHook				= bagHook,	AddLine				= addLine,	AddSeparator		= addSeparator,	LineColor			= lineColor,	LineQuality			= lineQuality,	LineSize_Large		= lineSize_Large,	LineSize_Small		= lineSize_Small,	SetIcon				= setIcon,	ClearTooltip		= clearTooltip,	HideTooltip			= hideTooltip,	ShowTooltip			= showTooltip,	GetglobalIterator	= getglobalIterator,	GetGSC				= getGSC,	GetTextGSC			= getTextGSC,	BaselinkFromLink	= baselinkFromLink,	BreakLink			= breakLink,	FindItemInBags		= findItemInBags,	FakeLink			= fakeLink,	HyperlinkFromLink	= hyperlinkFromLink,	NameFromLink		= nameFromLink,	QualityFromLink		= qualityFromLink,	LinkType			= linkType,	SetMoneySpacing		= setMoneySpacing,	SetPopupKey			= setPopupKey,	TooltipCall			= tooltipCall,	SetElapsed			= setElapsed,	DebugPrint			= debugPrint,}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -