diff --git a/CauldronMain.lua b/CauldronMain.lua index a9529f7..1608412 100644 --- a/CauldronMain.lua +++ b/CauldronMain.lua @@ -76,15 +76,25 @@ function Cauldron:OnInitialize() type = 'execute', func = function() self:DisplayVersion() end, }, + --@alpha@ logging = { name = L["Logging"], - desc = L["Sets the logging level"], + desc = L["Sets or displays the logging level"], type = 'select', values = { - ['normal'] = function() Cauldron:SetLogLevel(Cauldron.logLevels.INFO); end, - ['debug'] = function() Cauldron:SetLogLevel(Cauldron.logLevels.DEBUG); end, + ['normal'] = L["Normal logging of warnings and errors"], + ['debug'] = L["Debug logging (very verbose)"], }, + get = function() Cauldron:Print(Cauldron:GetLogLevel()); end, + set = function(l) + if l == "debug" then + Cauldron:SetLogLevel(Cauldron.logLevels.DEBUG); + else + Cauldron:SetLogLevel(Cauldron.logLevels.INFO); + end + end, }, + --@end-alpha@ reset = { name = L["Reset"], desc = L["Resets Cauldron to a fresh state"], @@ -162,6 +172,9 @@ function Cauldron:OnEnable() self:debug("OnEnable enter"); --@end-alpha@ + -- set init flag, for some callbacks + self.initializing = true; + self:InitPlayer(); -- scan bags @@ -195,6 +208,9 @@ function Cauldron:OnEnable() -- setup hooks for tooltips self:HookTooltips(); + + -- clear init flag + self.initializing = false; --@alpha@ self:debug("OnEnable exit"); @@ -351,7 +367,7 @@ function Cauldron:OnBagUpdate(event, bagid) --@end-alpha@ -- make sure we're not reacting to initial bag update events when the DB isn't initialized yet - if (not Cauldron.db) or (not Cauldron.vars) then + if (self.initializing) or (not self.db) or (not self.vars) then return; end @@ -364,29 +380,38 @@ function Cauldron:OnBagUpdate(event, bagid) --@end-alpha@ if itemCount > 0 then -- adjust shopping list - --@alpha@ - self:debug("OnBagUpdate: adjust shopping list"); - --@end-alpha@ --- CauldronShopping:RemoveFromList(self.db.realm.shopping, self.vars.playername, item, itemCount); - - -- adjust intermediate list --@alpha@ - self:debug("OnBagUpdate: adjust intermediate list"); + self:debug("OnBagUpdate: adjust shopping list"); --@end-alpha@ + CauldronShopping:RemoveFromList(self.db.realm.shopping, self.vars.playername, item, itemCount); + local queue = self.db.realm.userdata[self.vars.playername].queue; + + -- adjust intermediate list + self:debug("OnBagUpdate: adjust intermediate list"); local intItem = CauldronQueue:GetIntermediateItem(queue, item); - if intItem and (not recalc) then + if intItem then -- the item is found in the intermediate list, so recalculate the queue - CauldronQueue:CalculateAllRequiredItems(queue); - Cauldron:UpdateQueue(); - + self:debug("OnBagUpdate: set recalc flag"); recalc = true; --- return; + end + + -- adjust queue + if self.makingItem == item then + self:debug("OnBagUpdate: adjust queue for item: "..self.makingItem); + CauldronQueue:AdjustItemCount(queue, item, -itemCount); end end end + + if recalc then + self:debug("OnBagUpdate: recalculating queue"); + CauldronQueue:CalculateAllRequiredItems(queue); + Cauldron:UpdateQueue(); + end -- check if we were making something, and then update the queue + --[[ if self.makingItem then --@alpha@ self:debug("OnBagUpdate: self.makingItem="..self.makingItem); @@ -407,12 +432,16 @@ function Cauldron:OnBagUpdate(event, bagid) else -- end + --]] -- Cauldron:UpdateSkills(); self:Frame_Update(); Cauldron:UpdateShoppingList(); + -- update the bags + Cauldron:ScanBags(); + --@alpha@ self:debug("OnBagUpdate exit"); --@end-alpha@ @@ -1003,10 +1032,12 @@ end function Cauldron:Enable() Cauldron.vars.enabled = true; + self:Print(L["enabled"]); end function Cauldron:Disable() Cauldron.vars.enabled = false; + self:Print(L["disabled"]); Cauldron:Frame_Hide(); end @@ -1018,6 +1049,9 @@ function Cauldron:Reset() Cauldron:Frame_Hide(); HideUIPanel(TradeSkillFrame); + -- reset some internal variables + self.vars.enabled = true; + -- reset the shopping list self.db.realm.shopping = CauldronShopping:NewList(); @@ -1026,6 +1060,10 @@ function Cauldron:Reset() self.db.realm.userdata[toon] = {}; self.db.realm.userdata[toon].skills = {}; self.db.realm.userdata[toon].queue = CauldronQueue:NewQueue(); + self.db.realm.userdata[toon].options = { + autoBuy = false, + compactView = false, + }; end self:Print("Reset complete."); diff --git a/CauldronUtil.lua b/CauldronUtil.lua index 754a94d..15c0129 100644 --- a/CauldronUtil.lua +++ b/CauldronUtil.lua @@ -13,7 +13,7 @@ function Cauldron:IsVendorItem(item) end end -self:debug("not found"); + self:debug("not found"); return false; end @@ -140,7 +140,7 @@ function Cauldron:ScanBags() for i=1,GetContainerNumSlots(bagid) do local link = GetContainerItemLink(bagid, i); if link then - local name = select(1, {GetItemInfo(link)}); + local name,_ = GetItemInfo(link); local count = GetItemCount(link); self.vars.inventory[name] = count; @@ -168,13 +168,13 @@ function Cauldron:GetItemDeltas(bagid) for i=1,GetContainerNumSlots(bagid) do local link = GetContainerItemLink(bagid, i); if link then - local name = select(1, {GetItemInfo(link)}); + local name,_ = GetItemInfo(link); local count = GetItemCount(link); -- local count = select(2, {GetContainerItemInfo(bagid, i)}); local delta = count; if inv[name] then - delta = count - inv[name].count; + delta = count - inv[name]; end if delta ~= 0 then @@ -193,7 +193,7 @@ function Cauldron:GetMerchantItems() for i=1,GetMerchantNumItems() do local name, _, price, quantity, avail, _, extCost = GetMerchantItemInfo(i); - Cauldron:info("MERCHANT: item="..name.."; price="..tostring(price).."; quantity="..tostring(quantity).."; avail="..tostring(avail).."; extCost="..tostring(extCost)); + -- Cauldron:info("MERCHANT: item="..name.."; price="..tostring(price).."; quantity="..tostring(quantity).."; avail="..tostring(avail).."; extCost="..tostring(extCost)); local maxStack = GetMerchantItemMaxStack(i); if avail ~= 0 then diff --git a/Locale/Cauldron-enUS.lua b/Locale/Cauldron-enUS.lua index 05d66da..8c2a75e 100644 --- a/Locale/Cauldron-enUS.lua +++ b/Locale/Cauldron-enUS.lua @@ -25,7 +25,11 @@ L["Use Cauldron as your tradeskill interface"] = true L["Disable Cauldron"] = true L["Use the standard Blizzard window as your tradeskill interface"] = true L["Logging"] = true -L["Sets the logging level"] = true +L["Sets or displays the logging level"] = true +L["Normal logging of warnings and errors"] = true +L["Debug logging (very verbose)"] = true +L["enabled"] = true +L["disabled"] = true L["Auto-buy?"] = true L["If this option is checked, then any item that is in the list will be automatically purchased when a vendor window is opened, if that vendor has the items."] = true