Mercurial > wow > itemauditor
changeset 16:56de19d9bd8d
Cleaned up the messages. You can turn the notifications of price changes off and those messages will only show gold or silver if they are more than 0. I have also removed the dependency on AceConsole because it doesn't allow changing the color of the addon name when I print messages.
author | Asa Ayers <Asa.Ayers@Gmail.com> |
---|---|
date | Sat, 03 Jul 2010 10:05:53 -0700 |
parents | 44e70a3fdb19 |
children | e62d878c716d |
files | .pkgmeta Core.lua ItemAuditor.toc Modules/Debug.lua Modules/Options.lua Modules/Utils.lua embeds.xml |
diffstat | 7 files changed, 67 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/.pkgmeta Sat Jul 03 07:40:01 2010 -0700 +++ b/.pkgmeta Sat Jul 03 10:05:53 2010 -0700 @@ -14,9 +14,6 @@ Libs/AceConfig-3.0: url: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceConfig-3.0 tag: latest - Libs/AceConsole-3.0: - url: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceConsole-3.0 - tag: latest Libs/AceDB-3.0: url: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceDB-3.0 tag: latest
--- a/Core.lua Sat Jul 03 07:40:01 2010 -0700 +++ b/Core.lua Sat Jul 03 10:05:53 2010 -0700 @@ -1,5 +1,5 @@ local addonName, addonTable = ...; -_G[addonName] = LibStub("AceAddon-3.0"):NewAddon(addonName, "AceConsole-3.0", "AceEvent-3.0", "AceBucket-3.0") +_G[addonName] = LibStub("AceAddon-3.0"):NewAddon(addonName, "AceEvent-3.0", "AceBucket-3.0") local addon = _G[addonName] addonTable.ItemAuditor = addon @@ -17,10 +17,15 @@ function addon:OnInitialize() local DB_defaults = { char = { - debug = false, ah = 1, use_quick_auctions = false, }, + profile = { + messages = { + debug = false, + cost_updates = true, + } + }, factionrealm = { item_account = {}, items = {}, @@ -55,6 +60,11 @@ self:RefreshQAGroups() end +function addon:Print(message) + local prefix = "|cFFA3CEFF"..tostring( self ).."|r: " + DEFAULT_CHAT_FRAME:AddMessage( prefix .. message) +end + function addon:GetCurrentInventory() local i = {} local bagID @@ -229,10 +239,10 @@ end if abs(value) > 0 then - self:Debug("Updated price of " .. itemName .. " to " .. self:FormatMoney(item.invested) .. "(change: " .. self:FormatMoney(value) .. ")") - - if item.invested <= 0 then - self:Debug("Updated price of " .. itemName .. " to " ..self:FormatMoney(0)) + if item.invested <= 0 then + if self.db.profile.messages.cost_updates then + self:Print(format("Updated price of %s from %s to %s. %sYou just made a profit of %s.", itemName, self:FormatMoney(item.invested - value), self:FormatMoney(0), GREEN, self:FormatMoney(abs(item.invested)))) + end self:RemoveItem(link) -- This doesn't work when you mail the only copy of an item you have to another character. --[[ @@ -240,6 +250,10 @@ self:Print("You ran out of " .. itemName .. " and never recovered " .. self:FormatMoney(item.invested)) self:RemoveItem(link) ]] + else + if self.db.profile.messages.cost_updates then + self:Print(format("Updated price of %s from %s to %s. (total change:%s)", itemName, self:FormatMoney(item.invested - value), self:FormatMoney(item.invested), self:FormatMoney(value))) + end end end
--- a/ItemAuditor.toc Sat Jul 03 07:40:01 2010 -0700 +++ b/ItemAuditor.toc Sat Jul 03 10:05:53 2010 -0700 @@ -5,7 +5,7 @@ ## Version: 0.1 ## SavedVariables: ItemAuditorDB ## Dependencies: Altoholic -## OptionalDeps: QuickAuctions +## OptionalDeps: QuickAuctions, DevTools embeds.xml
--- a/Modules/Debug.lua Sat Jul 03 07:40:01 2010 -0700 +++ b/Modules/Debug.lua Sat Jul 03 10:05:53 2010 -0700 @@ -5,11 +5,24 @@ function addon:Debug(msg) - if self.db.char.debug then + if self.db.profile.messages.debug then self:Print(msg) end end +function addon:GetDebug(info) + return self.db.profile.messages.debug +end + +function addon:SetDebug(info, input) + self.db.profile.messages.debug = input + local value = "off" + if input then + value = "on" + end + self:Print("Debugging is now: " .. value) +end + local function DebugEventRegistration() addon.OriginalRegisterEvent = addon.RegisterEvent addon.OriginalUnregisterEvent = addon.UnregisterEvent
--- a/Modules/Options.lua Sat Jul 03 07:40:01 2010 -0700 +++ b/Modules/Options.lua Sat Jul 03 10:05:53 2010 -0700 @@ -39,6 +39,14 @@ desc = "Toggles debug messages in chat", get = "GetDebug", set = "SetDebug", + order = 100, + }, + item_cost = { + type = "toggle", + name = "Item Cost", + desc = "Shows a message every time an item's cost changes", + get = function() return ItemAuditor.db.profile.messages.cost_updates end, + set = function(info, value) ItemAuditor.db.profile.messages.cost_updates = value end, order = 0, }, }, @@ -136,15 +144,4 @@ InterfaceOptionsFrame_OpenToCategory(self.optionsFrame) end -function addon:GetDebug(info) - return self.db.char.debug -end -function addon:SetDebug(info, input) - self.db.char.debug = input - local value = "off" - if input then - value = "on" - end - self:Print("Debugging is now: " .. value) -end
--- a/Modules/Utils.lua Sat Jul 03 07:40:01 2010 -0700 +++ b/Modules/Utils.lua Sat Jul 03 10:05:53 2010 -0700 @@ -4,12 +4,33 @@ addonTable.utils = addon IAUtils = addon -function addon:FormatMoney(money) +function addon:FormatMoney(copper) + color = "|cFFFFFFFF" local prefix = "" - if money < 0 then + if copper < 0 then prefix = "-" + copper = abs(copper) end - return prefix .. Altoholic:GetMoneyString(abs(money), WHITE, false) + + local gold = floor( copper / 10000 ); + copper = mod(copper, 10000) + local silver = floor( copper / 100 ); + copper = mod(copper, 100) + + + copper = color..format(COPPER_AMOUNT_TEXTURE, copper, 13, 13) + if silver > 0 or gold > 0 then + silver = color..format(SILVER_AMOUNT_TEXTURE, silver, 13, 13) .. ' ' + else + silver = "" + end + if gold > 0 then + gold = color..format(GOLD_AMOUNT_TEXTURE, gold, 13, 13) .. ' ' + else + gold = "" + end + + return format("%s%s%s%s", prefix, gold, silver, copper) end -- This is only here to make sure this doesn't blow up if ReplaceItemCache is never called
--- a/embeds.xml Sat Jul 03 07:40:01 2010 -0700 +++ b/embeds.xml Sat Jul 03 10:05:53 2010 -0700 @@ -3,7 +3,6 @@ <Include file="Libs\CallbackHandler-1.0\CallbackHandler-1.0.xml"/> <Include file="Libs\AceGUI-3.0\AceGUI-3.0.xml"/> <Include file="Libs\AceAddon-3.0\AceAddon-3.0.xml"/> - <Include file="Libs\AceConsole-3.0\AceConsole-3.0.xml"/> <Include file="Libs\AceDB-3.0\AceDB-3.0.xml"/> <Include file="Libs\AceEvent-3.0\AceEvent-3.0.xml"/> <Include file="Libs\AceDbOptions-3.0\AceDbOptions-3.0.xml"/>