Added another message when items are acquired that are in the shopping list.
pschifferer [11-05-09 - 23:54]
Added another message when items are acquired that are in the shopping list.
diff --git a/CauldronMain.lua b/CauldronMain.lua
index 8e2fba2..dd8e8a2 100644
--- a/CauldronMain.lua
+++ b/CauldronMain.lua
@@ -386,7 +386,11 @@ function Cauldron:OnBagUpdate(event, bagid)
--@alpha@
self:debug("OnBagUpdate: adjust shopping list");
--@end-alpha@
- CauldronShopping:RemoveFromList(self.db.realm.shopping, self.vars.playername, item, itemCount);
+ local amtRemoved = CauldronShopping:RemoveFromList(self.db.realm.shopping, self.vars.playername, item, itemCount);
+ if amtRemoved > 0 then
+ local str = string.format("%s: %s: %d", L["Shopping list"], item, amtRemoved);
+ UIErrorsFrame:AddMessage(str, 1.0, 0.5, 0.25, 86, 3);
+ end
-- adjust intermediate list
self:debug("OnBagUpdate: adjust intermediate list");
diff --git a/CauldronShoppingList.lua b/CauldronShoppingList.lua
index 8b2b21f..b32de82 100644
--- a/CauldronShoppingList.lua
+++ b/CauldronShoppingList.lua
@@ -52,24 +52,32 @@ function CauldronShopping:RemoveFromList(list, requestor, itemName, quantity)
-- sanity checks
if not list then
Cauldron:error("No shopping list available!");
- return;
+ return -1;
end
if not list[requestor] then
-- initialize the list for the requestor
list[requestor] = {};
end
+
+ local numRemoved = 0;
if list[requestor][itemName] then
if quantity then
+ local origQty = list[requestor][itemName];
list[requestor][itemName] = list[requestor][itemName] - quantity;
+ numRemoved = quantity;
if list[requestor][itemName] < 1 then
+ numRemoved = origQty;
list[requestor][itemName] = nil;
end
else
+ numRemoved = list[requestor][itemName];
list[requestor][itemName] = nil;
end
end
+
+ return numRemoved;
end
function CauldronShopping:GetRequestors(list)