Mercurial > wow > reagentmaker
changeset 82:cf1da2654dc6 v1.0beta3
Expand headers when needed. Not heavily tested, could fail on a slow computer...
author | contrebasse |
---|---|
date | Sun, 15 May 2011 09:23:15 +0200 |
parents | 32c398de6812 |
children | 7a6232715a85 |
files | ReagentMaker.lua data.lua utils.lua |
diffstat | 3 files changed, 44 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/ReagentMaker.lua Sun May 15 01:35:38 2011 +0200 +++ b/ReagentMaker.lua Sun May 15 09:23:15 2011 +0200 @@ -116,8 +116,6 @@ if IsModifierKeyDown() and not IsShiftKeyDown() then return end local chooseNumberToCraft = IsShiftKeyDown() - --A.SaveActiveFilters() - -- Index of the reagent in the recipe, taken from the button name local reagentRecipeIndex = A.buttonNumber(btn) @@ -129,9 +127,16 @@ if not reagentID or not A.data[reagentID] then return end -- If only one recipe is known for the reagent, use it - if #(A.data[reagentID]) == 1 and not A.data[reagentID][1].macro then + if #(A.data[reagentID]) == 1 and not A.data[reagentID][1].macro then local numMakable, reagentIndex = A.numMakable(reagentID) - if not numMakable then + + -- Try to show the recipe once if it was not found + if not reagentIndex then + A.SaveActiveFilters(A.data[reagentID][1].header) + numMakable, reagentIndex = A.numMakable(reagentID) + end + + if not numMakable then A.Error(A.L["The recipe to make the reagent seems to be hidden, it is not makable. Try to remove the filters on the recipes."]) return end
--- a/data.lua Sun May 15 01:35:38 2011 +0200 +++ b/data.lua Sun May 15 09:23:15 2011 +0200 @@ -28,6 +28,10 @@ -- the function who scans the tradeskill function A:ScanSimpleRecipes() + -- Do not scan while we modify the tradeskill display + if A.blockScan then return end + + -- Check if the tradeskill is loaded -- Has to have recipes and begin with a header local NRecipes = GetNumTradeSkills() @@ -54,11 +58,15 @@ end end - for i = 2,NRecipes do -- The first one is a header + local lastHeader + for i = 1,NRecipes do -- skillName, skillType, numAvailable, isExpanded, serviceType, numSkillUps = GetTradeSkillInfo(index) -- serviceType is nil if the recipe creates an item - local _, skillType, _, _, serviceType = GetTradeSkillInfo(i) - if skillType and skillType ~= "header" and serviceType==nil then + local skillName, skillType, _, _, serviceType = GetTradeSkillInfo(i) + if skillType and skillType == "header" then + lastHeader = skillName + + elseif skillType and skillType ~= "header" and serviceType==nil then -- item ID local itemID = A.link2ID(GetTradeSkillItemLink(i)) @@ -102,6 +110,7 @@ local spell = {reagentID,reagentCount,minMade,maxMade} spell.spellID = tradeskillID spell.spellLink = recipeLink + spell.header = lastHeader spell.manyReagents = GetTradeSkillNumReagents(i)>1 tinsert(A.data[itemID],spell) end
--- a/utils.lua Sun May 15 01:35:38 2011 +0200 +++ b/utils.lua Sun May 15 09:23:15 2011 +0200 @@ -56,7 +56,7 @@ -- Find the first tradeskill index of the recipe to make an item function A.findSkillIndex(itemID) for i = 1,GetNumTradeSkills() do - local skillName, skillType = GetTradeSkillInfo(i) + local _, skillType = GetTradeSkillInfo(i) if skillType == "header" then else local ID = A.link2ID(GetTradeSkillItemLink(i)) @@ -65,7 +65,6 @@ end -- if end -- if end -- for - --A.Error(A.L["Tradeskill not found for %d, is the recipe hidden ?"]:format(itemID)) end -- function end -- do @@ -113,8 +112,12 @@ end end - function A.SaveActiveFilters() + function A.SaveActiveFilters(headerName) + A.blockScan = true + + --[[ print("save") + print(GetNumTradeSkills()) selectedTradeSkillIndex = GetTradeSkillSelectionIndex() subClasses = { GetTradeSkillSubClasses() } @@ -127,12 +130,14 @@ if TradeSkillSubClassDropDown then UIDropDownMenu_SetSelectedID(TradeSkillSubClassDropDown, 1) end + print(GetNumTradeSkills()) -- Inventory slots SetTradeSkillInvSlotFilter(0, 1, 1) -- this checks "All slots" if TradeSkillInvSlotDropDown then UIDropDownMenu_SetSelectedID(TradeSkillInvSlotDropDown, 1) end + print(GetNumTradeSkills()) -- Have Materials if TradeSkillFrameAvailableFilterCheckButton then @@ -140,25 +145,31 @@ TradeSkillFrameAvailableFilterCheckButton:SetChecked(false) end TradeSkillOnlyShowMakeable(false) + print(GetNumTradeSkills()) + --]] -- Headers - local headerCount = 0 -- use a counter to avoid being bound to header names, which might not be unique. - + --local headerCount = 0 -- use a counter to avoid being bound to header names, which might not be unique. for i = GetNumTradeSkills(), 1, -1 do -- 1st pass, expand all categories - local _, skillType, _, isExpanded = GetTradeSkillInfo(i) + local skillName, skillType, _, isExpanded = GetTradeSkillInfo(i) if (skillType == "header") then - headerCount = headerCount + 1 - if not isExpanded then + --headerCount = headerCount + 1 + if not isExpanded and skillName==headerName then ExpandTradeSkillSubClass(i) - headersState[headerCount] = true + --print(GetNumTradeSkills()) + --headersState[headerCount] = true end end end - print("saved") + --print("saved") + + A.blockScan = nil end function A.RestoreActiveFilters() + A.blockScan = true + print("restore") -- Subclasses SetTradeSkillSubClassFilter(subClassID-1, 1, 1) -- this checks the previously checked value @@ -213,6 +224,8 @@ wipe(headersState) end print("restored") + + A.blockScan = nil end function A.isRecipeUnique(itemData)