New Talent Tree Iterator

Is there one in the API? Is there a way to extract the selected talents (and their rankings if that 1/2 or 1/3 thing means ranked)?

Something like this. I’m a little confused on how you are supposed to get your current configID, so it might not be entirely correct. Only iterates your last selected spec, not any current changes that aren’t applied.

function PrintTalents()
    local specID = PlayerUtil.GetCurrentSpecID()
    
    -- last selected configID or fall back to default spec config
    local configID = C_ClassTalents.GetLastSelectedSavedConfigID(specID) or C_ClassTalents.GetActiveConfigID()
    
    local configInfo = C_Traits.GetConfigInfo(configID)
    local treeID = configInfo.treeIDs[1]

    local nodes = C_Traits.GetTreeNodes(treeID)

    for _, nodeID in ipairs(nodes) do
        local nodeInfo = C_Traits.GetNodeInfo(configID, nodeID)
        if nodeInfo.currentRank and nodeInfo.currentRank > 0 then
            local entryID = nodeInfo.activeEntry and nodeInfo.activeEntry.entryID and nodeInfo.activeEntry.entryID
            local entryInfo = entryID and C_Traits.GetEntryInfo(configID, entryID)
            local definitionInfo = entryInfo and entryInfo.definitionID and C_Traits.GetDefinitionInfo(entryInfo.definitionID)

            if definitionInfo ~= nil then
                local talentName = TalentUtil.GetTalentName(definitionInfo.overrideName, definitionInfo.spellID)
                print(string.format("%s %d/%d", talentName, nodeInfo.currentRank, nodeInfo.maxRanks))
            end
        end
    end
end

Thanks, Tyreith.

If you can piggyback off of the talent UI this looks a lot cleaner. But it does require Blizzard_ClassTalentUI to be loaded and opened once. This method does use the uncommitted changes.

for talentButton in ClassTalentFrame.TalentsTab:EnumerateAllTalentButtons() do
    local nodeInfo = talentButton:GetNodeInfo()
    
    if nodeInfo.currentRank and nodeInfo.currentRank > 0 then
        print(string.format("%s %d/%d", talentButton:GetName(), nodeInfo.currentRank, nodeInfo.maxRanks))
    end
end

I’ve been leaning in on support for a few addons today so I haven’t had a chance to test this until just now. The first version works perfectly as is. I can iterate through my current spec (all I need) and store the name, level, and max level of each just as I need to. Thanks a ton.