# HG changeset patch # User Asa Ayers # Date 1278658505 25200 # Node ID 819bfdc5d73c9d7a0d4eea4a8e4c0257ddfb870f # Parent 66b7c3f5937e194eba8f1d87c01ec69e2a9753eb More debug messages and added the ability to scroll the debug window. diff -r 66b7c3f5937e -r 819bfdc5d73c CHANGELOG.txt --- a/CHANGELOG.txt Thu Jul 08 19:30:30 2010 -0700 +++ b/CHANGELOG.txt Thu Jul 08 23:55:05 2010 -0700 @@ -3,6 +3,8 @@ - Added a (hopefully) more readable changelog. - I have removed the ability to show debug messages in the chat window and have replaced it with a new debug frame. /ia debug will show all of the debug messages and everything that IA has printed. - Fix a small bug so that if you sell something for your exact cost you don't get a message that says you made a profit of 0c. +- Added more debug messages +- The debug window will scroll with the scroll wheel 2010-07-06 Asa Ayers diff -r 66b7c3f5937e -r 819bfdc5d73c Core.lua --- a/Core.lua Thu Jul 08 19:30:30 2010 -0700 +++ b/Core.lua Thu Jul 08 23:55:05 2010 -0700 @@ -26,7 +26,9 @@ messages = { cost_updates = true, queue_skip = false, - } + }, + -- This is for development, so I have no plans to turn it into an option. + show_debug_frame_on_startup = false, }, factionrealm = { item_account = {}, @@ -40,6 +42,11 @@ self:RegisterOptions() self:RegisterEvent("PLAYER_ENTERING_WORLD") + + -- /run ItemAuditor.db.profile.show_debug_frame_on_startup = true + if self.db.profile.show_debug_frame_on_startup then + ItemAuditor_DebugFrame:Show() + end end function addon:ConvertItems() @@ -97,24 +104,27 @@ for link, count in pairs(current.items) do if pastInventory.items[link] == nil then diff[link] = count - -- self:Debug("1 diff[" .. name .. "]=" .. diff[name]) + self:Debug("1 diff[" .. link .. "]=" .. diff[link]) elseif count - pastInventory.items[link] ~= 0 then diff[link] = count - pastInventory.items[link] - -- self:Debug("2 diff[" .. name .. "]=" .. diff[name]) + self:Debug("2 diff[" .. link .. "]=" .. diff[link]) end end for link, count in pairs(pastInventory.items) do if current.items[link] == nil then diff[link] = -count - -- self:Debug("3 diff[" .. name .. "]=" .. diff[name]) + self:Debug("3 diff[" .. link .. "]=" .. diff[link]) elseif current.items[link] - count ~= 0 then diff[link] = current.items[link] - pastInventory.items[link] - -- self:Debug("4 diff[" .. name .. "]=" .. diff[name]) + self:Debug("4 diff[" .. link .. "]=" .. diff[link]) end end local moneyDiff = current.money - pastInventory.money + if abs(moneyDiff) > 0 then + self:Debug("moneyDiff: " .. moneyDiff) + end return {items = diff, money = moneyDiff} end @@ -172,6 +182,13 @@ end end + + for mailType, collection in pairs(results) do + for item, total in pairs(collection) do + self:Debug(format("|cFF00FF00MailScan|r: %s - %s - %s", mailType, item, total)) + end + end + return results end @@ -229,14 +246,17 @@ end function addon:SaveValue(link, value) + self:Debug(format("SaveValue(%s, %s)", tostring(link), value)) local item = nil local realLink = self:GetSafeLink(link) local itemName = nil if realLink == nil then + self:Debug('SaveValue: GetSafeLink failed, falling back to storing by name: ' .. tostring(itemName)) itemName = link self.db.factionrealm.item_account[itemName] = (self.db.factionrealm.item_account[itemName] or 0) + value item = {invested = self.db.factionrealm.item_account[itemName], count = 1} else + item = self:GetItem(realLink) item.invested = item.invested + value itemName = GetItemInfo(realLink) @@ -267,19 +287,10 @@ end -local defaultBagDelay = 0.2 - -function addon:WatchBags(delay) - delay = delay or defaultBagDelay - if delay ~= self.currentBagDelay then - self:UnwatchBags() - end - +function addon:WatchBags() if self.watch_handle == nil then - self.currentBagDelay = delay - self:Debug("currentBagDelay = " .. delay) addon:UpdateCurrentInventory() - self.watch_handle = self:RegisterBucketEvent({"BAG_UPDATE", "PLAYER_MONEY"}, self.currentBagDelay, "UpdateAudit") + self.watch_handle = self:RegisterBucketEvent({"BAG_UPDATE", "PLAYER_MONEY"}, 0.3, "UpdateAudit") end end diff -r 66b7c3f5937e -r 819bfdc5d73c ItemAuditor.xml --- a/ItemAuditor.xml Thu Jul 08 19:30:30 2010 -0700 +++ b/ItemAuditor.xml Thu Jul 08 23:55:05 2010 -0700 @@ -1,7 +1,7 @@ - + @@ -69,7 +69,7 @@ - + @@ -81,6 +81,21 @@ + + + local direction; + if delta > 0 then + direction = "up"; + self:ScrollUp() + else + direction = "down"; + self:ScrollDown() + end + + -- WowLua:ScrollingMessageFrameScroll(self, direction, type); + + + + + + + ItemAuditor_DebugFrame:Hide() diff -r 66b7c3f5937e -r 819bfdc5d73c Modules/Events.lua --- a/Modules/Events.lua Thu Jul 08 19:30:30 2010 -0700 +++ b/Modules/Events.lua Thu Jul 08 23:55:05 2010 -0700 @@ -18,10 +18,10 @@ self:UnregisterEvent("MAIL_SHOW") self:RegisterEvent("MAIL_CLOSED") self:RegisterEvent("MAIL_INBOX_UPDATE") - self:Debug("MAIL_SHOW complete") end function addon:MAIL_CLOSED() + self:Debug("MAIL_CLOSED") addon:UnregisterEvent("MAIL_CLOSED") self:MAIL_INBOX_UPDATE() self:UnregisterEvent("MAIL_INBOX_UPDATE") @@ -29,6 +29,7 @@ end function addon:MAIL_INBOX_UPDATE() + self:Debug("MAIL_INBOX_UPDATE") local newScan = addon:ScanMail() local diff for mailType, collection in pairs(self.lastMailScan) do @@ -48,6 +49,7 @@ function addon:UNIT_SPELLCAST_START(event, target, spell) if target == "player" and spell == "Milling" or spell == "Prospecting" or spell == "Disenchanting" then + self:Debug(event .. " " .. spell) self:UnwatchBags() self:UpdateCurrentInventory() self:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED") @@ -60,6 +62,7 @@ needs to be kept so it can be combined with the up coming loot. ]] function addon:LOOT_CLOSED() + self:Debug("LOOT_CLOSED") self:UnregisterEvent("LOOT_CLOSED") self:UnregisterEvent("UNIT_SPELLCAST_INTERRUPTED") local inventory = self.lastInventory @@ -69,6 +72,7 @@ function addon:UNIT_SPELLCAST_INTERRUPTED(event, target, spell) if target == "player" and spell == "Milling" or spell == "Prospecting" or spell == "Disenchanting" then + self:Debug(event .. " " .. spell) self:UnregisterEvent("UNIT_SPELLCAST_INTERRUPTED") self:UnregisterEvent("LOOT_CLOSED") self:WatchBags() @@ -80,11 +84,9 @@ end function addon:UpdateAudit() - -- self:Debug("UpdateAudit") + -- self:Debug("UpdateAudit " .. event) local currentInventory = self:GetCurrentInventory() local diff = addon:GetInventoryDiff(self.lastInventory, currentInventory) - -- this is only here for debugging - self.lastdiff = diff local positive, negative = {}, {} local positiveCount, negativeCount = 0, 0 @@ -98,6 +100,10 @@ end end + if positiveCount + negativeCount == 0 then + return + end + if diff.money > 0 and self:tcount(positive) > 0 and self:tcount(negative) == 0 then self:Debug("loot") elseif abs(diff.money) > 0 and self:tcount(diff.items) == 1 then @@ -106,26 +112,25 @@ for link, count in pairs(diff.items) do self:SaveValue(link, 0 - diff.money) end - elseif self:tcount(diff.items) > 1 then + elseif self:tcount(diff.items) > 1 and self:tcount(positive) > 0 and self:tcount(negative) > 0 then + -- we must have created/converted something + self:Debug("conversion") - if self:tcount(positive) > 0 and self:tcount(negative) > 0 then - -- we must have created/converted something - self:Debug("conversion") + local totalChange = 0 + for link, change in pairs(negative) do + local _, itemCost, count = self:GetItemCost(link, change) + self:SaveValue(link, itemCost * change) - local totalChange = 0 - for link, change in pairs(negative) do - local _, itemCost, count = self:GetItemCost(link, change) - self:SaveValue(link, itemCost * change) - - totalChange = totalChange + (itemCost * abs(change)) - end - - local valuePerItem = totalChange / positiveCount - - for link, change in pairs(positive) do - self:SaveValue(link, valuePerItem * change) - end + totalChange = totalChange + (itemCost * abs(change)) end + + local valuePerItem = totalChange / positiveCount + + for link, change in pairs(positive) do + self:SaveValue(link, valuePerItem * change) + end + else + self:Debug("No match in UpdateAudit.") end self.lastInventory = currentInventory diff -r 66b7c3f5937e -r 819bfdc5d73c Modules/QuickAuctions.lua --- a/Modules/QuickAuctions.lua Thu Jul 08 19:30:30 2010 -0700 +++ b/Modules/QuickAuctions.lua Thu Jul 08 23:55:05 2010 -0700 @@ -169,8 +169,13 @@ profit = (currentPrice - newCost) * toQueue } profitableIndex = profitableIndex + 1 - elseif ItemAuditor.db.profile.messages.queue_skip then - self:Print(format("Skipping %s x%s. Profit: %s ", itemLink, toQueue, addon:FormatMoney(currentPrice - newCost))) + else + local skipMessage = format("Skipping %s x%s. Profit: %s ", itemLink, toQueue, addon:FormatMoney(currentPrice - newCost)) + if ItemAuditor.db.profile.messages.queue_skip then + self:Print(skipMessage) + else + self:Debug(format("Skipping %s x%s. Profit: %s ", itemLink, toQueue, addon:FormatMoney(currentPrice - newCost))) + end end end end