begin utilizing ClassicAPI

This commit is contained in:
Brues
2026-05-16 13:02:38 -05:00
parent a8ee751b42
commit 67146ef3a4
12 changed files with 202 additions and 214 deletions
+16
View File
@@ -69,12 +69,14 @@ function GameTooltip.SetBagItem(self, container, slot)
end
libtooltip.itemLink = GetContainerItemLink(container, slot)
libtooltip.itemID = C_Container.GetContainerItemID(container, slot)
_, libtooltip.itemCount = GetContainerItemInfo(container, slot)
return pfHookSetBagItem(self, container, slot)
end
local pfHookSetQuestLogItem = GameTooltip.SetQuestLogItem
function GameTooltip.SetQuestLogItem(self, itemType, index)
libtooltip.itemID = GetQuestLogItemID(itemType, index)
libtooltip.itemLink = GetQuestLogItemLink(itemType, index)
if not libtooltip.itemLink then return end
return pfHookSetQuestLogItem(self, itemType, index)
@@ -82,12 +84,14 @@ end
local pfHookSetQuestItem = GameTooltip.SetQuestItem
function GameTooltip.SetQuestItem(self, itemType, index)
libtooltip.itemID = GetQuestItemID(itemType, index)
libtooltip.itemLink = GetQuestItemLink(itemType, index)
return pfHookSetQuestItem(self, itemType, index)
end
local pfHookSetLootItem = GameTooltip.SetLootItem
function GameTooltip.SetLootItem(self, slot)
libtooltip.itemID = GetLootSlotItemID(slot)
libtooltip.itemLink = GetLootSlotLink(slot)
pfHookSetLootItem(self, slot)
end
@@ -95,36 +99,42 @@ end
local pfHookSetInboxItem = GameTooltip.SetInboxItem
function GameTooltip.SetInboxItem(self, mailID, attachmentIndex)
local itemName, itemTexture, inboxItemCount, inboxItemQuality = GetInboxItem(mailID)
libtooltip.itemID = GetInboxItemID(mailID)
libtooltip.itemLink = GetItemLinkByName(itemName)
return pfHookSetInboxItem(self, mailID, attachmentIndex)
end
local pfHookSetInventoryItem = GameTooltip.SetInventoryItem
function GameTooltip.SetInventoryItem(self, unit, slot)
libtooltip.itemID = GetInventoryItemID(unit, slot)
libtooltip.itemLink = GetInventoryItemLink(unit, slot)
return pfHookSetInventoryItem(self, unit, slot)
end
local pfHookSetLootRollItem = GameTooltip.SetLootRollItem
function GameTooltip.SetLootRollItem(self, id)
libtooltip.itemID = GetLootRollItemID(id)
libtooltip.itemLink = GetLootRollItemLink(id)
return pfHookSetLootRollItem(self, id)
end
local pfHookSetMerchantItem = GameTooltip.SetMerchantItem
function GameTooltip.SetMerchantItem(self, merchantIndex)
libtooltip.itemID = GetMerchantItemID(merchantIndex)
libtooltip.itemLink = GetMerchantItemLink(merchantIndex)
return pfHookSetMerchantItem(self, merchantIndex)
end
local pfHookSetCraftItem = GameTooltip.SetCraftItem
function GameTooltip.SetCraftItem(self, skill, slot)
libtooltip.itemID = GetCraftReagentItemID(skill, slot)
libtooltip.itemLink = GetCraftReagentItemLink(skill, slot)
return pfHookSetCraftItem(self, skill, slot)
end
local pfHookSetCraftSpell = GameTooltip.SetCraftSpell
function GameTooltip.SetCraftSpell(self, slot)
libtooltip.itemID = GetCraftSpellID(slot)
libtooltip.itemLink = GetCraftItemLink(slot)
return pfHookSetCraftSpell(self, slot)
end
@@ -132,8 +142,10 @@ end
local pfHookSetTradeSkillItem = GameTooltip.SetTradeSkillItem
function GameTooltip.SetTradeSkillItem(self, skillIndex, reagentIndex)
if reagentIndex then
libtooltip.itemID = GetTradeSkillReagentItemID(skillIndex, reagentIndex)
libtooltip.itemLink = GetTradeSkillReagentItemLink(skillIndex, reagentIndex)
else
libtooltip.itemID = GetTradeSkillItemID(skillIndex)
libtooltip.itemLink = GetTradeSkillItemLink(skillIndex)
end
return pfHookSetTradeSkillItem(self, skillIndex, reagentIndex)
@@ -142,6 +154,7 @@ end
local pfHookSetAuctionItem = GameTooltip.SetAuctionItem
function GameTooltip.SetAuctionItem(self, atype, index)
_, _, libtooltip.itemCount = GetAuctionItemInfo(atype, index)
libtooltip.itemID = GetAuctionItemID(atype, index)
libtooltip.itemLink = GetAuctionItemLink(atype, index)
return pfHookSetAuctionItem(self, atype, index)
end
@@ -149,6 +162,7 @@ end
local pfHookSetAuctionSellItem = GameTooltip.SetAuctionSellItem
function GameTooltip.SetAuctionSellItem(self)
local itemName, _, itemCount = GetAuctionSellItemInfo()
libtooltip.itemID = GetAuctionSellItemID()
libtooltip.itemCount = itemCount
libtooltip.itemLink = GetItemLinkByName(itemName)
return pfHookSetAuctionSellItem(self)
@@ -156,12 +170,14 @@ end
local pfHookSetTradePlayerItem = GameTooltip.SetTradePlayerItem
function GameTooltip.SetTradePlayerItem(self, index)
libtooltip.itemID = GetTradePlayerItemID(index)
libtooltip.itemLink = GetTradePlayerItemLink(index)
return pfHookSetTradePlayerItem(self, index)
end
local pfHookSetTradeTargetItem = GameTooltip.SetTradeTargetItem
function GameTooltip.SetTradeTargetItem(self, index)
libtooltip.itemID = GetTradeTargetItemID(index)
libtooltip.itemLink = GetTradeTargetItemLink(index)
return pfHookSetTradeTargetItem(self, index)
end
+20 -3
View File
@@ -32,6 +32,18 @@ if pfUI.api.libunitscan then return end
local units = { players = {}, mobs = {} }
local queue = { }
-- Feed (guid, name, classToken) into ClassicAPI's persistent name
-- cache when the unit's GUID is resolvable. Roster-style packets
-- (party / raid / inspect on glance) carry class inline, so the
-- engine often doesn't issue a separate name query and the DLL's
-- NameCache hook never fires for them — this is where we close that gap.
local function RememberByUnit(unit, name, class)
if not (name and class) then return end
local guid = UnitGUID(unit)
if not guid then return end
C_PlayerCache.RememberPlayer(guid, name, class, UnitRace(unit), UnitSex(unit))
end
function GetUnitData(name, active)
if units["players"][name] then
local ret = units["players"][name]
@@ -78,6 +90,7 @@ libunitscan:SetScript("OnEvent", function()
local level = UnitLevel("player")
local guild = GetGuildInfo("player")
AddData("players", name, class, level, nil, guild)
RememberByUnit("player", name, class)
elseif event == "FRIENDLIST_UPDATE" then
local name, class, level
@@ -99,11 +112,13 @@ libunitscan:SetScript("OnEvent", function()
end
elseif event == "RAID_ROSTER_UPDATE" then
local name, class, SubGroup, level, _
local name, class, SubGroup, level, unit, _
for i = 1, GetNumRaidMembers() do
unit = "raid" .. i
name, _, SubGroup, level, class = GetRaidRosterInfo(i)
class = L["class"][class] or nil
AddData("players", name, class, level)
RememberByUnit(unit, name, class)
end
elseif event == "PARTY_MEMBERS_CHANGED" then
@@ -115,10 +130,11 @@ libunitscan:SetScript("OnEvent", function()
level = UnitLevel(unit)
guild = GetGuildInfo(unit)
AddData("players", name, class, level, nil, guild)
RememberByUnit(unit, name, class)
end
elseif event == "WHO_LIST_UPDATE" or event == "CHAT_MSG_SYSTEM" then
local name, class, level, _
local name, class, level, guild, _
for i = 1, GetNumWhoResults() do
name, guild, level, _, class, _ = GetWhoInfo(i)
class = L["class"][class] or nil
@@ -127,7 +143,7 @@ libunitscan:SetScript("OnEvent", function()
elseif event == "UPDATE_MOUSEOVER_UNIT" or event == "PLAYER_TARGET_CHANGED" then
local scan = event == "PLAYER_TARGET_CHANGED" and "target" or "mouseover"
local name, class, level, elite, _
local name, class, level, elite, guild, _
if UnitIsPlayer(scan) then
_, class = UnitClass(scan)
level = UnitLevel(scan)
@@ -136,6 +152,7 @@ libunitscan:SetScript("OnEvent", function()
name = UnitName(scan)
guild = GetGuildInfo(scan)
AddData("players", name, class, level, nil, guild)
RememberByUnit(scan, name, class)
else
_, class = UnitClass(scan)
elite = UnitClassification(scan)