Mercurial > wow > itemauditor
comparison Core.lua @ 23:819bfdc5d73c
More debug messages and added the ability to scroll the debug window.
| author | Asa Ayers <Asa.Ayers@Gmail.com> |
|---|---|
| date | Thu, 08 Jul 2010 23:55:05 -0700 |
| parents | 66b7c3f5937e |
| children | 554b30908b33 |
comparison
equal
deleted
inserted
replaced
| 22:66b7c3f5937e | 23:819bfdc5d73c |
|---|---|
| 24 }, | 24 }, |
| 25 profile = { | 25 profile = { |
| 26 messages = { | 26 messages = { |
| 27 cost_updates = true, | 27 cost_updates = true, |
| 28 queue_skip = false, | 28 queue_skip = false, |
| 29 } | 29 }, |
| 30 -- This is for development, so I have no plans to turn it into an option. | |
| 31 show_debug_frame_on_startup = false, | |
| 30 }, | 32 }, |
| 31 factionrealm = { | 33 factionrealm = { |
| 32 item_account = {}, | 34 item_account = {}, |
| 33 items = {}, | 35 items = {}, |
| 34 }, | 36 }, |
| 38 self.items = self.db.factionrealm.items | 40 self.items = self.db.factionrealm.items |
| 39 | 41 |
| 40 self:RegisterOptions() | 42 self:RegisterOptions() |
| 41 | 43 |
| 42 self:RegisterEvent("PLAYER_ENTERING_WORLD") | 44 self:RegisterEvent("PLAYER_ENTERING_WORLD") |
| 45 | |
| 46 -- /run ItemAuditor.db.profile.show_debug_frame_on_startup = true | |
| 47 if self.db.profile.show_debug_frame_on_startup then | |
| 48 ItemAuditor_DebugFrame:Show() | |
| 49 end | |
| 43 end | 50 end |
| 44 | 51 |
| 45 function addon:ConvertItems() | 52 function addon:ConvertItems() |
| 46 for itemName, value in pairs(self.db.factionrealm.item_account) do | 53 for itemName, value in pairs(self.db.factionrealm.item_account) do |
| 47 local itemID = self:GetItemID(itemName) | 54 local itemID = self:GetItemID(itemName) |
| 95 local diff = {} | 102 local diff = {} |
| 96 | 103 |
| 97 for link, count in pairs(current.items) do | 104 for link, count in pairs(current.items) do |
| 98 if pastInventory.items[link] == nil then | 105 if pastInventory.items[link] == nil then |
| 99 diff[link] = count | 106 diff[link] = count |
| 100 -- self:Debug("1 diff[" .. name .. "]=" .. diff[name]) | 107 self:Debug("1 diff[" .. link .. "]=" .. diff[link]) |
| 101 elseif count - pastInventory.items[link] ~= 0 then | 108 elseif count - pastInventory.items[link] ~= 0 then |
| 102 diff[link] = count - pastInventory.items[link] | 109 diff[link] = count - pastInventory.items[link] |
| 103 -- self:Debug("2 diff[" .. name .. "]=" .. diff[name]) | 110 self:Debug("2 diff[" .. link .. "]=" .. diff[link]) |
| 104 end | 111 end |
| 105 end | 112 end |
| 106 | 113 |
| 107 for link, count in pairs(pastInventory.items) do | 114 for link, count in pairs(pastInventory.items) do |
| 108 if current.items[link] == nil then | 115 if current.items[link] == nil then |
| 109 diff[link] = -count | 116 diff[link] = -count |
| 110 -- self:Debug("3 diff[" .. name .. "]=" .. diff[name]) | 117 self:Debug("3 diff[" .. link .. "]=" .. diff[link]) |
| 111 elseif current.items[link] - count ~= 0 then | 118 elseif current.items[link] - count ~= 0 then |
| 112 diff[link] = current.items[link] - pastInventory.items[link] | 119 diff[link] = current.items[link] - pastInventory.items[link] |
| 113 -- self:Debug("4 diff[" .. name .. "]=" .. diff[name]) | 120 self:Debug("4 diff[" .. link .. "]=" .. diff[link]) |
| 114 end | 121 end |
| 115 end | 122 end |
| 116 | 123 |
| 117 local moneyDiff = current.money - pastInventory.money | 124 local moneyDiff = current.money - pastInventory.money |
| 125 if abs(moneyDiff) > 0 then | |
| 126 self:Debug("moneyDiff: " .. moneyDiff) | |
| 127 end | |
| 118 | 128 |
| 119 return {items = diff, money = moneyDiff} | 129 return {items = diff, money = moneyDiff} |
| 120 end | 130 end |
| 121 | 131 |
| 122 | 132 |
| 170 self:Debug("Unhandled mail type: " .. mailType) | 180 self:Debug("Unhandled mail type: " .. mailType) |
| 171 self:Debug(msgSubject) | 181 self:Debug(msgSubject) |
| 172 end | 182 end |
| 173 | 183 |
| 174 end | 184 end |
| 185 | |
| 186 for mailType, collection in pairs(results) do | |
| 187 for item, total in pairs(collection) do | |
| 188 self:Debug(format("|cFF00FF00MailScan|r: %s - %s - %s", mailType, item, total)) | |
| 189 end | |
| 190 end | |
| 191 | |
| 175 return results | 192 return results |
| 176 end | 193 end |
| 177 | 194 |
| 178 function addon:GetItem(link, viewOnly) | 195 function addon:GetItem(link, viewOnly) |
| 179 if viewOnly == nil then | 196 if viewOnly == nil then |
| 227 self.items[link] = nil | 244 self.items[link] = nil |
| 228 end | 245 end |
| 229 end | 246 end |
| 230 | 247 |
| 231 function addon:SaveValue(link, value) | 248 function addon:SaveValue(link, value) |
| 249 self:Debug(format("SaveValue(%s, %s)", tostring(link), value)) | |
| 232 local item = nil | 250 local item = nil |
| 233 local realLink = self:GetSafeLink(link) | 251 local realLink = self:GetSafeLink(link) |
| 234 local itemName = nil | 252 local itemName = nil |
| 235 if realLink == nil then | 253 if realLink == nil then |
| 254 self:Debug('SaveValue: GetSafeLink failed, falling back to storing by name: ' .. tostring(itemName)) | |
| 236 itemName = link | 255 itemName = link |
| 237 self.db.factionrealm.item_account[itemName] = (self.db.factionrealm.item_account[itemName] or 0) + value | 256 self.db.factionrealm.item_account[itemName] = (self.db.factionrealm.item_account[itemName] or 0) + value |
| 238 item = {invested = self.db.factionrealm.item_account[itemName], count = 1} | 257 item = {invested = self.db.factionrealm.item_account[itemName], count = 1} |
| 239 else | 258 else |
| 259 | |
| 240 item = self:GetItem(realLink) | 260 item = self:GetItem(realLink) |
| 241 item.invested = item.invested + value | 261 item.invested = item.invested + value |
| 242 itemName = GetItemInfo(realLink) | 262 itemName = GetItemInfo(realLink) |
| 243 end | 263 end |
| 244 | 264 |
| 265 addon:UpdateQAThreshold(realLink) | 285 addon:UpdateQAThreshold(realLink) |
| 266 end | 286 end |
| 267 end | 287 end |
| 268 | 288 |
| 269 | 289 |
| 270 local defaultBagDelay = 0.2 | 290 function addon:WatchBags() |
| 271 | |
| 272 function addon:WatchBags(delay) | |
| 273 delay = delay or defaultBagDelay | |
| 274 if delay ~= self.currentBagDelay then | |
| 275 self:UnwatchBags() | |
| 276 end | |
| 277 | |
| 278 if self.watch_handle == nil then | 291 if self.watch_handle == nil then |
| 279 self.currentBagDelay = delay | |
| 280 self:Debug("currentBagDelay = " .. delay) | |
| 281 addon:UpdateCurrentInventory() | 292 addon:UpdateCurrentInventory() |
| 282 self.watch_handle = self:RegisterBucketEvent({"BAG_UPDATE", "PLAYER_MONEY"}, self.currentBagDelay, "UpdateAudit") | 293 self.watch_handle = self:RegisterBucketEvent({"BAG_UPDATE", "PLAYER_MONEY"}, 0.3, "UpdateAudit") |
| 283 end | 294 end |
| 284 end | 295 end |
| 285 | 296 |
| 286 function addon:UnwatchBags() | 297 function addon:UnwatchBags() |
| 287 if self.watch_handle ~= nil then | 298 if self.watch_handle ~= nil then |
