fix: auto sell junk items
This commit is contained in:
@@ -1346,6 +1346,15 @@ function CategoryManager:SyncEquipmentSetCategories()
|
|||||||
insertPos = table.getn(cats.order) + 1
|
insertPos = table.getn(cats.order) + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if not insertPos then
|
||||||
|
-- Insert before Junk category if it exists, otherwise at end of Main group
|
||||||
|
for i, orderId in ipairs(cats.order) do
|
||||||
|
if orderId == "Junk" then
|
||||||
|
insertPos = i
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
if not insertPos then
|
if not insertPos then
|
||||||
for i = table.getn(cats.order), 1, -1 do
|
for i = table.getn(cats.order), 1, -1 do
|
||||||
local existDef = cats.definitions[cats.order[i]]
|
local existDef = cats.definitions[cats.order[i]]
|
||||||
|
|||||||
@@ -130,6 +130,12 @@ function DB:Initialize()
|
|||||||
if Guda_CharDB.settings.markEquipmentSets == nil then
|
if Guda_CharDB.settings.markEquipmentSets == nil then
|
||||||
Guda_CharDB.settings.markEquipmentSets = true
|
Guda_CharDB.settings.markEquipmentSets = true
|
||||||
end
|
end
|
||||||
|
if Guda_CharDB.settings.autoVendorJunk == nil then
|
||||||
|
Guda_CharDB.settings.autoVendorJunk = true
|
||||||
|
end
|
||||||
|
if Guda_CharDB.settings.whiteItemsJunk == nil then
|
||||||
|
Guda_CharDB.settings.whiteItemsJunk = false
|
||||||
|
end
|
||||||
|
|
||||||
-- Initialize CategoryManager for custom categories
|
-- Initialize CategoryManager for custom categories
|
||||||
if addon.Modules.CategoryManager then
|
if addon.Modules.CategoryManager then
|
||||||
|
|||||||
@@ -241,8 +241,12 @@ local function DetectJunk(lines, itemData)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- White equippable items might be junk
|
-- White equippable items might be junk (only if whiteItemsJunk setting is enabled)
|
||||||
if quality == 1 and (itemClass == "Weapon" or itemClass == "Armor") then
|
local whiteItemsJunk = false
|
||||||
|
if addon and addon.Modules and addon.Modules.DB then
|
||||||
|
whiteItemsJunk = addon.Modules.DB:GetSetting("whiteItemsJunk")
|
||||||
|
end
|
||||||
|
if quality == 1 and whiteItemsJunk and (itemClass == "Weapon" or itemClass == "Armor") then
|
||||||
-- Exclusions: trinkets, rings, necklaces, tabards, shirts
|
-- Exclusions: trinkets, rings, necklaces, tabards, shirts
|
||||||
local subLower = string.lower(itemSubclass)
|
local subLower = string.lower(itemSubclass)
|
||||||
if string.find(subLower, "trinket") or
|
if string.find(subLower, "trinket") or
|
||||||
|
|||||||
@@ -3269,6 +3269,50 @@ function BagFrame:Initialize()
|
|||||||
if frameRef and not frameRef:IsShown() then
|
if frameRef and not frameRef:IsShown() then
|
||||||
frameRef:Show()
|
frameRef:Show()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Auto-sell junk items (spread across frames to avoid item locking)
|
||||||
|
local autoVendor = addon.Modules.DB:GetSetting("autoVendorJunk")
|
||||||
|
if autoVendor == nil then autoVendor = true end
|
||||||
|
if autoVendor then
|
||||||
|
local junkItems = {}
|
||||||
|
for bag = 0, 4 do
|
||||||
|
local numSlots = GetContainerNumSlots(bag)
|
||||||
|
for slot = 1, numSlots do
|
||||||
|
local link = GetContainerItemLink(bag, slot)
|
||||||
|
if link and string.find(link, "|cff9d9d9d") then
|
||||||
|
table.insert(junkItems, { bag = bag, slot = slot })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if table.getn(junkItems) > 0 then
|
||||||
|
local idx = 0
|
||||||
|
local soldCount = 0
|
||||||
|
local sellFrame = CreateFrame("Frame")
|
||||||
|
sellFrame:SetScript("OnUpdate", function()
|
||||||
|
if not isMerchantOpen then
|
||||||
|
this:SetScript("OnUpdate", nil)
|
||||||
|
if soldCount > 0 then
|
||||||
|
addon:Print("Sold " .. soldCount .. " junk item(s).")
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
idx = idx + 1
|
||||||
|
local item = junkItems[idx]
|
||||||
|
if item then
|
||||||
|
local link = GetContainerItemLink(item.bag, item.slot)
|
||||||
|
if link and string.find(link, "|cff9d9d9d") then
|
||||||
|
UseContainerItem(item.bag, item.slot)
|
||||||
|
soldCount = soldCount + 1
|
||||||
|
end
|
||||||
|
else
|
||||||
|
this:SetScript("OnUpdate", nil)
|
||||||
|
if soldCount > 0 then
|
||||||
|
addon:Print("Sold " .. soldCount .. " junk item(s).")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
end, "BagFrame")
|
end, "BagFrame")
|
||||||
|
|
||||||
addon.Modules.Events:Register("MERCHANT_CLOSED", function()
|
addon.Modules.Events:Register("MERCHANT_CLOSED", function()
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ function Guda_SettingsPopup_OnLoad(self)
|
|||||||
if generalTab then
|
if generalTab then
|
||||||
CreateSectionHeader(generalTab, "Appearance", -12)
|
CreateSectionHeader(generalTab, "Appearance", -12)
|
||||||
CreateSectionHeader(generalTab, "Options", -120)
|
CreateSectionHeader(generalTab, "Options", -120)
|
||||||
|
CreateSectionHeader(generalTab, "Automation", -230)
|
||||||
end
|
end
|
||||||
|
|
||||||
local layoutTab = getglobal("Guda_SettingsPopup_LayoutTab")
|
local layoutTab = getglobal("Guda_SettingsPopup_LayoutTab")
|
||||||
@@ -282,6 +283,22 @@ function Guda_SettingsPopup_OnShow(self)
|
|||||||
markEquipmentSetsCheckbox:SetChecked(markEquipmentSets and 1 or 0)
|
markEquipmentSetsCheckbox:SetChecked(markEquipmentSets and 1 or 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Automation checkboxes
|
||||||
|
local autoVendorJunkCheckbox = getglobal("Guda_SettingsPopup_AutoVendorJunkCheckbox")
|
||||||
|
local autoVendorJunk = Guda.Modules.DB:GetSetting("autoVendorJunk")
|
||||||
|
if autoVendorJunk == nil then autoVendorJunk = true end
|
||||||
|
if autoVendorJunkCheckbox then
|
||||||
|
autoVendorJunkCheckbox:SetChecked(autoVendorJunk and 1 or 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- White Items as Junk checkbox
|
||||||
|
local whiteItemsJunkCheckbox = getglobal("Guda_SettingsPopup_WhiteItemsJunkCheckbox")
|
||||||
|
local whiteItemsJunk = Guda.Modules.DB:GetSetting("whiteItemsJunk")
|
||||||
|
if whiteItemsJunk == nil then whiteItemsJunk = false end
|
||||||
|
if whiteItemsJunkCheckbox then
|
||||||
|
whiteItemsJunkCheckbox:SetChecked(whiteItemsJunk and 1 or 0)
|
||||||
|
end
|
||||||
|
|
||||||
if bagViewButton then
|
if bagViewButton then
|
||||||
if bagViewType == "single" then
|
if bagViewType == "single" then
|
||||||
bagViewButton:SetText("Bag View: Single")
|
bagViewButton:SetText("Bag View: Single")
|
||||||
@@ -1293,6 +1310,86 @@ function Guda_SettingsPopup_MarkEquipmentSetsCheckbox_OnClick(self)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Auto Vendor Junk Checkbox OnLoad
|
||||||
|
function Guda_SettingsPopup_AutoVendorJunkCheckbox_OnLoad(self)
|
||||||
|
local text = getglobal(self:GetName().."Text")
|
||||||
|
if text then
|
||||||
|
text:SetText("Auto Sell Junk")
|
||||||
|
|
||||||
|
local font, _, flags = text:GetFont()
|
||||||
|
if font then
|
||||||
|
text:SetFont(font, 13, flags)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
self.tooltipText = "Automatically sell gray (junk) items when you visit a vendor."
|
||||||
|
|
||||||
|
local enabled = true
|
||||||
|
if Guda and Guda.Modules and Guda.Modules.DB then
|
||||||
|
enabled = Guda.Modules.DB:GetSetting("autoVendorJunk")
|
||||||
|
if enabled == nil then enabled = true end
|
||||||
|
end
|
||||||
|
|
||||||
|
self:SetChecked(enabled and 1 or 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Auto Vendor Junk Checkbox OnClick
|
||||||
|
function Guda_SettingsPopup_AutoVendorJunkCheckbox_OnClick(self)
|
||||||
|
local isChecked = self:GetChecked() == 1
|
||||||
|
|
||||||
|
if Guda and Guda.Modules and Guda.Modules.DB then
|
||||||
|
Guda.Modules.DB:SetSetting("autoVendorJunk", isChecked)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- White Items as Junk Checkbox OnLoad
|
||||||
|
function Guda_SettingsPopup_WhiteItemsJunkCheckbox_OnLoad(self)
|
||||||
|
local text = getglobal(self:GetName().."Text")
|
||||||
|
if text then
|
||||||
|
text:SetText("White Items as Junk")
|
||||||
|
|
||||||
|
local font, _, flags = text:GetFont()
|
||||||
|
if font then
|
||||||
|
text:SetFont(font, 13, flags)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
self.tooltipText = "Treat white (common) equippable items as junk. They will be dimmed and auto-sold if auto-sell is enabled."
|
||||||
|
|
||||||
|
local enabled = false
|
||||||
|
if Guda and Guda.Modules and Guda.Modules.DB then
|
||||||
|
enabled = Guda.Modules.DB:GetSetting("whiteItemsJunk")
|
||||||
|
if enabled == nil then enabled = false end
|
||||||
|
end
|
||||||
|
|
||||||
|
self:SetChecked(enabled and 1 or 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- White Items as Junk Checkbox OnClick
|
||||||
|
function Guda_SettingsPopup_WhiteItemsJunkCheckbox_OnClick(self)
|
||||||
|
local isChecked = self:GetChecked() == 1
|
||||||
|
|
||||||
|
if Guda and Guda.Modules and Guda.Modules.DB then
|
||||||
|
Guda.Modules.DB:SetSetting("whiteItemsJunk", isChecked)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Clear item detection cache so junk status is re-evaluated
|
||||||
|
if Guda.Modules.ItemDetection and Guda.Modules.ItemDetection.ClearCache then
|
||||||
|
Guda.Modules.ItemDetection:ClearCache()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Update bag and bank frames
|
||||||
|
local bagFrame = getglobal("Guda_BagFrame")
|
||||||
|
if bagFrame and bagFrame:IsShown() then
|
||||||
|
Guda.Modules.BagFrame:Update()
|
||||||
|
end
|
||||||
|
|
||||||
|
local bankFrame = getglobal("Guda_BankFrame")
|
||||||
|
if bankFrame and bankFrame:IsShown() then
|
||||||
|
Guda.Modules.BankFrame:Update()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Theme Dropdown OnClick
|
-- Theme Dropdown OnClick
|
||||||
function Guda_SettingsPopup_ThemeDropdown_OnClick(button)
|
function Guda_SettingsPopup_ThemeDropdown_OnClick(button)
|
||||||
local themes = {
|
local themes = {
|
||||||
|
|||||||
+28
-1
@@ -317,6 +317,20 @@
|
|||||||
<OnClick>Guda_SettingsPopup_ReverseStackSortCheckbox_OnClick(this)</OnClick>
|
<OnClick>Guda_SettingsPopup_ReverseStackSortCheckbox_OnClick(this)</OnClick>
|
||||||
</Scripts>
|
</Scripts>
|
||||||
</CheckButton>
|
</CheckButton>
|
||||||
|
|
||||||
|
<!-- Automation section -->
|
||||||
|
<!-- Auto Sell Junk Checkbox -->
|
||||||
|
<CheckButton name="Guda_SettingsPopup_AutoVendorJunkCheckbox" inherits="OptionsCheckButtonTemplate">
|
||||||
|
<Anchors>
|
||||||
|
<Anchor point="TOPLEFT" relativePoint="BOTTOMLEFT" relativeTo="Guda_SettingsPopup_ShowTooltipCountsCheckbox">
|
||||||
|
<Offset><AbsDimension x="0" y="-35"/></Offset>
|
||||||
|
</Anchor>
|
||||||
|
</Anchors>
|
||||||
|
<Scripts>
|
||||||
|
<OnLoad>Guda_SettingsPopup_AutoVendorJunkCheckbox_OnLoad(this)</OnLoad>
|
||||||
|
<OnClick>Guda_SettingsPopup_AutoVendorJunkCheckbox_OnClick(this)</OnClick>
|
||||||
|
</Scripts>
|
||||||
|
</CheckButton>
|
||||||
</Frames>
|
</Frames>
|
||||||
</Frame>
|
</Frame>
|
||||||
|
|
||||||
@@ -555,11 +569,24 @@
|
|||||||
</Scripts>
|
</Scripts>
|
||||||
</CheckButton>
|
</CheckButton>
|
||||||
|
|
||||||
|
<!-- White Items as Junk Checkbox -->
|
||||||
|
<CheckButton name="Guda_SettingsPopup_WhiteItemsJunkCheckbox" inherits="OptionsCheckButtonTemplate">
|
||||||
|
<Anchors>
|
||||||
|
<Anchor point="TOPLEFT" relativePoint="BOTTOMLEFT" relativeTo="Guda_SettingsPopup_MarkUnusableCheckbox">
|
||||||
|
<Offset><AbsDimension x="0" y="-8"/></Offset>
|
||||||
|
</Anchor>
|
||||||
|
</Anchors>
|
||||||
|
<Scripts>
|
||||||
|
<OnLoad>Guda_SettingsPopup_WhiteItemsJunkCheckbox_OnLoad(this)</OnLoad>
|
||||||
|
<OnClick>Guda_SettingsPopup_WhiteItemsJunkCheckbox_OnClick(this)</OnClick>
|
||||||
|
</Scripts>
|
||||||
|
</CheckButton>
|
||||||
|
|
||||||
<!-- Junk Item Opacity Slider -->
|
<!-- Junk Item Opacity Slider -->
|
||||||
<Slider name="Guda_SettingsPopup_JunkOpacitySlider" inherits="OptionsSliderTemplate">
|
<Slider name="Guda_SettingsPopup_JunkOpacitySlider" inherits="OptionsSliderTemplate">
|
||||||
<Size><AbsDimension x="450" y="17"/></Size>
|
<Size><AbsDimension x="450" y="17"/></Size>
|
||||||
<Anchors>
|
<Anchors>
|
||||||
<Anchor point="TOPLEFT" relativePoint="BOTTOMLEFT" relativeTo="Guda_SettingsPopup_MarkUnusableCheckbox">
|
<Anchor point="TOPLEFT" relativePoint="BOTTOMLEFT" relativeTo="Guda_SettingsPopup_WhiteItemsJunkCheckbox">
|
||||||
<Offset><AbsDimension x="0" y="-25"/></Offset>
|
<Offset><AbsDimension x="0" y="-25"/></Offset>
|
||||||
</Anchor>
|
</Anchor>
|
||||||
</Anchors>
|
</Anchors>
|
||||||
|
|||||||
Reference in New Issue
Block a user