From 70b8e2bb118bd9bbceb8a086d6dca710905f1389 Mon Sep 17 00:00:00 2001 From: Larsj02 Date: Sat, 18 May 2024 10:48:59 +0200 Subject: [PATCH] Checking Slots doesn't require opening Socketing UI now (less lag) --- GemUtil.lua | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/GemUtil.lua b/GemUtil.lua index 37387f3..b16c07e 100644 --- a/GemUtil.lua +++ b/GemUtil.lua @@ -52,21 +52,22 @@ end ---@return integer usedSlots ---@return integer maxSlots function gemUtil:GetSocketsInfo(socketTypeName) - misc:MuteSounds() local usedSlots, maxSlots = 0, 0 for _, equipmentSlot in ipairs(const.SOCKET_EQUIPMENT_SLOTS) do - SocketInventoryItem(equipmentSlot) - for socketSlot = 1, GetNumSockets() do - if GetSocketTypes(socketSlot) == socketTypeName then - if GetExistingSocketInfo(socketSlot) then - usedSlots = usedSlots + 1 + local itemLoc = ItemLocation:CreateFromEquipmentSlot(equipmentSlot) + if itemLoc:IsValid() then + local itemLink = C_Item.GetItemLink(itemLoc) + if itemLink then + local itemStats = C_Item.GetItemStats(itemLink) + for stat, count in pairs(itemStats) do + if stat:match("EMPTY_SOCKET_"..socketTypeName:upper()) then + maxSlots = maxSlots + count + usedSlots = usedSlots + #gemUtil:GetItemGems(itemLink) + end end - maxSlots = maxSlots + 1 end end - CloseSocketInfo() end - misc:UnmuteSounds() return usedSlots, maxSlots end @@ -144,7 +145,7 @@ local function passesFilter(itemID, filter) filter = filter:gsub("%%", "%%%%"):gsub("%+", "%%+") local gemItemInfo = Private.Cache:GetItemInfo(itemID) local gemNameAndDesc = (gemItemInfo and gemItemInfo.name or "") .. - (gemItemInfo and gemItemInfo.description or ""):lower() + (gemItemInfo and gemItemInfo.description or ""):lower() if not (filter and not gemNameAndDesc:match(filter)) then return true end