Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions Source/Tooltips/Hooks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,31 @@ end

if GameTooltip.SetRecipeResultItem then -- Dragonflight onwards
TooltipHandlers["SetRecipeResultItem"] = function(tip, recipeID, reagents, allocations, recipeLevel, qualityID)
local outputInfo = C_TradeSkillUI.GetRecipeOutputItemData(recipeID, reagents, allocations, qualityID)
local outputLink = outputInfo and outputInfo.hyperlink
local outputLink
-- Use GetRecipeOutputLink when Crafting page visible (same resolution as profit line for quality items)
if ProfessionsFrame and ProfessionsFrame.CraftingPage and ProfessionsFrame.CraftingPage:IsVisible() then
local schematicForm = ProfessionsFrame.CraftingPage.SchematicForm
outputLink = schematicForm and Auctionator.CraftingInfo.GetRecipeOutputLink(schematicForm, qualityID)
end
if not outputLink then
local rInfo = C_TradeSkillUI.GetRecipeInfo(recipeID, recipeLevel or 0)
if rInfo and rInfo.qualityItemIDs and #rInfo.qualityItemIDs > 0 and qualityID and qualityID >= 13 and qualityID <= 14 then
local outID = rInfo.qualityItemIDs[qualityID - 12]
if outID then outputLink = select(2, C_Item.GetItemInfo(outID)) end
end
end
if not outputLink then
local out = C_TradeSkillUI.GetRecipeOutputItemData(recipeID, reagents or {}, allocations, qualityID)
outputLink = out and out.hyperlink
end
if not outputLink and Auctionator.CraftingInfo and Auctionator.CraftingInfo.EnchantSpellsToItems and Auctionator.CraftingInfo.EnchantSpellsToItems[recipeID] then
local itemID = Auctionator.CraftingInfo.EnchantSpellsToItems[recipeID][1]
if itemID then outputLink = select(2, C_Item.GetItemInfo(itemID)) end
end

if outputLink then
local recipeSchematic = C_TradeSkillUI.GetRecipeSchematic(recipeID, false, recipeLevel)

Auctionator.Tooltip.ShowTipWithPricing(tip, outputLink, recipeSchematic.quantityMin)
local schematic = C_TradeSkillUI.GetRecipeSchematic(recipeID, false, recipeLevel or 0)
Auctionator.Tooltip.ShowTipWithPricing(tip, outputLink, schematic and schematic.quantityMin or 1)
end
end
end
Expand Down
15 changes: 9 additions & 6 deletions Source_Mainline/CraftingInfo/Mixins/Professions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ function AuctionatorCraftingInfoProfessionsFrameMixin:OnLoad()
end
end

-- Uses Init rather than an event as the event handler can fire before the
-- ProfessionsPane pane has finished initialising a recipe
hooksecurefunc(self:GetParent(), "Init", Update)
-- Immediate + deferred: recipe/transaction may not be ready when handlers fire
local function UpdateWithDefer()
Update()
C_Timer.After(0, Update)
end

self:GetParent():RegisterCallback(ProfessionsRecipeSchematicFormMixin.Event.AllocationsModified, Update)
self:GetParent():RegisterCallback(ProfessionsRecipeSchematicFormMixin.Event.UseBestQualityModified, Update)
hooksecurefunc(self:GetParent(), "statsChangedHandler", Update)
hooksecurefunc(self:GetParent(), "Init", UpdateWithDefer)
self:GetParent():RegisterCallback(ProfessionsRecipeSchematicFormMixin.Event.AllocationsModified, UpdateWithDefer)
self:GetParent():RegisterCallback(ProfessionsRecipeSchematicFormMixin.Event.UseBestQualityModified, UpdateWithDefer)
hooksecurefunc(self:GetParent(), "statsChangedHandler", UpdateWithDefer)

Auctionator.API.v1.RegisterForDBUpdate(AUCTIONATOR_L_REAGENT_SEARCH, function()
if self:IsVisible() then
Expand Down
55 changes: 41 additions & 14 deletions Source_Mainline/CraftingInfo/Professions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,35 @@ local function CalculateProfitFromCosts(currentAH, toCraft, count)
return math.floor(math.floor(currentAH * count * Auctionator.Constants.AfterAHCut - toCraft) / 100) * 100
end

-- Shared with tooltip: resolves recipe output link using guaranteedCraftingQualityID.
-- Midnight only: quality 13/14 -> qualityItemIDs index 1/2 (subtract 12).
function Auctionator.CraftingInfo.GetRecipeOutputLink(schematicForm, qualityID)
if not schematicForm then return nil end
local recipeInfo = schematicForm:GetRecipeInfo()
local recipeID = recipeInfo.recipeID
local transaction = schematicForm:GetTransaction()
local reagents = transaction:CreateCraftingReagentInfoTbl()
local allocationGUID = transaction:GetAllocationItemGUID()
local op = C_TradeSkillUI.GetCraftingOperationInfo(recipeID, reagents, allocationGUID, transaction:IsApplyingConcentration())
local q = qualityID or (op and op.guaranteedCraftingQualityID)

if recipeInfo.qualityItemIDs and #recipeInfo.qualityItemIDs > 0 and q then
local idx = (q >= 13 and q <= 14) and (q - 12) or q
local outID = recipeInfo.qualityItemIDs[idx]
if outID then return select(2, C_Item.GetItemInfo(outID)) end
end

local qualityOverride = op and recipeInfo.qualityIDs and recipeInfo.qualityIDs[op.craftingQuality]
local out = C_TradeSkillUI.GetRecipeOutputItemData(recipeID, reagents, allocationGUID, qualityOverride)
if out and out.hyperlink then return out.hyperlink end

if Auctionator.CraftingInfo.EnchantSpellsToItems and Auctionator.CraftingInfo.EnchantSpellsToItems[recipeID] then
local itemID = Auctionator.CraftingInfo.EnchantSpellsToItems[recipeID][1]
if itemID then return select(2, C_Item.GetItemInfo(itemID)) end
end
return nil
end

-- Search through a list of items for the first matching the wantedQuality
local function GetItemIDByReagentQuality(possibleItemIDs, wantedQuality, allQualities)
if #possibleItemIDs == 1 then
Expand Down Expand Up @@ -141,6 +170,11 @@ local function GetEnchantProfit(schematicForm)
end

if itemID ~= nil then
-- Do not display profit for bind-on-pickup items; they cannot be sold on the auction house.
local itemInfo = { C_Item.GetItemInfo(itemID) }
if Auctionator.Utilities.IsBound(itemInfo) then
return nil
end
local currentAH = Auctionator.API.v1.GetAuctionPriceByItemID(AUCTIONATOR_L_REAGENT_SEARCH, itemID) or 0
local age = Auctionator.API.v1.GetAuctionAgeByItemID(AUCTIONATOR_L_REAGENT_SEARCH, itemID)
local exact = Auctionator.API.v1.IsAuctionDataExactByItemID(AUCTIONATOR_L_REAGENT_SEARCH, itemID)
Expand All @@ -163,22 +197,15 @@ local function GetAHProfit(schematicForm)
return GetEnchantProfit(schematicForm)

else
local operationInfo = C_TradeSkillUI.GetCraftingOperationInfo(
recipeInfo.recipeID,
schematicForm:GetTransaction():CreateCraftingReagentInfoTbl(),
schematicForm:GetTransaction():GetAllocationItemGUID(),
schematicForm:GetTransaction():IsApplyingConcentration()
)
local qualityOverride = operationInfo and recipeInfo.qualityIDs and recipeInfo.qualityIDs[operationInfo.craftingQuality]
local outputData = C_TradeSkillUI.GetRecipeOutputItemData(
recipeInfo.recipeID,
schematicForm:GetTransaction():CreateCraftingReagentInfoTbl(),
schematicForm:GetTransaction():GetAllocationItemGUID(),
qualityOverride
)
local recipeLink = outputData and outputData.hyperlink
-- Use same output resolution as tooltip (GetRecipeOutputLink) so profit line matches tooltip.
local recipeLink = Auctionator.CraftingInfo.GetRecipeOutputLink(schematicForm, nil)

if recipeLink ~= nil then
-- Do not display profit for bind-on-pickup items; they cannot be sold on the auction house.
local itemInfo = { C_Item.GetItemInfo(recipeLink) }
if Auctionator.Utilities.IsBound(itemInfo) then
return nil
end
local currentAH = Auctionator.API.v1.GetAuctionPriceByItemLink(AUCTIONATOR_L_REAGENT_SEARCH, recipeLink) or 0
local age = Auctionator.API.v1.GetAuctionAgeByItemLink(AUCTIONATOR_L_REAGENT_SEARCH, recipeLink)
local exact = Auctionator.API.v1.IsAuctionDataExactByItemLink(AUCTIONATOR_L_REAGENT_SEARCH, recipeLink)
Expand Down