comparison utils.lua @ 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 9d487333bf10
children 996aaa818d04
comparison
equal deleted inserted replaced
81:32c398de6812 82:cf1da2654dc6
54 end 54 end
55 55
56 -- Find the first tradeskill index of the recipe to make an item 56 -- Find the first tradeskill index of the recipe to make an item
57 function A.findSkillIndex(itemID) 57 function A.findSkillIndex(itemID)
58 for i = 1,GetNumTradeSkills() do 58 for i = 1,GetNumTradeSkills() do
59 local skillName, skillType = GetTradeSkillInfo(i) 59 local _, skillType = GetTradeSkillInfo(i)
60 if skillType == "header" then 60 if skillType == "header" then
61 else 61 else
62 local ID = A.link2ID(GetTradeSkillItemLink(i)) 62 local ID = A.link2ID(GetTradeSkillItemLink(i))
63 if ID and ID == itemID then 63 if ID and ID == itemID then
64 return i 64 return i
65 end -- if 65 end -- if
66 end -- if 66 end -- if
67 end -- for 67 end -- for
68 --A.Error(A.L["Tradeskill not found for %d, is the recipe hidden ?"]:format(itemID))
69 end -- function 68 end -- function
70 end -- do 69 end -- do
71 70
72 71
73 -- Taken from Datastore_Crafts 72 -- Taken from Datastore_Crafts
111 return i+1 -- ex: 3rd element of the invSlots array, but 4th in the dropdown due to "All Slots", so return i+1 110 return i+1 -- ex: 3rd element of the invSlots array, but 4th in the dropdown due to "All Slots", so return i+1
112 end 111 end
113 end 112 end
114 end 113 end
115 114
116 function A.SaveActiveFilters() 115 function A.SaveActiveFilters(headerName)
116 A.blockScan = true
117
118 --[[
117 print("save") 119 print("save")
120 print(GetNumTradeSkills())
118 selectedTradeSkillIndex = GetTradeSkillSelectionIndex() 121 selectedTradeSkillIndex = GetTradeSkillSelectionIndex()
119 122
120 subClasses = { GetTradeSkillSubClasses() } 123 subClasses = { GetTradeSkillSubClasses() }
121 invSlots = { GetTradeSkillInvSlots() } 124 invSlots = { GetTradeSkillInvSlots() }
122 subClassID = GetSubClassID() 125 subClassID = GetSubClassID()
125 -- Subclasses 128 -- Subclasses
126 SetTradeSkillSubClassFilter(0, 1, 1) -- this checks "All subclasses" 129 SetTradeSkillSubClassFilter(0, 1, 1) -- this checks "All subclasses"
127 if TradeSkillSubClassDropDown then 130 if TradeSkillSubClassDropDown then
128 UIDropDownMenu_SetSelectedID(TradeSkillSubClassDropDown, 1) 131 UIDropDownMenu_SetSelectedID(TradeSkillSubClassDropDown, 1)
129 end 132 end
133 print(GetNumTradeSkills())
130 134
131 -- Inventory slots 135 -- Inventory slots
132 SetTradeSkillInvSlotFilter(0, 1, 1) -- this checks "All slots" 136 SetTradeSkillInvSlotFilter(0, 1, 1) -- this checks "All slots"
133 if TradeSkillInvSlotDropDown then 137 if TradeSkillInvSlotDropDown then
134 UIDropDownMenu_SetSelectedID(TradeSkillInvSlotDropDown, 1) 138 UIDropDownMenu_SetSelectedID(TradeSkillInvSlotDropDown, 1)
135 end 139 end
140 print(GetNumTradeSkills())
136 141
137 -- Have Materials 142 -- Have Materials
138 if TradeSkillFrameAvailableFilterCheckButton then 143 if TradeSkillFrameAvailableFilterCheckButton then
139 haveMats = TradeSkillFrameAvailableFilterCheckButton:GetChecked() -- nil or true 144 haveMats = TradeSkillFrameAvailableFilterCheckButton:GetChecked() -- nil or true
140 TradeSkillFrameAvailableFilterCheckButton:SetChecked(false) 145 TradeSkillFrameAvailableFilterCheckButton:SetChecked(false)
141 end 146 end
142 TradeSkillOnlyShowMakeable(false) 147 TradeSkillOnlyShowMakeable(false)
148 print(GetNumTradeSkills())
149 --]]
143 150
144 -- Headers 151 -- Headers
145 local headerCount = 0 -- use a counter to avoid being bound to header names, which might not be unique. 152 --local headerCount = 0 -- use a counter to avoid being bound to header names, which might not be unique.
146
147 for i = GetNumTradeSkills(), 1, -1 do -- 1st pass, expand all categories 153 for i = GetNumTradeSkills(), 1, -1 do -- 1st pass, expand all categories
148 local _, skillType, _, isExpanded = GetTradeSkillInfo(i) 154 local skillName, skillType, _, isExpanded = GetTradeSkillInfo(i)
149 if (skillType == "header") then 155 if (skillType == "header") then
150 headerCount = headerCount + 1 156 --headerCount = headerCount + 1
151 if not isExpanded then 157 if not isExpanded and skillName==headerName then
152 ExpandTradeSkillSubClass(i) 158 ExpandTradeSkillSubClass(i)
153 headersState[headerCount] = true 159 --print(GetNumTradeSkills())
160 --headersState[headerCount] = true
154 end 161 end
155 end 162 end
156 end 163 end
157 164
158 print("saved") 165 --print("saved")
166
167 A.blockScan = nil
159 end 168 end
160 169
161 function A.RestoreActiveFilters() 170 function A.RestoreActiveFilters()
171 A.blockScan = true
172
162 print("restore") 173 print("restore")
163 -- Subclasses 174 -- Subclasses
164 SetTradeSkillSubClassFilter(subClassID-1, 1, 1) -- this checks the previously checked value 175 SetTradeSkillSubClassFilter(subClassID-1, 1, 1) -- this checks the previously checked value
165 176
166 local frame = TradeSkillSubClassDropDown 177 local frame = TradeSkillSubClassDropDown
211 end 222 end
212 end 223 end
213 wipe(headersState) 224 wipe(headersState)
214 end 225 end
215 print("restored") 226 print("restored")
227
228 A.blockScan = nil
216 end 229 end
217 230
218 function A.isRecipeUnique(itemData) 231 function A.isRecipeUnique(itemData)
219 local unique = true 232 local unique = true
220 233