vendor sell icon for junk items in sigle bag view
This commit is contained in:
+68
-1
@@ -17,6 +17,58 @@ local function IsQuestItem(bagID, slotID, isBank)
|
|||||||
return false, false
|
return false, false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--=====================================================
|
||||||
|
-- Junk Icon Helper Functions (reusable for all views)
|
||||||
|
-- Shows a vendor sell icon on junk items
|
||||||
|
--=====================================================
|
||||||
|
|
||||||
|
-- Create junk icon for a button (parented to UIParent for full opacity)
|
||||||
|
local function CreateJunkIcon(button)
|
||||||
|
if button.junkIcon then return button.junkIcon end
|
||||||
|
|
||||||
|
local junkFrame = CreateFrame("Frame", nil, UIParent)
|
||||||
|
junkFrame:SetFrameStrata("HIGH")
|
||||||
|
junkFrame:SetWidth(14)
|
||||||
|
junkFrame:SetHeight(14)
|
||||||
|
|
||||||
|
local texture = junkFrame:CreateTexture(nil, "OVERLAY")
|
||||||
|
texture:SetAllPoints(junkFrame)
|
||||||
|
texture:SetTexture("Interface\\GossipFrame\\VendorGossipIcon")
|
||||||
|
texture:SetTexCoord(0, 1, 0, 1)
|
||||||
|
|
||||||
|
junkFrame:Hide()
|
||||||
|
button.junkIcon = junkFrame
|
||||||
|
return junkFrame
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Update junk icon visibility and position
|
||||||
|
local function UpdateJunkIcon(button, isJunk, iconSize)
|
||||||
|
-- Create icon if it doesn't exist
|
||||||
|
if not button.junkIcon then
|
||||||
|
CreateJunkIcon(button)
|
||||||
|
end
|
||||||
|
|
||||||
|
if isJunk then
|
||||||
|
-- Scale icon size based on button size
|
||||||
|
local junkIconSize = math.max(10, math.min(14, iconSize * 0.30))
|
||||||
|
button.junkIcon:SetWidth(junkIconSize)
|
||||||
|
button.junkIcon:SetHeight(junkIconSize)
|
||||||
|
button.junkIcon:ClearAllPoints()
|
||||||
|
button.junkIcon:SetPoint("TOPLEFT", button, "TOPLEFT", 2, -2)
|
||||||
|
button.junkIcon:SetAlpha(1.0)
|
||||||
|
button.junkIcon:Show()
|
||||||
|
else
|
||||||
|
button.junkIcon:Hide()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Hide junk icon (for cleanup/reset)
|
||||||
|
local function HideJunkIcon(button)
|
||||||
|
if button.junkIcon then
|
||||||
|
button.junkIcon:Hide()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--=====================================================
|
--=====================================================
|
||||||
-- Unusable item detection (pfUI-inspired implementation)
|
-- Unusable item detection (pfUI-inspired implementation)
|
||||||
-- Adds a red tint overlay to items that your character
|
-- Adds a red tint overlay to items that your character
|
||||||
@@ -276,6 +328,9 @@ function Guda_ItemButton_OnLoad(self)
|
|||||||
self.questIcon = iconFrame
|
self.questIcon = iconFrame
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Create junk icon overlay (vendor sell icon in top-left corner)
|
||||||
|
CreateJunkIcon(self)
|
||||||
|
|
||||||
-- Ensure the item button sits above its container backdrop and is mouse-enabled
|
-- Ensure the item button sits above its container backdrop and is mouse-enabled
|
||||||
local parent = self:GetParent()
|
local parent = self:GetParent()
|
||||||
if parent and parent.GetFrameLevel then
|
if parent and parent.GetFrameLevel then
|
||||||
@@ -296,7 +351,12 @@ function Guda_ItemButton_OnLoad(self)
|
|||||||
if self.RegisterForClicks then
|
if self.RegisterForClicks then
|
||||||
self:RegisterForClicks("LeftButtonUp", "RightButtonUp")
|
self:RegisterForClicks("LeftButtonUp", "RightButtonUp")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Hide junk icon when button is hidden (since it's parented to UIParent)
|
||||||
|
self:SetScript("OnHide", function()
|
||||||
|
HideJunkIcon(this)
|
||||||
|
end)
|
||||||
|
|
||||||
self:SetScript("OnClick", function()
|
self:SetScript("OnClick", function()
|
||||||
if IsAltKeyDown() and arg1 == "LeftButton" and this.hasItem and not this.otherChar and not this.isReadOnly then
|
if IsAltKeyDown() and arg1 == "LeftButton" and this.hasItem and not this.otherChar and not this.isReadOnly then
|
||||||
local link = GetContainerItemLink(this.bagID, this.slotID)
|
local link = GetContainerItemLink(this.bagID, this.slotID)
|
||||||
@@ -403,6 +463,7 @@ local function ResetButtonVisualState(self)
|
|||||||
if self.questIcon then self.questIcon:Hide() end
|
if self.questIcon then self.questIcon:Hide() end
|
||||||
if self.qualityBorder then self.qualityBorder:Hide() end
|
if self.qualityBorder then self.qualityBorder:Hide() end
|
||||||
if self.unusableOverlay then self.unusableOverlay:Hide() end
|
if self.unusableOverlay then self.unusableOverlay:Hide() end
|
||||||
|
HideJunkIcon(self)
|
||||||
|
|
||||||
-- Clear cooldown overlay
|
-- Clear cooldown overlay
|
||||||
local cd = getglobal(self:GetName().."Cooldown") or self.cooldown
|
local cd = getglobal(self:GetName().."Cooldown") or self.cooldown
|
||||||
@@ -668,6 +729,9 @@ local function ClearItemButton(self, emptySlotBg, countText, bagID)
|
|||||||
self.unusableOverlay:Hide()
|
self.unusableOverlay:Hide()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Hide junk icon
|
||||||
|
HideJunkIcon(self)
|
||||||
|
|
||||||
-- Hide normal texture
|
-- Hide normal texture
|
||||||
self:SetNormalTexture("")
|
self:SetNormalTexture("")
|
||||||
local normalBorder = getglobal(self:GetName().."NormalTexture")
|
local normalBorder = getglobal(self:GetName().."NormalTexture")
|
||||||
@@ -948,6 +1012,9 @@ function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCha
|
|||||||
self:SetAlpha(0.25)
|
self:SetAlpha(0.25)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Show/hide junk icon (vendor sell icon in top-left corner)
|
||||||
|
UpdateJunkIcon(self, isJunk, iconSize)
|
||||||
|
|
||||||
-- Set count (use displayCount which was determined above based on mode)
|
-- Set count (use displayCount which was determined above based on mode)
|
||||||
if displayCount and displayCount > 1 then
|
if displayCount and displayCount > 1 then
|
||||||
countText:SetText(displayCount)
|
countText:SetText(displayCount)
|
||||||
|
|||||||
Reference in New Issue
Block a user