From 8e797f28f6ec4ccad3b876057c19b4cacc369931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Mon, 3 Feb 2020 13:43:51 +0100 Subject: [PATCH] Fixed appearance of recipe tooltips --- .luacheckrc | 2 +- RECrystallize.lua | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index 50562ed..42227e8 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,4 +1,4 @@ -globals = {'LibStub', 'BUTTON_LAG_AUCTIONHOUSE', 'LANDING_PAGE_REPORT', 'COPPER_PER_SILVER', 'SILVER_PER_GOLD', 'GOLD_AMOUNT_TEXTURE_STRING', 'SILVER_AMOUNT_TEXTURE'} +globals = {'LibStub', 'BUTTON_LAG_AUCTIONHOUSE', 'LANDING_PAGE_REPORT', 'COPPER_PER_SILVER', 'SILVER_PER_GOLD', 'GOLD_AMOUNT_TEXTURE_STRING', 'SILVER_AMOUNT_TEXTURE', 'LE_ITEM_CLASS_RECIPE', 'LE_ITEM_RECIPE_BOOK'} ignore = {'self'} max_line_length = false self = false diff --git a/RECrystallize.lua b/RECrystallize.lua index 205e500..f7057c2 100644 --- a/RECrystallize.lua +++ b/RECrystallize.lua @@ -12,13 +12,14 @@ local ExtractLink = _G.LinkUtil.ExtractLink local After = _G.C_Timer.After local Round = _G.Round local PlaySound = _G.PlaySound +local GetItemInfo = _G.GetItemInfo +local GetItemCount = _G.GetItemCount local GetRealmName = _G.GetRealmName local SecondsToTime = _G.SecondsToTime local IsShiftKeyDown = _G.IsShiftKeyDown local SendChatMessage = _G.SendChatMessage local SetTooltipMoney = _G.SetTooltipMoney local FormatLargeNumber = _G.FormatLargeNumber -local GetItemCount = _G.GetItemCount local ReplicateItems = _G.C_AuctionHouse.ReplicateItems local GetNumReplicateItems = _G.C_AuctionHouse.GetNumReplicateItems local GetReplicateItemInfo = _G.C_AuctionHouse.GetReplicateItemInfo @@ -33,6 +34,7 @@ local PETCAGEID = 82800 RE.DefaultConfig = {["LastScan"] = 0, ["GuildChatPC"] = false, ["DatabaseCleanup"] = 432000, ["ScanPulse"] = 1, ["DatabaseVersion"] = 1} RE.GUIInitialized = false +RE.RecipeLock = false RE.BlockTooltip = 0 RE.TooltipLink = "" RE.TooltipItemVariant = "" @@ -190,6 +192,7 @@ function RE:OnEvent(self, event, ...) end _G.GameTooltip:HookScript("OnTooltipSetItem", function(self) RE:TooltipAddPrice(self); RE.TooltipCustomCount = -1 end) + _G.GameTooltip:HookScript("OnTooltipCleared", function(_) RE.RecipeLock = false end) hooksecurefunc("BattlePetToolTip_Show", function(speciesID, level, breedQuality, maxHealth, power, speed) RE:TooltipPetAddPrice(sFormat("|cffffffff|Hbattlepet:%s:%s:%s:%s:%s:%s:0000000000000000:0|h[XYZ]|h|r", speciesID, level, breedQuality, maxHealth, power, speed)) end) hooksecurefunc("FloatingBattlePet_Show", function(speciesID, level, breedQuality, maxHealth, power, speed) RE:TooltipPetAddPrice(sFormat("|cffffffff|Hbattlepet:%s:%s:%s:%s:%s:%s:0000000000000000:0|h[XYZ]|h|r", speciesID, level, breedQuality, maxHealth, power, speed)) end) @@ -223,6 +226,13 @@ function RE:TooltipAddPrice(self) if self:IsForbidden() then return end local _, link = self:GetItem() if link and IsLinkType(link, "item") then + local itemTypeId, itemSubTypeId = select(12, GetItemInfo(link)) + if not RE.RecipeLock and itemTypeId == LE_ITEM_CLASS_RECIPE and itemSubTypeId ~= LE_ITEM_RECIPE_BOOK then + RE.RecipeLock = true + return + else + RE.RecipeLock = false + end if link ~= RE.TooltipLink then RE.TooltipLink = link RE.TooltipItemID = tonumber(sMatch(link, "item:(%d+)"))