Thread Tools Display Modes
Prev Previous Post   Next Post Next
05-19-16, 05:55 PM   #11
Simca
An Aku'mai Servant
 
Simca's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2012
Posts: 33
Here's an example of how TradeSkill stuff changed from Live to Legion. This code was designed to execute an a passed function on every result for a tradeskill.

Before:
Code:
-- Clear the search box focus so the scan will have correct results.
local search_box = _G.TradeSkillFrameSearchBox
search_box:SetText("")

_G.TradeSkillSearch_OnTextChanged(search_box)
search_box:ClearFocus()
search_box:GetScript("OnEditFocusLost")(search_box)

table.wipe(header_list)

-- Save the current state of the TradeSkillFrame so it can be restored after we muck with it.
local have_materials = _G.TradeSkillFrame.filterTbl.hasMaterials
local have_skillup = _G.TradeSkillFrame.filterTbl.hasSkillUp

if have_materials then
    _G.TradeSkillFrame.filterTbl.hasMaterials = false
    _G.TradeSkillOnlyShowMakeable(false)
end

if have_skillup then
    _G.TradeSkillFrame.filterTbl.hasSkillUp = false
    _G.TradeSkillOnlyShowSkillUps(false)
end
_G.SetTradeSkillInvSlotFilter(0, true, true)
_G.TradeSkillUpdateFilterBar()
_G.TradeSkillFrame_Update()

-- Expand all headers so we can see all the recipes there are
for tradeskill_index = 1, _G.GetNumTradeSkills() do
    local name, tradeskill_type, _, is_expanded = _G.GetTradeSkillInfo(tradeskill_index)

    if tradeskill_type == "header" or tradeskill_type == "subheader" then
        if not is_expanded then
            header_list[name] = true
            _G.ExpandTradeSkillSubClass(tradeskill_index)
        end
    elseif iter_func(name, tradeskill_index) then
        break
    end
end

-- Restore the state of the things we changed.
for tradeskill_index = 1, _G.GetNumTradeSkills() do
    local name, tradeskill_type, _, is_expanded = _G.GetTradeSkillInfo(tradeskill_index)

    if header_list[name] then
        _G.CollapseTradeSkillSubClass(tradeskill_index)
    end
end
_G.TradeSkillFrame.filterTbl.hasMaterials = have_materials
_G.TradeSkillOnlyShowMakeable(have_materials)
_G.TradeSkillFrame.filterTbl.hasSkillUp = have_skillup
_G.TradeSkillOnlyShowSkillUps(have_skillup)

_G.TradeSkillUpdateFilterBar()
_G.TradeSkillFrame_Update()
After:
Code:
local recipes = _G.C_TradeSkillUI.GetAllRecipeIDs()

if recipes and (#recipes > 0) then
    for i = 1, #recipes do
        if iter_func(_G.C_TradeSkillUI.GetRecipeInfo(recipes[i]).name, recipes[i]) then
            break
        end
    end
end
If you had trouble working with filters with the old UI like I did, you will love these changes, since there are two main APIs - C_TradeSkillUI.GetAllRecipeIDs() and C_TradeSkillUI.GetFilteredRecipeIDs() (spelling?). The former ignores filters/searching while the latter respects them.
__________________
Assistant admin for MMO-Champion
WoW database file expert - ask me anything
 
 

WoWInterface » Site Forums » Archived Beta Forums » Legion Beta archived threads » Notable API changes in Legion


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off