Mercurial > wow > reagentmaker
changeset 107:d64a19e5a47d
Bypass the filtering. Not fully tested, but mostly works.
author | contrebasse |
---|---|
date | Thu, 02 Jun 2011 00:57:17 +0200 |
parents | f857e01b067e |
children | 618163a6d970 |
files | ReagentMaker.lua utils.lua |
diffstat | 2 files changed, 62 insertions(+), 96 deletions(-) [+] |
line wrap: on
line diff
--- a/ReagentMaker.lua Tue May 31 00:57:27 2011 +0200 +++ b/ReagentMaker.lua Thu Jun 02 00:57:17 2011 +0200 @@ -3,7 +3,7 @@ -- @todo clean the A table -- @todo check local copy of globals functions -- @todo add support for dez ? --- @todo add support for hidden recipes, removing filtering +-- @todo add support for hidden recipes, removing filtering => save the reagent count to be able to compute the number of craftable items -- @todo add support for cross tradeskill, like mining + forge/ingé -- @todo when a reagent can not be crafted and the recipe has many reagents, do like ReverseEngeneering and go to this recipe (with a one step return button) -- @todo scroll to the selected recipe on opening (usefull also for the previous todo) @@ -151,10 +151,12 @@ 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."]) + A.RestoreActiveFilters() return end if numMakable>0 then A.craft(recipeIndex,reagentRecipeIndex,reagentIndex,numMakable,chooseNumberToCraft) + A.RestoreActiveFilters() return end @@ -162,11 +164,13 @@ -- one step recursion, enables to mill to create an ink if A.data[reagentID][1][1] and A.data[A.data[reagentID][1][1]] then if A.externalCraftWindow(A.data[reagentID][1][1],reagentID) ~= false then + A.RestoreActiveFilters() return end end A.Error(A.L["You do not have enough reagents to craft [%s]"]:format(GetItemInfo(reagentID) or "item #"..reagentID)) + A.RestoreActiveFilters() return else A.externalCraftWindow(reagentID)
--- a/utils.lua Tue May 31 00:57:27 2011 +0200 +++ b/utils.lua Thu Jun 02 00:57:17 2011 +0200 @@ -73,9 +73,8 @@ -- *** Scanning functions *** do local selectedTradeSkillIndex - local subClasses, subClassID - local invSlots, invSlotID - local haveMats + local stateSaved + local filtersState = {} local headersState = {} local function GetSubClassID() @@ -112,125 +111,87 @@ end end + local function ApplyFilters() + TradeSkillOnlyShowSkillUps(TradeSkillFrame.filterTbl.hasSkillUp); + TradeSkillOnlyShowMakeable(TradeSkillFrame.filterTbl.hasMaterials); + SetTradeSkillSubClassFilter(TradeSkillFrame.filterTbl.subClassValue, 1, 1); + SetTradeSkillInvSlotFilter(TradeSkillFrame.filterTbl.slotValue, 1, 1); + TradeSkillUpdateFilterBar(); + CloseDropDownMenus(); + end + function A.SaveActiveFilters(headerName) A.blockScan = true - --[[ - print("save") - print(GetNumTradeSkills()) - selectedTradeSkillIndex = GetTradeSkillSelectionIndex() + -- Save filters + filtersState.hasMaterials = TradeSkillFrame.filterTbl.hasMaterials + filtersState.hasSkillUp = TradeSkillFrame.filterTbl.hasSkillUp + filtersState.subClassValue = TradeSkillFrame.filterTbl.subClassValue + filtersState.slotValue = TradeSkillFrame.filterTbl.slotValue - subClasses = { GetTradeSkillSubClasses() } - invSlots = { GetTradeSkillInvSlots() } - subClassID = GetSubClassID() - invSlotID = GetInvSlotID() - - -- Subclasses - SetTradeSkillSubClassFilter(0, 1, 1) -- this checks "All subclasses" - 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 - haveMats = TradeSkillFrameAvailableFilterCheckButton:GetChecked() -- nil or true - TradeSkillFrameAvailableFilterCheckButton:SetChecked(false) - end - TradeSkillOnlyShowMakeable(false) - print(GetNumTradeSkills()) - --]] + -- Remove all filters + TradeSkillFrame.filterTbl.hasMaterials = false + TradeSkillFrame.filterTbl.hasSkillUp = false + TradeSkillFrame.filterTbl.subClassValue = -1 + TradeSkillFrame.filterTbl.slotValue = -1 + ApplyFilters() -- Headers --local headerCount = 0 -- use a counter to avoid being bound to header names, which might not be unique. + headersState.headerName = headerName for i = GetNumTradeSkills(), 1, -1 do -- 1st pass, expand all categories local skillName, skillType, _, isExpanded = GetTradeSkillInfo(i) - if (skillType == "header") then - --headerCount = headerCount + 1 - if not isExpanded and skillName==headerName then - ExpandTradeSkillSubClass(i) - --print(GetNumTradeSkills()) - --headersState[headerCount] = true + if (skillType == "header") and skillName==headerName then + if not isExpanded then + ExpandTradeSkillSubClass(i) + table.insert(headersState,true) + else + table.insert(headersState,false) + end end - end end - --print("saved") + --@todo Scroll down to the selected recipe + -- with TradeSkillSkillXX:Show() ? + + stateSaved = true A.blockScan = nil end function A.RestoreActiveFilters() + if not stateSaved then return end + A.blockScan = true - print("restore") - -- Subclasses - SetTradeSkillSubClassFilter(subClassID-1, 1, 1) -- this checks the previously checked value - - local frame = TradeSkillSubClassDropDown - if frame then -- other addons might nil this frame (delayed load, etc..), so secure DDM calls - local text = (subClassID == 1) and ALL_SUBCLASSES or subClasses[subClassID-1] - UIDropDownMenu_SetSelectedID(frame, subClassID) - UIDropDownMenu_SetText(frame, text); - end - - subClassID = nil - wipe(subClasses) - subClasses = nil - - -- Inventory slots - invSlotID = invSlotID or 1 - SetTradeSkillInvSlotFilter(invSlotID-1, 1, 1) -- this checks the previously checked value - - frame = TradeSkillInvSlotDropDown - if frame then - local text = (invSlotID == 1) and ALL_INVENTORY_SLOTS or invSlots[invSlotID-1] - UIDropDownMenu_SetSelectedID(frame, invSlotID) - UIDropDownMenu_SetText(frame, text); - end - - invSlotID = nil - wipe(invSlots) - invSlots = nil - - -- Have Materials - if TradeSkillFrameAvailableFilterCheckButton then - TradeSkillFrameAvailableFilterCheckButton:SetChecked(haveMats or false) - end - TradeSkillOnlyShowMakeable(haveMats or false) - haveMats = nil - - SelectTradeSkill(selectedTradeSkillIndex) - selectedTradeSkillIndex = nil - - -- Headers - local headerCount = 0 + -- restore headers for i = GetNumTradeSkills(), 1, -1 do - local _, skillType = GetTradeSkillInfo(i) - if (skillType == "header") then - headerCount = headerCount + 1 - if headersState[headerCount] then + local skillName, skillType = GetTradeSkillInfo(i) + if (skillType == "header") and skillName==headersState.headerName and table.remove(headersState,1) then CollapseTradeSkillSubClass(i) - end end end wipe(headersState) + + -- restore filters + TradeSkillFrame.filterTbl.hasMaterials = filtersState.hasMaterials + TradeSkillFrame.filterTbl.hasSkillUp = filtersState.hasSkillUp + TradeSkillFrame.filterTbl.subClassValue = filtersState.subClassValue + TradeSkillFrame.filterTbl.slotValue = filtersState.slotValue + ApplyFilters() + + + --print("restored") + + stateSaved = nil + + A.blockScan = nil end - print("restored") - - A.blockScan = nil end function A.isRecipeUnique(itemData) local unique = true - + -- Check if the item is made by only one recipe. If not, return if #itemData>1 then local spellLink @@ -245,14 +206,14 @@ end end end - + return unique end --[[ function A.isTradeskillUnique(itemData) local spellName = itemData[1].spellName - + -- Check if the item is made by only one recipe. If not, return if #itemData>1 then for _,v in ipairs(itemData) do @@ -265,4 +226,4 @@ return spellName end ---]] \ No newline at end of file +--]]