Quantcast

several fixes. tabards will not be sold by 'Sell Gear' anymore, manually selling items via the tooltip when at a vendor will now delete items without value (which therefore cannot be sold), clicking 'Create Default Lists' will now work again

ckaotik [04-13-10 - 18:57]
several fixes. tabards will not be sold by 'Sell Gear' anymore, manually selling items via the tooltip when at a vendor will now delete items without value (which therefore cannot be sold), clicking 'Create Default Lists' will now work again
Filename
Broker_Garbage.toc
constants.lua
core.lua
helper.lua
options.lua
readme.txt
diff --git a/Broker_Garbage.toc b/Broker_Garbage.toc
index 0900cdb..51e5d23 100644
--- a/Broker_Garbage.toc
+++ b/Broker_Garbage.toc
@@ -8,7 +8,7 @@
 ## Notes: Full bags no more! Find your least valuable item .. and destroy it!
 ## Notes-deDE: Endlich wieder Platz! Finde dein billigstes Item ... und zerstöre es.
 ## Author: ckaotik
-## Version: 3.3v23
+## Version: 3.3v24
 ## X-Embeds: LibPeriodicTable-3.1
 ## X-Category: Inventory
 ## X-Credits: GarbageFu(Jaerin/wmrojer), tekKonfig(Tekkub)
diff --git a/constants.lua b/constants.lua
index 0971e55..ba8f109 100644
--- a/constants.lua
+++ b/constants.lua
@@ -100,7 +100,7 @@ local weaponTypes = { GetAuctionItemSubClasses(1) }
 local ammoTypes = { GetAuctionItemSubClasses(7) }
 BrokerGarbage.usableByClass = {
 	["DEATHKNIGHT"] = {
-		--[armorTypes[1]] = true,		-- misc
+		[armorTypes[1]] = true,		-- misc, e.g. tabards
 		[armorTypes[2]] = true,		-- cloth
 		[armorTypes[3]] = true,		-- leather
 		[armorTypes[4]] = true,		-- mail
@@ -120,7 +120,7 @@ BrokerGarbage.usableByClass = {
 		--[weaponTypes[12]] = true,	-- misc
 	},
 	["DRUID"] = {
-		--[armorTypes[1]] = true,		-- misc
+		[armorTypes[1]] = true,		-- misc, e.g. tabards
 		[armorTypes[2]] = true,		-- cloth
 		[armorTypes[3]] = true,		-- leather

@@ -136,7 +136,7 @@ BrokerGarbage.usableByClass = {
 		[weaponTypes[13]] = true,	-- daggers
 	},
 	["HUNTER"] = {
-		--[armorTypes[1]] = true,		-- misc
+		[armorTypes[1]] = true,		-- misc, e.g. tabards
 		[armorTypes[2]] = true,		-- cloth
 		[armorTypes[3]] = true,		-- leather
 		[armorTypes[4]] = true,		-- mail
@@ -159,7 +159,7 @@ BrokerGarbage.usableByClass = {
 		[ammoTypes[2]] = true,		-- bullet
 	},
 	["MAGE"] = {
-		--[armorTypes[1]] = true,		-- misc
+		[armorTypes[1]] = true,		-- misc, e.g. tabards
 		[armorTypes[2]] = true,		-- cloth
 		[weaponTypes[8]] = true,	-- 1H swords
 		[weaponTypes[10]] = true,	-- staves
@@ -170,7 +170,7 @@ BrokerGarbage.usableByClass = {

 	},
 	["PALADIN"] = {
-		--[armorTypes[1]] = true,		-- misc
+		[armorTypes[1]] = true,		-- misc, e.g. tabards
 		[armorTypes[2]] = true,		-- cloth
 		[armorTypes[3]] = true,		-- leather
 		[armorTypes[4]] = true,		-- mail
@@ -190,7 +190,7 @@ BrokerGarbage.usableByClass = {
 		[weaponTypes[17]] = true,	-- fishing rod
 	},
 	["PRIEST"] = {
-		--[armorTypes[1]] = true,		-- misc
+		[armorTypes[1]] = true,		-- misc, e.g. tabards
 		[armorTypes[2]] = true,		-- cloth
 		[weaponTypes[5]] = true,	-- 1H maces
 		[weaponTypes[10]] = true,	-- staves
@@ -200,7 +200,7 @@ BrokerGarbage.usableByClass = {
 		[weaponTypes[17]] = true,	-- fishing rod
 	},
 	["ROGUE"] = {
-		--[armorTypes[1]] = true,		-- misc
+		[armorTypes[1]] = true,		-- misc, e.g. tabards
 		[armorTypes[2]] = true,		-- cloth
 		[armorTypes[3]] = true,		-- leather
 		[weaponTypes[3]] = true,	-- bows
@@ -217,7 +217,7 @@ BrokerGarbage.usableByClass = {
 		[ammoTypes[2]] = true,		-- bullet
 	},
 	["SHAMAN"] = {
-		--[armorTypes[1]] = true,		-- misc
+		[armorTypes[1]] = true,		-- misc, e.g. tabards
 		[armorTypes[2]] = true,		-- cloth
 		[armorTypes[3]] = true,		-- leather
 		[armorTypes[4]] = true,		-- mail
@@ -236,7 +236,7 @@ BrokerGarbage.usableByClass = {
 		[weaponTypes[17]] = true,	-- fishing rod
 	},
 	["WARLOCK"] = {
-		--[armorTypes[1]] = true,		-- misc
+		[armorTypes[1]] = true,		-- misc, e.g. tabards
 		[armorTypes[2]] = true,		-- cloth
 		[weaponTypes[8]] = true,	-- 1H swords
 		[weaponTypes[10]] = true,	-- staves
@@ -246,7 +246,7 @@ BrokerGarbage.usableByClass = {
 		[weaponTypes[17]] = true,	-- fishing rod
 	},
 	["WARRIOR"] = {
-		--[armorTypes[1]] = true,		-- misc
+		[armorTypes[1]] = true,		-- misc, e.g. tabards
 		[armorTypes[2]] = true,		-- cloth
 		[armorTypes[3]] = true,		-- leather
 		[armorTypes[4]] = true,		-- mail
diff --git a/core.lua b/core.lua
index 242bc45..8d3f625 100644
--- a/core.lua
+++ b/core.lua
@@ -1,5 +1,7 @@
 -- Broker_Garbage
---   Author: ckaotik (Quay@EU-Die Todeskrallen)
+--   Author: ckaotik
+--   License: You may use this code - or parts of it - freely as long as you give proper credit. Please do not upload this addon on any kind of addon distribution website. If you got it somewhere else than Curse.com or Wowinterface.com, please send me a message/write a comment on either of those two sites.
+--   Disclaimer: I provide no warranty whatsoever for what this addon does or doesn't do, even though I try my best to keep it working ;)
 _, BrokerGarbage = ...

 -- Libraries & setting up the LDB
@@ -8,11 +10,11 @@ local LibQTip = LibStub("LibQTip-1.0")
 BrokerGarbage.PT = LibStub("LibPeriodicTable-3.1")

 -- notation mix-up for Broker2FuBar to work
-local LDB = LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("Garbage", {
+local LDB = LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("Broker_Garbage", {
 	type	= "data source",
 	icon	= "Interface\\Icons\\achievement_bg_returnxflags_def_wsg",
 	label	= "Garbage",
-	text 	= BrokerGarbage.locale.label
+	text 	= BrokerGarbage.locale.label,		-- this is a placeholder until the first scan
 })

 LDB.OnClick = function(...) BrokerGarbage:OnClick(...) end
@@ -25,8 +27,10 @@ local sellValue = 0		-- represents the actual value that we sold stuff for, oppo
 local cost = 0
 local lastReminder = time()

+BrokerGarbage.inventory = {}
 BrokerGarbage.tt = nil
 BrokerGarbage.isAtVendor = false
+BrokerGarbage.optionsModules = {}

 -- Event Handler
 -- ---------------------------------------------------------
@@ -85,7 +89,7 @@ local function eventHandler(self, event, ...)

 		BrokerGarbage:ScanInventory()

-	elseif event == "PLAYER_ENTERING_WORLD" then
+	elseif event == "PLAYER_LOGIN" then
 		BrokerGarbage:CheckSettings()

 		if not locked and loaded then
@@ -106,7 +110,7 @@ local frame = CreateFrame("frame")
 frame:RegisterEvent("MERCHANT_SHOW")
 frame:RegisterEvent("MERCHANT_CLOSED")
 frame:RegisterEvent("PLAYER_MONEY")
-frame:RegisterEvent("PLAYER_ENTERING_WORLD")
+frame:RegisterEvent("PLAYER_LOGIN")
 frame:RegisterEvent("BAG_UPDATE")

 frame:SetScript("OnEvent", eventHandler)
@@ -262,14 +266,17 @@ end
 function BrokerGarbage:OnClick(itemTable, button)
 	-- handle LDB clicks seperately
 	if not itemTable.itemID or type(itemTable.itemID) ~= "number" then
+		BrokerGarbage:Debug("No valid itemTable for OnClick")
 		itemTable = BrokerGarbage.cheapestItem
 	end
+	BrokerGarbage:Debug("ItemTable", itemTable.itemID, itemTable.value, itemTable.count, itemTable.bag, itemTable.slot)

 	-- handle different clicks
 	if itemTable and IsShiftKeyDown() then
 		-- delete or sell item, depending on if we're at a vendor or not
 		BrokerGarbage:Debug("SHIFT-Click!")
-		if BrokerGarbage.isAtVendor then
+		if BrokerGarbage.isAtVendor and itemTable.value > 0 then
+			BrokerGarbage:Debug("@Vendor", "Selling")
 			BG_GlobalDB.moneyEarned = BG_GlobalDB.moneyEarned + itemTable.value
 			BG_LocalDB.moneyEarned = BG_LocalDB.moneyEarned + itemTable.value
 			BG_GlobalDB.itemsSold = BG_GlobalDB.itemsSold + itemTable.count
@@ -277,6 +284,7 @@ function BrokerGarbage:OnClick(itemTable, button)
 			ClearCursor()
 			UseContainerItem(itemTable.bag, itemTable.slot)
 		else
+			BrokerGarbage:Debug("Not @Vendor", "Deleting")
 			BrokerGarbage:Delete(itemTable)
 		end

@@ -291,18 +299,15 @@ function BrokerGarbage:OnClick(itemTable, button)
 	elseif itemTable and IsControlKeyDown() then
 		-- add to exclude list
 		BrokerGarbage:Debug("CTRL-Click!")
-		BG_LocalDB.exclude[itemTable.itemID] = true
+		if not BG_LocalDB.exclude[itemTable.itemID] then
+			BG_LocalDB.exclude[itemTable.itemID] = true
+		end
 		BrokerGarbage:Print(format(BrokerGarbage.locale.addedToSaveList, select(2,GetItemInfo(itemTable.itemID))))

 		if BrokerGarbage.optionsLoaded then
 			BrokerGarbage:ListOptionsUpdate("exclude")
 		end

-	elseif button == "RightButton" then
-		-- open config
-		BrokerGarbage:OptionsFirstLoad()
-		InterfaceOptionsFrame_OpenToCategory(BrokerGarbage.options)
-
 	elseif itemTable and IsAltKeyDown() then
 		-- add to force vendor price list
 		BrokerGarbage:Debug("ALT-Click!")
@@ -314,6 +319,11 @@ function BrokerGarbage:OnClick(itemTable, button)
 		end
 		BrokerGarbage:ScanInventory()

+	elseif button == "RightButton" then
+		-- open config
+		BrokerGarbage:OptionsFirstLoad()
+		InterfaceOptionsFrame_OpenToCategory(BrokerGarbage.options)
+
 	else
 		-- do nothing
 	end
@@ -345,17 +355,17 @@ function BrokerGarbage:GetItemValue(itemLink, count)

 	-- calculate auction value
 	if IsAddOnLoaded("Auctionator") then
-		BrokerGarbage:Debug("Found auction addon:", "Auctionator")
+		BrokerGarbage.auctionAddon = "Auctionator"
 		auctionPrice = Atr_GetAuctionBuyout(itemLink)
 		disenchantPrice = DE and Atr_GetDisenchantValue(itemLink)

 	elseif IsAddOnLoaded("AuctionLite") then
-		BrokerGarbage:Debug("Found auction addon:", "AuctionLite")
+		BrokerGarbage.auctionAddon = "AuctionLite"
 		auctionPrice = AuctionLite:GetAuctionValue(itemLink)
 		disenchantPrice = DE and AuctionLite:GetDisenchantValue(itemLink)

 	elseif IsAddOnLoaded("WOWEcon_PriceMod") then
-		BrokerGarbage:Debug("Found auction addon:", "WoWecon")
+		BrokerGarbage.auctionAddon = "WoWecon"
 		auctionPrice = Wowecon.API.GetAuctionPrice_ByLink(itemLink)

 		if DE then
@@ -369,7 +379,7 @@ function BrokerGarbage:GetItemValue(itemLink, count)
 		end

 	elseif IsAddOnLoaded("Auc-Advanced") then
-		BrokerGarbage:Debug("Found auction addon:", "Auc-Advanced")
+		BrokerGarbage.auctionAddon = "Auc-Advanced"
 		auctionPrice = AucAdvanced.API.GetMarketValue(itemLink)

 		if DE and IsAddOnLoaded("Enchantrix") then
@@ -408,7 +418,7 @@ function BrokerGarbage:GetItemValue(itemLink, count)
 		end

 	else
-		BrokerGarbage:Debug("Found auction addon:", "Unknown")
+		BrokerGarbage.auctionAddon = "Unknown/None"
 		auctionPrice = GetAuctionBuyout and GetAuctionBuyout(itemLink) or nil
 		disenchantPrice = DE and GetDisenchantValue and GetDisenchantValue(itemLink) or nil

@@ -515,7 +525,10 @@ end
 -- ---------------------------------------------------------
 -- scans your inventory for possible junk items and updates LDB display
 function BrokerGarbage:ScanInventory()
-	BrokerGarbage.inventory = {}
+	--BrokerGarbage.inventory = {}
+	for i=1, #BrokerGarbage.inventory do
+		table.remove(BrokerGarbage.inventory, i)
+	end
 	BrokerGarbage.unopened = {}
 	local limitedItemsChecked = {}

@@ -555,7 +568,6 @@ function BrokerGarbage:ScanInventory()
 							_, isExclude = BrokerGarbage.PT:ItemInSet(itemID, setName)
 						end
 						if isExclude then
-							BrokerGarbage:Debug("Found item in set:", setName, GetItemInfo(itemID))
 							break
 						end
 					end
diff --git a/helper.lua b/helper.lua
index 261e9fe..4ace4a5 100644
--- a/helper.lua
+++ b/helper.lua
@@ -1,6 +1,6 @@
 _, BrokerGarbage = ...

-local debug = false
+local debug = true


 -- Addon Basics
@@ -88,10 +88,10 @@ end
 -- inserts some basic list settings
 function BrokerGarbage:CreateDefaultLists(global)
 	if global then
-		BG_GlobalDB.include[46106] = true											-- argentum lance
+		BG_GlobalDB.include[46069] = true											-- argentum lance
 		if not BG_GlobalDB.include[6265] then BG_GlobalDB.include[6265] = 20 end	-- soulshards
 		BG_GlobalDB.include["Consumable.Water.Conjured"] = true
-		BG_GlobalDB.forceVendorPrice["Consumable.Food.Edible"] = true
+		BG_GlobalDB.forceVendorPrice["Consumable.Food.Edible.Basic"] = true
 		BG_GlobalDB.forceVendorPrice["Consumable.Water.Basic"] = true
 	end

diff --git a/options.lua b/options.lua
index ec95f76..efe3641 100644
--- a/options.lua
+++ b/options.lua
@@ -37,12 +37,12 @@ for set, _ in pairs(BrokerGarbage.PT.sets) do
 end

 -- options panel / statistics
-BrokerGarbage.options = CreateFrame("Frame", "BrokerGarbageOptionsFrame", InterfaceOptionsFramePanelContainer)
+BrokerGarbage.options = CreateFrame("Frame", "BrokerGarbageStatisticsFrame", InterfaceOptionsFramePanelContainer)
 BrokerGarbage.options.name = "Broker_Garbage"
 BrokerGarbage.options:Hide()

 -- default / main options
-BrokerGarbage.basicOptions = CreateFrame("Frame", "BrokerGarbageOptionsPositiveFrame", InterfaceOptionsFramePanelContainer)
+BrokerGarbage.basicOptions = CreateFrame("Frame", "BrokerGarbageOptionsFrame", InterfaceOptionsFramePanelContainer)
 BrokerGarbage.basicOptions.name = BrokerGarbage.locale.BasicOptionsTitle
 BrokerGarbage.basicOptions.parent = "Broker_Garbage"
 BrokerGarbage.basicOptions:Hide()
@@ -646,7 +646,7 @@ local function ShowOptions(frame)
 	default:SetText(BrokerGarbage.locale.defaultListsText)
 	default.tiptext = BrokerGarbage.locale.defaultListsTooltip
 	default:SetWidth(150)
-	default:RegisterForClicks("RightButtonUp")
+	default:RegisterForClicks("RightButtonUp", "LeftButtonUp")
 	default:SetScript("OnClick", function(self, button)
 		BrokerGarbage:CreateDefaultLists(button == "RightButton")
 	end)
@@ -1422,26 +1422,25 @@ local function ShowListOptions(frame)
 	BrokerGarbage.optionsLoaded = true
 end

+local index = #BrokerGarbage.optionsModules
+table.insert(BrokerGarbage.optionsModules, BrokerGarbage.options)
+BrokerGarbage.optionsModules[index+1].OnShow = ShowOptions
+table.insert(BrokerGarbage.optionsModules, BrokerGarbage.basicOptions)
+BrokerGarbage.optionsModules[index+2].OnShow = ShowOptions
+table.insert(BrokerGarbage.optionsModules, BrokerGarbage.listOptionsPositive)
+BrokerGarbage.optionsModules[index+3].OnShow = ShowListOptions
+table.insert(BrokerGarbage.optionsModules, BrokerGarbage.listOptionsNegative)
+BrokerGarbage.optionsModules[index+4].OnShow = ShowListOptions
+
 local firstLoad = true
 function BrokerGarbage:OptionsFirstLoad()
 	if not firstLoad then return end

-	InterfaceOptions_AddCategory(BrokerGarbage.options)
-	InterfaceOptions_AddCategory(BrokerGarbage.basicOptions)
-	if BrokerGarbage.lootManagerOptions then
-		InterfaceOptions_AddCategory(BrokerGarbage.lootManagerOptions)
-	end
-	InterfaceOptions_AddCategory(BrokerGarbage.listOptionsPositive)
-	InterfaceOptions_AddCategory(BrokerGarbage.listOptionsNegative)
-	if BrokerGarbage.categoryTest then
-		InterfaceOptions_AddCategory(BrokerGarbage.categoryTest)
+	for i, options in pairs(BrokerGarbage.optionsModules) do
+		InterfaceOptions_AddCategory(options)
+		options:SetScript("OnShow", options.OnShow)
 	end
 	LibStub("tekKonfig-AboutPanel").new("Broker_Garbage", "Broker_Garbage")
-
-	BrokerGarbage.options:SetScript("OnShow", ShowOptions)
-	BrokerGarbage.basicOptions:SetScript("OnShow", ShowOptions)
-	BrokerGarbage.listOptionsPositive:SetScript("OnShow", ShowListOptions)
-	BrokerGarbage.listOptionsNegative:SetScript("OnShow", ShowListOptions)

 	firstLoad = false
 end
diff --git a/readme.txt b/readme.txt
index 741b470..34c3b38 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,7 +1,7 @@
 Broker_Garbage
 ==============
 Author: ckaotik
-Version: 3.3v23
+Version: 3.3v24
 WoW Version: 3.3.3 (TOC 30300)

 WoWInterface: http://www.wowinterface.com/downloads/info15531-Broker_Garbage.html
@@ -15,7 +15,7 @@ As you probably don't want to drop everything just by it's vendor price, Broker_

 2. First Start
 -----------------
-Depending on your LDB display addon you may or may not already see the Broker_Garbage plugin on it. If you don't, please check if you need to enable it in oder to be displayed (e.g. for DockingStation). It will be listed as "Garbage".
+Depending on your LDB display addon you may or may not already see the Broker_Garbage plugin on it. If you don't, please check if you need to enable it in oder to be displayed (e.g. for DockingStation). It will be listed as either "Garbage" or "Broker_Garbage".
 If you still can't find it, have a look at your options panel (ESC - Interface - Addon Tab - look for Broker_Garbage). Should you not find it there it might be because it caused an error (you can turn on Lua error messages in the Interface menu).

 If you get past that point (and really, you should) it's about time to set up your lists. For more information on lists, have at look at 5. List Management.