From 641e5cf0dca2e2c2795505a980f15da8bfc9dcab Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Sun, 11 Dec 2022 14:09:44 -0300 Subject: [PATCH] Lib OpenRaid and Details! Framework updates --- Libs/DF/cooltip.lua | 7 +- Libs/DF/fw.lua | 2 +- Libs/LibOpenRaid/Functions.lua | 100 ++++++++++++---------- Libs/LibOpenRaid/GetPlayerInformation.lua | 14 ++- Libs/LibOpenRaid/LibOpenRaid.lua | 10 ++- Libs/LibOpenRaid/docs.txt | 13 +++ 6 files changed, 92 insertions(+), 54 deletions(-) diff --git a/Libs/DF/cooltip.lua b/Libs/DF/cooltip.lua index acabc149..cc69ff2c 100644 --- a/Libs/DF/cooltip.lua +++ b/Libs/DF/cooltip.lua @@ -15,7 +15,7 @@ local max = math.max --api locals local PixelUtil = PixelUtil or DFPixelUtil -local version = 8 +local version = 9 local CONST_MENU_TYPE_MAINMENU = "main" local CONST_MENU_TYPE_SUBMENU = "sub" @@ -3217,6 +3217,8 @@ function DF:CreateCoolTip() end local wait = 0.2 + local delayToHide = 0.11 + local delayToHideDefault = 0.11 local InjectOnUpdateEnter = function(self, deltaTime) elapsedTime = elapsedTime + deltaTime if (elapsedTime > wait) then @@ -3227,7 +3229,7 @@ function DF:CreateCoolTip() local InjectOnUpdateLeave = function(self, deltaTime) elapsedTime = elapsedTime + deltaTime - if (elapsedTime > 0.2) then + if (elapsedTime > delayToHide) then if (not gameCooltip.mouseOver and not gameCooltip.buttonOver and self == gameCooltip.Host) then gameCooltip:ShowMe(false) end @@ -3240,6 +3242,7 @@ function DF:CreateCoolTip() if (gameCooltip.active) then elapsedTime = 0 + delayToHide = self.CoolTip.HideSpeed or delayToHideDefault self:SetScript("OnUpdate", InjectOnUpdateLeave) else self:SetScript("OnUpdate", nil) diff --git a/Libs/DF/fw.lua b/Libs/DF/fw.lua index 4f59bdbf..c3427b4d 100644 --- a/Libs/DF/fw.lua +++ b/Libs/DF/fw.lua @@ -1,6 +1,6 @@ -local dversion = 402 +local dversion = 403 local major, minor = "DetailsFramework-1.0", dversion local DF, oldminor = LibStub:NewLibrary(major, minor) diff --git a/Libs/LibOpenRaid/Functions.lua b/Libs/LibOpenRaid/Functions.lua index 6e083f23..315bc580 100644 --- a/Libs/LibOpenRaid/Functions.lua +++ b/Libs/LibOpenRaid/Functions.lua @@ -429,6 +429,7 @@ function openRaidLib.GetFoodTierFromAura(auraInfo) return nil end +--called from AddUnitGearList() on LibOpenRaid file function openRaidLib.GearManager.BuildEquipmentItemLinks(equippedGearList) equippedGearList = equippedGearList or {} --nil table for older versions @@ -441,64 +442,71 @@ function openRaidLib.GearManager.BuildEquipmentItemLinks(equippedGearList) local itemLevel = equipmentTable[3] local partialItemLink = equipmentTable[4] - --get the itemId from the partial link to query the itemName with GetItemInfo - local itemId = partialItemLink:match("^%:(%d+)%:") - itemId = tonumber(itemId) - local itemName, _, itemQuality = GetItemInfo(itemId) + if (partialItemLink and type(partialItemLink) == "string") then + --get the itemId from the partial link to query the itemName with GetItemInfo + local itemId = partialItemLink:match("^%:(%d+)%:") + itemId = tonumber(itemId) - --build the full item link - local itemLink = "|cFFEEEEEE|Hitem" .. partialItemLink .. "|h[" .. itemName .. "]|r" + if (itemId) then + local itemName = GetItemInfo(itemId) + if (itemName) then + --build the full item link + local itemLink = "|cFFEEEEEE|Hitem" .. partialItemLink .. "|h[" .. itemName .. "]|r" - --use GetItemInfo again with the now completed itemLink to query the item color - local _, _, itemQuality = GetItemInfo(itemLink) - local qualityColor = ITEM_QUALITY_COLORS[itemQuality] + --use GetItemInfo again with the now completed itemLink to query the item color + local _, _, itemQuality = GetItemInfo(itemLink) + itemQuality = itemQuality or 1 + local qualityColor = ITEM_QUALITY_COLORS[itemQuality] - --replace the item color - --local r, g, b, hex = GetItemQualityColor(qualityColor) - itemLink = itemLink:gsub("FFEEEEEE", qualityColor.color:GenerateHexColor()) + --replace the item color + --local r, g, b, hex = GetItemQualityColor(qualityColor) + itemLink = itemLink:gsub("FFEEEEEE", qualityColor.color:GenerateHexColor()) - wipe(equipmentTable) + wipe(equipmentTable) - equipmentTable.slotId = slotId - equipmentTable.gemSlots = numGemSlots - equipmentTable.itemLevel = itemLevel - equipmentTable.itemLink = itemLink - equipmentTable.itemQuality = itemQuality - equipmentTable.itemId = itemId - equipmentTable.itemName = itemName + equipmentTable.slotId = slotId + equipmentTable.gemSlots = numGemSlots + equipmentTable.itemLevel = itemLevel + equipmentTable.itemLink = itemLink + equipmentTable.itemQuality = itemQuality + equipmentTable.itemId = itemId + equipmentTable.itemName = itemName - local _, _, enchantId, gemId1, gemId2, gemId3, gemId4, suffixId, uniqueId, levelOfTheItem, specId, upgradeInfo, instanceDifficultyId, numBonusIds, restLink = strsplit(":", itemLink) + local _, _, enchantId, gemId1, gemId2, gemId3, gemId4, suffixId, uniqueId, levelOfTheItem, specId, upgradeInfo, instanceDifficultyId, numBonusIds, restLink = strsplit(":", itemLink) - local enchantAttribute = LIB_OPEN_RAID_ENCHANT_SLOTS[slotId] - local nEnchantId = 0 - if (enchantAttribute) then --this slot can receive an enchat - if (enchantId and enchantId ~= "") then - enchantId = tonumber(enchantId) - nEnchantId = enchantId - end + local enchantAttribute = LIB_OPEN_RAID_ENCHANT_SLOTS[slotId] + local nEnchantId = 0 + if (enchantAttribute) then --this slot can receive an enchat + if (enchantId and enchantId ~= "") then + enchantId = tonumber(enchantId) + nEnchantId = enchantId + end - --6400 and above is dragonflight enchantId number space - if (nEnchantId < 6300 and not LIB_OPEN_RAID_DEATHKNIGHT_RUNEFORGING_ENCHANT_IDS[nEnchantId]) then - nEnchantId = 0 - end - end - equipmentTable.enchantId = nEnchantId + --6400 and above is dragonflight enchantId number space + if (nEnchantId < 6300 and not LIB_OPEN_RAID_DEATHKNIGHT_RUNEFORGING_ENCHANT_IDS[nEnchantId]) then + nEnchantId = 0 + end + end + equipmentTable.enchantId = nEnchantId - local nGemId = 0 - local gemsIds = {gemId1, gemId2, gemId3, gemId4} + local nGemId = 0 + local gemsIds = {gemId1, gemId2, gemId3, gemId4} - --check if the item has a socket - if (numGemSlots) then - --check if the socket is empty - for gemSlotId = 1, numGemSlots do - local gemId = tonumber(gemsIds[gemSlotId]) - if (gemId and gemId >= 180000) then - nGemId = gemId - break + --check if the item has a socket + if (numGemSlots) then + --check if the socket is empty + for gemSlotId = 1, numGemSlots do + local gemId = tonumber(gemsIds[gemSlotId]) + if (gemId and gemId >= 180000) then + nGemId = gemId + break + end + end + end + + equipmentTable.gemId = nGemId end end end - - equipmentTable.gemId = nGemId end end \ No newline at end of file diff --git a/Libs/LibOpenRaid/GetPlayerInformation.lua b/Libs/LibOpenRaid/GetPlayerInformation.lua index d09a74ad..e17c384e 100644 --- a/Libs/LibOpenRaid/GetPlayerInformation.lua +++ b/Libs/LibOpenRaid/GetPlayerInformation.lua @@ -20,6 +20,10 @@ local CONST_BTALENT_VERSION_COVENANTS = 9 local CONST_SPELLBOOK_CLASSSPELLS_TABID = 2 local CONST_SPELLBOOK_GENERAL_TABID = 1 +local GetItemInfo = GetItemInfo +local GetItemStats = GetItemStats +local GetInventoryItemLink = GetInventoryItemLink + local isTimewalkWoW = function() local _, _, _, buildInfo = GetBuildInfo() if (buildInfo < 40000) then @@ -390,9 +394,15 @@ function openRaidLib.GearManager.BuildPlayerEquipmentList() local itemID, enchantID, gemID1, gemID2, gemID3, gemID4, suffixID, uniqueID, linkLevel, specializationID, modifiersMask, itemContext = select(2, strsplit(":", itemLink)) itemID = tonumber(itemID) + local effectiveILvl, isPreview, baseILvl = GetDetailedItemLevelInfo(itemLink) + if (not effectiveILvl) then + openRaidLib.mainControl.scheduleUpdatePlayerData() + effectiveILvl = 0 + openRaidLib.__errors[#openRaidLib.__errors+1] = "Fail to get Item Level: " .. (itemID or "invalid itemID") .. " " .. (itemLink and itemLink:gsub("|H", "") or "invalid itemLink") + end + GetItemStats(itemLink, itemStatsTable) local gemSlotsAvailable = itemStatsTable and itemStatsTable.EMPTY_SOCKET_PRISMATIC or 0 - local _, _, _, itemLevel = GetItemInfo(itemLink) local noPrefixItemLink = itemLink : gsub("^|c%x%x%x%x%x%x%x%x|Hitem", "") local linkTable = {strsplit(":", noPrefixItemLink)} @@ -405,7 +415,7 @@ function openRaidLib.GearManager.BuildPlayerEquipmentList() local newItemLink = table.concat(linkTable, ":") newItemLink = newItemLink - equipmentList[#equipmentList+1] = {equipmentSlotId, gemSlotsAvailable, itemLevel, newItemLink} + equipmentList[#equipmentList+1] = {equipmentSlotId, gemSlotsAvailable, effectiveILvl, newItemLink} if (equipmentSlotId == 2) then debug = {itemLink:gsub("|H", ""), newItemLink} diff --git a/Libs/LibOpenRaid/LibOpenRaid.lua b/Libs/LibOpenRaid/LibOpenRaid.lua index 9a7e1b4e..7d63cfd1 100644 --- a/Libs/LibOpenRaid/LibOpenRaid.lua +++ b/Libs/LibOpenRaid/LibOpenRaid.lua @@ -88,6 +88,8 @@ local unpack = table.unpack or _G.unpack LIB_OPEN_RAID_CAN_LOAD = true + openRaidLib.__errors = {} --/dump LibStub:GetLibrary("LibOpenRaid-1.0").__errors + --default values openRaidLib.inGroup = false openRaidLib.UnitIDCache = {} @@ -1013,9 +1015,11 @@ end local playerFullInfo = openRaidLib.UnitInfoManager.GetPlayerFullInfo() openRaidLib.UnitInfoManager.AddUnitInfo(unitName, unpack(playerFullInfo)) - --gear info - local playerGearInfo = openRaidLib.GearManager.GetPlayerFullGearInfo() - openRaidLib.GearManager.AddUnitGearList(unitName, unpack(playerGearInfo)) + --gear info + --C_Timer.After(2, function() + local playerGearInfo = openRaidLib.GearManager.GetPlayerFullGearInfo() + openRaidLib.GearManager.AddUnitGearList(unitName, unpack(playerGearInfo)) + --end) --cooldowns openRaidLib.CooldownManager.UpdatePlayerCooldownsLocally() diff --git a/Libs/LibOpenRaid/docs.txt b/Libs/LibOpenRaid/docs.txt index 3c2493df..514aa1d2 100644 --- a/Libs/LibOpenRaid/docs.txt +++ b/Libs/LibOpenRaid/docs.txt @@ -79,6 +79,19 @@ playerGear = { .noGems = {socketId} .noEnchants = {socketId} .weaponEnchant = number (oils) + .equippedGear = { + { + .slotId = number + .gemSlots = number + .itemLevel = number + .itemLink = string + .itemQuality = number + .itemId = number + .itemName = string + .enchantId = number + .gemId = number + } + } }