changeset 63:e7d287cc3b02

Replaced all instances of addon with ItemAuditor and I moved ItemAuditor out of the global namespace. The conversion was mostly a search/replace offering no new functionality. That will come in a later commit.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Tue, 27 Jul 2010 17:58:33 -0700
parents 70dc84df13b3
children e92a5adf75bf
files CHANGELOG.txt Core.lua Modules/Crafting.lua Modules/Debug.lua Modules/DisplayInvested.lua Modules/Events.lua Modules/Frames.lua Modules/Options.lua Modules/QuickAuctions.lua Modules/Tooltip.lua Modules/Utils.lua
diffstat 11 files changed, 145 insertions(+), 149 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGELOG.txt	Tue Jul 27 17:52:21 2010 -0700
+++ b/CHANGELOG.txt	Tue Jul 27 17:58:33 2010 -0700
@@ -1,6 +1,7 @@
 2010-07-27  Asa Ayers  <Asa.Ayers@Gmail.com>
 
 - Fixed an infinite loop when when adding items to the Skillet queue from the crafting interface.
+- For Developers: Changed ItemAuditor to no longer be in the global namespace
 
 2010-07-25  Asa Ayers  <Asa.Ayers@Gmail.com>
 
--- a/Core.lua	Tue Jul 27 17:52:21 2010 -0700
+++ b/Core.lua	Tue Jul 27 17:58:33 2010 -0700
@@ -1,7 +1,5 @@
-local addonName, addonTable = ...; 
-_G[addonName] = LibStub("AceAddon-3.0"):NewAddon(addonName, "AceEvent-3.0", "AceBucket-3.0")
-local addon = _G[addonName]
-addonTable.ItemAuditor = addon
+local ItemAuditor = select(2, ...)
+ItemAuditor = LibStub("AceAddon-3.0"):NewAddon(ItemAuditor, "ItemAuditor", "AceEvent-3.0", "AceBucket-3.0")
 
 local WHITE		= "|cFFFFFFFF"
 local RED		= "|cFFFF0000"
@@ -11,7 +9,7 @@
 local TEAL		= "|cFF00FF9A"
 local GOLD		= "|cFFFFD700"
 
-function addon:OnInitialize()
+function ItemAuditor:OnInitialize()
 	local DB_defaults = {
 		char = {
 			ah = 1,
@@ -25,7 +23,7 @@
 				cost_updates = true,
 				queue_skip = false,
 			},
-			addon_enabled = true,
+			ItemAuditor_enabled = true,
 			-- This is for development, so I have no plans to turn it into an option.
 			show_debug_frame_on_startup = false,
 		},
@@ -36,7 +34,6 @@
 		},
 	}
 	self.db = LibStub("AceDB-3.0"):New("ItemAuditorDB", DB_defaults, true)
-	addonTable.db= self.db
 	self.items = self.db.factionrealm.items
 	
 	self:RegisterOptions()
@@ -53,8 +50,8 @@
 end
 
 local registeredEvents = {}
-local originalRegisterEvent = addon.RegisterEvent 
-function addon:RegisterEvent(event, callback, arg)
+local originalRegisterEvent = ItemAuditor.RegisterEvent 
+function ItemAuditor:RegisterEvent(event, callback, arg)
 	registeredEvents[event] = true
 	if arg ~= nil then
 		return originalRegisterEvent(self, event, callback, arg)
@@ -65,24 +62,24 @@
 	end
 end
 
-local originalUnregisterEvent = addon.UnregisterEvent
-function addon:UnregisterEvent(event)
+local originalUnregisterEvent = ItemAuditor.UnregisterEvent
+function ItemAuditor:UnregisterEvent(event)
 	registeredEvents[event] = nil
         return originalUnregisterEvent(self, event)
 end
 
-function addon:UnregisterAllEvents()
+function ItemAuditor:UnregisterAllEvents()
 	for event in pairs(registeredEvents) do
 		self:UnregisterEvent(event)
 	end
 end
 
 local registeredFrames = {}
-function addon:RegisterFrame(frame)
+function ItemAuditor:RegisterFrame(frame)
 	tinsert(registeredFrames, frame)
 end
 
-function addon:HideAllFrames()
+function ItemAuditor:HideAllFrames()
 	for key, frame in pairs(registeredFrames) do
 		if frame then
 			frame:Hide()
@@ -90,7 +87,7 @@
 	end
 end
 
-function addon:ConvertItems()
+function ItemAuditor:ConvertItems()
 	for itemName, value in pairs(self.db.factionrealm.item_account) do
 		local itemID = self:GetItemID(itemName)
 		if itemID ~= nil then
@@ -111,12 +108,12 @@
 end
 
 local printPrefix = "|cFFA3CEFFItemAuditor|r: "
-function addon:Print(message, ...)
+function ItemAuditor:Print(message, ...)
 	message = format(message, ...)
 	self:GetSelectedChatWindow():AddMessage( printPrefix .. tostring(message))
 end
 
-function addon:GetCurrentInventory()
+function ItemAuditor:GetCurrentInventory()
 	local i = {}
 	local bagID
 	local slotID
@@ -136,7 +133,7 @@
 	return {items = i, money = GetMoney()}
 end
 
-function addon:GetInventoryDiff(pastInventory, current)
+function ItemAuditor:GetInventoryDiff(pastInventory, current)
 	if current == nil then
 		current = self:GetCurrentInventory()
 	end
@@ -172,7 +169,7 @@
 
 local inboundCOD = {}
 local skipMail = {}
-function addon:ScanMail()
+function ItemAuditor:ScanMail()
 	local results = {}
 	local CODPaymentRegex = gsub(COD_PAYMENT, "%%s", "(.*)")
 	
@@ -279,7 +276,7 @@
 	return results   
 end
 
-function addon:GetItem(link, viewOnly)
+function ItemAuditor:GetItem(link, viewOnly)
 	if viewOnly == nil then
 		viewOnly = false
 	end
@@ -330,18 +327,18 @@
 	return self.items[link]
 end
 
-function addon:RemoveItem(link)
+function ItemAuditor:RemoveItem(link)
 	self.db.factionrealm.item_account[link] = nil
 	link = self:GetSafeLink(link)
 	if link ~= nil then
-		local item = addon:GetItem(link)
+		local item = ItemAuditor:GetItem(link)
 		item.invested = 0
 	else
 		self:Debug('Failed to convert link' .. tostring(link))
 	end
 end
 
-function addon:SaveValue(link, value, countChange)
+function ItemAuditor:SaveValue(link, value, countChange)
 	self:Debug("SaveValue(%s, %s, %s)", tostring(link), value, (countChange or 'default'))
 	countChange = countChange or 0
 	local item = nil
@@ -386,20 +383,20 @@
 	end
 	
 	if realLink ~= nil then
-		addon:UpdateQAThreshold(realLink)
+		ItemAuditor:UpdateQAThreshold(realLink)
 	end
 	UpdateInvestedData()
 end
 
 
-function addon:WatchBags()
+function ItemAuditor:WatchBags()
 	if self.watch_handle == nil then
-		addon:UpdateCurrentInventory()
+		ItemAuditor:UpdateCurrentInventory()
 		self.watch_handle = self:RegisterBucketEvent({"BAG_UPDATE", "PLAYER_MONEY"}, 0.3, "UpdateAudit")
 	end
 end
 
-function addon:UnwatchBags()
+function ItemAuditor:UnwatchBags()
 	if self.watch_handle ~= nil then
 		self:UnregisterBucket(self.watch_handle)
 		self.watch_handle = nil
@@ -407,7 +404,7 @@
 end
 
 
-function addon:GetSafeLink(link)
+function ItemAuditor:GetSafeLink(link)
 	local newLink = nil
 
 	if link and link == string.match(link, '.-:[-0-9]+[:0-9]*') then
@@ -425,12 +422,12 @@
 	return newLink and string.gsub(newLink, ":0:0:0:0:0:0", "")
 end
 
-function addon:GetIDFromLink(link)
+function ItemAuditor:GetIDFromLink(link)
 	local _, _, _, _, Id = string.find(link, "|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?")
 	return tonumber(Id)
 end
 
-function addon:GetItemCost(link, countModifier)
+function ItemAuditor:GetItemCost(link, countModifier)
 	local item = self:GetItem(link, true)
 
 	if item.invested > 0 then
--- a/Modules/Crafting.lua	Tue Jul 27 17:52:21 2010 -0700
+++ b/Modules/Crafting.lua	Tue Jul 27 17:58:33 2010 -0700
@@ -1,5 +1,5 @@
-local addonName, addonTable = ...; 
-local ItemAuditor = _G[addonName]
+local ItemAuditor = select(2, ...)
+local Crafting = ItemAuditor:NewModule("Crafting")
 
 local AceGUI = LibStub("AceGUI-3.0")
 local ScrollingTable = LibStub("ScrollingTable")
--- a/Modules/Debug.lua	Tue Jul 27 17:52:21 2010 -0700
+++ b/Modules/Debug.lua	Tue Jul 27 17:58:33 2010 -0700
@@ -1,21 +1,22 @@
-local addonName, addonTable = ...; 
-local addon = _G[addonName]
+local ItemAuditor = select(2, ...)
+local Debug = ItemAuditor:NewModule("Debug")
+local ItemAuditor = ItemAuditor
 
-function addon:Debug(msg, ...)
+function ItemAuditor:Debug(msg, ...)
 	msg = format(msg, ...)
 	self:Log(msg, " |cffffff00DEBUG")
 end
 
-function addon:Log(message, prefix)
+function ItemAuditor:Log(message, prefix)
 	prefix = prefix or ""
 	ItemAuditor_DebugFrameTxt:AddMessage(format("%d%s|r: %s", time(), prefix, tostring(message)))
 end
 
-function addon:GetDebug(info)
+function ItemAuditor:GetDebug(info)
        return self.db.profile.messages.debug
 end
 
-function addon:SetDebug(info, input)
+function ItemAuditor:SetDebug(info, input)
        self.db.profile.messages.debug = input
        local value = "off"
        if input then
@@ -25,23 +26,23 @@
 end
 
 local function DebugEventRegistration()
-	addon.OriginalRegisterEvent = addon.RegisterEvent 
-	addon.OriginalUnregisterEvent = addon.UnregisterEvent
+	ItemAuditor.OriginalRegisterEvent = ItemAuditor.RegisterEvent 
+	ItemAuditor.OriginalUnregisterEvent = ItemAuditor.UnregisterEvent
 
-	function addon:RegisterEvent(event, callback, arg)
+	function ItemAuditor:RegisterEvent(event, callback, arg)
 	   self:Debug("RegisterEvent " .. event )
 	   if arg ~= nil then
-	      addon:OriginalRegisterEvent(event, callback, arg)
+	      ItemAuditor:OriginalRegisterEvent(event, callback, arg)
 	   elseif callback ~= nil then
-	      addon:OriginalRegisterEvent(event, callback)
+	      ItemAuditor:OriginalRegisterEvent(event, callback)
 	   else
-	      addon:OriginalRegisterEvent(event)
+	      ItemAuditor:OriginalRegisterEvent(event)
 	   end
 	end
 
-	function addon:UnregisterEvent(event)
+	function ItemAuditor:UnregisterEvent(event)
 		self:Debug("UnregisterEvent " .. event )
-		addon:OriginalUnregisterEvent (event)
+		ItemAuditor:OriginalUnregisterEvent (event)
 	end
 
 end
--- a/Modules/DisplayInvested.lua	Tue Jul 27 17:52:21 2010 -0700
+++ b/Modules/DisplayInvested.lua	Tue Jul 27 17:58:33 2010 -0700
@@ -1,5 +1,5 @@
-local addonName, addonTable = ...; 
-local ItemAuditor = _G[addonName]
+local ItemAuditor = select(2, ...)
+local DisplayInvested = ItemAuditor:NewModule("DisplayInvested")
 
 local AceGUI = LibStub("AceGUI-3.0")
 local ScrollingTable = LibStub("ScrollingTable")
--- a/Modules/Events.lua	Tue Jul 27 17:52:21 2010 -0700
+++ b/Modules/Events.lua	Tue Jul 27 17:58:33 2010 -0700
@@ -1,25 +1,25 @@
-local addonName, addonTable = ...; 
-local addon = _G[addonName]
+local ItemAuditor = select(2, ...)
+local Events = ItemAuditor:NewModule("Events", "AceEvent-3.0")
 
-function addon:OnEnable()
+function ItemAuditor:OnEnable()
 	self:RegisterEvent("MAIL_SHOW")
 	self:RegisterEvent("UNIT_SPELLCAST_START")
-	addon:UpdateCurrentInventory()
+	ItemAuditor:UpdateCurrentInventory()
 	self:WatchBags()
 	
-	self:SetEnabled(nil, self.db.profile.addon_enabled)
+	self:SetEnabled(nil, self.db.profile.ItemAuditor_enabled)
 end
 
-function addon:OnDisable()
+function ItemAuditor:OnDisable()
 	self:UnwatchBags()
 	self:UnregisterAllEvents()
-	addon:HideAllFrames()
+	ItemAuditor:HideAllFrames()
 end
  
- function addon:MAIL_SHOW()
+ function ItemAuditor:MAIL_SHOW()
 	self:Debug("MAIL_SHOW")
 	self:UnwatchBags()
-	addon:UpdateCurrentInventory()
+	ItemAuditor:UpdateCurrentInventory()
 	self.lastMailScan = self:ScanMail()
 	
 	self:UnregisterEvent("MAIL_SHOW")
@@ -31,7 +31,7 @@
 	self:RegisterEvent("MAIL_SUCCESS")
 end
 
-function addon:GenerateBlankOutbox()
+function ItemAuditor:GenerateBlankOutbox()
 	self.mailOutbox = {
 		from = UnitName("player"),
 		to = "",
@@ -124,7 +124,7 @@
 	return Orig_SendMail(recipient, subject, body, ...)
 end
 
-function addon:MAIL_SUCCESS(event)
+function ItemAuditor:MAIL_SUCCESS(event)
 	skipCODTracking = false
 	for link, data in pairs(attachedItems) do
 		self:SaveValue(link, data.price, data.count)
@@ -140,9 +140,9 @@
 	self:GenerateBlankOutbox()
 end
 
-function addon:MAIL_CLOSED()
+function ItemAuditor:MAIL_CLOSED()
 	self:Debug("MAIL_CLOSED")
-	addon:UnregisterEvent("MAIL_CLOSED")
+	ItemAuditor:UnregisterEvent("MAIL_CLOSED")
 	self:MAIL_INBOX_UPDATE()
 	self:UnregisterEvent("MAIL_INBOX_UPDATE")
 	self:RegisterEvent("MAIL_SHOW")
@@ -150,9 +150,9 @@
 end
 
 local storedCountDiff
-function addon:MAIL_INBOX_UPDATE()
+function ItemAuditor:MAIL_INBOX_UPDATE()
 	self:Debug("MAIL_INBOX_UPDATE")
-	local newScan = addon:ScanMail()
+	local newScan = ItemAuditor:ScanMail()
 	local diff
 	
 	for mailType, collection in pairs(self.lastMailScan) do
@@ -187,7 +187,7 @@
 	self.lastMailScan = newScan
 end
 
-function addon:UNIT_SPELLCAST_START(event, target, spell)
+function ItemAuditor: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()
@@ -201,7 +201,7 @@
 	The item should be destroyed before this point, so the last inventory check
 	needs to be kept so it can be combined with the up coming loot.
  ]]
-function addon:LOOT_CLOSED()
+function ItemAuditor:LOOT_CLOSED()
 	self:Debug("LOOT_CLOSED")
 	self:UnregisterEvent("LOOT_CLOSED")
 	self:UnregisterEvent("UNIT_SPELLCAST_INTERRUPTED")
@@ -210,7 +210,7 @@
 	self.lastInventory = inventory 
 end
 
-function addon:UNIT_SPELLCAST_INTERRUPTED(event, target, spell)
+function ItemAuditor: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")
@@ -219,7 +219,7 @@
 	end
 end
 
-function addon:UpdateCurrentInventory()
+function ItemAuditor:UpdateCurrentInventory()
 	self.lastInventory = self:GetCurrentInventory()
 end
 
@@ -234,7 +234,7 @@
 			The only time I know that this is a problem is when crafting a BOP item, and it 
 			is always crafted 1 at a time, so a weight of 1 will work.
 		]]
-		local ap = (addon:GetAuctionPrice(link) or 1) * change
+		local ap = (ItemAuditor:GetAuctionPrice(link) or 1) * change
 		totalWeight = totalWeight + ap
 		weights[link] = ap
 	end
@@ -245,10 +245,10 @@
 	end
 end
 
-function addon:UpdateAudit()
+function ItemAuditor:UpdateAudit()
 	-- self:Debug("UpdateAudit " .. event)
 	local currentInventory = self:GetCurrentInventory()
-	local diff =  addon:GetInventoryDiff(self.lastInventory, currentInventory)
+	local diff =  ItemAuditor:GetInventoryDiff(self.lastInventory, currentInventory)
 	
 	local positive, negative = {}, {}
 	local positiveCount, negativeCount = 0, 0
@@ -293,5 +293,5 @@
 	end
 	
 	self.lastInventory = currentInventory
-	addon:WatchBags()
+	ItemAuditor:WatchBags()
 end
\ No newline at end of file
--- a/Modules/Frames.lua	Tue Jul 27 17:52:21 2010 -0700
+++ b/Modules/Frames.lua	Tue Jul 27 17:58:33 2010 -0700
@@ -1,11 +1,11 @@
-local addonName, addonTable = ...; 
-local addon = _G[addonName]
+local ItemAuditor = select(2, ...)
+local Frames = ItemAuditor:NewModule("Frames")
 
 local AceGUI = LibStub("AceGUI-3.0")
 
 local tabs = {}
 
-function addon:RegisterTab(text, value, callback)
+function ItemAuditor:RegisterTab(text, value, callback)
 	tabs[value] = {text=text, callback=callback}
 end
 
@@ -30,7 +30,7 @@
 end
 
 
-function addon:CreateFrame(selectedTab)
+function ItemAuditor:CreateFrame(selectedTab)
 	
 	if not displayFrame then
 		-- Create the frame container
@@ -77,7 +77,7 @@
 	displayFrame:Show()
 end
 
-function addon:UpdateStatusText(message)
+function ItemAuditor:UpdateStatusText(message)
 	if displayFrame then
 		displayFrame:SetStatusText(message)
 	end
--- a/Modules/Options.lua	Tue Jul 27 17:52:21 2010 -0700
+++ b/Modules/Options.lua	Tue Jul 27 17:58:33 2010 -0700
@@ -1,5 +1,5 @@
-local addonName, addonTable = ...; 
-local addon = _G[addonName]
+local ItemAuditor = select(2, ...)
+local Options = ItemAuditor:NewModule("Options")
 
 local currentFaction = UnitFactionGroup("player")
 local AHFactions = { currentFaction, 'Neutral' }
@@ -10,12 +10,12 @@
 local currentVersion = "@project-version@"
 
 for key, value in pairs(craftingThresholds) do
-	craftingThresholdsDisplay[key] = addon:FormatMoney(value, '', true)
+	craftingThresholdsDisplay[key] = ItemAuditor:FormatMoney(value, '', true)
 	-- craftingThresholdsDisplay[key] = value
 end
 
 local windowIndex = nil
-function addon:GetChatWindowList()
+function ItemAuditor:GetChatWindowList()
 	local windows = {}
 	for i=1, NUM_CHAT_WINDOWS do
 		local name, _, _, _, _, _, shown, locked, docked = GetChatWindowInfo(i)
@@ -26,7 +26,7 @@
 	return windows
 end
 
-function addon:GetChatWindowIndex()
+function ItemAuditor:GetChatWindowIndex()
 	local cf = self.db.char.output_chat_frame
 	if not windowIndex then
 		for i=1, NUM_CHAT_WINDOWS do
@@ -42,7 +42,7 @@
 
 local selectedWindow = nil
 
-function addon:SetChatWindow(info, index)
+function ItemAuditor:SetChatWindow(info, index)
 	windowIndex = index
 	local name = GetChatWindowInfo(windowIndex)
 	
@@ -50,7 +50,7 @@
 	selectedWindow = nil
 end
 
-function addon:GetSelectedChatWindow()
+function ItemAuditor:GetSelectedChatWindow()
 	if not selectedWindow then
 		local index = self:GetChatWindowIndex()
 		if index then
@@ -63,8 +63,8 @@
 	return DEFAULT_CHAT_FRAME
 end
 
-local options = {
-	handler = addon,
+local optionsTable = {
+	handler = ItemAuditor,
 	name = "ItemAuditor "..currentVersion,
 	type = 'group',
 	args = {
@@ -123,7 +123,6 @@
 			name = "QA Options",
 			desc = "Control how ItemAuditor integrates with QuickAuctions",
 			type = 'group',
-			-- disabled = (not addon.QA_compatibile),
 			disabled = function() return not ItemAuditor:IsQACompatible() end,
 			args = {
 				toggle_qa = {
@@ -232,7 +231,7 @@
 	},
 }
 
-function addon:SetEnabled(info, enable)
+function ItemAuditor:SetEnabled(info, enable)
 	self.db.profile.addon_enabled = enable
 	if enable == self:IsEnabled() then
 		-- do nothing
@@ -245,9 +244,9 @@
 	end
 end
 
-function addon:RegisterOptions()
+function ItemAuditor:RegisterOptions()
 	self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("ItemAuditor", "ItemAuditor")
-	LibStub("AceConfig-3.0"):RegisterOptionsTable("ItemAuditor", options, {"ia"})
+	LibStub("AceConfig-3.0"):RegisterOptionsTable("ItemAuditor", optionsTable, {"ia"})
 end
 
 local function pairsByKeys (t, f)
@@ -264,35 +263,35 @@
 	return iter
 end
 
-function addon:GetCraftingThreshold()
+function ItemAuditor:GetCraftingThreshold()
 	local key = ItemAuditor.db.char.crafting_threshold
 	return craftingThresholds[key]
 end
 
-function addon:GetAuctionThreshold()
+function ItemAuditor:GetAuctionThreshold()
 	return ItemAuditor.db.char.auction_threshold
 end
 
-function addon:GetAH()
+function ItemAuditor:GetAH()
 	return ItemAuditor.db.char.ah
 end
 
-function addon:SetAH(info, value)
+function ItemAuditor:SetAH(info, value)
 	ItemAuditor.db.char.ah = value
 end
 
-function addon:GetAHCut()
+function ItemAuditor:GetAHCut()
 	if ItemAuditor.db.char.ah == 1 then
 		return 0.05
 	end
 	return 0.15
 end
 
-function addon:GetAHFaction()
+function ItemAuditor:GetAHFaction()
 	return AHFactions[ItemAuditor.db.char.ah]
 end
 
-function addon:ShowOptionsGUI()
+function ItemAuditor:ShowOptionsGUI()
 	InterfaceOptionsFrame_OpenToCategory(self.optionsFrame)
 end
 
--- a/Modules/QuickAuctions.lua	Tue Jul 27 17:52:21 2010 -0700
+++ b/Modules/QuickAuctions.lua	Tue Jul 27 17:58:33 2010 -0700
@@ -1,5 +1,5 @@
-local addonName, addonTable = ...; 
-local addon = _G[addonName]
+local ItemAuditor = select(2, ...)
+local QuickAuctions= ItemAuditor:NewModule("QuickAuctions")
 
 --[[
 	This is simply for compatibility while I change the QA API. Once
@@ -21,24 +21,24 @@
 
 
 
-function addon:IsQACompatible()
+function ItemAuditor:IsQACompatible()
 	return (QAAPI ~= nil and QAAPI.GetGroupConfig ~= nil)
 end
 
-function addon:IsQAEnabled()
-	return addon:IsQACompatible() and ItemAuditor.db.char.use_quick_auctions
+function ItemAuditor:IsQAEnabled()
+	return ItemAuditor:IsQACompatible() and ItemAuditor.db.char.use_quick_auctions
 end
 
-function addon:IsQADisabled()
+function ItemAuditor:IsQADisabled()
 	return not self:IsQAEnabled()
 end
 
-function addon:SetQAEnabled(info, value)
+function ItemAuditor:SetQAEnabled(info, value)
 	ItemAuditor.db.char.use_quick_auctions = value
 end
 
-function addon:RefreshQAGroups()
-	if not addon.IsQAEnabled() then
+function ItemAuditor:RefreshQAGroups()
+	if not ItemAuditor.IsQAEnabled() then
 		return
 	end
 	for groupName in pairs(QAAPI:GetGroups()) do
@@ -46,8 +46,8 @@
 	end
 end
 
-function addon:UpdateQAThreshold(link)
-	if not addon.IsQAEnabled() then
+function ItemAuditor:UpdateQAThreshold(link)
+	if not ItemAuditor.IsQAEnabled() then
 		return
 	end
 	_, link= GetItemInfo(link)
@@ -55,8 +55,6 @@
 	self:UpdateQAGroup(QAAPI:GetItemGroup(link))
 end
 
-addon.profit_margin = 1.15
-
 local function calculateQAThreshold(copper)
 	if copper == 0 then
 		copper = 1
@@ -64,15 +62,15 @@
 	
 	-- add my minimum profit margin
 	-- GetAuctionThreshold returns a percent as a whole number. This will convert 25 to 1.25
-	copper = copper *  (1+addon:GetAuctionThreshold())
+	copper = copper *  (1+ItemAuditor:GetAuctionThreshold())
 	
 	-- add AH Cut
-	local keep = 1 - addon:GetAHCut()
+	local keep = 1 - ItemAuditor:GetAHCut()
 	return copper/keep
 end
 
-function addon:UpdateQAGroup(groupName)
-	if not addon.IsQAEnabled() then
+function ItemAuditor:UpdateQAGroup(groupName)
+	if not ItemAuditor.IsQAEnabled() then
 		return
 	end
 	if groupName then
@@ -91,10 +89,10 @@
 end
 
 local function isProfitable(data)
-	if addon.IsQAEnabled() then
+	if ItemAuditor.IsQAEnabled() then
 		local QAGroup = QAAPI:GetItemGroup(data.link)
 		if QAGroup ~= nil then
-			local currentInvested, _, currentCount = addon:GetItemCost(data.link)
+			local currentInvested, _, currentCount = ItemAuditor:GetItemCost(data.link)
 			local threshold, postCap, perAuction = QAAPI:GetGroupConfig(QAGroup)
 			local stackSize = postCap * perAuction
 			
@@ -120,7 +118,7 @@
 --[[
 	This is based on KTQ
 ]]
-function addon:Queue()
+function ItemAuditor:Queue()
 	if LSW == nil then
 		self:Print("This feature requires LilSparky's Workshop.")
 		return
@@ -137,7 +135,7 @@
 	end
 	
 	
-	if addon.IsQAEnabled() then
+	if ItemAuditor.IsQAEnabled() then
 		self:Debug("Auction Threshold: %d%%", self:GetAuctionThreshold()*100 )
 	end
 	self:Debug(format("Crafting Threshold: %s", self:FormatMoney(self:GetCraftingThreshold())))
@@ -165,7 +163,7 @@
 			
 			-- if QA isn't enabled, this will just return nil
 			local QAGroup = nil
-			if addon.IsQAEnabled() then
+			if ItemAuditor.IsQAEnabled() then
 				QAGroup = QAAPI:GetItemGroup(itemLink)
 				if QAGroup ~= nil then
 					local threshold, postCap, perAuction = QAAPI:GetGroupConfig(QAGroup)
@@ -188,20 +186,20 @@
 				for reagentId = 1, GetTradeSkillNumReagents(i) do
 					_, _, reagentCount = GetTradeSkillReagentInfo(i, reagentId);
 					reagentLink = GetTradeSkillReagentItemLink(i, reagentId)
-					newCost = newCost + addon:GetReagentCost(reagentLink, reagentCount)  
+					newCost = newCost + ItemAuditor:GetReagentCost(reagentLink, reagentCount)
 				end
 				
-				local currentInvested, _, currentCount = addon:GetItemCost(itemLink)
+				local currentInvested, _, currentCount = ItemAuditor:GetItemCost(itemLink)
 				local newThreshold = (newCost + currentInvested) / (currentCount + toQueue)
 				
-				if addon.IsQAEnabled() then
+				if ItemAuditor.IsQAEnabled() then
 					newThreshold = calculateQAThreshold(newThreshold)
 				else
 					-- if quick auctions isn't enabled, this will cause the decision to rely
 					-- completly on the crafting threshold
 					newThreshold = 0
 				end
-				local currentPrice = addon:GetAuctionPrice(itemLink) or 0
+				local currentPrice = ItemAuditor:GetAuctionPrice(itemLink) or 0
 				numChecked = numChecked  + 1
 				
 				if newThreshold < currentPrice and (currentPrice - newCost) > self:GetCraftingThreshold() then
@@ -215,11 +213,11 @@
 					}
 					profitableIndex = profitableIndex + 1
 				else
-					local skipMessage = format("Skipping %s x%s. Profit: %s ", itemLink, toQueue, addon:FormatMoney(currentPrice - newCost))
+					local skipMessage = format("Skipping %s x%s. Profit: %s ", itemLink, toQueue, ItemAuditor: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)))
+						self:Debug(format("Skipping %s x%s. Profit: %s ", itemLink, toQueue, ItemAuditor:FormatMoney(currentPrice - newCost)))
 					end
 				end
 			end
@@ -240,7 +238,7 @@
 	self:Print(format("%d queued", numAdded))
 end
 
-function addon:GetReagentCost(link, total)
+function ItemAuditor:GetReagentCost(link, total)
 	local totalCost = 0
 	
 	if Skillet:VendorSellsReagent(link) then
@@ -250,7 +248,7 @@
 	end
 
 	
-	local investedTotal, investedPerItem, count = addon:GetItemCost(link)
+	local investedTotal, investedPerItem, count = ItemAuditor:GetItemCost(link)
 	
 	if count > 0 then
 		if total <= count then
@@ -270,7 +268,7 @@
 	return totalCost + (ahPrice * total)
 end
 
-function addon:GetAuctionPrice(itemLink)
+function ItemAuditor:GetAuctionPrice(itemLink)
 	if GetAuctionBuyout ~= nil then
 		return GetAuctionBuyout(itemLink)
 	elseif AucAdvanced and AucAdvanced.Version then
@@ -280,7 +278,7 @@
 	return nil
 end
 
-function addon:AddToQueue(skillId,skillIndex, toQueue)
+function ItemAuditor:AddToQueue(skillId,skillIndex, toQueue)
 	if Skillet == nil then
 		self:Print("Skillet not loaded")
 		return
--- a/Modules/Tooltip.lua	Tue Jul 27 17:52:21 2010 -0700
+++ b/Modules/Tooltip.lua	Tue Jul 27 17:58:33 2010 -0700
@@ -1,5 +1,5 @@
-local addonName, addonTable = ...; 
-local addon = _G[addonName]
+local ItemAuditor = select(2, ...)
+local Tooltip = ItemAuditor:NewModule("Tooltip")
 
 local function ShowTipWithPricing(tip, link, num)
 	if (link == nil) then
@@ -11,12 +11,12 @@
 
 	local investedTotal, investedPerItem, count = ItemAuditor:GetItemCost(link)
 	
-	local keep = 1 - addon:GetAHCut()
+	local keep = 1 - ItemAuditor:GetAHCut()
 	local show = false
 
 	if investedTotal > 0 then
 		local suggestColor
-		local ap = addon:GetAuctionPrice(link)
+		local ap = ItemAuditor:GetAuctionPrice(link)
 		if ap == nil then
 			suggestColor = nil
 		elseif ap > ceil(investedPerItem/keep) then
@@ -26,18 +26,18 @@
 		end
 	
 	
-		tip:AddDoubleLine("\124cffffffffIA: Total Invested", addon:FormatMoney(investedTotal));
-		tip:AddDoubleLine("\124cffffffffIA: Invested per Item (own: " .. count .. ")", addon:FormatMoney(ceil(investedPerItem)));
-		tip:AddDoubleLine("\124cffffffffIA: Minimum " .. addon:GetAHFaction() .. " AH Price: ", addon:FormatMoney(ceil(investedPerItem/keep), suggestColor))
+		tip:AddDoubleLine("\124cffffffffIA: Total Invested", ItemAuditor:FormatMoney(investedTotal));
+		tip:AddDoubleLine("\124cffffffffIA: Invested per Item (own: " .. count .. ")", ItemAuditor:FormatMoney(ceil(investedPerItem)));
+		tip:AddDoubleLine("\124cffffffffIA: Minimum " .. ItemAuditor:GetAHFaction() .. " AH Price: ", ItemAuditor:FormatMoney(ceil(investedPerItem/keep), suggestColor))
 		show = true
 		
 	end
 	
-	if addon:IsQAEnabled() then
+	if ItemAuditor:IsQAEnabled() then
 		local groupName = QAAPI:GetItemGroup(link)
 		if groupName then
 			local threshold = QAAPI:GetGroupConfig(groupName)
-			tip:AddDoubleLine("\124cffffffffIA: QA Threshold: ", addon:FormatMoney(threshold))
+			tip:AddDoubleLine("\124cffffffffIA: QA Threshold: ", ItemAuditor:FormatMoney(threshold))
 			show = true
 		end
 	end
--- a/Modules/Utils.lua	Tue Jul 27 17:52:21 2010 -0700
+++ b/Modules/Utils.lua	Tue Jul 27 17:58:33 2010 -0700
@@ -1,7 +1,7 @@
-local addonName, addonTable = ...; 
-local addon = _G[addonName]
+local ItemAuditor = select(2, ...)
+local Utils = ItemAuditor:NewModule("Utils")
 
-function addon:FormatMoney(copper, color, textOnly)
+function ItemAuditor:FormatMoney(copper, color, textOnly)
 	color = color or "|cFFFFFFFF"
 	local prefix = ""
 	if copper < 0 then
@@ -67,13 +67,13 @@
 -- This is only here to make sure this doesn't blow up if ReplaceItemCache is never called
 local item_db = {}
 
-function addon:ReplaceItemCache(new_cache)
+function ItemAuditor:ReplaceItemCache(new_cache)
 	item_db  = new_cache
 end
 
 -- This will be reset every session
 local tmp_item_cache = {}
-function addon:GetItemID(itemName)
+function ItemAuditor:GetItemID(itemName)
 	if item_db[itemName] ~= nil then
 		return item_db[itemName]
 	end
@@ -100,7 +100,7 @@
 	return tmp_item_cache[itemName]
 end
 
-function addon:GetLinkFromName(itemName)
+function ItemAuditor:GetLinkFromName(itemName)
 	local itemID = self:GetItemID(itemName)
 	local itemLink
 	if itemID ~= nil then
@@ -110,11 +110,11 @@
 	return itemLink
 end
 
-function addon:SaveItemID(itemName, id)
+function ItemAuditor:SaveItemID(itemName, id)
 	item_db[itemName] = tonumber(id)
 end
 
-addon.SubjectPatterns = {
+ItemAuditor.SubjectPatterns = {
 	AHCancelled = gsub(AUCTION_REMOVED_MAIL_SUBJECT, "%%s", ".*"),
 	AHExpired = gsub(AUCTION_EXPIRED_MAIL_SUBJECT, "%%s", ".*"),
 	AHOutbid = gsub(AUCTION_OUTBID_MAIL_SUBJECT, "%%s", ".*"),
@@ -123,7 +123,7 @@
 	CODPayment = gsub(COD_PAYMENT, "%%s", "(.*)"),
 }
 
-function addon:GetMailType(msgSubject)
+function ItemAuditor:GetMailType(msgSubject)
 	if msgSubject then
 		for k, v in pairs(self.SubjectPatterns) do
 			if msgSubject:find(v) then return k end
@@ -132,7 +132,7 @@
 	return "NonAHMail"
 end
 
-function addon:tcount(tab)
+function ItemAuditor:tcount(tab)
    local n = #tab
    if (n == 0) then
       for _ in pairs(tab) do
@@ -142,11 +142,11 @@
    return n
 end
 
-function addon:GetDebug(info)
+function ItemAuditor:GetDebug(info)
 	return self.db.char.debug
 end
 
-function addon:SetDebug(info, input)
+function ItemAuditor:SetDebug(info, input)
 	
 	ItemAuditor.db.char.debug = input
 	local value = "off"