fix: quality item colors
This commit is contained in:
@@ -491,6 +491,20 @@ function Utils:GetQualityColor(quality)
|
|||||||
return color.r, color.g, color.b
|
return color.r, color.g, color.b
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Extract RGB color from an item link's |cffRRGGBB prefix (the title color)
|
||||||
|
-- Returns r, g, b (0-1 floats) or nil if no color found
|
||||||
|
function Utils:GetLinkColor(itemLink)
|
||||||
|
if not itemLink then return nil end
|
||||||
|
-- Lua 5.0: use string.find with captures instead of string.match
|
||||||
|
local _, _, hex = string.find(itemLink, "|c(%x%x%x%x%x%x%x%x)")
|
||||||
|
if not hex then return nil end
|
||||||
|
-- hex is AARRGGBB
|
||||||
|
local r = tonumber(string.sub(hex, 3, 4), 16) / 255
|
||||||
|
local g = tonumber(string.sub(hex, 5, 6), 16) / 255
|
||||||
|
local b = tonumber(string.sub(hex, 7, 8), 16) / 255
|
||||||
|
return r, g, b
|
||||||
|
end
|
||||||
|
|
||||||
-- Create colored text
|
-- Create colored text
|
||||||
function Utils:ColorText(text, r, g, b)
|
function Utils:ColorText(text, r, g, b)
|
||||||
local red = math.floor(r * 255)
|
local red = math.floor(r * 255)
|
||||||
|
|||||||
+29
-13
@@ -865,9 +865,18 @@ local function UpdateQualityBorder(self, itemQuality, itemLink, bagID, Utils)
|
|||||||
local shouldShowBorder = (isEquipment and showEquipmentBorder) or (not isEquipment and showOtherBorder)
|
local shouldShowBorder = (isEquipment and showEquipmentBorder) or (not isEquipment and showOtherBorder)
|
||||||
|
|
||||||
if shouldShowBorder then
|
if shouldShowBorder then
|
||||||
local r, g, b = 1, 1, 1
|
-- Use the item link's title color directly (matches what the player sees)
|
||||||
if Utils and Utils.GetQualityColor then
|
local r, g, b
|
||||||
r, g, b = Utils:GetQualityColor(itemQuality)
|
if itemLink and Utils and Utils.GetLinkColor then
|
||||||
|
r, g, b = Utils:GetLinkColor(itemLink)
|
||||||
|
end
|
||||||
|
if not r then
|
||||||
|
-- Fallback to quality-based color
|
||||||
|
if Utils and Utils.GetQualityColor then
|
||||||
|
r, g, b = Utils:GetQualityColor(itemQuality)
|
||||||
|
else
|
||||||
|
r, g, b = 1, 1, 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
self.qualityBorder:SetBackdropBorderColor(r, g, b, 1)
|
self.qualityBorder:SetBackdropBorderColor(r, g, b, 1)
|
||||||
self.qualityBorder:Show()
|
self.qualityBorder:Show()
|
||||||
@@ -1165,13 +1174,13 @@ function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCha
|
|||||||
-- Ensure itemData is populated for live items (needed for ItemDetection)
|
-- Ensure itemData is populated for live items (needed for ItemDetection)
|
||||||
if itemLink then
|
if itemLink then
|
||||||
local itemName, _, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture = GetItemInfo(itemLink)
|
local itemName, _, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture = GetItemInfo(itemLink)
|
||||||
-- For bank main bag, get quality from GetItemInfo
|
-- Always prefer GetItemInfo quality — GetContainerItemInfo often
|
||||||
if self.isBank and bagID == -1 then
|
-- returns wrong quality (e.g. 1/white) for epic tokens in TurtleWoW 1.12
|
||||||
|
if itemRarity then
|
||||||
itemQuality = itemRarity
|
itemQuality = itemRarity
|
||||||
-- Fall back to itemData.quality if GetItemInfo returned nil
|
end
|
||||||
if itemQuality == nil and itemData and itemData.quality then
|
if itemQuality == nil and itemData and itemData.quality then
|
||||||
itemQuality = itemData.quality
|
itemQuality = itemData.quality
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if not itemData then
|
if not itemData then
|
||||||
-- Create new itemData
|
-- Create new itemData
|
||||||
@@ -1306,10 +1315,17 @@ function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCha
|
|||||||
local shouldShowBorder = (isEquipment and showEquipmentBorder) or (not isEquipment and showOtherBorder)
|
local shouldShowBorder = (isEquipment and showEquipmentBorder) or (not isEquipment and showOtherBorder)
|
||||||
|
|
||||||
if shouldShowBorder then
|
if shouldShowBorder then
|
||||||
-- Show colored border for all items (Poor, Common, Uncommon, Rare, Epic, etc.)
|
-- Use the item link's title color directly (matches what the player sees)
|
||||||
local r, g, b = 1, 1, 1
|
local r, g, b
|
||||||
if Utils and Utils.GetQualityColor then
|
if itemLink and Utils and Utils.GetLinkColor then
|
||||||
r, g, b = Utils:GetQualityColor(itemQuality)
|
r, g, b = Utils:GetLinkColor(itemLink)
|
||||||
|
end
|
||||||
|
if not r then
|
||||||
|
if Utils and Utils.GetQualityColor then
|
||||||
|
r, g, b = Utils:GetQualityColor(itemQuality)
|
||||||
|
else
|
||||||
|
r, g, b = 1, 1, 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
self.qualityBorder:SetBackdropBorderColor(r, g, b, 1)
|
self.qualityBorder:SetBackdropBorderColor(r, g, b, 1)
|
||||||
self.qualityBorder:Show()
|
self.qualityBorder:Show()
|
||||||
|
|||||||
Reference in New Issue
Block a user