From 1133309198a989a96a80715cb72d4f2d444f7d21 Mon Sep 17 00:00:00 2001 From: Dack Janiels Date: Mon, 22 Jul 2024 08:31:10 -0500 Subject: [PATCH] Core: Updated WOW APIs for patch 11.0.2 --- .luacheckrc | 5 +++++ Core.lua | 2 +- Core/Announcements.lua | 3 +++ Core/EventHandlers.lua | 10 ++++------ Core/GUI.lua | 6 +++--- Core/GUI/DataBrokerDisplay.lua | 8 +++++--- Core/GUI/FauxAchievementPopup.lua | 1 + Core/GUI/GameTooltipHooks.lua | 1 + Core/GUI/MainWindow.lua | 2 ++ Core/Init.lua | 5 ++++- Core/Interoperability/Blizzard/AddonCompartment.lua | 7 ++++--- Core/Interoperability/TradeSkillMaster/AuctionDB.lua | 4 ++-- Core/Interoperability/WoWUnit/Testing.lua | 4 ++-- Core/Profiling.lua | 4 ++-- Core/Session.lua | 2 +- 15 files changed, 40 insertions(+), 24 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index 38a2706c..5f2dc089 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -55,6 +55,11 @@ globals = { "READY_CHECK_WAITING_TEXTURE", -- FrameXML (Blizzard interface) + "C_AddOns", + "C_Container", + "C_Item", + "Settings", + "AuraUtil", "BackdropTemplateMixin", "ChatFontNormal", diff --git a/Core.lua b/Core.lua index 0d4b7547..5631c4ab 100644 --- a/Core.lua +++ b/Core.lua @@ -93,7 +93,7 @@ local UnitIsDead = _G.UnitIsDead local GetNumLootItems = _G.GetNumLootItems local GetLootSlotInfo = _G.GetLootSlotInfo local GetLootSlotLink = _G.GetLootSlotLink -local GetItemInfo_Blizzard = _G.GetItemInfo +local GetItemInfo_Blizzard = _G.C_Item.GetItemInfo local GetItemInfo = function(id) return R:GetItemInfo(id) end diff --git a/Core/Announcements.lua b/Core/Announcements.lua index a6aef004..5d2a76a6 100644 --- a/Core/Announcements.lua +++ b/Core/Announcements.lua @@ -11,6 +11,9 @@ local Output = Rarity.Output -- Upvalues local CONSTANTS = addonTable.constants +--- WoW API +local GetItemInfo = _G.C_Item.GetItemInfo + function Announcements:AnnounceAttemptForItem(item) local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture, itemSellPrice = GetItemInfo(item.itemId) diff --git a/Core/EventHandlers.lua b/Core/EventHandlers.lua index 24765610..6498f731 100644 --- a/Core/EventHandlers.lua +++ b/Core/EventHandlers.lua @@ -24,7 +24,7 @@ local format = _G.format local GetCurrencyInfo = _G.C_CurrencyInfo.GetCurrencyInfo local CombatLogGetCurrentEventInfo = _G.CombatLogGetCurrentEventInfo local UnitGUID = UnitGUID -local LoadAddOn = LoadAddOn +local LoadAddOn = _G.C_AddOns.LoadAddOn local GetBestMapForUnit = _G.C_Map.GetBestMapForUnit local GetMapInfo = _G.C_Map.GetMapInfo local IsQuestFlaggedCompleted = C_QuestLog.IsQuestFlaggedCompleted @@ -34,7 +34,7 @@ local UnitIsDead = _G.UnitIsDead local GetNumLootItems = _G.GetNumLootItems local GetLootSlotInfo = _G.GetLootSlotInfo local GetLootSlotLink = _G.GetLootSlotLink -local GetItemInfo_Blizzard = _G.GetItemInfo +local GetItemInfo_Blizzard = _G.C_Item.GetItemInfo local GetItemInfo = function(id) return R:GetItemInfo(id) end @@ -178,7 +178,7 @@ local TYPE_IDENTIFIER_ITEM = "item" -- What others do they have? currency? gold? -- Upvalues --- WOW API -local GetItemInfoInstant = GetItemInfoInstant +local GetItemInfoInstant = _G.C_Item.GetItemInfoInstant function R:OnShowLootToast( event, @@ -746,9 +746,7 @@ function R:OnChatCommand(input) else LoadAddOn("Rarity_Options") if R.optionsFrame then - -- Thanks, Blizzard (https://www.wowinterface.com/forums/showthread.php?t=54599) - InterfaceOptionsFrame_OpenToCategory(R.optionsFrame) - InterfaceOptionsFrame_OpenToCategory(R.optionsFrame) + Settings.OpenToCategory("Rarity") else self:Print(L["The Rarity Options module has been disabled. Log out and enable it from your add-ons menu."]) end diff --git a/Core/GUI.lua b/Core/GUI.lua index 11031dff..330c15d1 100644 --- a/Core/GUI.lua +++ b/Core/GUI.lua @@ -28,10 +28,10 @@ local date = date local time = time -- WOW APIs -local GetItemInfo = GetItemInfo +local GetItemInfo = C_Item.GetItemInfo local IsShiftKeyDown = IsShiftKeyDown local IsControlKeyDown = IsControlKeyDown -local LoadAddOn = LoadAddOn +local LoadAddOn = C_AddOns.LoadAddOn local UnitClass = UnitClass local GetMapInfo = C_Map.GetMapInfo local GetTime = GetTime @@ -45,7 +45,7 @@ local UnitIsPVP = UnitIsPVP local GetAchievementLink = GetAchievementLink local GetRealZoneText = GetRealZoneText local GetSubZoneText = GetSubZoneText -local GetContainerItemID = GetContainerItemID +local GetContainerItemID = C_Container.GetContainerItemID local RequestRaidInfo = RequestRaidInfo local RequestLFDPlayerLockInfo = RequestLFDPlayerLockInfo diff --git a/Core/GUI/DataBrokerDisplay.lua b/Core/GUI/DataBrokerDisplay.lua index b978b4c1..a70c85a4 100644 --- a/Core/GUI/DataBrokerDisplay.lua +++ b/Core/GUI/DataBrokerDisplay.lua @@ -10,6 +10,10 @@ local R = Rarity local GUI = Rarity.GUI local CONSTANTS = addonTable.constants +--- WoW API +local GetItemInfo = _G.C_Item.GetItemInfo +local LoadAddOn = _G.C_AddOns.LoadAddOn + local dataobj = ldb:NewDataObject("Rarity", { type = "data source", text = L["Loading"], @@ -60,9 +64,7 @@ function dataobj:OnClick(button) Rarity:Debug("Loading Rarity_Options addon") LoadAddOn("Rarity_Options") if R.optionsFrame then - -- Thanks, Blizzard (https://www.wowinterface.com/forums/showthread.php?t=54599) - InterfaceOptionsFrame_OpenToCategory(R.optionsFrame) - InterfaceOptionsFrame_OpenToCategory(R.optionsFrame) + Settings.OpenToCategory("Rarity") else R:Print(L["The Rarity Options module has been disabled. Log out and enable it from your add-ons menu."]) end diff --git a/Core/GUI/FauxAchievementPopup.lua b/Core/GUI/FauxAchievementPopup.lua index ba2a8937..af3faa22 100644 --- a/Core/GUI/FauxAchievementPopup.lua +++ b/Core/GUI/FauxAchievementPopup.lua @@ -2,6 +2,7 @@ local _, addonTable = ... local CONSTANTS = addonTable.constants -- WOW API +local GetItemInfo = _G.C_Item.GetItemInfo local TextureKitConstants = _G.TextureKitConstants local GetAchievementInfo = _G.GetAchievementInfo diff --git a/Core/GUI/GameTooltipHooks.lua b/Core/GUI/GameTooltipHooks.lua index ad5d44d7..a1bb580d 100644 --- a/Core/GUI/GameTooltipHooks.lua +++ b/Core/GUI/GameTooltipHooks.lua @@ -13,6 +13,7 @@ local lbz = LibStub("LibBabble-Zone-3.0"):GetUnstrictLookupTable() local GetBestMapForUnit = _G.C_Map.GetBestMapForUnit local IsQuestFlaggedCompleted = _G.C_QuestLog.IsQuestFlaggedCompleted local UnitFactionGroup = _G.UnitFactionGroup +local GetItemInfo = _G.C_Item.GetItemInfo --- Addon API local CONSTANTS = addonTable.constants local colorize = Rarity.Utils.String.Colorize diff --git a/Core/GUI/MainWindow.lua b/Core/GUI/MainWindow.lua index bc27f235..48decf61 100644 --- a/Core/GUI/MainWindow.lua +++ b/Core/GUI/MainWindow.lua @@ -5,6 +5,8 @@ local R = Rarity local GUI = Rarity.GUI local CONSTANTS = addonTable.constants +--- WoW API +local GetItemInfo = _G.C_Item.GetItemInfo local GetBestMapForUnit = C_Map.GetBestMapForUnit local IsWorldQuestActive = C_TaskQuest.IsActive local IsQuestFlaggedCompleted = _G.C_QuestLog.IsQuestFlaggedCompleted diff --git a/Core/Init.lua b/Core/Init.lua index e7eabb7e..a9d6bdaa 100644 --- a/Core/Init.lua +++ b/Core/Init.lua @@ -14,7 +14,10 @@ Rarity = LibStub("AceAddon-3.0"):NewAddon( "AceSerializer-3.0" ) -- Rarity.MINOR_VERSION = tonumber(("$Revision: 650 $"):match("%d+")) -- Disabled after switching entirely to Git (from SVN) -local projectVersion, noReplacements = (GetAddOnMetadata("Rarity", "Version"):match("r%d+") or "r0"):gsub("r", "") -- e.g., r654 1 (the second value can be discarded) +local projectVersion, noReplacements = (C_AddOns.GetAddOnMetadata("Rarity", "Version"):match("r%d+") or "r0"):gsub( + "r", + "" +) -- e.g., r654 1 (the second value can be discarded) Rarity.MINOR_VERSION = tonumber(projectVersion) -- Set up modules diff --git a/Core/Interoperability/Blizzard/AddonCompartment.lua b/Core/Interoperability/Blizzard/AddonCompartment.lua index b10207a9..aa78b5df 100644 --- a/Core/Interoperability/Blizzard/AddonCompartment.lua +++ b/Core/Interoperability/Blizzard/AddonCompartment.lua @@ -1,14 +1,15 @@ local L = LibStub("AceLocale-3.0"):GetLocale("Rarity") +--- WoW API +local LoadAddOn = _G.C_AddOns.LoadAddOn + local AddonCompartment = {} function AddonCompartment.OnClick() -- Should behave the same as the default /rarity slash command (copy/pasted for now) - improve UX later? LoadAddOn("Rarity_Options") if Rarity.optionsFrame then - -- Thanks, Blizzard (https://www.wowinterface.com/forums/showthread.php?t=54599) - InterfaceOptionsFrame_OpenToCategory(Rarity.optionsFrame) - InterfaceOptionsFrame_OpenToCategory(Rarity.optionsFrame) + Settings.OpenToCategory("Rarity") else Rarity:Print(L["The Rarity Options module has been disabled. Log out and enable it from your add-ons menu."]) end diff --git a/Core/Interoperability/TradeSkillMaster/AuctionDB.lua b/Core/Interoperability/TradeSkillMaster/AuctionDB.lua index f3ce2c64..1fb0f804 100644 --- a/Core/Interoperability/TradeSkillMaster/AuctionDB.lua +++ b/Core/Interoperability/TradeSkillMaster/AuctionDB.lua @@ -9,8 +9,8 @@ local AuctionDB = {} -- Lua APIs local format = string.format --- WOW APIs -local GetItemInfo = GetItemInfo +--- WoW API +local GetItemInfo = _G.C_Item.GetItemInfo --- Attempts to determine whether or not the TSM_API can safely be used (it's probably not perfect) -- @return True if the required functionality appears to be loaded; false (nil) otherwise diff --git a/Core/Interoperability/WoWUnit/Testing.lua b/Core/Interoperability/WoWUnit/Testing.lua index d47b01be..4e1d1af5 100644 --- a/Core/Interoperability/WoWUnit/Testing.lua +++ b/Core/Interoperability/WoWUnit/Testing.lua @@ -9,8 +9,8 @@ local Testing = { --- Externals local L = LibStub("AceLocale-3.0"):GetLocale("Rarity", false) --- WOW API -local IsAddOnLoaded = IsAddOnLoaded -local LoadAddOn = LoadAddOn +local IsAddOnLoaded = C_AddOns.IsAddOnLoaded +local LoadAddOn = C_AddOns.LoadAddOn function Testing:RunIntegrationTests() Rarity:Debug("Attempting to run the full integration test suite") diff --git a/Core/Profiling.lua b/Core/Profiling.lua index 8d75b878..aa24bae4 100644 --- a/Core/Profiling.lua +++ b/Core/Profiling.lua @@ -2,8 +2,8 @@ local _, addonTable = ... -- Upvalues --- WOW API -local IsAddOnLoaded = IsAddOnLoaded -local LoadAddOn = LoadAddOn +local IsAddOnLoaded = C_AddOns.IsAddOnLoaded +local LoadAddOn = C_AddOns.LoadAddOn --- Lua API local table_wipe = table.wipe local pairs = pairs diff --git a/Core/Session.lua b/Core/Session.lua index 84df1c97..afa6a8a8 100644 --- a/Core/Session.lua +++ b/Core/Session.lua @@ -13,7 +13,7 @@ local R = Rarity local FormatTime = Rarity.Utils.PrettyPrint.FormatTime -- Utils are loaded before Core modules, so this should be fine local GetDate = Rarity.Utils.Time.GetDate -- WOW APIs -local GetItemInfo = GetItemInfo +local GetItemInfo = C_Item.GetItemInfo local GetTime = GetTime local C_Timer = C_Timer