diff --git a/!Compatibility/api/wowAPI.lua b/!Compatibility/api/wowAPI.lua index 2a853cf..27d8e84 100644 --- a/!Compatibility/api/wowAPI.lua +++ b/!Compatibility/api/wowAPI.lua @@ -10,6 +10,7 @@ local unpack = unpack local find, format, gsub, lower, match, upper = string.find, string.format, string.gsub, string.lower, string.match, string.upper local getn = table.getn --WoW API +local GetInventoryItemTexture = GetInventoryItemTexture local GetItemInfo = GetItemInfo local GetQuestGreenRange = GetQuestGreenRange local GetRealZoneText = GetRealZoneText @@ -21,6 +22,7 @@ local UnitLevel = UnitLevel local DUNGEON_DIFFICULTY1 = DUNGEON_DIFFICULTY1 local TIMEMANAGER_AM = gsub(TIME_TWELVEHOURAM, "^.-(%w+)$", "%1") local TIMEMANAGER_PM = gsub(TIME_TWELVEHOURPM, "^.-(%w+)$", "%1") +local DURABILITY_TEMPLATE = gsub(DURABILITY_TEMPLATE, "%%d / %%d", "(%%d+) / (%%d+)") --Libs local LBC = LibStub("LibBabble-Class-3.0"):GetLookupTable() local LBZ = LibStub("LibBabble-Zone-3.0"):GetLookupTable() @@ -472,4 +474,24 @@ function GetItemCount(itemName) end return count +end + +local scan +function GetInventoryItemDurability(slot) + if not GetInventoryItemTexture("player", slot) then return nil, nil end + + if not scan then + scan = CreateFrame("GameTooltip", "DurabilityScan", nil, "ShoppingTooltipTemplate") + scan:SetOwner(UIParent, "ANCHOR_NONE") + end + + scan:ClearLines() + scan:SetInventoryItem("player", slot) + + for i = 4, scan:NumLines() do + local text = _G[scan:GetName().."TextLeft"..i]:GetText() + for durability, max in string.gfind(text, DURABILITY_TEMPLATE) do + return tonumber(durability), tonumber(max) + end + end end \ No newline at end of file diff --git a/ElvUI/Modules/DataTexts/Durability.lua b/ElvUI/Modules/DataTexts/Durability.lua index c3e510d..9d3f4bd 100644 --- a/ElvUI/Modules/DataTexts/Durability.lua +++ b/ElvUI/Modules/DataTexts/Durability.lua @@ -11,9 +11,8 @@ local GetInventoryItemDurability = GetInventoryItemDurability local GetInventoryItemTexture = GetInventoryItemTexture local GetInventorySlotInfo = GetInventorySlotInfo local ToggleCharacter = ToggleCharacter -local DURABILITY_TEMPLATE = string.gsub(DURABILITY_TEMPLATE, "%%d / %%d", "(%%d+) / (%%d+)") -local DURABILITY = "Durability" -- Neel ElvUI locale +local DURABILITY = "Durability" local displayString = "" local tooltipString = "%d%%" @@ -34,26 +33,6 @@ local slots = { "HeadSlot" } -local scan -local function GetInventoryItemDurability(slot) - if not GetInventoryItemTexture("player", slot) then return nil, nil end - - if not scan then - scan = CreateFrame("GameTooltip", "DurabilityScan", nil, "ShoppingTooltipTemplate") - scan:SetOwner(UIParent, "ANCHOR_NONE") - end - - scan:ClearLines() - scan:SetInventoryItem("player", slot) - - for i = 4, scan:NumLines() do - local text = _G[scan:GetName().."TextLeft"..i]:GetText() - for durability, max in string.gfind(text, DURABILITY_TEMPLATE) do - return tonumber(durability), tonumber(max) - end - end -end - local function OnEvent(self, t) lastPanel = self totalDurability = 100