Mercurial > wow > inventory
diff 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 |
line wrap: on
line diff
--- a/Modules/Scanner.lua Sun Jan 09 17:52:02 2011 +0100 +++ b/Modules/Scanner.lua Tue Jan 11 19:48:35 2011 +0100 @@ -7,9 +7,23 @@ Guild = 2, }; -local Mover, paused; +local Mover, paused, currentLocation; local itemCache = {}; +local function OnMoveAccept(this) + mod:Pause(); + Mover:BeginMove(currentLocation, mod.Unpause); + + InventoriumItemMover:Hide(); +end + +local function OnMoveCancel(this) + Mover:ResetQueue(); + currentLocation = nil; + + InventoriumItemMover:Hide(); +end + function mod:ClearCache() table.wipe(itemCache); end @@ -115,6 +129,7 @@ local playerName = UnitName("player"); + currentLocation = location; self:CacheLocation(location, true); -- Go through all groups @@ -136,13 +151,15 @@ if itemCache[itemId] and missingItems > 0 then -- Check how many are available local availableItems = ((itemCache[itemId] and itemCache[itemId].totalCount) or 0); + -- Calculate how many we'll be moving (less missing than available? use missing, otherwise use available) + local moving = (((missingItems <= availableItems) and missingItems) or availableItems); if availableItems > 0 then - addon:Print("Insufficient " .. select(2, GetItemInfo(itemId)) .. " but this location has " .. availableItems .. " (moving " .. missingItems .. ")"); + --addon:Print("Insufficient " .. IdToItemLink(itemId) .. " but this location has " .. availableItems .. " (moving " .. moving .. ")"); - Mover:AddMove(itemId, missingItems); + Mover:AddMove(itemId, moving, missingItems, availableItems); else - addon:Print("Insufficient " .. IdToItemLink(itemId)); + --addon:Print("Insufficient " .. IdToItemLink(itemId)); end end end @@ -152,20 +169,70 @@ self:ClearCache(); if Mover:HasMoves() then - StaticPopupDialogs["InventoriumRefill"] = { - text = "There are items that can be refilled from this location, do you wish to proceed?", - button1 = YES, - button2 = NO, - OnAccept = function() - mod:Pause(); - Mover:BeginMove(location, self.Unpause); - end, - timeout = 0, - whileDead = 1, - hideOnEscape = 1, - exclusive = 1, - }; - StaticPopup_Show("InventoriumRefill"); + if addon.db.profile.defaults.autoRefillSkipConfirm then + OnMoveAccept(true); + else + local data = {}; + + local columns = { + { + value = function(d, cols, realrow, column, table) + return IdToItemLink(d[realrow].colorargs[2]); + end, + }, -- item + { + value = function(d, cols, realrow, column, table) + local queue = Mover:GetMoves(); + return queue[d[realrow].colorargs[1]].num; + end, + }, -- moving + { + value = function(d, cols, realrow, column, table) + local queue = Mover:GetMoves(); + return queue[d[realrow].colorargs[1]].missing; + end, + }, -- missing + { + value = function(d, cols, realrow, column, table) + local queue = Mover:GetMoves(); + return queue[d[realrow].colorargs[1]].available; + end, + color = function(d, cols, realrow, column, table) + local queue = Mover:GetMoves(); + 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 }; + end, + }, -- available + }; + + local queue = Mover:GetMoves(); + + for i, move in pairs(Mover:GetMoves()) do + local row = { + ["colorargs"] = { i, queue[i].id }, + ["cols"] = columns, + }; + + table.insert(data, row); + end + + addon:SetMoverFrameData(data); + + --[[ + StaticPopupDialogs["InventoriumRefill"] = { + text = "There are items that can be refilled from this location, do you wish to proceed?", + button1 = YES, + button2 = NO, + OnAccept = function() + mod:Pause(); + Mover:BeginMove(location, self.Unpause); + end, + timeout = 0, + whileDead = 1, + hideOnEscape = 1, + exclusive = 1, + }; + StaticPopup_Show("InventoriumRefill");]] + end end end @@ -191,7 +258,9 @@ mod:UnregisterEvent("BANKFRAME_CLOSED"); - StaticPopup_Hide("InventoriumRefill"); + --StaticPopup_Hide("InventoriumRefill"); + InventoriumItemMover:Hide(); + Mover:ResetQueue(); end -- Guild bank @@ -226,7 +295,9 @@ self:CancelTimer(tmrScanGuild, true); -- silent - StaticPopup_Hide("InventoriumRefill"); + --StaticPopup_Hide("InventoriumRefill"); + InventoriumItemMover:Hide(); + Mover:ResetQueue(); end function mod:GUILDBANKFRAME_OPENED() @@ -252,10 +323,16 @@ self:RegisterEvent("GUILDBANKFRAME_OPENED"); Mover = addon:GetModule("Mover"); + + if not InventoriumItemMover then + addon:CreateMoverFrame(OnMoveAccept, OnMoveCancel); + end end function mod:OnDisable() Mover = nil; + currentLocation = nil; + paused = nil; -- Bank self:UnregisterEvent("BANKFRAME_OPENED");