From dd6f3dcb130f9947163bd158f758abe65d700017 Mon Sep 17 00:00:00 2001 From: Lars Norberg Date: Tue, 25 Jul 2023 18:08:11 +0200 Subject: [PATCH] 2.0.77-Release --- Bagnon_ItemLevel/main.lua | 51 ++++++++++++++++++++++++--------------- CHANGELOG.md | 4 +++ 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/Bagnon_ItemLevel/main.lua b/Bagnon_ItemLevel/main.lua index 7b30593..f3cb817 100644 --- a/Bagnon_ItemLevel/main.lua +++ b/Bagnon_ItemLevel/main.lua @@ -31,6 +31,9 @@ end local Module = Bagnon:NewModule(Addon, Private) +local Cache = LibStub("LibItemCache-2.0") +local Container = LibStub("C_Everywhere").Container + -- Speed! local _G = _G local ipairs = ipairs @@ -87,8 +90,16 @@ Module:AddUpdater(function(self) local ispet = battlepetclass and class == battlepetclass -- We only want quality coloring on item- and pet levels, not bag slots. - if (isgear or ispet) and (BagnonItemLevel_DB.enableRarityColoring) then - color = quality and colors[quality] + if (isgear or ispet) then + if (BagnonItemLevel_DB.enableRarityColoring) then + color = quality and colors[quality] + end + -- Update the bagnon cache + if (not level and not self.info.link) then + self.info.link = Container.GetContainerItemLink(self:GetBag(), self:GetID()) + self.info = Cache:RestoreItemData(self.info) + level = self.info.level + end message = level end @@ -99,27 +110,29 @@ Module:AddUpdater(function(self) if (retail) then local tooltipData = C_TooltipInfo.GetBagItem(self:GetBag(), self:GetID()) + if (tooltipData) then - -- Assign data to 'type' and 'guid' fields. - TooltipUtil.SurfaceArgs(tooltipData) - - -- Assign data to 'leftText' fields. - for _, line in ipairs(tooltipData.lines) do - TooltipUtil.SurfaceArgs(line) - end + -- Assign data to 'type' and 'guid' fields. + TooltipUtil.SurfaceArgs(tooltipData) - if (isgear) then - for i = 2,3 do - local msg = tooltipData.lines[i] and tooltipData.lines[i].leftText - if (not msg) then break end + -- Assign data to 'leftText' fields. + for _, line in ipairs(tooltipData.lines) do + TooltipUtil.SurfaceArgs(line) + end - local itemlevel = string_match(msg, s_item_level) - if (itemlevel) then - itemlevel = tonumber(itemlevel) - if (itemlevel > 0) then - message = itemlevel + if (isgear) then + for i = 2,3 do + local msg = tooltipData.lines[i] and tooltipData.lines[i].leftText + if (not msg) then break end + + local itemlevel = string_match(msg, s_item_level) + if (itemlevel) then + itemlevel = tonumber(itemlevel) + if (itemlevel > 0) then + message = itemlevel + end + break end - break end end end diff --git a/CHANGELOG.md b/CHANGELOG.md index c40768d..033a76d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [2.0.77-Release] 2023-07-25 +### Fixed +- Fixed issues occurring with item caches resulting in missing item levels with Bagnon 10.1.3 and higher. + ## [2.0.76-Release] 2023-07-22 ### Changed - Updated addon listing icon and text format.