diff --git a/Broker_Garbage.toc b/Broker_Garbage.toc index 6df4723..dc1ad6c 100644 --- a/Broker_Garbage.toc +++ b/Broker_Garbage.toc @@ -1,4 +1,4 @@ -## Interface: 30300 +## Interface: 30300 ## Dependencies: ## OptionalDeps: Auctionator, AuctionLite, Auctioneer ## SavedVariables: BG_GlobalDB @@ -6,11 +6,11 @@ ## Title: Broker_Garbage ## Notes: Full bags no more! Find your least valuable item .. and destroy it! -## Notes-deDE: Endlich wieder Platz! Finde dein billigstes Item ... und zerstre es. -## Author: ckaotik (Raisa@EU-Die Todeskrallen) -## Version: 3.3v1 +## Notes-deDE: Endlich wieder Platz! Finde dein billigstes Item ... und zerstöre es. +## Author: ckaotik +## Version: 3.3v4 ## X-Category: Inventory -## X-Credits: GarbageFu +## X-Credits: GarbageFu, Tekkub Libs\LibStub.lua Libs\LibQTip-1.0.lua diff --git a/Libs/tekKonfig/tekKonfig.xml b/Libs/tekKonfig/tekKonfig.xml index 688f431..0f5bfe2 100644 --- a/Libs/tekKonfig/tekKonfig.xml +++ b/Libs/tekKonfig/tekKonfig.xml @@ -4,8 +4,5 @@ <Script file="tekKonfigCheckbox.lua"/> <Script file="tekKonfigHeading.lua"/> <Script file="tekKonfigSlider.lua"/> -<Script file="tekKonfigDropdown.lua"/> <Script file="tekKonfigAboutPanel.lua"/> -<Script file="tekKonfigGroup.lua"/> -<Script file="tekKonfigTopTab.lua"/> </Ui> \ No newline at end of file diff --git a/Libs/tekKonfig/tekKonfigDropdown.lua b/Libs/tekKonfig/tekKonfigDropdown.lua deleted file mode 100644 index ca95ba4..0000000 --- a/Libs/tekKonfig/tekKonfigDropdown.lua +++ /dev/null @@ -1,84 +0,0 @@ -local lib, oldminor = LibStub:NewLibrary("tekKonfig-Dropdown", 3) -if not lib then return end -oldminor = oldminor or 0 - - -local GameTooltip = GameTooltip -local function HideTooltip() GameTooltip:Hide() end -local function ShowTooltip(self) -if self.frame.tiptext then -GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT") -GameTooltip:SetText(self.frame.tiptext, nil, nil, nil, nil, true) -end -end -local function ShowTooltip2(self) ShowTooltip(self.container) end - - -local function OnClick(self) -ToggleDropDownMenu(nil, nil, self:GetParent()) -PlaySound("igMainMenuOptionCheckBoxOn") -end - -local function OnHide() CloseDropDownMenus() end - - --- Create a dropdown. --- All args optional, parent recommended -function lib.new(parent, label, ...) -local container = CreateFrame("Button", nil, parent) -container:SetWidth(149+13) container:SetHeight(32+24) -container:SetScript("OnEnter", ShowTooltip) -container:SetScript("OnLeave", HideTooltip) -if select("#", ...) > 0 then container:SetPoint(...) end - -local name = "tekKonfigDropdown"..GetTime() -- Sadly, some of these frames must be named -local f = CreateFrame("Frame", name, parent) -f:SetWidth(149) f:SetHeight(32) -f:SetPoint("TOPLEFT", container, -13, -24) -f:EnableMouse(true) -f:SetScript("OnHide", OnHide) -container.frame = f - -local ltex = f:CreateTexture(name.."Left", "ARTWORK") -ltex:SetWidth(25) ltex:SetHeight(64) -ltex:SetPoint("TOPLEFT", 0, 17) -ltex:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame") -ltex:SetTexCoord(0, 0.1953125, 0, 1) - -local rtex = f:CreateTexture(nil, "ARTWORK") -rtex:SetWidth(25) rtex:SetHeight(64) -rtex:SetPoint("RIGHT") -rtex:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame") -rtex:SetTexCoord(0.8046875, 1, 0, 1) - -local mtex = f:CreateTexture(nil, "ARTWORK") -mtex:SetWidth(115) mtex:SetHeight(64) -mtex:SetPoint("LEFT", ltex, "RIGHT") -mtex:SetPoint("RIGHT", rtex, "LEFT") -mtex:SetTexture("Interface\\Glues\\CharacterCreate\\CharacterCreate-LabelFrame") -mtex:SetTexCoord(0.1953125, 0.8046875, 0, 1) - -local text = f:CreateFontString(name.."Text", "ARTWORK", "GameFontHighlightSmall") -text:SetWidth(0) text:SetHeight(10) -text:SetPoint("RIGHT", rtex, -43, 2) -text:SetJustifyH("RIGHT") - -local button = CreateFrame("Button", nil, f) -button:SetWidth(24) button:SetHeight(24) -button:SetPoint("TOPRIGHT", rtex, -16, -18) -button:SetScript("OnClick", OnClick) -button:SetScript("OnEnter", ShowTooltip2) -button.container = container - -button:SetNormalTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Up") -button:SetPushedTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Down") -button:SetHighlightTexture("Interface\\Buttons\\UI-Common-MouseHilight") -button:SetDisabledTexture("Interface\\ChatFrame\\UI-ChatIcon-ScrollDown-Disabled") -button:GetHighlightTexture():SetBlendMode("ADD") - -local labeltext = f:CreateFontString(nil, "BACKGROUND", "GameFontNormal")--GameFontHighlight -labeltext:SetPoint("BOTTOMLEFT", container, "TOPLEFT", 16-13, 3-24) -labeltext:SetText(label) - -return f, text, container, labeltext -end diff --git a/Libs/tekKonfig/tekKonfigGroup.lua b/Libs/tekKonfig/tekKonfigGroup.lua deleted file mode 100644 index d406c54..0000000 --- a/Libs/tekKonfig/tekKonfigGroup.lua +++ /dev/null @@ -1,31 +0,0 @@ - -local lib, oldminor = LibStub:NewLibrary("tekKonfig-Group", 2) -if not lib then return end - -lib.bg = { - bgFile = "Interface\\ChatFrame\\ChatFrameBackground", - edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", - tile = true, - tileSize = 16, - edgeSize = 16, - insets = { left = 5, right = 5, top = 5, bottom = 5 } -} - - --- Creates a background box to place behind widgets for visual grouping. --- All args optional, parent highly recommended -function lib.new(parent, label, ...) - local box = CreateFrame('Frame', nil, parent) - box:SetBackdrop(lib.bg) - box:SetBackdropBorderColor(0.4, 0.4, 0.4) - box:SetBackdropColor(0.1, 0.1, 0.1) - if select('#',...) > 0 then box:SetPoint(...) end - - if label then - local fs = box:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall") - fs:SetPoint("BOTTOMLEFT", box, "TOPLEFT", 16, 0) - fs:SetText(label) - end - - return box -end diff --git a/Libs/tekKonfig/tekKonfigTopTab.lua b/Libs/tekKonfig/tekKonfigTopTab.lua deleted file mode 100644 index bd4165c..0000000 --- a/Libs/tekKonfig/tekKonfigTopTab.lua +++ /dev/null @@ -1,67 +0,0 @@ -local lib, oldminor = LibStub:NewLibrary("tekKonfig-TopTab", 1) -if not lib then return end -oldminor = oldminor or 0 - - -function lib:activatetab() -self.left:ClearAllPoints() -self.left:SetPoint("TOPLEFT") -self.left:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-ActiveTab") -self.middle:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-ActiveTab") -self.right:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-ActiveTab") -self:Disable() -end - -function lib:deactivatetab() -self.left:ClearAllPoints() -self.left:SetPoint("BOTTOMLEFT", 0, 2) -self.left:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-InActiveTab") -self.middle:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-InActiveTab") -self.right:SetTexture("Interface\\OptionsFrame\\UI-OptionsFrame-InActiveTab") -self:Enable() -end - -function lib:SetTextHelper(...) self:SetWidth(40 + self:GetFontString():GetStringWidth()); return ... end -function lib:NewSetText(...) return lib.SetTextHelper(self, self.OrigSetText(self, ...)) end - -function lib.new(parent, text, ...) -local tab = CreateFrame("Button", nil, parent) -tab:SetHeight(24) -tab:SetPoint(...) -tab:SetFrameLevel(tab:GetFrameLevel() + 4) - -tab.left = tab:CreateTexture(nil, "BORDER") -tab.left:SetWidth(20) tab.left:SetHeight(24) -tab.left:SetTexCoord(0, 0.15625, 0, 1) - -tab.right = tab:CreateTexture(nil, "BORDER") -tab.right:SetWidth(20) tab.right:SetHeight(24) -tab.right:SetPoint("TOP", tab.left) -tab.right:SetPoint("RIGHT", tab) -tab.right:SetTexCoord(0.84375, 1, 0, 1) - -tab.middle = tab:CreateTexture(nil, "BORDER") -tab.middle:SetHeight(24) -tab.middle:SetPoint("LEFT", tab.left, "RIGHT") -tab.middle:SetPoint("RIGHT", tab.right, "Left") -tab.middle:SetTexCoord(0.15625, 0.84375, 0, 1) - -tab:SetHighlightTexture("Interface\\PaperDollInfoFrame\\UI-Character-Tab-Highlight", "ADD") -local hilite = tab:GetHighlightTexture() -hilite:ClearAllPoints() -hilite:SetPoint("LEFT", 10, -4) -hilite:SetPoint("RIGHT", -10, -4) - -tab:SetDisabledFontObject(GameFontHighlightSmall) -tab:SetHighlightFontObject(GameFontHighlightSmall) -tab:SetNormalFontObject(GameFontNormalSmall) -tab.OrigSetText = tab.SetText -tab.SetText = lib.NewSetText -tab:SetText(text) - -tab.Activate, tab.Deactivate = lib.activatetab, lib.deactivatetab -tab:Activate() - -return tab -end - \ No newline at end of file diff --git a/core.lua b/core.lua index f5aa5cc..6629904 100644 --- a/core.lua +++ b/core.lua @@ -14,8 +14,7 @@ LDB.label = "Garbage" LDB.text = BrokerGarbage.locale.label LDB.OnClick = function(...) BrokerGarbage:OnClick(...) end LDB.OnEnter = function(...) BrokerGarbage:Tooltip(...) end -LDB.OnLeave = function(...) BrokerGarbage:HideTT(...) end -LDB.OnTooltipShow = function(...) BrokerGarbage:Tooltip(...) end +LDB.OnMouseWheel = function(...) BrokerGarbage:OnScroll(...) end -- default saved variables @@ -34,11 +33,13 @@ if not BG_GlobalDB or BG_GlobalDB == {} then } end +if not BG_GlobalDB.neverRepairGuildBank then BG_GlobalDB.neverRepairGuildBank = false end + -- internal locals -local debug = false +local debug = true local locked = false local loaded = false -local sellValue +local sellValue = 0 local cost = 0 BrokerGarbage.tt = nil @@ -56,12 +57,12 @@ local function eventHandler(self, event, ...) -- wrong player_money event -- testing: add a span for wich we recognize this one as repair bill - if sellValue and cost ~= 0 and ((-1)*sellValue <= cost+2 and (-1)*sellValue >= cost-2) then + if sellValue ~= 0 and cost ~= 0 and ((-1)*sellValue <= cost+2 and (-1)*sellValue >= cost-2) then BrokerGarbage:Debug("Not yet ... Waiting for actual money change.") return end - if sellValue and cost ~= 0 and BG_GlobalDB.autoRepairAtVendor and BG_GlobalDB.autoSellToVendor then + if sellValue ~= 0 and cost ~= 0 and BG_GlobalDB.autoRepairAtVendor and BG_GlobalDB.autoSellToVendor then -- repair & auto-sell BrokerGarbage:Print(format(BrokerGarbage.locale.sellAndRepair, BrokerGarbage:FormatMoney(sellValue), @@ -73,12 +74,12 @@ local function eventHandler(self, event, ...) -- repair only BrokerGarbage:Print(format(BrokerGarbage.locale.repair, BrokerGarbage:FormatMoney(cost))) - elseif sellValue and BG_GlobalDB.autoSellToVendor then + elseif sellValue ~= 0 and BG_GlobalDB.autoSellToVendor then -- autosell only BrokerGarbage:Print(format(BrokerGarbage.locale.sell, BrokerGarbage:FormatMoney(sellValue))) end - sellValue = nil + sellValue = 0 cost = 0 locked = false BrokerGarbage:Debug("lock released") @@ -87,7 +88,7 @@ local function eventHandler(self, event, ...) elseif locked and event == "MERCHANT_CLOSED" then -- fallback unlock - sellValue = nil + sellValue = 0 cost = 0 locked = false BrokerGarbage:Debug("lock released") @@ -190,6 +191,12 @@ function BrokerGarbage:Find(table, value) return false end +function BrokerGarbage:Count(table) + local i = 0 + for _, _ in pairs(table) do i = i + 1 end + return i +end + function BrokerGarbage:ResetMoneyLost() BG_GlobalDB.moneyLostByDeleting = 0 end @@ -226,7 +233,7 @@ function BrokerGarbage:Tooltip(wut) -- adds lines: itemLink, count, itemPrice lineNum = BrokerGarbage.tt:AddLine( select(2,GetItemInfo(cheapList[i].itemID)), - cheapList[i].count, + cheapList[i].count, BrokerGarbage:FormatMoney(cheapList[i].value)) BrokerGarbage.tt:SetLineScript(lineNum, "OnMouseDown", BrokerGarbage.OnClick, cheapList[i]) end @@ -238,6 +245,7 @@ function BrokerGarbage:Tooltip(wut) -- Use smart anchoring code to anchor the tooltip to our frame BrokerGarbage.tt:SmartAnchorTo(wut) + BrokerGarbage.tt:SetAutoHideDelay(0.25, wut) -- Show it, et voil ! BrokerGarbage.tt:Show() @@ -245,7 +253,9 @@ function BrokerGarbage:Tooltip(wut) end function BrokerGarbage:HideTT() - if BrokerGarbage.tt and MouseIsOver(BrokerGarbage.tt) then return end + if BrokerGarbage.tt and BrokerGarbage.tt:IsMouseOver() then + return + end BrokerGarbage.tt:Hide() -- Release the tooltip @@ -253,8 +263,14 @@ function BrokerGarbage:HideTT() BrokerGarbage.tt = nil end +function BrokerGarbage:OnScroll(self, direction) + BrokerGarbage:Debug("Scroll!", direction) + --BG_GlobalDB.dropQuality +end + -- onClick function for when you ... click -function BrokerGarbage:OnClick(itemTable) +function BrokerGarbage:OnClick(itemTable, button) + BrokerGarbage:Debug("Click!", button) -- just in case our drop list is empty if not itemTable then itemTable = {} end @@ -275,17 +291,19 @@ function BrokerGarbage:OnClick(itemTable) elseif itemTable ~= {} and IsControlKeyDown() then -- add to exclude list BrokerGarbage:Debug("CTRL-Click!") - tinsert(BG_GlobalDB.exclude, itemTable.itemID) + --if not BrokerGarbage:Find(BG_GlobalDB.exclude, itemTable.itemID) then tinsert(BG_GlobalDB.exclude, itemTable.itemID) end + BG_GlobalDB.exclude[itemTable.itemID] = true BrokerGarbage:Print(format(BrokerGarbage.locale.addedToSaveList, select(2,GetItemInfo(itemTable.itemID)))) BrokerGarbage:ScanInventory() - elseif GetMouseButtonClicked() == "RightButton" then + elseif button == "RightButton" then -- open config InterfaceOptionsFrame_OpenToCategory(BrokerGarbage.options) BrokerGarbage:ScanInventory() else -- do nothing + BrokerGarbage:ScanInventory() end end @@ -379,8 +397,10 @@ function BrokerGarbage:ScanInventory() end if quality and (quality <= BG_GlobalDB.dropQuality or BrokerGarbage:Find(BG_GlobalDB.include, itemID)) - and not BrokerGarbage:Find(BG_GlobalDB.exclude, itemID) then + and not BG_GlobalDB.exclude[itemID] then + --and not BrokerGarbage:Find(BG_GlobalDB.exclude, itemID) then local value = BrokerGarbage:GetItemValue(itemLink,count) + if BrokerGarbage:Find(BG_GlobalDB.include, itemID) then value = 1 end if value ~= 0 then local currentItem = { bag = container, @@ -477,6 +497,7 @@ end -- show lootable containers in your bag! make "open items" not as spammy -- increase/decrease loot treshold with mousewheel -- restack if necessary +-- force vendor price (food and stuff extremely overprice in the AH) -- make "autosell" list - e.g. mages selling dropped water/food [quickfix: use include list] -- local selectiveLooting = false diff --git a/deDE.lua b/deDE.lua index 52eb218..dd2ff51 100644 --- a/deDE.lua +++ b/deDE.lua @@ -15,6 +15,7 @@ BrokerGarbage.locale = { sell = "M\195\188ll verkauft f\195\188r %s.", addedToSaveList = "%s zur Ausnahmeliste hinzugef\195\188gt.", + addedToDestroyList = "%s zur Einschlussliste hinzugef\195\188gt.", itemDeleted = "%s wurde gel\195\182scht.", openPlease = "Bitte \195\182ffne %s - es nimmt unn\195\182tig Platz weg.", @@ -51,7 +52,7 @@ BrokerGarbage.locale = { rescanInventory = "Inventar neu scannen", rescanInventoryText = "Klicke um dein Inventar neu zu scannen. Dies sollte normalerweise nicht n\195\182tig sein!", - resetMoneyLost = "'Verlorenes Geld' zur\195\188cksetzen", + resetMoneyLost = "'Verlorenes Geld' leeren", resetMoneyLostText = "Klicke um die Statistik 'Verlorenes Geld' zur\195\188ckzusetzen.", emptyExcludeList = "Ausschlussliste leeren", @@ -59,6 +60,22 @@ BrokerGarbage.locale = { emptyIncludeList = "Einschlussliste leeren", emptyIncludeListText = "Klicke um deine Einschlussliste zu leeren.", + + -- List Options Panel + LOTitle = "Listen-Optionen", + LOSubTitle = "Stelle hier deine Listen ein. Um Items hinzuzuf\195\188gen, zieh sie auf das jeweilige '+'. Um sie zu entfernen, w\195\164hle sie aus und klicke auf '-'.", + + LOExcludeHeader = "Ausschlussliste - Items hier werden nie verkauft/gel\195\182scht.", + LOExcludePlusTT = "Items hinzuf\195\188gen, indem du sie hierher ziehst/hier ablegst", + LOExcludeRefreshTT = "Klicke, um die Anzeige zu aktualisieren", + LOExcludeMinusTT = "W\195\164hle Items, die du entfernen willst. Dann klicke hier.", + LOExcludeEmptyTT = "Klicke, um die Ausschlussliste v\195\182llig zu leeren.\nAchtung!", + + LOIncludeHeader = "Einschlussliste - Items hier werden zum L\195\182schen vorgeschlagen.", + LOIncludePlusTT = "Items hinzuf\195\188gen, indem du sie hierher ziehst/hier ablegst", + LOIncludeRefreshTT = "Klicke, um die Anzeige zu aktualisieren", + LOIncludeMinusTT = "W\195\164hle Items, die du entfernen willst. Dann klicke hier.", + LOIncludeEmptyTT = "Klicke, um die Einschlussliste v\195\182llig zu leeren.\nAchtung!", } end \ No newline at end of file diff --git a/enUS.lua b/enUS.lua index b0ff76e..dd0e105 100644 --- a/enUS.lua +++ b/enUS.lua @@ -8,7 +8,8 @@ BrokerGarbage.locale = { repair = "Repaired for %s.", sell = "Sold trash for %s.", - addedToSaveList = "%s added to save list.", + addedToSaveList = "%s has been added to the save list.", + addedToDestroyList = "%s has been added to the destroy list.", itemDeleted = "%s has been deleted.", openPlease = "Please open your %s. It's in your bags, stealing your space!", @@ -53,4 +54,20 @@ BrokerGarbage.locale = { emptyIncludeList = "Empty Include List", emptyIncludeListText = "Click to clear your include list.", + + -- List Options Panel + LOTitle = "List Options", + LOSubTitle = "Set up your master lists here. To add Items, drag them over the corresponding '+' icon, to remove them select them and klick the '-'.", + + LOExcludeHeader = "Exclude List - these items will never be sold/deleted.", + LOExcludePlusTT = "Add items to the list by dragging/placing them on me!", + LOExcludeRefreshTT = "Click to refresh the Exclude List display", + LOExcludeMinusTT = "Select items you want to remove, then click here.", + LOExcludeEmptyTT = "Click to fully empty your Exclude List. Caution!", + + LOIncludeHeader = "Include List - these items will be suggested to be deleted.", + LOIncludePlusTT = "Add items to the list by dragging/placing them on me!", + LOIncludeRefreshTT = "Click to refresh the Include List display", + LOIncludeMinusTT = "Select items you want to remove, then click here.", + LOIncludeEmptyTT = "Click to fully empty your Include List. Caution!", } \ No newline at end of file diff --git a/options.lua b/options.lua index 6925b21..83814d1 100644 --- a/options.lua +++ b/options.lua @@ -1,9 +1,4 @@ -_, BrokerGarbage = ... - -BrokerGarbage.options = CreateFrame("Frame", "BrokerGarbageOptionsFrame", InterfaceOptionsFramePanelContainer) -BrokerGarbage.options.name = "Broker_Garbage" --- no, you don't want to see this until it's done -BrokerGarbage.options:Hide() +addonName, BrokerGarbage = ... BrokerGarbage.quality = { [0] = "|cff9D9D9D"..ITEM_QUALITY0_DESC.."|r", @@ -15,38 +10,53 @@ BrokerGarbage.quality = { [6] = "|cffE6CC80"..ITEM_QUALITY6_DESC.."|r", } -BrokerGarbage.options:SetScript("OnShow", function(self) - local title, subtitle = LibStub("tekKonfig-Heading").new(self, "Broker_Garbage", BrokerGarbage.locale.subTitle) +-- main options panel +BrokerGarbage.options = CreateFrame("Frame", "BrokerGarbageOptionsFrame", InterfaceOptionsFramePanelContainer) +BrokerGarbage.options.name = addonName +BrokerGarbage.options:Hide() + +BrokerGarbage.listOptions = CreateFrame("Frame", "BrokerGarbageOptionsFrame", InterfaceOptionsFramePanelContainer) +BrokerGarbage.listOptions.name = BrokerGarbage.locale.LOTitle +BrokerGarbage.listOptions.parent = addonName +BrokerGarbage.listOptions:Hide() +BrokerGarbage.optionRows = {} +BrokerGarbage.listButtons = { + include = {}, + exclude = {}, +} + +BrokerGarbage.options:SetScript("OnShow", function(frame) + + local title, subtitle = LibStub("tekKonfig-Heading").new(BrokerGarbage.options, addonName, BrokerGarbage.locale.subTitle) - local autosell = LibStub("tekKonfig-Checkbox").new(self, nil, BrokerGarbage.locale.autoSellTitle, "TOPLEFT", subtitle, "BOTTOMLEFT", -2, -4) + local autosell = LibStub("tekKonfig-Checkbox").new(BrokerGarbage.options, nil, BrokerGarbage.locale.autoSellTitle, "TOPLEFT", subtitle, "BOTTOMLEFT", -2, -4) autosell.tiptext = BrokerGarbage.locale.autoSellText autosell:SetChecked(BG_GlobalDB.autoSellToVendor) local checksound = autosell:GetScript("OnClick") - autosell:SetScript("OnClick", function(self) - checksound(self) + autosell:SetScript("OnClick", function(checksound) + checksound(checksound) BG_GlobalDB.autoSellToVendor = not BG_GlobalDB.autoSellToVendor end) - - local autorepair = LibStub("tekKonfig-Checkbox").new(self, nil, BrokerGarbage.locale.autoRepairTitle, "TOPLEFT", subtitle, "BOTTOMLEFT", 178, -4) + + local autorepair = LibStub("tekKonfig-Checkbox").new(BrokerGarbage.options, nil, BrokerGarbage.locale.autoRepairTitle, "LEFT", autosell, "LEFT", 200, 0) autorepair.tiptext = BrokerGarbage.locale.autoRepairText autorepair:SetChecked(BG_GlobalDB.autoRepairAtVendor) local checksound = autorepair:GetScript("OnClick") - autorepair:SetScript("OnClick", function(self) - checksound(self) + autorepair:SetScript("OnClick", function(autorepair) + checksound(autorepair) BG_GlobalDB.autoRepairAtVendor = not BG_GlobalDB.autoRepairAtVendor end) - - local guildrepair = LibStub("tekKonfig-Checkbox").new(self, nil, BrokerGarbage.locale.autoRepairGuildTitle, "TOPLEFT", autorepair, "BOTTOMLEFT", 0, 0) + + local guildrepair = LibStub("tekKonfig-Checkbox").new(BrokerGarbage.options, nil, BrokerGarbage.locale.autoRepairGuildTitle, "TOPLEFT", autorepair, "BOTTOMLEFT", 0, 0) guildrepair.tiptext = BrokerGarbage.locale.autoRepairGuildText guildrepair:SetChecked(BG_GlobalDB.neverRepairGuildBank) local checksound = guildrepair:GetScript("OnClick") - guildrepair:SetScript("OnClick", function(self) - checksound(self) + guildrepair:SetScript("OnClick", function(guildrepair) + checksound(guildrepair) BG_GlobalDB.neverRepairGuildBank = not BG_GlobalDB.neverRepairGuildBank end) - - local quality = LibStub("tekKonfig-Slider").new(self, BrokerGarbage.locale.dropQualityTitle, 0, 6, "TOPLEFT", autosell, "BOTTOMLEFT", 2, -25) + local quality = LibStub("tekKonfig-Slider").new(BrokerGarbage.options, BrokerGarbage.locale.dropQualityTitle, 0, 6, "TOPLEFT", autosell, "BOTTOMLEFT", 2, -50) quality.tiptext = BrokerGarbage.locale.dropQualityText quality:SetWidth(200) quality:SetValueStep(1); @@ -54,14 +64,14 @@ BrokerGarbage.options:SetScript("OnShow", function(self) quality.text = quality:CreateFontString("$parentCenterText", "ARTWORK", "GameFontHighlightSmall") quality.text:SetPoint("TOP", quality, "BOTTOM", 0, 3) quality.text:SetText(BrokerGarbage.quality[BG_GlobalDB.dropQuality]) - quality:SetScript("OnValueChanged", function(self) - BG_GlobalDB.dropQuality = self:GetValue() - self.text:SetText(BrokerGarbage.quality[self:GetValue()]) + quality:SetScript("OnValueChanged", function(quality) + BG_GlobalDB.dropQuality = quality:GetValue() + quality.text:SetText(BrokerGarbage.quality[quality:GetValue()]) BrokerGarbage:ScanInventory() end) - + local testValue = 130007 - local moneyFormat = LibStub("tekKonfig-Slider").new(self, BrokerGarbage.locale.moneyFormatTitle, 0, 4, "LEFT", quality, "RIGHT", 40, 0) + local moneyFormat = LibStub("tekKonfig-Slider").new(BrokerGarbage.options, BrokerGarbage.locale.moneyFormatTitle, 0, 4, "LEFT", quality, "RIGHT", 40, 0) moneyFormat.tiptext = BrokerGarbage.locale.moneyFormatText moneyFormat:SetWidth(200) moneyFormat:SetValueStep(1); @@ -69,13 +79,13 @@ BrokerGarbage.options:SetScript("OnShow", function(self) moneyFormat.text = moneyFormat:CreateFontString("$parentCenterText", "ARTWORK", "GameFontHighlightSmall") moneyFormat.text:SetPoint("TOP", moneyFormat, "BOTTOM", 0, 3) moneyFormat.text:SetText(BrokerGarbage:FormatMoney(testValue)) - moneyFormat:SetScript("OnValueChanged", function(self) - BG_GlobalDB.showMoney = self:GetValue() - self.text:SetText(BrokerGarbage:FormatMoney(testValue)) + moneyFormat:SetScript("OnValueChanged", function(moneyFormat) + BG_GlobalDB.showMoney = moneyFormat:GetValue() + moneyFormat.text:SetText(BrokerGarbage:FormatMoney(testValue)) end) - - - local ttMaxItems = LibStub("tekKonfig-Slider").new(self, BrokerGarbage.locale.maxItemsTitle, 0, 50, "TOPLEFT", quality, "BOTTOMLEFT", 2, -15) + + + local ttMaxItems = LibStub("tekKonfig-Slider").new(BrokerGarbage.options, BrokerGarbage.locale.maxItemsTitle, 0, 50, "TOPLEFT", quality, "BOTTOMLEFT", 2, -15) ttMaxItems.tiptext = BrokerGarbage.locale.maxItemsText ttMaxItems:SetWidth(200) ttMaxItems:SetValueStep(1); @@ -83,13 +93,13 @@ BrokerGarbage.options:SetScript("OnShow", function(self) ttMaxItems.text = ttMaxItems:CreateFontString("$parentCenterText", "ARTWORK", "GameFontHighlightSmall") ttMaxItems.text:SetPoint("TOP", ttMaxItems, "BOTTOM", 0, 3) ttMaxItems.text:SetText(ttMaxItems:GetValue()) - ttMaxItems:SetScript("OnValueChanged", function(self) - BG_GlobalDB.tooltipNumItems = self:GetValue() - self.text:SetText(self:GetValue()) + ttMaxItems:SetScript("OnValueChanged", function(ttMaxItems) + BG_GlobalDB.tooltipNumItems = ttMaxItems:GetValue() + ttMaxItems.text:SetText(ttMaxItems:GetValue()) end) - - - local ttMaxHeight = LibStub("tekKonfig-Slider").new(self, BrokerGarbage.locale.maxHeightTitle, 0, 400, "LEFT", ttMaxItems, "RIGHT", 40, 0) + + + local ttMaxHeight = LibStub("tekKonfig-Slider").new(BrokerGarbage.options, BrokerGarbage.locale.maxHeightTitle, 0, 400, "LEFT", ttMaxItems, "RIGHT", 40, 0) ttMaxHeight.tiptext = BrokerGarbage.locale.maxHeightText ttMaxHeight:SetWidth(200) ttMaxHeight:SetValueStep(10); @@ -97,51 +107,338 @@ BrokerGarbage.options:SetScript("OnShow", function(self) ttMaxHeight.text = ttMaxHeight:CreateFontString("$parentCenterText", "ARTWORK", "GameFontHighlightSmall") ttMaxHeight.text:SetPoint("TOP", ttMaxHeight, "BOTTOM", 0, 3) ttMaxHeight.text:SetText(ttMaxHeight:GetValue()) - ttMaxHeight:SetScript("OnValueChanged", function(self) - BG_GlobalDB.tooltipMaxHeight = self:GetValue() - self.text:SetText(self:GetValue()) + ttMaxHeight:SetScript("OnValueChanged", function(ttMaxHeight) + BG_GlobalDB.tooltipMaxHeight = ttMaxHeight:GetValue() + ttMaxHeight.text:SetText(ttMaxHeight:GetValue()) end) - - - local rescan = LibStub("tekKonfig-Button").new_small(self, "TOPLEFT", ttMaxItems, "BOTTOMLEFT", 0, -50) + + + local rescan = LibStub("tekKonfig-Button").new_small(BrokerGarbage.options, "TOPLEFT", ttMaxItems, "BOTTOMLEFT", 0, -50) rescan:SetText(BrokerGarbage.locale.rescanInventory) rescan.tiptext = BrokerGarbage.locale.rescanInventoryText rescan:SetWidth(150) rescan:SetHeight(18) rescan:SetScript("OnClick", function() BrokerGarbage:ScanInventory() end) - - local resetmoneylost = LibStub("tekKonfig-Button").new_small(self, "LEFT", rescan, "RIGHT", 40, 0) + + local resetmoneylost = LibStub("tekKonfig-Button").new_small(BrokerGarbage.options, "LEFT", rescan, "RIGHT", 40, 0) resetmoneylost:SetText(BrokerGarbage.locale.resetMoneyLost) resetmoneylost.tiptext = BrokerGarbage.locale.resetMoneyLostText resetmoneylost:SetWidth(150) resetmoneylost:SetHeight(18) resetmoneylost:SetScript("OnClick", function() BrokerGarbage:ResetMoneyLost() end) + + -- ---------------------------------- + -- List Options panel + + local title, subtitle = LibStub("tekKonfig-Heading").new(BrokerGarbage.listOptions, addonName .. " - " .. BrokerGarbage.locale.LOTitle , BrokerGarbage.locale.LOSubTitle) + + -- list frame: excludes + local boxHeight = 150 + local boxWidth = 330 + + local excludeListHeader = BrokerGarbage.listOptions:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall") + excludeListHeader:SetHeight(32) + excludeListHeader:SetPoint("TOPLEFT", subtitle, "BOTTOMLEFT", 0, 15) + excludeListHeader:SetText(BrokerGarbage.locale.LOExcludeHeader) + local excludeBox = CreateFrame("ScrollFrame", "BG_ExcludeListBox", BrokerGarbage.listOptions, "UIPanelScrollFrameTemplate") + excludeBox:SetPoint("TOPLEFT", excludeListHeader, "BOTTOMLEFT", 0, 2) + excludeBox:SetHeight(boxHeight) + excludeBox:SetWidth(boxWidth) + local group = CreateFrame("Frame", nil, excludeBox) + excludeBox:SetScrollChild(group) + group:SetAllPoints() + group:SetHeight(boxHeight) + group:SetWidth(boxWidth) - local excludeReset = LibStub("tekKonfig-Button").new_small(self, "TOPLEFT", rescan, "BOTTOMLEFT", 0, -50) - excludeReset:SetText(BrokerGarbage.locale.emptyExcludeList) - excludeReset.tiptext = BrokerGarbage.locale.emptyExcludeListText - excludeReset:SetWidth(150) excludeReset:SetHeight(18) - excludeReset:SetScript("OnClick", function() - BG_GlobalDB.exclude = {} - end) + local backdrop = {bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", + tile = true, + tileSize = 32, + insets = { left = 0, right = -22, top = 0, bottom = 0 }} + excludeBox:SetBackdrop(backdrop) + excludeBox:SetBackdropBorderColor(0.4, 0.4, 0.4) + excludeBox:SetBackdropColor(0.1, 0.1, 0.1) + + -- action buttons + local plus = CreateFrame("Button", nil, BrokerGarbage.listOptions) + plus:SetPoint("TOPLEFT", "BG_ExcludeListBoxScrollBar", "TOPRIGHT", 8, -3) + plus:SetWidth(25) + plus:SetHeight(25) + plus:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Square") + plus:SetNormalTexture("Interface\\Icons\\Spell_chargepositive") + plus.tiptext = BrokerGarbage.locale.LOExcludePlusTT + + local refresh = CreateFrame("Button", nil, BrokerGarbage.listOptions) + refresh:SetPoint("TOP", plus, "BOTTOM", 0, -6) + refresh:SetWidth(25) + refresh:SetHeight(25) + refresh:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Square") + refresh:SetNormalTexture("Interface\\Icons\\achievement_bg_returnxflags_def_wsg") + refresh.tiptext = BrokerGarbage.locale.LOExcludeRefreshTT - local includeReset = LibStub("tekKonfig-Button").new_small(self, "TOPLEFT", excludeReset, "BOTTOMLEFT", 0, -10) - includeReset:SetText(BrokerGarbage.locale.emptyIncludeList) - includeReset.tiptext = BrokerGarbage.locale.emptyIncludeListText - includeReset:SetWidth(150) includeReset:SetHeight(18) - includeReset:SetScript("OnClick", function() - BG_GlobalDB.include = {} - end) + local minus = CreateFrame("Button", nil, BrokerGarbage.listOptions) + minus:SetPoint("TOP", refresh, "BOTTOM", 0, -6) + minus:SetWidth(25) + minus:SetHeight(25) + minus:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Square") + minus:SetNormalTexture("Interface\\Icons\\Spell_chargenegative") + minus.tiptext = BrokerGarbage.locale.LOExcludeMinusTT - -- ---------------------------------- + local emptyExcludeList = CreateFrame("Button", nil, BrokerGarbage.listOptions) + emptyExcludeList:SetPoint("TOP", minus, "BOTTOM", 0, -6) + emptyExcludeList:SetWidth(25) + emptyExcludeList:SetHeight(25) + emptyExcludeList:SetNormalTexture("Interface\\Buttons\\Ui-grouploot-pass-up") + emptyExcludeList.tiptext = BrokerGarbage.locale.LOExcludeEmptyTT + + -- list frame: includes + local includeListHeader = BrokerGarbage.listOptions:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall") + includeListHeader:SetHeight(32) + includeListHeader:SetPoint("TOPLEFT", excludeBox, "BOTTOMLEFT", 0, -8) + includeListHeader:SetText(BrokerGarbage.locale.LOIncludeHeader) + + local includeBox = CreateFrame("ScrollFrame", "BG_IncludeListBox", BrokerGarbage.listOptions, "UIPanelScrollFrameTemplate") + includeBox:SetPoint("TOPLEFT", includeListHeader, "BOTTOMLEFT", 0, 2) + includeBox:SetHeight(boxHeight) + includeBox:SetWidth(boxWidth) + local group2 = CreateFrame("Frame", nil, excludeBox) + group2:SetAllPoints() + group2:SetHeight(boxHeight) + group2:SetWidth(boxWidth) + includeBox:SetScrollChild(group2) + + includeBox:SetBackdrop(backdrop) + includeBox:SetBackdropBorderColor(0.4, 0.4, 0.4) + includeBox:SetBackdropColor(0.1, 0.1, 0.1) + + -- action buttons + local plus2 = CreateFrame("Button", nil, BrokerGarbage.listOptions) + plus2:SetPoint("TOPLEFT", "BG_IncludeListBoxScrollBar", "TOPRIGHT", 8, -3) + plus2:SetWidth(25) + plus2:SetHeight(25) + plus2:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Square") + plus2:SetNormalTexture("Interface\\Icons\\Spell_chargepositive") + plus2.tiptext = BrokerGarbage.locale.LOIncludePlusTT + + local refresh2 = CreateFrame("Button", nil, BrokerGarbage.listOptions) + refresh2:SetPoint("TOP", plus2, "BOTTOM", 0, -6) + refresh2:SetWidth(25) + refresh2:SetHeight(25) + refresh2:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Square") + refresh2:SetNormalTexture("Interface\\Icons\\achievement_bg_returnxflags_def_wsg") + refresh2.tiptext = BrokerGarbage.locale.LOIncludeRefreshTT + + local minus2 = CreateFrame("Button", nil, BrokerGarbage.listOptions) + minus2:SetPoint("TOP", refresh2, "BOTTOM", 0, -6) + minus2:SetWidth(25) + minus2:SetHeight(25) + minus2:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Square") + minus2:SetNormalTexture("Interface\\Icons\\Spell_chargenegative") + minus2.tiptext = BrokerGarbage.locale.LOIncludeMinusTT + + local emptyIncludeList = CreateFrame("Button", nil, BrokerGarbage.listOptions) + emptyIncludeList:SetPoint("TOP", minus2, "BOTTOM", 0, -6) + emptyIncludeList:SetWidth(25) + emptyIncludeList:SetHeight(25) + emptyIncludeList:SetNormalTexture("Interface\\Buttons\\Ui-grouploot-pass-up") + emptyIncludeList.tiptext = BrokerGarbage.locale.LOIncludeEmptyTT + 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 numCols = 8 + local offset = 0 + local function ListOptionsUpdate(listName) + local list, box, parent, buttonList + if listName == "include" then + list = BG_GlobalDB.include + box = includeBox + parent = group2 + buttonList = BrokerGarbage.listButtons.include + else + list = BG_GlobalDB.exclude + box = excludeBox + parent = group + buttonList = BrokerGarbage.listButtons.exclude + end + + local index = 1 + for itemID,_ in pairs(list) do + if buttonList[index] then + -- use available button + local button = buttonList[index] + local itemName, itemLink, _, _, _, _, _, _, _, texture, _ = GetItemInfo(itemID) + button.name = itemName + button.itemID = itemID + button.itemLink = itemLink + button:SetNormalTexture(texture) + button:SetChecked(false) + button:Show() + else + -- create another button + local iconbutton = CreateFrame("CheckButton", nil, parent) + iconbutton:Hide() + iconbutton:SetWidth(36) + iconbutton:SetHeight(36) - self:SetScript("OnShow", nil) -end) + iconbutton:SetNormalTexture("Interface\\Icons\\achievement_bg_returnxflags_def_wsg") + 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("OnEnter", ShowTooltip) + iconbutton:SetScript("OnLeave", HideTooltip) + --iconbutton:SetScript("OnClick", OnClick) + + if index == 1 then + -- place first icon + iconbutton:SetPoint("TOPLEFT", parent, "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 + + index = index + 1 + end + -- hide unnessessary buttons + while buttonList[index] do + buttonList[index]:Hide() + index = index + 1 + end + + box:UpdateScrollChildRect() + end + + local function ItemDrop(self) + _, itemID, link = GetCursorInfo() + + if self == group2 or self == includeBox or self == plus2 then + BG_GlobalDB.include[itemID] = true + BrokerGarbage:Print(format(BrokerGarbage.locale.addedToDestroyList, link)) + ListOptionsUpdate("include") + ClearCursor() + elseif self == group or self == excludeBox or self == plus then + BG_GlobalDB.exclude[itemID] = true + BrokerGarbage:Print(format(BrokerGarbage.locale.addedToSaveList), link) + ListOptionsUpdate("exclude") + ClearCursor() + end + end + + local function OnClick(self, button) + if self == refresh then + ListOptionsUpdate("exclude") + + elseif self == refresh2 then + ListOptionsUpdate("include") + + elseif self == emptyExcludeList then + BG_GlobalDB.exclude = {} + ListOptionsUpdate("exclude") + BrokerGarbage:ScanInventory() + + elseif self == emptyIncludeList then + BG_GlobalDB.include = {} + ListOptionsUpdate("include") + BrokerGarbage:ScanInventory() + + elseif self == minus then + for i, button in pairs(BrokerGarbage.listButtons.exclude) do + if button:GetChecked() then + BG_GlobalDB.exclude[button.itemID] = nil + end + end + ListOptionsUpdate("exclude") + BrokerGarbage:ScanInventory() + + elseif self == minus2 then + for i, button in pairs(BrokerGarbage.listButtons.include) do + if button:GetChecked() then + BG_GlobalDB.include[button.itemID] = nil + end + end + ListOptionsUpdate("include") + BrokerGarbage:ScanInventory() + + elseif self == plus then + BrokerGarbage:Debug("Include1") + ItemDrop(self) + elseif self == plus2 then + BrokerGarbage:Debug("Include2") + ItemDrop(self) + end + + ListOptionsUpdate("include") + ListOptionsUpdate("exclude") + end + + refresh:SetScript("OnClick", OnClick) + refresh:SetScript("OnEnter", ShowTooltip) + refresh:SetScript("OnLeave", HideTooltip) + + refresh2:SetScript("OnClick", OnClick) + refresh2:SetScript("OnEnter", ShowTooltip) + refresh2:SetScript("OnLeave", HideTooltip) + + emptyExcludeList:SetScript("OnClick", OnClick) + emptyExcludeList:SetScript("OnEnter", ShowTooltip) + emptyExcludeList:SetScript("OnLeave", HideTooltip) + + emptyIncludeList:SetScript("OnClick", OnClick) + emptyIncludeList:SetScript("OnEnter", ShowTooltip) + emptyIncludeList:SetScript("OnLeave", HideTooltip) + + minus:SetScript("OnClick", OnClick) + minus:SetScript("OnEnter", ShowTooltip) + minus:SetScript("OnLeave", HideTooltip) + + minus2:SetScript("OnClick", OnClick) + minus2:SetScript("OnEnter", ShowTooltip) + minus2:SetScript("OnLeave", HideTooltip) + + plus:SetScript("OnClick", OnClick) + plus:SetScript("OnEnter", ShowTooltip) + plus:SetScript("OnLeave", HideTooltip) + + plus2:SetScript("OnClick", OnClick) + plus2:SetScript("OnEnter", ShowTooltip) + plus2:SetScript("OnLeave", HideTooltip) + + -- ---------------------------------- + plus:RegisterForDrag("LeftButton") + plus:SetScript("OnReceiveDrag", ItemDrop) + plus:SetScript("OnMouseDown", ItemDrop) + plus2:RegisterForDrag("LeftButton") + plus2:SetScript("OnReceiveDrag", ItemDrop) + plus2:SetScript("OnMouseDown", ItemDrop) + + buttons = {} + ListOptionsUpdate() + frame:SetScript("OnShow", nil) + BrokerGarbage.listOptions:SetScript("OnShow", ListOptionsUpdate) +end) InterfaceOptions_AddCategory(BrokerGarbage.options) +InterfaceOptions_AddCategory(BrokerGarbage.listOptions) LibStub("tekKonfig-AboutPanel").new("Broker_Garbage", "Broker_Garbage") \ No newline at end of file