Skip to content

Commit 32244ea

Browse files
committed
Crafting UI: tooltip and profit fixes for quality items
- Tooltip: use GetRecipeOutputLink when Crafting page visible for correct auction price on quality/ilvl items (armor, weapons) - Profit: shared GetRecipeOutputLink with qualityItemIDs (13/14 -> q-12 for Midnight) - Profit: hide for BoP crafted results - Deferred updates on Init/AllocationsModified/UseBestQualityModified/statsChangedHandler so profit line shows on first click and when toggling concentration Fixes: Crafting UI tooltip now shows correct AH price based on item level or quality level. Profit line correct for both single-quality and multi-quality recipes. Profit line hidden when crafted result is bind-on-pickup. Resolves race condition so profit line displays reliably on first recipe selection and when switching concentration/guaranteed quality. Made-with: Cursor
1 parent 0caaf84 commit 32244ea

File tree

3 files changed

+74
-23
lines changed

3 files changed

+74
-23
lines changed

Source/Tooltips/Hooks.lua

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,31 @@ end
8888

8989
if GameTooltip.SetRecipeResultItem then -- Dragonflight onwards
9090
TooltipHandlers["SetRecipeResultItem"] = function(tip, recipeID, reagents, allocations, recipeLevel, qualityID)
91-
local outputInfo = C_TradeSkillUI.GetRecipeOutputItemData(recipeID, reagents, allocations, qualityID)
92-
local outputLink = outputInfo and outputInfo.hyperlink
91+
local outputLink
92+
-- Use GetRecipeOutputLink when Crafting page visible (same resolution as profit line for quality items)
93+
if ProfessionsFrame and ProfessionsFrame.CraftingPage and ProfessionsFrame.CraftingPage:IsVisible() then
94+
local schematicForm = ProfessionsFrame.CraftingPage.SchematicForm
95+
outputLink = schematicForm and Auctionator.CraftingInfo.GetRecipeOutputLink(schematicForm, qualityID)
96+
end
97+
if not outputLink then
98+
local rInfo = C_TradeSkillUI.GetRecipeInfo(recipeID, recipeLevel or 0)
99+
if rInfo and rInfo.qualityItemIDs and #rInfo.qualityItemIDs > 0 and qualityID and qualityID >= 13 and qualityID <= 14 then
100+
local outID = rInfo.qualityItemIDs[qualityID - 12]
101+
if outID then outputLink = select(2, C_Item.GetItemInfo(outID)) end
102+
end
103+
end
104+
if not outputLink then
105+
local out = C_TradeSkillUI.GetRecipeOutputItemData(recipeID, reagents or {}, allocations, qualityID)
106+
outputLink = out and out.hyperlink
107+
end
108+
if not outputLink and Auctionator.CraftingInfo and Auctionator.CraftingInfo.EnchantSpellsToItems and Auctionator.CraftingInfo.EnchantSpellsToItems[recipeID] then
109+
local itemID = Auctionator.CraftingInfo.EnchantSpellsToItems[recipeID][1]
110+
if itemID then outputLink = select(2, C_Item.GetItemInfo(itemID)) end
111+
end
93112

94113
if outputLink then
95-
local recipeSchematic = C_TradeSkillUI.GetRecipeSchematic(recipeID, false, recipeLevel)
96-
97-
Auctionator.Tooltip.ShowTipWithPricing(tip, outputLink, recipeSchematic.quantityMin)
114+
local schematic = C_TradeSkillUI.GetRecipeSchematic(recipeID, false, recipeLevel or 0)
115+
Auctionator.Tooltip.ShowTipWithPricing(tip, outputLink, schematic and schematic.quantityMin or 1)
98116
end
99117
end
100118
end

Source_Mainline/CraftingInfo/Mixins/Professions.lua

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,19 @@ function AuctionatorCraftingInfoProfessionsFrameMixin:OnLoad()
1818

1919
-- Uses Init rather than an event as the event handler can fire before the
2020
-- ProfessionsPane pane has finished initialising a recipe
21-
hooksecurefunc(self:GetParent(), "Init", Update)
21+
hooksecurefunc(self:GetParent(), "Init", function()
22+
Update()
23+
-- Deferred update: recipe/transaction may not be ready on first Init
24+
C_Timer.After(0, Update)
25+
end)
2226

23-
self:GetParent():RegisterCallback(ProfessionsRecipeSchematicFormMixin.Event.AllocationsModified, Update)
24-
self:GetParent():RegisterCallback(ProfessionsRecipeSchematicFormMixin.Event.UseBestQualityModified, Update)
25-
hooksecurefunc(self:GetParent(), "statsChangedHandler", Update)
27+
local function UpdateWithDefer()
28+
Update()
29+
C_Timer.After(0, Update)
30+
end
31+
self:GetParent():RegisterCallback(ProfessionsRecipeSchematicFormMixin.Event.AllocationsModified, UpdateWithDefer)
32+
self:GetParent():RegisterCallback(ProfessionsRecipeSchematicFormMixin.Event.UseBestQualityModified, UpdateWithDefer)
33+
hooksecurefunc(self:GetParent(), "statsChangedHandler", UpdateWithDefer)
2634

2735
Auctionator.API.v1.RegisterForDBUpdate(AUCTIONATOR_L_REAGENT_SEARCH, function()
2836
if self:IsVisible() then

Source_Mainline/CraftingInfo/Professions.lua

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,35 @@ local function CalculateProfitFromCosts(currentAH, toCraft, count)
100100
return math.floor(math.floor(currentAH * count * Auctionator.Constants.AfterAHCut - toCraft) / 100) * 100
101101
end
102102

103+
-- Shared with tooltip: resolves recipe output link using guaranteedCraftingQualityID.
104+
-- Midnight only: quality 13/14 -> qualityItemIDs index 1/2 (subtract 12).
105+
function Auctionator.CraftingInfo.GetRecipeOutputLink(schematicForm, qualityID)
106+
if not schematicForm then return nil end
107+
local recipeInfo = schematicForm:GetRecipeInfo()
108+
local recipeID = recipeInfo.recipeID
109+
local transaction = schematicForm:GetTransaction()
110+
local reagents = transaction:CreateCraftingReagentInfoTbl()
111+
local allocationGUID = transaction:GetAllocationItemGUID()
112+
local op = C_TradeSkillUI.GetCraftingOperationInfo(recipeID, reagents, allocationGUID, transaction:IsApplyingConcentration())
113+
local q = qualityID or (op and op.guaranteedCraftingQualityID)
114+
115+
if recipeInfo.qualityItemIDs and #recipeInfo.qualityItemIDs > 0 and q then
116+
local idx = (q >= 13 and q <= 14) and (q - 12) or q
117+
local outID = recipeInfo.qualityItemIDs[idx]
118+
if outID then return select(2, C_Item.GetItemInfo(outID)) end
119+
end
120+
121+
local qualityOverride = op and recipeInfo.qualityIDs and recipeInfo.qualityIDs[op.craftingQuality]
122+
local out = C_TradeSkillUI.GetRecipeOutputItemData(recipeID, reagents, allocationGUID, qualityOverride)
123+
if out and out.hyperlink then return out.hyperlink end
124+
125+
if Auctionator.CraftingInfo.EnchantSpellsToItems and Auctionator.CraftingInfo.EnchantSpellsToItems[recipeID] then
126+
local itemID = Auctionator.CraftingInfo.EnchantSpellsToItems[recipeID][1]
127+
if itemID then return select(2, C_Item.GetItemInfo(itemID)) end
128+
end
129+
return nil
130+
end
131+
103132
-- Search through a list of items for the first matching the wantedQuality
104133
local function GetItemIDByReagentQuality(possibleItemIDs, wantedQuality, allQualities)
105134
if #possibleItemIDs == 1 then
@@ -141,6 +170,10 @@ local function GetEnchantProfit(schematicForm)
141170
end
142171

143172
if itemID ~= nil then
173+
local itemInfo = { C_Item.GetItemInfo(itemID) }
174+
if Auctionator.Utilities.IsBound(itemInfo) then
175+
return nil
176+
end
144177
local currentAH = Auctionator.API.v1.GetAuctionPriceByItemID(AUCTIONATOR_L_REAGENT_SEARCH, itemID) or 0
145178
local age = Auctionator.API.v1.GetAuctionAgeByItemID(AUCTIONATOR_L_REAGENT_SEARCH, itemID)
146179
local exact = Auctionator.API.v1.IsAuctionDataExactByItemID(AUCTIONATOR_L_REAGENT_SEARCH, itemID)
@@ -163,22 +196,14 @@ local function GetAHProfit(schematicForm)
163196
return GetEnchantProfit(schematicForm)
164197

165198
else
166-
local operationInfo = C_TradeSkillUI.GetCraftingOperationInfo(
167-
recipeInfo.recipeID,
168-
schematicForm:GetTransaction():CreateCraftingReagentInfoTbl(),
169-
schematicForm:GetTransaction():GetAllocationItemGUID(),
170-
schematicForm:GetTransaction():IsApplyingConcentration()
171-
)
172-
local qualityOverride = operationInfo and recipeInfo.qualityIDs and recipeInfo.qualityIDs[operationInfo.craftingQuality]
173-
local outputData = C_TradeSkillUI.GetRecipeOutputItemData(
174-
recipeInfo.recipeID,
175-
schematicForm:GetTransaction():CreateCraftingReagentInfoTbl(),
176-
schematicForm:GetTransaction():GetAllocationItemGUID(),
177-
qualityOverride
178-
)
179-
local recipeLink = outputData and outputData.hyperlink
199+
-- Use same output resolution as tooltip (GetRecipeOutputLink) so profit line matches tooltip.
200+
local recipeLink = Auctionator.CraftingInfo.GetRecipeOutputLink(schematicForm, nil)
180201

181202
if recipeLink ~= nil then
203+
local itemInfo = { C_Item.GetItemInfo(recipeLink) }
204+
if Auctionator.Utilities.IsBound(itemInfo) then
205+
return nil
206+
end
182207
local currentAH = Auctionator.API.v1.GetAuctionPriceByItemLink(AUCTIONATOR_L_REAGENT_SEARCH, recipeLink) or 0
183208
local age = Auctionator.API.v1.GetAuctionAgeByItemLink(AUCTIONATOR_L_REAGENT_SEARCH, recipeLink)
184209
local exact = Auctionator.API.v1.IsAuctionDataExactByItemLink(AUCTIONATOR_L_REAGENT_SEARCH, recipeLink)

0 commit comments

Comments
 (0)