Added merchant close callback to close the shopping list when the merchant window closes, only if the shopping list is empty.
pschifferer [10-30-09 - 02:29]
Added merchant close callback to close the shopping list when the merchant window closes, only if the shopping list is empty.
Added a check on merchant open to only open the shopping list (and subsequently execute auto-buy) if there are items in the list.
diff --git a/CauldronMain.lua b/CauldronMain.lua
index 1687d82..f3e6673 100644
--- a/CauldronMain.lua
+++ b/CauldronMain.lua
@@ -193,7 +193,7 @@ function Cauldron:OnEnable()
-- self:RegisterEvent("PLAYERBANKBAGSLOTS_CHANGED");
self:RegisterEvent("MERCHANT_SHOW", "OnMerchantShow");
-- self:RegisterEvent("MERCHANT_UPDATE");
--- self:RegisterEvent("MERCHANT_CLOSED");
+ self:RegisterEvent("MERCHANT_CLOSED", "OnMerchantClose");
self:RegisterEvent("BAG_UPDATE", "OnBagUpdate");
-- self:RegisterEvent("TRAINER_CLOSED");
-- self:RegisterEvent("PLAYER_REGEN_DISABLED");
@@ -477,10 +477,13 @@ function Cauldron:OnMerchantShow()
self:debug("OnMerchantShow enter");
--@end-alpha@
- Cauldron:ShowShoppingList();
-
- if Cauldron.db.realm.userdata[Cauldron.vars.playername].options.autoBuy then
- CauldronShopping:AutoBuyShoppingItems(Cauldron.db.realm.shopping, Cauldron.vars.playername);
+ -- check if there's anything in the shopping list
+ if CauldronShopping:ContainsItems(Cauldron.db.realm.shopping) then
+ Cauldron:ShowShoppingList();
+
+ if Cauldron.db.realm.userdata[Cauldron.vars.playername].options.autoBuy then
+ CauldronShopping:AutoBuyShoppingItems(Cauldron.db.realm.shopping, Cauldron.vars.playername);
+ end
end
--@alpha@
@@ -488,6 +491,20 @@ function Cauldron:OnMerchantShow()
--@end-alpha@
end
+function Cauldron:OnMerchantClose()
+--@alpha@
+ self:debug("OnMerchantClose enter");
+--@end-alpha@
+
+ if not CauldronShopping:ContainsItems(Cauldron.db.realm.shopping) then
+ Cauldron:HideShoppingList();
+ end
+
+--@alpha@
+ self:debug("OnMerchantClose exit");
+--@end-alpha@
+end
+
function Cauldron:OnBankOpened()
--@alpha@
self:debug("OnBankOpened enter");