So what we have so far is ...
A way to open direct to a recipe page via a recipe id
And
A way to open the professions page from a hyperlink.
What we need now is a way to find out the recipe id from a recipe link which hopefully will be figureoutable from this page :
https://warcraft.wiki.gg/wiki/Hyperlinks
Ah never mind, looks like the recipe links are either item links or enchant links.
Looking at the tradeskill window itself, it only allows people to link their whole profession not a recipe, so you might only be able to open to a particular recipe page using a known recipe ID. Unfortunately the only way I could see to get both a recipelink and recipeid automagically was by reading the recipes from the tradeskill page.
The last known recipe in my example was the Enchant Vellum I could craft with my Inscription Gal.
The recipe ID for it is 52739 but none of the numbers in the Enchant Vellum recipe link contains that number. Instead it has 38682 which is the actual item id and 70:266 which I assume is the player level and specialization id who provided the link and the next numbers that appear are 1:3524 which don't provide any clues to me but could be the number of bonsuses and a bonus id - if I am reading the info on
https://warcraft.wiki.gg/wiki/ItemLink correctly.
Anyway, this is my last attempt, and is the best I could do using both the info Fizzle provided and what I tracked down and hopefully gets you part way at least.
Lua Code:
local addonName,db = ...
local cf = CreateFrame("Frame","TestFrame",UIParent)
cf:SetSize(600,100)
cf:SetPoint("CENTER",0,0)
cf:SetHyperlinksEnabled(true)
cf.fs = cf:CreateFontString(nil,"OVERLAY","GameFontNormal")
cf.fs:SetAllPoints()
cf:SetScript("OnHyperlinkClick", ChatFrame_OnHyperlinkShow)
local cf2 = CreateFrame("Frame","TestFrame2",UIParent)
cf2:SetSize(600,100)
cf2:SetPoint("TOP",cf, "BOTTOM",0,0)
cf2:SetHyperlinksEnabled(true)
cf2.fs = cf2:CreateFontString(nil,"OVERLAY","GameFontNormal")
cf2.fs:SetAllPoints()
cf2:SetScript("OnHyperlinkClick", function(self)
-- if you have a recipeInfo.recipeID then use that to jump to its crafting page
if db.recipeInfo and db.recipeInfo.recipeID then
ProfessionsUtil.OpenProfessionFrameToRecipe(db.recipeInfo.recipeID)
end
end)
local function OnEvent(self,event,...)
local args = { ... }
if event == "ADDON_LOADED" and args[1] == addonName then
elseif event =="TRADE_SKILL_SHOW" then
db.link = C_TradeSkillUI.GetTradeSkillListLink()
-- Cycles through all recipes known to the player or player who provided the link ( only tested on myself )
for _, id in pairs(C_TradeSkillUI.GetAllRecipeIDs()) do
local recipeInfo = C_TradeSkillUI.GetRecipeInfo(id)
if recipeInfo.learned then
print(recipeInfo.recipeID, recipeInfo.name, recipeInfo.learned)
db.recipeInfo = recipeInfo
end
end
end
-- set the profession link to the first text area
cf.fs:SetText(db.link)
-- set the last recipe found's hyperlink to the second text area
-- If you have a specific recipeInfo.hyperlink ) use that instead
if db.recipeInfo and db.recipeInfo.hyperlink then
cf2.fs:SetText(db.recipeInfo.hyperlink)
end
end
local f = CreateFrame("Frame")
f:RegisterEvent("ADDON_LOADED")
f:RegisterEvent("PLAYER_LOGIN")
f:RegisterEvent("TRADE_SKILL_SHOW")
f:SetScript("OnEvent",OnEvent)