hotfix: unusable item overlay

This commit is contained in:
Salikh Gurgenidze
2025-11-23 16:03:30 +04:00
parent b8f46eca33
commit fddb101200
+31 -26
View File
@@ -169,35 +169,40 @@ end
-- Apply/remove red tint on item texture for unusable items -- Apply/remove red tint on item texture for unusable items
local function Guda_ItemButton_UpdateUsableTint(self) local function Guda_ItemButton_UpdateUsableTint(self)
-- Only evaluate for live (player) items; DB cached items from other chars cannot be scanned -- Clear any existing tint/overlay first
if not self or not self.hasItem or not self.bagID or not self.slotID or self.isReadOnly then if self.unusableOverlay and self.unusableOverlay.Hide then
-- Clear any tint/overlay on non-live/empty slots self.unusableOverlay:Hide()
if self.unusableOverlay and self.unusableOverlay.Hide then self.unusableOverlay:Hide() end end
if SetItemButtonTextureVertexColor then SetItemButtonTextureVertexColor(self, 1.0, 1.0, 1.0) end if SetItemButtonTextureVertexColor then
return SetItemButtonTextureVertexColor(self, 1.0, 1.0, 1.0)
end end
local unusable = IsItemUnusable(self.bagID, self.slotID, self.isBank) -- Only evaluate for live (player) items; DB cached items from other chars cannot be scanned
-- Ensure overlay exists (created in OnLoad, but be defensive) if not self or not self.hasItem or not self.bagID or not self.slotID or self.isReadOnly or self.otherChar then
if not self.unusableOverlay then return
local icon = getglobal(self:GetName().."IconTexture") or getglobal(self:GetName().."Icon") or self.icon or self.Icon end
local overlay = (icon and icon:GetParent() or self):CreateTexture(nil, "OVERLAY")
overlay:SetAllPoints(icon or self)
overlay:SetTexture("Interface\\ChatFrame\\ChatFrameBackground")
overlay:Hide()
self.unusableOverlay = overlay
end
-- Always reset base icon vertex color to white; we drive the red via overlay to avoid external resets local unusable = IsItemUnusable(self.bagID, self.slotID, self.isBank)
if SetItemButtonTextureVertexColor then SetItemButtonTextureVertexColor(self, 1.0, 1.0, 1.0) end
if unusable then -- Ensure overlay exists (created in OnLoad, but be defensive)
local r, g, b, a = Guda_GetUnusableColor() if not self.unusableOverlay then
-- Slightly reduce alpha to avoid over-darkening the icon local icon = getglobal(self:GetName().."IconTexture") or getglobal(self:GetName().."Icon") or self.icon or self.Icon
local alpha = (a or 1.0) * 0.45 local overlay = (icon and icon:GetParent() or self):CreateTexture(nil, "OVERLAY")
self.unusableOverlay:SetVertexColor(r or 0.9, g or 0.2, b or 0.2, alpha) overlay:SetAllPoints(icon or self)
self.unusableOverlay:Show() overlay:SetTexture("Interface\\ChatFrame\\ChatFrameBackground")
end overlay:Hide()
self.unusableOverlay = overlay
end
if unusable then
local r, g, b, a = Guda_GetUnusableColor()
-- Slightly reduce alpha to avoid over-darkening the icon
local alpha = (a or 1.0) * 0.45
self.unusableOverlay:SetVertexColor(r or 0.9, g or 0.2, b or 0.2, alpha)
self.unusableOverlay:Show()
else
self.unusableOverlay:Hide()
end
end end