Skip to content

Commit

Permalink
Update for C_Item deprecations (and others)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nevcairiel committed Jul 3, 2024
1 parent 372bfb2 commit 18506fc
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 25 deletions.
3 changes: 0 additions & 3 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ read_globals = {
"DepositReagentBank",
"GetBankSlotCost",
"GetBuildInfo",
"GetItemIcon",
"GetItemInfo",
"GetItemInfoInstant",
"GetNumBankSlots",
"GetReagentBankCost",
"GetRealmName",
Expand Down
2 changes: 1 addition & 1 deletion Bag.lua
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ function BagMixin:UpdateSlotInfo()
if link then
self.hasItem = link

SetItemButtonTexture(self, texture or GetItemIcon(link))
SetItemButtonTexture(self, texture or C_Item.GetItemIconByID(link))
SetItemButtonTextureVertexColor(self, 1, 1, 1)
else
self.hasItem = nil
Expand Down
6 changes: 3 additions & 3 deletions Item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ function InventorianItemMixin:GetInfo()
if self:IsCached() then
icon, count, locked, quality, readable, lootable, link = ItemCache:GetItemInfo(player, self.bag, self.slot)
if link then
itemID = GetItemInfoInstant(link)
itemID = C_Item.GetItemInfoInstant(link)
end
else
-- LibItemCache doesn't provide noValue or itemID, so fallback to base API
Expand All @@ -412,12 +412,12 @@ function InventorianItemMixin:GetInfo()
isBound = info.isBound
end
if link and (not quality or quality < 0) then
quality = select(3, GetItemInfo(link))
quality = C_Item.GetItemQualityByID(link)
end
end

if not icon and (itemID or link) then
self.itemID = itemID or GetItemInfoInstant(link)
self.itemID = itemID or C_Item.GetItemInfoInstant(link)
if self:IsCached() then
self:RegisterEvent("ITEM_DATA_LOAD_RESULT")
C_Item.RequestLoadItemDataByID(self.itemID)
Expand Down
14 changes: 7 additions & 7 deletions libs/LibItemCache-1.1/Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ along with this library. If not, see <http://www.gnu.org/licenses/>.
This file is part of LibItemCache.
--]]

local Lib = LibStub:NewLibrary('LibItemCache-1.1', 30)
local Lib = LibStub:NewLibrary('LibItemCache-1.1', 31)
if not Lib then
return
end
Expand Down Expand Up @@ -237,7 +237,7 @@ function Lib:GetItemQuality(link)
if link:find('battlepet') then
return tonumber(link:match('%d+:%d+:(%d+)'))
else
return select(3, GetItemInfo(link))
return C_Item.GetItemQualityByID(link)
end
end

Expand All @@ -250,8 +250,8 @@ function Lib:GetItemCounts(player, id)
else
local vault, guild = select(4, Cache('GetItemCounts', realm, name, id))
local id, equip = tonumber(id), 0
local total = GetItemCount(id, true)
local bags = GetItemCount(id)
local total = C_Item.GetItemCount(id, true, false, true)
local bags = C_Item.GetItemCount(id)

for i = 1, INVSLOT_LAST_EQUIPPED do
if GetInventoryItemID('player', i) == id then
Expand Down Expand Up @@ -280,16 +280,16 @@ function Lib:RestorePetLink(partial)
local id, _, quality = strsplit(':', partial)
local name, icon = C_PetJournal.GetPetInfoBySpeciesID(id)

local color = select(4, GetItemQualityColor(quality))
local color = select(4, C_Item.GetItemQualityColor(quality))
local link = PetLinkFormat:format(color, partial, name)

return link, icon, tonumber(quality)
end

function Lib:RestoreItemLink(partial)
local partial = 'item:' .. partial
local _, link, quality = GetItemInfo(partial)
return link or partial, GetItemIcon(link), quality
local _, link, quality = C_Item.GetItemInfo(partial)
return link or partial, C_Item.GetItemIconByID(link), quality
end


Expand Down
22 changes: 11 additions & 11 deletions libs/LibItemSearch-1.0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<op> := : | = | == | != | ~= | < | > | <= | >=
--]]

local Lib = LibStub:NewLibrary('LibItemSearch-Inventorian-1.0', 4)
local Lib = LibStub:NewLibrary('LibItemSearch-Inventorian-1.0', 5)
if not Lib then
return
else
Expand Down Expand Up @@ -207,7 +207,7 @@ Lib:RegisterTypedSearch{
end,

findItem = function(self, item, _, search)
local name = GetItemInfo(item)
local name = C_Item.GetItemInfo(item)
return match(search, name)
end
}
Expand All @@ -224,7 +224,7 @@ Lib:RegisterTypedSearch{
end,

findItem = function(self, item, _, search)
local type, subType, _, equipSlot = select(6, GetItemInfo(item))
local type, subType, _, equipSlot = select(6, C_Item.GetItemInfo(item))
return match(search, type, subType, _G[equipSlot])
end
}
Expand All @@ -250,7 +250,7 @@ Lib:RegisterTypedSearch{
end,

findItem = function(self, link, operator, num)
local quality = select(3, GetItemInfo(link))
local quality = select(3, C_Item.GetItemInfo(link))
return compare(operator, quality, num)
end,
}
Expand All @@ -267,7 +267,7 @@ Lib:RegisterTypedSearch{
end,

findItem = function(self, link, operator, num)
local lvl = select(4, GetItemInfo(link))
local lvl = select(4, C_Item.GetItemInfo(link))
if lvl then
return compare(operator, lvl, num)
end
Expand All @@ -285,7 +285,7 @@ Lib:RegisterTypedSearch{
end,

findItem = function(self, link, operator, num)
local lvl = select(5, GetItemInfo(link))
local lvl = select(5, C_Item.GetItemInfo(link))
if lvl then
return compare(operator, lvl, num)
end
Expand All @@ -312,7 +312,7 @@ Lib:RegisterTypedSearch{
end,

findItem = function(self, link, operator, num)
local isCrafting = select(17, GetItemInfo(link))
local isCrafting = select(17, C_Item.GetItemInfo(link))
return isCrafting
end,
}
Expand Down Expand Up @@ -381,7 +381,7 @@ Lib:RegisterTypedSearch{
['bop'] = ITEM_BIND_ON_PICKUP,
['bou'] = ITEM_BIND_ON_USE,
['quest'] = ITEM_BIND_QUEST,
[GetItemClassInfo(Enum.ItemClass.Questitem):lower()] = ITEM_BIND_QUEST,
[C_Item.GetItemClassInfo(Enum.ItemClass.Questitem):lower()] = ITEM_BIND_QUEST,
['boa'] = ITEM_BIND_TO_BNETACCOUNT,
['unique'] = ITEM_UNIQUE,
[ITEM_UNIQUE:lower()] = ITEM_UNIQUE,
Expand Down Expand Up @@ -478,7 +478,7 @@ local function ES_TrySetName(setName, search, exactMatch)
end

--Addon Support: ItemRack
if IsAddOnLoaded('ItemRack') then
if C_AddOns.IsAddOnLoaded('ItemRack') then
function ES_FindSets(setList, search, exactMatch)
for setName, _ in pairs(ItemRackUser.Sets) do
if ES_TrySetName(setName, search, exactMatch) then
Expand Down Expand Up @@ -513,7 +513,7 @@ if IsAddOnLoaded('ItemRack') then
end

--Addon Support: Wardrobe
elseif IsAddOnLoaded('Wardrobe') then
elseif C_AddOns.IsAddOnLoaded('Wardrobe') then
function ES_FindSets(setList, search, exactMatch)
for _, waOutfit in ipairs(Wardrobe.CurrentConfig.Outfit) do
if ES_TrySetName(waOutfit.OutfitName, search, exactMatch) then
Expand Down Expand Up @@ -580,7 +580,7 @@ Lib:RegisterTypedSearch{

findItem = function(self, itemLink, _, search)
--this is an item-set search and we know that the only items that can possibly match will be *equippable* items, so we'll short-circuit the response for non-equippable items to speed up searches.
if not IsEquippableItem(itemLink) then return false end
if not C_Item.IsEquippableItem(itemLink) then return false end

--default to matching *all* equipment sets if no set name has been provided yet
if search == '' then search = '*' end
Expand Down

0 comments on commit 18506fc

Please sign in to comment.