Mercurial > wow > inventory
comparison Modules/Scanner.lua @ 101:6ae44d372360
The confirmation window when refilling from the (guild) bank is enabled can now be skipped at the general config. It defaults to false.
Added a window displaying a list of movable items when at least one is available at the (guild) bank.
Resetting the queue when closing the storage.
author | Zerotorescue |
---|---|
date | Tue, 11 Jan 2011 19:48:35 +0100 |
parents | 252292b703ce |
children | d3fbb5676a5e |
comparison
equal
deleted
inserted
replaced
100:dbb239fcc91b | 101:6ae44d372360 |
---|---|
5 Bag = 0, | 5 Bag = 0, |
6 Bank = 1, | 6 Bank = 1, |
7 Guild = 2, | 7 Guild = 2, |
8 }; | 8 }; |
9 | 9 |
10 local Mover, paused; | 10 local Mover, paused, currentLocation; |
11 local itemCache = {}; | 11 local itemCache = {}; |
12 | |
13 local function OnMoveAccept(this) | |
14 mod:Pause(); | |
15 Mover:BeginMove(currentLocation, mod.Unpause); | |
16 | |
17 InventoriumItemMover:Hide(); | |
18 end | |
19 | |
20 local function OnMoveCancel(this) | |
21 Mover:ResetQueue(); | |
22 currentLocation = nil; | |
23 | |
24 InventoriumItemMover:Hide(); | |
25 end | |
12 | 26 |
13 function mod:ClearCache() | 27 function mod:ClearCache() |
14 table.wipe(itemCache); | 28 table.wipe(itemCache); |
15 end | 29 end |
16 | 30 |
113 return; | 127 return; |
114 end | 128 end |
115 | 129 |
116 local playerName = UnitName("player"); | 130 local playerName = UnitName("player"); |
117 | 131 |
132 currentLocation = location; | |
118 self:CacheLocation(location, true); | 133 self:CacheLocation(location, true); |
119 | 134 |
120 -- Go through all groups | 135 -- Go through all groups |
121 for groupName, values in pairs(addon.db.profile.groups) do | 136 for groupName, values in pairs(addon.db.profile.groups) do |
122 local trackAt = addon:GetOptionByKey(groupName, "trackAtCharacters"); | 137 local trackAt = addon:GetOptionByKey(groupName, "trackAtCharacters"); |
134 local missingItems = itemCache[itemId] and (minLocalStock - addon:GetLocalItemCount(itemId, groupName)); | 149 local missingItems = itemCache[itemId] and (minLocalStock - addon:GetLocalItemCount(itemId, groupName)); |
135 | 150 |
136 if itemCache[itemId] and missingItems > 0 then | 151 if itemCache[itemId] and missingItems > 0 then |
137 -- Check how many are available | 152 -- Check how many are available |
138 local availableItems = ((itemCache[itemId] and itemCache[itemId].totalCount) or 0); | 153 local availableItems = ((itemCache[itemId] and itemCache[itemId].totalCount) or 0); |
154 -- Calculate how many we'll be moving (less missing than available? use missing, otherwise use available) | |
155 local moving = (((missingItems <= availableItems) and missingItems) or availableItems); | |
139 | 156 |
140 if availableItems > 0 then | 157 if availableItems > 0 then |
141 addon:Print("Insufficient " .. select(2, GetItemInfo(itemId)) .. " but this location has " .. availableItems .. " (moving " .. missingItems .. ")"); | 158 --addon:Print("Insufficient " .. IdToItemLink(itemId) .. " but this location has " .. availableItems .. " (moving " .. moving .. ")"); |
142 | 159 |
143 Mover:AddMove(itemId, missingItems); | 160 Mover:AddMove(itemId, moving, missingItems, availableItems); |
144 else | 161 else |
145 addon:Print("Insufficient " .. IdToItemLink(itemId)); | 162 --addon:Print("Insufficient " .. IdToItemLink(itemId)); |
146 end | 163 end |
147 end | 164 end |
148 end | 165 end |
149 end | 166 end |
150 end | 167 end |
151 | 168 |
152 self:ClearCache(); | 169 self:ClearCache(); |
153 | 170 |
154 if Mover:HasMoves() then | 171 if Mover:HasMoves() then |
155 StaticPopupDialogs["InventoriumRefill"] = { | 172 if addon.db.profile.defaults.autoRefillSkipConfirm then |
156 text = "There are items that can be refilled from this location, do you wish to proceed?", | 173 OnMoveAccept(true); |
157 button1 = YES, | 174 else |
158 button2 = NO, | 175 local data = {}; |
159 OnAccept = function() | 176 |
160 mod:Pause(); | 177 local columns = { |
161 Mover:BeginMove(location, self.Unpause); | 178 { |
162 end, | 179 value = function(d, cols, realrow, column, table) |
163 timeout = 0, | 180 return IdToItemLink(d[realrow].colorargs[2]); |
164 whileDead = 1, | 181 end, |
165 hideOnEscape = 1, | 182 }, -- item |
166 exclusive = 1, | 183 { |
167 }; | 184 value = function(d, cols, realrow, column, table) |
168 StaticPopup_Show("InventoriumRefill"); | 185 local queue = Mover:GetMoves(); |
186 return queue[d[realrow].colorargs[1]].num; | |
187 end, | |
188 }, -- moving | |
189 { | |
190 value = function(d, cols, realrow, column, table) | |
191 local queue = Mover:GetMoves(); | |
192 return queue[d[realrow].colorargs[1]].missing; | |
193 end, | |
194 }, -- missing | |
195 { | |
196 value = function(d, cols, realrow, column, table) | |
197 local queue = Mover:GetMoves(); | |
198 return queue[d[realrow].colorargs[1]].available; | |
199 end, | |
200 color = function(d, cols, realrow, column, table) | |
201 local queue = Mover:GetMoves(); | |
202 return ((queue[d[realrow].colorargs[1]].available < queue[d[realrow].colorargs[1]].missing) and { r = 1, g = 0, b = 0, a = 1 }) or { r = 1, g = 1, b = 1, a = 1 }; | |
203 end, | |
204 }, -- available | |
205 }; | |
206 | |
207 local queue = Mover:GetMoves(); | |
208 | |
209 for i, move in pairs(Mover:GetMoves()) do | |
210 local row = { | |
211 ["colorargs"] = { i, queue[i].id }, | |
212 ["cols"] = columns, | |
213 }; | |
214 | |
215 table.insert(data, row); | |
216 end | |
217 | |
218 addon:SetMoverFrameData(data); | |
219 | |
220 --[[ | |
221 StaticPopupDialogs["InventoriumRefill"] = { | |
222 text = "There are items that can be refilled from this location, do you wish to proceed?", | |
223 button1 = YES, | |
224 button2 = NO, | |
225 OnAccept = function() | |
226 mod:Pause(); | |
227 Mover:BeginMove(location, self.Unpause); | |
228 end, | |
229 timeout = 0, | |
230 whileDead = 1, | |
231 hideOnEscape = 1, | |
232 exclusive = 1, | |
233 }; | |
234 StaticPopup_Show("InventoriumRefill");]] | |
235 end | |
169 end | 236 end |
170 end | 237 end |
171 | 238 |
172 | 239 |
173 | 240 |
189 | 256 |
190 self:ClearCache(); | 257 self:ClearCache(); |
191 | 258 |
192 mod:UnregisterEvent("BANKFRAME_CLOSED"); | 259 mod:UnregisterEvent("BANKFRAME_CLOSED"); |
193 | 260 |
194 StaticPopup_Hide("InventoriumRefill"); | 261 --StaticPopup_Hide("InventoriumRefill"); |
262 InventoriumItemMover:Hide(); | |
263 Mover:ResetQueue(); | |
195 end | 264 end |
196 | 265 |
197 -- Guild bank | 266 -- Guild bank |
198 | 267 |
199 local tmrScanGuild, scanned; | 268 local tmrScanGuild, scanned; |
224 self:UnregisterEvent("GUILDBANKFRAME_CLOSED"); | 293 self:UnregisterEvent("GUILDBANKFRAME_CLOSED"); |
225 self:UnregisterEvent("GUILDBANKBAGSLOTS_CHANGED"); | 294 self:UnregisterEvent("GUILDBANKBAGSLOTS_CHANGED"); |
226 | 295 |
227 self:CancelTimer(tmrScanGuild, true); -- silent | 296 self:CancelTimer(tmrScanGuild, true); -- silent |
228 | 297 |
229 StaticPopup_Hide("InventoriumRefill"); | 298 --StaticPopup_Hide("InventoriumRefill"); |
299 InventoriumItemMover:Hide(); | |
300 Mover:ResetQueue(); | |
230 end | 301 end |
231 | 302 |
232 function mod:GUILDBANKFRAME_OPENED() | 303 function mod:GUILDBANKFRAME_OPENED() |
233 addon:Debug("Scanner:GUILDBANKFRAME_OPENED"); | 304 addon:Debug("Scanner:GUILDBANKFRAME_OPENED"); |
234 | 305 |
250 -- Scan once when the bankframe is opened | 321 -- Scan once when the bankframe is opened |
251 self:RegisterEvent("BANKFRAME_OPENED"); | 322 self:RegisterEvent("BANKFRAME_OPENED"); |
252 self:RegisterEvent("GUILDBANKFRAME_OPENED"); | 323 self:RegisterEvent("GUILDBANKFRAME_OPENED"); |
253 | 324 |
254 Mover = addon:GetModule("Mover"); | 325 Mover = addon:GetModule("Mover"); |
326 | |
327 if not InventoriumItemMover then | |
328 addon:CreateMoverFrame(OnMoveAccept, OnMoveCancel); | |
329 end | |
255 end | 330 end |
256 | 331 |
257 function mod:OnDisable() | 332 function mod:OnDisable() |
258 Mover = nil; | 333 Mover = nil; |
334 currentLocation = nil; | |
335 paused = nil; | |
259 | 336 |
260 -- Bank | 337 -- Bank |
261 self:UnregisterEvent("BANKFRAME_OPENED"); | 338 self:UnregisterEvent("BANKFRAME_OPENED"); |
262 | 339 |
263 -- Guild | 340 -- Guild |