Mercurial > wow > itemauditor
comparison Core.lua @ 65:32d53abee666
Converting ItemAuditor modules into true modules instead of a bunch of files that all write to the ItemAuditor table.
| author | Asa Ayers <Asa.Ayers@Gmail.com> |
|---|---|
| date | Tue, 27 Jul 2010 18:15:38 -0700 |
| parents | e7d287cc3b02 |
| children | b6c30a5156f9 |
comparison
equal
deleted
inserted
replaced
| 64:e92a5adf75bf | 65:32d53abee666 |
|---|---|
| 1 local ItemAuditor = select(2, ...) | 1 local ItemAuditor = select(2, ...) |
| 2 ItemAuditor = LibStub("AceAddon-3.0"):NewAddon(ItemAuditor, "ItemAuditor", "AceEvent-3.0", "AceBucket-3.0") | 2 ItemAuditor = LibStub("AceAddon-3.0"):NewAddon(ItemAuditor, "ItemAuditor", "AceEvent-3.0", "AceBucket-3.0") |
| 3 --@debug@ | |
| 4 _G['ItemAuditor'] = ItemAuditor | |
| 5 --@end-debug@ | |
| 3 | 6 |
| 4 local WHITE = "|cFFFFFFFF" | 7 local WHITE = "|cFFFFFFFF" |
| 5 local RED = "|cFFFF0000" | 8 local RED = "|cFFFF0000" |
| 6 local GREEN = "|cFF00FF00" | 9 local GREEN = "|cFF00FF00" |
| 7 local YELLOW = "|cFFFFFF00" | 10 local YELLOW = "|cFFFFFF00" |
| 32 items = {}, | 35 items = {}, |
| 33 outbound_cod = {}, | 36 outbound_cod = {}, |
| 34 }, | 37 }, |
| 35 } | 38 } |
| 36 self.db = LibStub("AceDB-3.0"):New("ItemAuditorDB", DB_defaults, true) | 39 self.db = LibStub("AceDB-3.0"):New("ItemAuditorDB", DB_defaults, true) |
| 37 self.items = self.db.factionrealm.items | |
| 38 | 40 |
| 39 self:RegisterOptions() | 41 self:RegisterOptions() |
| 40 ItemAuditor:RegisterFrame(ItemAuditor_DebugFrame) | 42 ItemAuditor:RegisterFrame(ItemAuditor_DebugFrame) |
| 41 | 43 |
| 42 -- /run ItemAuditor.db.profile.show_debug_frame_on_startup = true | 44 --@debug@ |
| 43 if self.db.profile.show_debug_frame_on_startup then | |
| 44 -- ItemAuditor_DebugFrame:Show() | 45 -- ItemAuditor_DebugFrame:Show() |
| 45 -- self:CreateFrame('tab_crafting') | 46 -- self:CreateFrame('tab_crafting') |
| 46 self:RegisterEvent("TRADE_SKILL_SHOW", function() | 47 self:RegisterEvent("TRADE_SKILL_SHOW", function() |
| 47 ItemAuditor:CreateFrame('tab_crafting') | 48 ItemAuditor:CreateFrame('tab_crafting') |
| 48 end) | 49 end) |
| 49 end | 50 --@end-debug@ |
| 50 end | 51 end |
| 51 | 52 |
| 52 local registeredEvents = {} | 53 local registeredEvents = {} |
| 53 local originalRegisterEvent = ItemAuditor.RegisterEvent | 54 local originalRegisterEvent = ItemAuditor.RegisterEvent |
| 54 function ItemAuditor:RegisterEvent(event, callback, arg) | 55 function ItemAuditor:RegisterEvent(event, callback, arg) |
| 105 end | 106 end |
| 106 | 107 |
| 107 self:RefreshQAGroups() | 108 self:RefreshQAGroups() |
| 108 end | 109 end |
| 109 | 110 |
| 111 -- Options doesn't exist when this file is created the first time, so getOptions will | |
| 112 -- make one call to :GetModule and return the result and replace itself with a | |
| 113 -- function that simply returns the same object. The permanent solution will probably be | |
| 114 -- to move :Print to a different module. | |
| 115 local function getOptions() | |
| 116 local Options = ItemAuditor:GetModule("Options") | |
| 117 getOptions = function() return Options end | |
| 118 return Options | |
| 119 end | |
| 120 | |
| 110 local printPrefix = "|cFFA3CEFFItemAuditor|r: " | 121 local printPrefix = "|cFFA3CEFFItemAuditor|r: " |
| 111 function ItemAuditor:Print(message, ...) | 122 function ItemAuditor:Print(message, ...) |
| 112 message = format(message, ...) | 123 message = format(message, ...) |
| 113 self:GetSelectedChatWindow():AddMessage( printPrefix .. tostring(message)) | 124 getOptions().GetSelectedChatWindow():AddMessage( printPrefix .. tostring(message)) |
| 114 end | 125 end |
| 115 | 126 |
| 116 function ItemAuditor:GetCurrentInventory() | 127 function ItemAuditor:GetCurrentInventory() |
| 117 local i = {} | 128 local i = {} |
| 118 local bagID | 129 local bagID |
| 289 itemName = GetItemInfo(link) | 300 itemName = GetItemInfo(link) |
| 290 end | 301 end |
| 291 | 302 |
| 292 | 303 |
| 293 if self.db.factionrealm.item_account[itemName] ~= nil then | 304 if self.db.factionrealm.item_account[itemName] ~= nil then |
| 294 self.items[link] = { | 305 self.db.factionrealm.items[link] = { |
| 295 count = Altoholic:GetItemCount(self:GetIDFromLink(link)), | 306 count = Altoholic:GetItemCount(self:GetIDFromLink(link)), |
| 296 invested = abs(self.db.factionrealm.item_account[itemName] or 0), | 307 invested = abs(self.db.factionrealm.item_account[itemName] or 0), |
| 297 } | 308 } |
| 298 self.db.factionrealm.item_account[itemName] = nil | 309 self.db.factionrealm.item_account[itemName] = nil |
| 299 end | 310 end |
| 300 | 311 |
| 301 if viewOnly == false and self.items[link] == nil then | 312 if viewOnly == false and self.db.factionrealm.items[link] == nil then |
| 302 | 313 |
| 303 self.items[link] = { | 314 self.db.factionrealm.items[link] = { |
| 304 count = Altoholic:GetItemCount(self:GetIDFromLink(link)), | 315 count = Altoholic:GetItemCount(self:GetIDFromLink(link)), |
| 305 invested = abs(self.db.factionrealm.item_account[itemName] or 0), | 316 invested = abs(self.db.factionrealm.item_account[itemName] or 0), |
| 306 } | 317 } |
| 307 | 318 |
| 308 end | 319 end |
| 309 | 320 |
| 310 if self.items[link] ~= nil then | 321 if self.db.factionrealm.items[link] ~= nil then |
| 311 self.items[link].count = Altoholic:GetItemCount(self:GetIDFromLink(link)) | 322 self.db.factionrealm.items[link].count = Altoholic:GetItemCount(self:GetIDFromLink(link)) |
| 312 | 323 |
| 313 if self.items[link].invested == nil then | 324 if self.db.factionrealm.items[link].invested == nil then |
| 314 self.items[link].invested = 0 | 325 self.db.factionrealm.items[link].invested = 0 |
| 315 end | 326 end |
| 316 end | 327 end |
| 317 | 328 |
| 318 if viewOnly == true and self.items[link] == nil then | 329 if viewOnly == true and self.db.factionrealm.items[link] == nil then |
| 319 return {count = 0, invested = 0} | 330 return {count = 0, invested = 0} |
| 320 elseif viewOnly == true then | 331 elseif viewOnly == true then |
| 321 | 332 |
| 322 return {count = self.items[link].count, invested = self.items[link].invested} | 333 return {count = self.db.factionrealm.items[link].count, invested = self.db.factionrealm.items[link].invested} |
| 323 end | 334 end |
| 324 | 335 |
| 325 | 336 |
| 326 | 337 |
| 327 return self.items[link] | 338 return self.db.factionrealm.items[link] |
| 328 end | 339 end |
| 329 | 340 |
| 330 function ItemAuditor:RemoveItem(link) | 341 function ItemAuditor:RemoveItem(link) |
| 331 self.db.factionrealm.item_account[link] = nil | 342 self.db.factionrealm.item_account[link] = nil |
| 332 link = self:GetSafeLink(link) | 343 link = self:GetSafeLink(link) |
