From d4baf0ae128865d08096483499a0c2d05509f320 Mon Sep 17 00:00:00 2001 From: wardz <10900212+wardz@users.noreply.github.com> Date: Sat, 7 Sep 2024 02:50:29 +0200 Subject: [PATCH] fix 11.0.2 deprecated/removed api functions --- .luacheckrc | 2 ++ ClassicCastbars/ClassicCastbars.lua | 8 +++++++- ClassicCastbars/core/ClassicSpellData.lua | 2 ++ ClassicCastbars/core/LoadOptionsOnDemand.lua | 8 ++++---- ClassicCastbars_Options/ClassicCastbars_Options.lua | 2 ++ ClassicCastbars_Options/TestMode.lua | 5 ++++- 6 files changed, 21 insertions(+), 6 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index 31c0a44..0fb92dd 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -84,4 +84,6 @@ read_globals = { "UnitChannelInfo", "UnitIsFriend", "strsplit", + "C_AddOns", + "C_Spell", } diff --git a/ClassicCastbars/ClassicCastbars.lua b/ClassicCastbars/ClassicCastbars.lua index 5907c9d..1131a73 100644 --- a/ClassicCastbars/ClassicCastbars.lua +++ b/ClassicCastbars/ClassicCastbars.lua @@ -140,7 +140,13 @@ function ClassicCastbars:BindCurrentCastData(castbar, unitID, isChanneled, chann -- HACK: UnitChannelInfo is bugged for classic era, tmp fallback method if channelSpellID and not spellName then - spellName, _, iconTexturePath = GetSpellInfo(channelSpellID) + if C_Spell.GetSpellInfo then + local info = C_Spell.GetSpellInfo(channelSpellID) + spellName = info and info.name + iconTexturePath = info and info.iconID + else + spellName, _, iconTexturePath = GetSpellInfo(channelSpellID) + end local channelCastTime = spellName and channeledSpells[spellName] if not channelCastTime then return end diff --git a/ClassicCastbars/core/ClassicSpellData.lua b/ClassicCastbars/core/ClassicSpellData.lua index 43c6e03..d48c856 100644 --- a/ClassicCastbars/core/ClassicSpellData.lua +++ b/ClassicCastbars/core/ClassicSpellData.lua @@ -5,6 +5,8 @@ local CLIENT_IS_CLASSIC_ERA = (WOW_PROJECT_ID == WOW_PROJECT_CLASSIC) if not CLIENT_IS_TBC and not CLIENT_IS_CLASSIC_ERA then return end +local GetSpellInfo = C_Spell and C_Spell.GetSpellName or _G.GetSpellInfo + local physicalClasses = { ["WARRIOR"] = true, ["ROGUE"] = true, diff --git a/ClassicCastbars/core/LoadOptionsOnDemand.lua b/ClassicCastbars/core/LoadOptionsOnDemand.lua index 6f50da4..f6dc88c 100644 --- a/ClassicCastbars/core/LoadOptionsOnDemand.lua +++ b/ClassicCastbars/core/LoadOptionsOnDemand.lua @@ -8,8 +8,8 @@ SLASH_CLASSICCASTBARS6 = "/classicastbars" local isLoaded = false GameMenuFrame:HookScript("OnShow", function() - if not isLoaded and not IsAddOnLoaded("ClassicCastbars_Options") then - local loaded, reason = LoadAddOn("ClassicCastbars_Options") + if not isLoaded and not C_AddOns.IsAddOnLoaded("ClassicCastbars_Options") then + local loaded, reason = C_AddOns.LoadAddOn("ClassicCastbars_Options") if not loaded and reason == "DISABLED" then isLoaded = true -- disabled, dont attempt to load it anymore return @@ -20,9 +20,9 @@ GameMenuFrame:HookScript("OnShow", function() end) SlashCmdList["CLASSICCASTBARS"] = function() - if not IsAddOnLoaded("ClassicCastbars_Options") then + if not C_AddOns.IsAddOnLoaded("ClassicCastbars_Options") then if not isLoaded then - local loaded, reason = LoadAddOn("ClassicCastbars_Options") + local loaded, reason = C_AddOns.LoadAddOn("ClassicCastbars_Options") if not loaded and reason == "DISABLED" then isLoaded = true -- disabled, dont attempt to load it anymore return print(string.format(_G.ADDON_LOAD_FAILED, "ClassicCastbars_Options", _G["ADDON_" .. reason] or _G.ADDON_UNKNOWN_ERROR)) -- luacheck: ignore diff --git a/ClassicCastbars_Options/ClassicCastbars_Options.lua b/ClassicCastbars_Options/ClassicCastbars_Options.lua index 595e685..e308fb5 100644 --- a/ClassicCastbars_Options/ClassicCastbars_Options.lua +++ b/ClassicCastbars_Options/ClassicCastbars_Options.lua @@ -622,6 +622,8 @@ local function CreateUnitTabGroup(unitID, localizedUnit, order) } end +local GetAddOnMetadata = C_AddOns and C_AddOns.GetAddOnMetadata or _G.GetAddOnMetadata + local function GetOptionsTable() return { -- only create table on demand type = "group", diff --git a/ClassicCastbars_Options/TestMode.lua b/ClassicCastbars_Options/TestMode.lua index 7b48c74..7ef42af 100644 --- a/ClassicCastbars_Options/TestMode.lua +++ b/ClassicCastbars_Options/TestMode.lua @@ -2,8 +2,11 @@ local L = LibStub("AceLocale-3.0"):GetLocale("ClassicCastbars") local TestMode = CreateFrame("Frame", "ClassicCastbars_TestMode") TestMode.isTesting = {} +local GetSpellName = C_Spell and C_Spell.GetSpellName or _G.GetSpellInfo +local GetSpellTexture = C_Spell and C_Spell.GetSpellTexture or _G.GetSpellTexture + local dummySpellData = { - spellName = GetSpellInfo(118), + spellName = GetSpellName(118), icon = GetSpellTexture(118), spellID = 118, maxValue = 10,