fix: trackedItem bar item live
This commit is contained in:
@@ -30,6 +30,7 @@ function TrackedItemBar:ScanForTrackedItems()
|
|||||||
local itemOrder = {}
|
local itemOrder = {}
|
||||||
local itemIsQuest = {}
|
local itemIsQuest = {}
|
||||||
local itemIsQuestStarter = {}
|
local itemIsQuestStarter = {}
|
||||||
|
local itemQualities = {}
|
||||||
|
|
||||||
-- Scan backpack and 4 bags
|
-- Scan backpack and 4 bags
|
||||||
for bagID = 0, 4 do
|
for bagID = 0, 4 do
|
||||||
@@ -50,6 +51,9 @@ function TrackedItemBar:ScanForTrackedItems()
|
|||||||
local isQuest, isStarter = IsQuestItem(bagID, slotID)
|
local isQuest, isStarter = IsQuestItem(bagID, slotID)
|
||||||
itemIsQuest[id] = isQuest
|
itemIsQuest[id] = isQuest
|
||||||
itemIsQuestStarter[id] = isStarter
|
itemIsQuestStarter[id] = isStarter
|
||||||
|
-- Get item quality
|
||||||
|
local _, _, itemQuality = GetItemInfo(id)
|
||||||
|
itemQualities[id] = tonumber(itemQuality)
|
||||||
table.insert(itemOrder, id)
|
table.insert(itemOrder, id)
|
||||||
end
|
end
|
||||||
itemCounts[id] = itemCounts[id] + count
|
itemCounts[id] = itemCounts[id] + count
|
||||||
@@ -84,6 +88,7 @@ function TrackedItemBar:ScanForTrackedItems()
|
|||||||
isQuestStarter = itemIsQuestStarter[id],
|
isQuestStarter = itemIsQuestStarter[id],
|
||||||
isUnusable = isUnusable,
|
isUnusable = isUnusable,
|
||||||
isJunk = isJunk,
|
isJunk = isJunk,
|
||||||
|
quality = itemQualities[id],
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -107,6 +112,7 @@ function TrackedItemBar:Update()
|
|||||||
-- Hide all buttons and their overlays initially
|
-- Hide all buttons and their overlays initially
|
||||||
for _, btn in ipairs(buttons) do
|
for _, btn in ipairs(buttons) do
|
||||||
btn:Hide()
|
btn:Hide()
|
||||||
|
if btn.qualityBorder then btn.qualityBorder:Hide() end
|
||||||
if btn.unusableOverlay then btn.unusableOverlay:Hide() end
|
if btn.unusableOverlay then btn.unusableOverlay:Hide() end
|
||||||
if btn.junkIcon then btn.junkIcon:Hide() end
|
if btn.junkIcon then btn.junkIcon:Hide() end
|
||||||
end
|
end
|
||||||
@@ -130,6 +136,19 @@ function TrackedItemBar:Update()
|
|||||||
questBorder:Hide()
|
questBorder:Hide()
|
||||||
button.questBorder = questBorder
|
button.questBorder = questBorder
|
||||||
|
|
||||||
|
-- Create quality border (colored by rarity)
|
||||||
|
local qualityBorder = CreateFrame("Frame", nil, button)
|
||||||
|
qualityBorder:SetFrameLevel(button:GetFrameLevel() + 5)
|
||||||
|
qualityBorder:SetBackdrop({
|
||||||
|
bgFile = nil,
|
||||||
|
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
|
||||||
|
edgeSize = 12,
|
||||||
|
insets = {left = 4, right = 4, top = 4, bottom = 4}
|
||||||
|
})
|
||||||
|
qualityBorder:SetBackdropBorderColor(0, 0, 0, 0)
|
||||||
|
qualityBorder:Hide()
|
||||||
|
button.qualityBorder = qualityBorder
|
||||||
|
|
||||||
-- Create quest icon (question mark in corner)
|
-- Create quest icon (question mark in corner)
|
||||||
local questIcon = CreateFrame("Frame", nil, button)
|
local questIcon = CreateFrame("Frame", nil, button)
|
||||||
questIcon:SetFrameLevel(button:GetFrameLevel() + 7)
|
questIcon:SetFrameLevel(button:GetFrameLevel() + 7)
|
||||||
@@ -239,6 +258,23 @@ function TrackedItemBar:Update()
|
|||||||
emptyBg:SetHeight(buttonSize)
|
emptyBg:SetHeight(buttonSize)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Position and show/hide quality border
|
||||||
|
if button.qualityBorder then
|
||||||
|
button.qualityBorder:ClearAllPoints()
|
||||||
|
button.qualityBorder:SetPoint("TOPLEFT", icon, "TOPLEFT", -5, 5)
|
||||||
|
button.qualityBorder:SetPoint("BOTTOMRIGHT", icon, "BOTTOMRIGHT", 5, -5)
|
||||||
|
if info.quality and info.quality >= 1 then
|
||||||
|
local r, g, b = 1, 1, 1
|
||||||
|
if addon.Modules.Utils and addon.Modules.Utils.GetQualityColor then
|
||||||
|
r, g, b = addon.Modules.Utils:GetQualityColor(info.quality)
|
||||||
|
end
|
||||||
|
button.qualityBorder:SetBackdropBorderColor(r, g, b, 1)
|
||||||
|
button.qualityBorder:Show()
|
||||||
|
else
|
||||||
|
button.qualityBorder:Hide()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Position and show/hide quest border
|
-- Position and show/hide quest border
|
||||||
if button.questBorder then
|
if button.questBorder then
|
||||||
button.questBorder:ClearAllPoints()
|
button.questBorder:ClearAllPoints()
|
||||||
@@ -386,6 +422,16 @@ function TrackedItemBar:Initialize()
|
|||||||
TrackedItemBar:Update()
|
TrackedItemBar:Update()
|
||||||
end, "TrackedItemBar")
|
end, "TrackedItemBar")
|
||||||
|
|
||||||
|
addon.Modules.Events:Register("PLAYER_LEVEL_UP", function()
|
||||||
|
-- Delay to let client update internal player level before re-scanning tooltips
|
||||||
|
Guda_ScheduleTimer(0.5, function()
|
||||||
|
if addon.Modules.ItemDetection then
|
||||||
|
addon.Modules.ItemDetection:ClearCache()
|
||||||
|
end
|
||||||
|
TrackedItemBar:Update()
|
||||||
|
end)
|
||||||
|
end, "TrackedItemBar")
|
||||||
|
|
||||||
TrackedItemBar:Update()
|
TrackedItemBar:Update()
|
||||||
addon:Debug("TrackedItemBar initialized")
|
addon:Debug("TrackedItemBar initialized")
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user