# HG changeset patch # User contrebasse # Date 1303940780 -7200 # Node ID 5f3a5b88fb191615de0a2156547830753eebe116 # Parent 8acb6dc1ff9efb247bcc47c8af4b9f2891d134c4 First attempt to unfilter, failed badly... I'm not even sure it'll be possible at all. diff -r 8acb6dc1ff9e -r 5f3a5b88fb19 ReagentMaker.lua --- a/ReagentMaker.lua Wed Apr 27 21:55:33 2011 +0200 +++ b/ReagentMaker.lua Wed Apr 27 23:46:20 2011 +0200 @@ -101,6 +101,7 @@ -- Function run after selecting a item in the tradeskill window function A.ProcessReagent(btn, ...) + -- Do not manage guild tradeskill if IsTradeSkillGuild() or IsTradeSkillLinked() then return end @@ -108,6 +109,8 @@ 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) @@ -134,6 +137,7 @@ else A.externalCraftWindow(reagentID) end -- if + --A.RestoreActiveFilters() end -- function @@ -189,6 +193,8 @@ -- Index of the reagent in the recipe, taken from the button name local reagentRecipeIndex = A.buttonNumber(btn) + --A.SaveActiveFilters() + -- ID of the reagent we want to craft local reagentLink = GetTradeSkillReagentItemLink(GetTradeSkillSelectionIndex(), reagentRecipeIndex) local reagentID = A.link2ID(reagentLink) @@ -208,6 +214,9 @@ link = GetTradeSkillRecipeLink(A.findSkillIndex(reagentID)) end end + + --A.RestoreActiveFilters() + if link then A.tooltipRecipe:SetOwner(btn) A.tooltipRecipe:SetHyperlink(link) diff -r 8acb6dc1ff9e -r 5f3a5b88fb19 utils.lua --- a/utils.lua Wed Apr 27 21:55:33 2011 +0200 +++ b/utils.lua Wed Apr 27 23:46:20 2011 +0200 @@ -58,3 +58,149 @@ A.DEBUG("Tradeskill not found for "..itemID) end -- function end -- do + + +-- Taken from Datastore_Crafts +-- *** Scanning functions *** +do + local selectedTradeSkillIndex + local subClasses, subClassID + local invSlots, invSlotID + local haveMats + local headersState = {} + + local function GetSubClassID() + -- The purpose of this function is to get the subClassID in a UI independant way + -- ie: without relying on UIDropDownMenu_GetSelectedID(TradeSkillSubClassDropDown), which uses a hardcoded frame name. + + if GetTradeSkillSubClassFilter(0) then -- if "All Subclasses" is selected, GetTradeSkillSubClassFilter() will return 1 for all indexes, including 0 + return 1 -- thus return 1 as selected id (as would be returned by UIDropDownMenu_GetSelectedID(TradeSkillSubClassDropDown)) + end + + local filter + for i = 1, #subClasses do + filter = GetTradeSkillSubClassFilter(i) + if filter then + return i+1 -- ex: 3rd element of the subClasses array, but 4th in the dropdown due to "All Subclasses", so return i+1 + end + end + end + + local function GetInvSlotID() + -- The purpose of this function is to get the invSlotID in a UI independant way (same as GetSubClassID) + -- ie: without relying on UIDropDownMenu_GetSelectedID(TradeSkillInvSlotDropDown), which uses a hardcoded frame name. + + if GetTradeSkillInvSlotFilter(0) then -- if "All Slots" is selected, GetTradeSkillInvSlotFilter() will return 1 for all indexes, including 0 + return 1 -- thus return 1 as selected id (as would be returned by UIDropDownMenu_GetSelectedID(TradeSkillInvSlotDropDown)) + end + + local filter + for i = 1, #invSlots do + filter = GetTradeSkillInvSlotFilter(i) + if filter then + return i+1 -- ex: 3rd element of the invSlots array, but 4th in the dropdown due to "All Slots", so return i+1 + end + end + end + + function A.SaveActiveFilters() + print("save") + selectedTradeSkillIndex = GetTradeSkillSelectionIndex() + + 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 + + -- Inventory slots + SetTradeSkillInvSlotFilter(0, 1, 1) -- this checks "All slots" + if TradeSkillInvSlotDropDown then + UIDropDownMenu_SetSelectedID(TradeSkillInvSlotDropDown, 1) + end + + -- Have Materials + if TradeSkillFrameAvailableFilterCheckButton then + haveMats = TradeSkillFrameAvailableFilterCheckButton:GetChecked() -- nil or true + TradeSkillFrameAvailableFilterCheckButton:SetChecked(false) + end + TradeSkillOnlyShowMakeable(false) + + -- Headers + 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) + if (skillType == "header") then + headerCount = headerCount + 1 + if not isExpanded then + ExpandTradeSkillSubClass(i) + headersState[headerCount] = true + end + end + end + + print("saved") + end + + function A.RestoreActiveFilters() + 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 + for i = GetNumTradeSkills(), 1, -1 do + local _, skillType = GetTradeSkillInfo(i) + if (skillType == "header") then + headerCount = headerCount + 1 + if headersState[headerCount] then + CollapseTradeSkillSubClass(i) + end + end + end + wipe(headersState) + end + print("restored") +end