Quantcast

Added panel to check what's in those LPT categories

ckaotik [03-30-10 - 13:48]
Added panel to check what's in those LPT categories
Filename
Broker_Garbage.toc
Locale/deDE.lua
Locale/enUS.lua
category_test.lua
core.lua
options.lua
readme.txt
diff --git a/Broker_Garbage.toc b/Broker_Garbage.toc
index 6d4f4d9..0900cdb 100644
--- a/Broker_Garbage.toc
+++ b/Broker_Garbage.toc
@@ -34,4 +34,4 @@ constants.lua
 helper.lua
 core.lua
 options.lua
-#category_test.lua
\ No newline at end of file
+category_test.lua
\ No newline at end of file
diff --git a/Locale/deDE.lua b/Locale/deDE.lua
index 8caa08e..ce7ab8e 100644
--- a/Locale/deDE.lua
+++ b/Locale/deDE.lua
@@ -154,7 +154,7 @@ BrokerGarbage.locale = {
 		"[bagspacecolor]...[endcolor] zum färben",

 	-- List Options Panel
-	LOPTitle = "Positiv-Listen",
+	LOPTitle = "Whitelist",
 	LOPSubTitle = "Zum Hinzufügen ziehe Items auf das jeweilige '+'. Zum Entfernen wähle sie aus und klicke auf '-'. Nutze Kategorien per Rechts-Klick auf '+'.",

 		-- Exclude List
@@ -173,7 +173,7 @@ BrokerGarbage.locale = {
 	LOPForceEmptyTT = "|cffff0000Achtung! Shift-Klicke, um die Händlerpreisliste zu leeren",

 	-- AutoSell Options Panel
-	LONTitle = "Negativ-Listen",
+	LONTitle = "Blacklist",
 	LONSubTitle = "Analog zu den Positiv-Listen. Um eine maximale Anzahl für ein bestimmtes Item festzulegen, nutze das Mausrad über dem Item-Icon.",

 		-- Include List
@@ -192,9 +192,13 @@ BrokerGarbage.locale = {
 	LONAutoSellEmptyTT = "|cffff0000Achtung! Klicke, um die lokale Verkaufsliste zu leeren.\n"..
 		"Shift-Klicke, um die globale Verkaufsliste zu leeren",

-	-- LibPeriodicTable texts
-	PTCategoryTooltipHeader = "Kategorien hinzufügen",
-	PTCategoryTooltipText = "Füge Kategorien hinzu, indem du auf die entsprechenden Einträge clickst.",
+	-- LibPeriodicTable category testing
+	PTCategoryTest = "Teste Kategorien",
+	PTCategoryTestTitle = "LibPeriodicTable Kategorietest",
+	PTCategoryTestSubTitle = "Wenn du unsicher bist, warum ein Item irgendwo auftaucht oder welche Items zu welcher Kategorie zählen, kannst du das hier testen.",
+	PTCategoryTestExplanation = "Wähle einfach unten eine Kategorie aus und es wird dir alle Gegenstände aus deinem Inventar anzeigen, die dazuzählen.\nKategoriedaten kommen von LPT und nicht Broker_Garbage.",
+	PTCategoryTestDropdownTitle = "Kategorie, die getestet werden soll",
+	PTCategoryTestDropdownText = "Wähle eine Kategorie",
 }

 end
\ No newline at end of file
diff --git a/Locale/enUS.lua b/Locale/enUS.lua
index 7c39a63..bd844ed 100644
--- a/Locale/enUS.lua
+++ b/Locale/enUS.lua
@@ -18,12 +18,6 @@ BrokerGarbage.locale = {
 	limitSet = "%s has been assigned a limit of %d.",
 	itemDeleted = "%1$sx%2$d has been deleted.",

-	openPlease = "Please open your %s. It's in your bags, stealing your space!",
-	openClams = "You own a %s. Maybe consider opening it.",
-	couldNotLootValue = "Did not loot %s because it's too cheap.",
-	couldNotLootLocked = "Could not loot %s because it is locked. Please loot manually.",
-	couldNotLootSpace = "Could not loot %s because your inventory is full.",
-	couldNotLootLM = "%s was not looted. You are the Loot Master so please distrivute the item manually.",
 	slashCommandHelp = "The following commands are available: |cffc0c0c0/garbage|r\n"..
 		"|cffc0c0c0config|r opens the options panel.\n"..
 		"|cffc0c0c0format |cffc0c0ffformatstring|r lets you customize the LDB display text, |cffc0c0c0 format reset|r resets it.\n"..
@@ -49,7 +43,8 @@ BrokerGarbage.locale = {
 	reportNothingToSell = "Nothing to sell!",

 	-- Statistics Frame
-	StatisticsHeading = "Statistics, everone needs them!\nTo delete any part of them, click the red x.",
+	StatisticsHeading = "Statistics, everone needs them!\n"..
+		"To delete any part of them, click the red x.",

 	MemoryUsageText = "Please notice that especially after scanning your inventory the memory usage goes up a lot. It will automatically be reduced once the garbage collector kicks in.",
 	MemoryUsageTitle = "Memory Usage (kB)",
@@ -159,7 +154,7 @@ BrokerGarbage.locale = {
 		"[bagspacecolor]...[endcolor] to colorize",

 	-- List Options Panel
-	LOPTitle = "Positive Lists",
+	LOPTitle = "Whitelist",
 	LOPSubTitle = "To add Items to lists, drag them over the corresponding '+' icon, to remove them select them and click the '-'. To add categories right-click on '+'.",

 		-- Exclude List
@@ -167,8 +162,7 @@ BrokerGarbage.locale = {
 	LOPExcludePlusTT = "Add items to the Exclude List by dragging/placing them on me. Right click on me for categories!",
 	LOPExcludeMinusTT = "Select items you want to remove, then click here.",
 	LOPExcludePromoteTT = "Selected items will be written onto your global Exclude List, as seen by every character.",
-	LOPExcludeEmptyTT = "|cffff0000Caution!\n"..
-		"Click to empty your local Exclude List.\n"..
+	LOPExcludeEmptyTT = "|cffff0000Caution! Click to empty your local Exclude List.\n"..
 		"SHIFT-Click to empty your global Exclude List.",

 		-- Force Vendor Price List
@@ -176,11 +170,10 @@ BrokerGarbage.locale = {
 	LOPForcePlusTT = "Add items to the Exclude List by dragging/placing them on me. Right click on me for categories!",
 	LOPForceMinusTT = "Select items you want to remove, then click here.",
 	LOPForcePromoteTT = "The Vendor Price List is already global and effects every character.",
-	LOPForceEmptyTT = "|cffff0000Caution!\n"..
-		"SHIFT-Click to empty your Vendor Price List.",
+	LOPForceEmptyTT = "|cffff0000Caution! SHIFT-Click to empty your Vendor Price List.",

 	-- AutoSell Options Panel
-	LONTitle = "Negative Lists",
+	LONTitle = "Blacklist",
 	LONSubTitle = "Similar usage to Positive Lists. To set an item limit, use your mousewheel when over the item icon.",

 		-- Include List
@@ -188,8 +181,7 @@ BrokerGarbage.locale = {
 	LONIncludePlusTT = "Add items to the Exclude List by dragging/placing them on me. Right click on me for categories!",
 	LONIncludeMinusTT = "Select items you want to remove, then click here.",
 	LONIncludePromoteTT = "Selected items will be written onto your global Include List, as seen by every character.",
-	LONIncludeEmptyTT = "|cffff0000Caution!\n"..
-		"Click to empty your local Include List.\n"..
+	LONIncludeEmptyTT = "|cffff0000Caution! Click to empty your local Include List.\n"..
 		"SHIFT-Click to empty your global Include List.",

 		-- Auto Sell List
@@ -197,12 +189,15 @@ BrokerGarbage.locale = {
 	LONAutoSellPlusTT = "Add items to the Exclude List by dragging/placing them on me. Right click on me for categories!",
 	LONAutoSellMinusTT = "Select items you want to remove, then click here.",
 	LONAutoSellPromoteTT = "Selected items will be written onto your global Sell List, as seen by every character.",
-	LONAutoSellEmptyTT = "|cffff0000Caution!\n"..
-		"Click to empty your local Sell List.\n"..
+	LONAutoSellEmptyTT = "|cffff0000Caution! Click to empty your local Sell List.\n"..
 		"SHIFT-Click to empty your global Sell List.",

-	-- LibPeriodicTable texts
-	PTCategoryTooltipHeader = "Add Categories",
-	PTCategoryTooltipText = "Navigate through this menu and add any of these categories by clicking on them.",
+	-- LibPeriodicTable category testing
+	PTCategoryTest = "Test category strings",
+	PTCategoryTestTitle = "LibPeriodicTable Category String Test",
+	PTCategoryTestSubTitle = "If you're unsure why an item shows up as it does or which items are included in which category, you can test that here.",
+	PTCategoryTestExplanation = "Simply select a category below and it will display all items in your inventory that match this category.\nCategory information comes from LPT and not Broker_Garbage.",
+	PTCategoryTestDropdownTitle = "Category to check",
+	PTCategoryTestDropdownText = "Choose a category string",
 }

diff --git a/category_test.lua b/category_test.lua
new file mode 100644
index 0000000..646ef8f
--- /dev/null
+++ b/category_test.lua
@@ -0,0 +1,234 @@
+_, BrokerGarbage = ...
+
+BrokerGarbage:CheckSettings()
+
+-- options panel
+BrokerGarbage.categoryTest = CreateFrame("Frame", "BrokerGarbageCategoryTestFrame", InterfaceOptionsFramePanelContainer)
+BrokerGarbage.categoryTest.name = BrokerGarbage.locale.PTCategoryTest
+BrokerGarbage.categoryTest.parent = "Broker_Garbage"
+BrokerGarbage.categoryTest:Hide()
+
+-- button tooltip infos
+local function ShowTooltip(self)
+	GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
+	if self.tiptext then
+		GameTooltip:SetText(self.tiptext, nil, nil, nil, nil, true)
+	elseif self.itemLink then
+		GameTooltip:SetHyperlink(self.itemLink)
+	end
+	GameTooltip:Show()
+end
+local function HideTooltip() GameTooltip:Hide() end
+
+local category
+local boxHeight = 200
+local boxWidth = 330
+local numCols = 8
+
+local backdrop = {
+	bgFile = "Interface\\ChatFrame\\ChatFrameBackground", insets = {left = 4, right = 4, top = 4, bottom = 4},
+	edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", edgeSize = 16
+}
+
+function BrokerGarbage:UpdatePreviewBox(finish)
+	if category == nil or category == "" then return end
+	if not BrokerGarbage.listButtons.preview then BrokerGarbage.listButtons.preview = {} end
+	local buttonList = BrokerGarbage.listButtons.preview
+	local itemList = {}
+
+	local index = 1
+	for itemID, value, set in BrokerGarbage.PT:IterateSet(category) do
+		if buttonList[index] then
+			-- use available button
+			local button = buttonList[index]
+			local itemLink, texture
+			_, itemLink, _, _, _, _, _, _, _, texture, _ = GetItemInfo(itemID)
+			button.itemID = itemID
+			button.itemLink = itemLink
+			button:SetNormalTexture(texture)
+			button:SetChecked(false)
+			button:Show()
+
+		else
+			-- create another button
+			local iconbutton = CreateFrame("CheckButton", "BG_PreviewIconButton"..index, _G["BG_PreviewBoxContent"])
+			iconbutton:Hide()
+			iconbutton:SetWidth(36)
+			iconbutton:SetHeight(36)
+
+			iconbutton:SetNormalTexture("Interface\\Icons\\Inv_misc_questionmark")
+			iconbutton:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Square")
+			iconbutton:SetCheckedTexture("Interface\\Buttons\\UI-Button-Outline")
+			iconbutton:SetChecked(false)
+			local tex = iconbutton:GetCheckedTexture()
+			tex:ClearAllPoints()
+			tex:SetPoint("CENTER")
+			tex:SetWidth(36/37*66) tex:SetHeight(36/37*66)
+
+			iconbutton:SetScript("OnClick", function(self)
+				local check = self:GetChecked()
+				BrokerGarbage:Debug("OnClick", check)
+
+				if IsModifiedClick("CHATLINK") and ChatFrameEditBox:IsVisible() then
+					-- post item link
+					ChatFrameEditBox:Insert(self.itemLink)
+					self:SetChecked(not check)
+				else
+					self:SetChecked(not check)
+				end
+			end)
+			iconbutton:SetScript("OnEnter", ShowTooltip)
+			iconbutton:SetScript("OnLeave", HideTooltip)
+
+			if index == 1 then
+				-- place first icon
+				iconbutton:SetPoint("TOPLEFT", "BG_PreviewBoxContent", "TOPLEFT", 6, -6)
+			elseif mod(index, numCols) == 1 then
+				-- new row
+				iconbutton:SetPoint("TOPLEFT", buttonList[index-numCols], "BOTTOMLEFT", 0, -6)
+			else
+				-- new button next to the old one
+				iconbutton:SetPoint("LEFT", buttonList[index-1], "RIGHT", 4, 0)
+			end
+			buttonList[index] = iconbutton
+		end
+
+		if GetItemCount(itemID) ~= 0 and not itemList[itemID] then
+			itemList[itemID] = true
+			index = index + 1
+		end
+	end
+
+	-- hide unnessessary buttons
+	while buttonList[index] do
+		buttonList[index]:Hide()
+		index = index + 1
+	end
+
+	if not finish then
+		BrokerGarbage:UpdatePreviewBox(true)
+	end
+end
+
+local function ShowOptions()
+	local title, subtitle = LibStub("tekKonfig-Heading").new(BrokerGarbage.categoryTest, BrokerGarbage.locale.PTCategoryTestTitle, BrokerGarbage.locale.PTCategoryTestSubTitle)
+
+	local explainText = BrokerGarbage.categoryTest:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
+	explainText:SetPoint("TOPLEFT", subtitle, "BOTTOMLEFT", 0, 0)
+	explainText:SetPoint("RIGHT", BrokerGarbage.categoryTest, -32, 0)
+	explainText:SetHeight(40)
+	explainText:SetNonSpaceWrap(true)
+	explainText:SetJustifyH("LEFT")
+	explainText:SetJustifyV("TOP")
+	explainText:SetText(BrokerGarbage.locale.PTCategoryTestExplanation)
+
+	-- dropdown menu for choosing the LPT string to view
+	local categoryString, categoryText, categoryContainer = LibStub("tekKonfig-Dropdown").new(BrokerGarbage.categoryTest, BrokerGarbage.locale.PTCategoryTestDropdownTitle, "TOPLEFT", explainText, "BOTTOMLEFT", 0, -10)
+	categoryText:SetText(BrokerGarbage.locale.PTCategoryTestDropdownText)
+	categoryString:SetWidth(400)
+
+	local function OnClick()
+		UIDropDownMenu_SetSelectedValue(categoryString, this.category)
+		category = this.category
+		BrokerGarbage.debug = this
+		categoryText:SetText(category)
+		BrokerGarbage:UpdatePreviewBox()
+	end
+
+	UIDropDownMenu_Initialize(categoryString, function(self,level)
+		local selected = UIDropDownMenu_GetSelectedValue(categoryString)
+		level = level or 1
+		if level == 1 then
+			for key, subarray in pairs(BrokerGarbage.PTSets) do
+				-- submenus
+				local info = UIDropDownMenu_CreateInfo()
+				info.hasArrow = true
+				info.text = key
+				info.category = key
+				info.checked = key == selected
+				info.value = {
+					[1] = key
+				}
+				info.func = function()
+					category = key
+					UIDropDownMenu_SetSelectedValue(categoryString, category)
+					BrokerGarbage.debug = this
+					categoryText:SetText(category)
+					BrokerGarbage:UpdatePreviewBox()
+				end
+				UIDropDownMenu_AddButton(info, level)
+			end
+
+		else
+			-- getting values of first menu
+			local parentValue = UIDROPDOWNMENU_MENU_VALUE
+			local PTSets = BrokerGarbage.PTSets
+			for i = 1, level - 1 do
+				PTSets = PTSets[ parentValue[i] ]
+			end
+
+			for key, value in pairs(PTSets) do
+				local newValue = {}
+				for i = 1, level - 1 do
+					newValue[i] = parentValue[i]
+				end
+				newValue[level] = key
+				-- calculate category string
+				local valueString = newValue[1]
+				for i = 2, level do
+					valueString = valueString.."."..newValue[i]
+				end
+
+				local info = UIDropDownMenu_CreateInfo();
+				if type(value) == "table" then
+					-- submenu
+					info.hasArrow = true
+					info.category = valueString
+					info.value = newValue
+					info.func = function()
+						category = valueString
+						UIDropDownMenu_SetSelectedValue(categoryString, category)
+						BrokerGarbage.debug = this
+						categoryText:SetText(category)
+						BrokerGarbage:UpdatePreviewBox()
+					end
+				else
+					-- end node
+					info.hasArrow = false
+					info.func = function()
+						category = valueString
+						UIDropDownMenu_SetSelectedValue(categoryString, category)
+						BrokerGarbage.debug = this
+						categoryText:SetText(category)
+						BrokerGarbage:UpdatePreviewBox()
+					end
+				end
+				info.checked = valueString == selected
+				info.text = key
+
+				UIDropDownMenu_AddButton(info, level);
+			end
+		end
+	end)
+
+	-- create the container
+	local previewBox = CreateFrame("ScrollFrame", "BG_PreviewBox", BrokerGarbage.categoryTest, "UIPanelScrollFrameTemplate")
+	previewBox:SetPoint("TOPLEFT", categoryContainer, "BOTTOMLEFT", 8, 4)
+	previewBox:SetHeight(boxHeight)
+	previewBox:SetWidth(boxWidth)
+	previewBox:SetBackdrop(backdrop)
+	previewBox:SetBackdropBorderColor(0.4, 0.4, 0.4)
+	previewBox:SetBackdropColor(0.1, 0.1, 0.1)
+
+	local group_preview = CreateFrame("Frame", "BG_PreviewBoxContent", previewBox)
+	group_preview:SetAllPoints()
+	group_preview:SetHeight(boxHeight)
+	group_preview:SetWidth(boxWidth)
+	previewBox:SetScrollChild(group_preview)
+
+	-- now do the update & reset functions
+	BrokerGarbage:UpdatePreviewBox()
+	BrokerGarbage.categoryTest:SetScript("OnShow", BrokerGarbage.UpdatePreviewBox)
+end
+
+BrokerGarbage.categoryTest:SetScript("OnShow", ShowOptions)
\ No newline at end of file
diff --git a/core.lua b/core.lua
index 88a6996..03aec88 100644
--- a/core.lua
+++ b/core.lua
@@ -113,10 +113,7 @@ frame:SetScript("OnEvent", eventHandler)

 -- Sell Icon
 -- ---------------------------------------------------------
-local orig_MerchantFrame_UpdateRepairButtons = MerchantFrame_UpdateRepairButtons
-function MerchantFrame_UpdateRepairButtons(...)
-	orig_MerchantFrame_UpdateRepairButtons(...)
-
+function BrokerGarbage:UpdateRepairButton(...)
 	if not BG_GlobalDB.showAutoSellIcon then
 		-- resets guild repair icon
 		MerchantGuildBankRepairButton:ClearAllPoints()
@@ -176,6 +173,7 @@ function MerchantFrame_UpdateRepairButtons(...)
 		_G["BrokerGarbage_SellIcon"]:GetNormalTexture():SetDesaturated(true)
 	end
 end
+hooksecurefunc("MerchantFrame_UpdateRepairButtons", BrokerGarbage.UpdateRepairButton)
 loaded = true

 -- Tooltip
@@ -271,14 +269,15 @@ function BrokerGarbage:OnClick(itemTable, button)
 	if itemTable and IsShiftKeyDown() then
 		-- delete or sell item, depending on if we're at a vendor or not
 		BrokerGarbage:Debug("SHIFT-Click!")
-		if not BrokerGarbage.isAtVendor then
-			BrokerGarbage:Delete(itemTable)
-		else
+		if BrokerGarbage.isAtVendor then
 			BG_GlobalDB.moneyEarned = BG_GlobalDB.moneyEarned + itemTable.value
 			BG_LocalDB.moneyEarned = BG_LocalDB.moneyEarned + itemTable.value
 			BG_GlobalDB.itemsSold = BG_GlobalDB.itemsSold + itemTable.count

+			ClearCursor()
 			UseContainerItem(itemTable.bag, itemTable.slot)
+		else
+			BrokerGarbage:Delete(itemTable)
 		end

 	--[[elseif itemTable and IsAltKeyDown() and IsControlKeyDown() then
@@ -489,6 +488,7 @@ function BrokerGarbage:Delete(itemLink, position)
 		position = {itemLink.bag, itemLink.slot}
 		itemID = itemLink.itemID
 		itemLink = select(2,GetItemInfo(itemID))
+		ClearCursor()
 	end

 	-- security check
@@ -848,6 +848,7 @@ function BrokerGarbage:AutoSell()
 				BG_GlobalDB.moneyEarned = BG_GlobalDB.moneyEarned + itemTable.value
 				BG_LocalDB.moneyEarned = BG_LocalDB.moneyEarned + itemTable.value

+				ClearCursor()
 				UseContainerItem(itemTable.bag, itemTable.slot)
 				BG_GlobalDB.itemsSold = BG_GlobalDB.itemsSold + itemTable.count
 				i = i+1
diff --git a/options.lua b/options.lua
index ccb699f..cd51d6e 100644
--- a/options.lua
+++ b/options.lua
@@ -1136,7 +1136,7 @@ local function ShowListOptions(frame)
 		end

 		BrokerGarbage:ScanInventory()
-		MerchantFrame_UpdateRepairButtons()
+		BrokerGarbage:UpdateRepairButton()
 	end

 	if not _G["BrokerGarbagePTMenuFrame"] then
@@ -1345,7 +1345,7 @@ local function ShowListOptions(frame)
 		end

 		BrokerGarbage:ScanInventory()
-		MerchantFrame_UpdateRepairButtons()
+		BrokerGarbage:UpdateRepairButton()
 	end

 	emptyExcludeList:SetScript("OnClick", OnClick)
diff --git a/readme.txt b/readme.txt
index 94fba23..741b470 100644
--- a/readme.txt
+++ b/readme.txt
@@ -45,19 +45,19 @@ Still, do not feel bad if it doesn't make it into the addon. In that case I will
 -----------------
 There are several lists for you to use. Please be aware that itemIDs are prioritized above LPT category strings, so if for example you had "Misc.Reagent.Class.Priest" on your Exclude List but 17056 (Light Feather) on your Include List, the feathers would be considered as included items.

-* Exclude List
+* Whitelist: Exclude List
 Items on here will be "saved" from any actions - they will not be sold, dropped or anything else.
 Grayed out items on there are items that are on your global list, active for all characters. Colorful ones are just for your current character.

-* 'Force Vendor Price' List
+* Whitelist: 'Force Vendor Price' List
 Items on this list will never have their auction value used. This is useful for food, drinks and other things people tend to put on the AH at unbelievable prices.

-* Include List
+* Blacklist: Include List
 Items on this list will be always be shown in the drop Tooltip, no matter what Quality Treshold you might have set. If you have too many, you won't see any other items in the tooltip. Caution!
 Grayed out items on there are items that are on your global list, active for all characters. Colorful ones are just for your current character.
 Since 3.3v17 include list items also can have a limit set. Use this if for example you only want to keep 5 Soulshards. Excess items will be listed in the Tooltip!

-* Auto-Sell List
+* Blacklist: Auto-Sell List
 Items on this list will be sold whenever you talk to a vendor. Items of higher quality than your Quality Treshold WILL be sold, just keep that in mind.

 Each of these lists except the 'Force Vendor Price' list have a global (affects all your characters) and local (only affects the current character) component. You can broadcast items on your local lists as global by selecting them and then clicking on the promote icon next to the list.
@@ -76,6 +76,7 @@ If you check 'Show Source' in the options panel, the tooltip will display an add
 Starting in version 3.3v11 you can add category strings to make your life easier. To do so, go to your settings panel for the list you wish to add it to and right-click on the 'plus' icon. You will see a list of all categories LibPeriodicTable (LPT) has to offer (or at least the parts of it that I chose to include).
 Navigate your way through the menu and add any category you like simply by clicking on it.
 To remove a category simply do as you would with any other item on your list: Select it and then hit the corresponding 'minus' icon.
+If you want to test which items are on what lists, just use the 'Test category strings' panel in the options.

 Why these categories are only in English? There's a simple answer to that: Because that's what LPT does and I do not want to localize the complete LPT. Sorry for that, but it's kind of not my job to do that ;)