Skip to content

Commit

Permalink
Refactors for depreciated API calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Wutname1 committed Aug 14, 2024
1 parent 536f1c8 commit b62c1f5
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 33 deletions.
14 changes: 12 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,13 @@
"issecurevariable",
"AddonList",
"DropDownList1",
"securecallfunction"
"securecallfunction",
"CreateUnsecuredObjectPool",
"HUD_EDIT_MODE_RESET_POSITION",
"RESET_TO_DEFAULT",
"GenerateClosure",
"MinimalSliderWithSteppersMixin",
"CreateMinimalSliderFormatter"
],
"Lua.workspace.ignoreDir": [".vscode", "libs/*"],
"Lua.diagnostics.enable": true,
Expand Down Expand Up @@ -649,6 +655,10 @@
},
"Lua.workspace.library": [
"..\\LibLuaDefinitions",
"$USERPROFILE\\.vscode\\extensions\\ketho.wow-api-0.15.8\\Annotations"
"~\\.vscode\\extensions\\ketho.wow-api-0.16.6\\Annotations",
"Core",
"libs\\oUF_Plugins",
"Modules",
"Themes"
]
}
13 changes: 7 additions & 6 deletions Core/oUF.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ local unpack = unpack
-------------- oUF Functions ------------------------------------
function SUI:HotsListing()
local _, classFileName = UnitClass('player')
local LifebloomSpellId = select(7, GetSpellInfo('Lifebloom'))
local lifebloomInfo = C_Spell.GetSpellInfo('Lifebloom')
local lifebloomSpellId = lifebloomInfo and lifebloomInfo.spellID
if classFileName == 'DRUID' then
return {
774, -- Rejuvenation
LifebloomSpellId, -- Lifebloom
lifebloomSpellId, -- Lifebloom
8936, -- Regrowth
-- 48438, -- Wild Growth
-- 155777, -- Germination
-- 102351, -- Cenarion Ward
-- 102342 -- Ironbark
48438, -- Wild Growth
155777, -- Germination
102351, -- Cenarion Ward
102342, -- Ironbark
}
elseif classFileName == 'PRIEST' then
if SUI.IsClassic then
Expand Down
2 changes: 1 addition & 1 deletion Modules/AutoTurnIn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ function module.QUEST_COMPLETE()
end

function module:GetItemAmount(isCurrency, item)
local amount = isCurrency and select(2, GetCurrencyInfo(item)) or GetItemCount(item, nil, true)
local amount = isCurrency and select(2, GetCurrencyInfo(item)) or C_Item.GetItemCount(item, nil, true)
return amount and amount or 0
end

Expand Down
1 change: 1 addition & 0 deletions Modules/UnitFrames/Elements/AuraBars.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ end
---@param unitName string
---@param OptionSet AceConfig.OptionsTable
local function Options(unitName, OptionSet)
local ElementSettings = UF.CurrentSettings[unitName].elements.AuraWatch
local function OptUpdate(option, val)
--Update memory
UF.CurrentSettings[unitName].elements.AuraBars[option] = val
Expand Down
23 changes: 13 additions & 10 deletions Modules/UnitFrames/Elements/AuraWatch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ local function Options(unitName, OptionSet, DB)
local ElementSettings = UF.CurrentSettings[unitName].elements.AuraWatch
local UserSetting = UF.DB.UserSettings[UF.DB.Style][unitName].elements.AuraWatch

--Remove Basic Filters
-- Remove Basic Filters
OptionSet.args.Filters = nil
--Remove Blacklist
-- Remove Blacklist
OptionSet.args.whitelist = nil
OptionSet.args.blacklist = nil
--Remove Layout Configuration
-- Remove Layout Configuration
OptionSet.args.Layout = nil
local buildItemList

Expand All @@ -50,8 +50,8 @@ local function Options(unitName, OptionSet, DB)
local id = tonumber(string.match(info[#info], '(%d+)'))
local name = 'unknown'
if id then
local spellName, _, spellIcon = GetSpellInfo(id)
name = string.format('|T%s:14:14:0:0|t %s (#%i)', spellIcon or 'Interface\\Icons\\Inv_misc_questionmark', spellName or SUI.L['Unknown'], id)
local spellInfo = C_Spell.GetSpellInfo(id)
if spellInfo then name = string.format('|T%s:14:14:0:0|t %s (#%i)', spellInfo.iconID or 'Interface\\Icons\\Inv_misc_questionmark', spellInfo.name or SUI.L['Unknown'], id) end
end
return name
end,
Expand All @@ -67,11 +67,11 @@ local function Options(unitName, OptionSet, DB)
func = function(info)
local id = tonumber(info[#info])

--Remove Setting
-- Remove Setting
ElementSettings.rules[info[#info - 2]][id] = nil
UserSetting.rules[info[#info - 2]][id] = nil

--Update Screen
-- Update Screen
buildItemList(info[#info - 2])
UF.Unit[unitName]:ElementUpdate('AuraWatch')
end,
Expand All @@ -86,16 +86,19 @@ local function Options(unitName, OptionSet, DB)
spellsOpt[tostring(spellID)] = spellDelete
end
end

local additem = function(info, input)
local spellId
if type(input) == 'string' then
--See if we got a spell link
-- See if we got a spell link
if input:find('|Hspell:%d+') then
spellId = tonumber(input:match('|Hspell:(%d+)'))
elseif input:find('%[(.-)%]') then
spellId = select(7, GetSpellInfo(input:match('%[(.-)%]')))
local spellInfo = C_Spell.GetSpellInfo(input:match('%[(.-)%]'))
spellId = spellInfo and spellInfo.spellID
else
spellId = select(7, GetSpellInfo(input))
local spellInfo = C_Spell.GetSpellInfo(input)
spellId = spellInfo and spellInfo.spellID
end
if not spellId then
SUI:Print('Invalid spell name or ID')
Expand Down
9 changes: 6 additions & 3 deletions Modules/UnitFrames/Handlers/Auras.lua
Original file line number Diff line number Diff line change
Expand Up @@ -255,17 +255,20 @@ end
---@param button any
---@param index integer
function Auras.PostUpdateAura(element, unit, button, index)
local _, _, _, _, duration, expiration, owner, canStealOrPurge = UnitAura(unit, index, button.filter)
local auraData = C_UnitAuras.GetAuraDataByIndex(unit, index, button.filter)
if not auraData then return end

local duration, expiration = auraData.duration, auraData.expirationTime
if duration and duration > 0 then
button.expiration = expiration - GetTime()
else
button.expiration = math.huge
end

if button.SetBackdrop then
if unit == 'target' and canStealOrPurge then
if unit == 'target' and auraData.isStealable then
button:SetBackdropColor(0, 1 / 2, 1 / 2)
elseif owner ~= 'player' then
elseif auraData.sourceUnit ~= 'player' then
button:SetBackdropColor(0, 0, 0)
end
end
Expand Down
12 changes: 7 additions & 5 deletions Modules/UnitFrames/Options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1292,8 +1292,8 @@ function Options:Initialize()
local id = tonumber(string.match(info[#info], '(%d+)'))
local name = 'unknown'
if id then
local spellName, _, spellIcon = GetSpellInfo(id)
name = string.format('|T%s:14:14:0:0|t %s (#%i)', spellIcon or 'Interface\\Icons\\Inv_misc_questionmark', spellName or L['Unknown'], id)
local spellInfo = C_Spell.GetSpellInfo(id)
if spellInfo then name = string.format('|T%s:14:14:0:0|t %s (#%i)', spellInfo.iconID or 'Interface\\Icons\\Inv_misc_questionmark', spellInfo.name or L['Unknown'], id) end
end
return name
end,
Expand Down Expand Up @@ -1331,13 +1331,15 @@ function Options:Initialize()
local additem = function(info, input)
local spellId
if type(input) == 'string' then
--See if we got a spell link
-- See if we got a spell link
if input:find('|Hspell:%d+') then
spellId = tonumber(input:match('|Hspell:(%d+)'))
elseif input:find('%[(.-)%]') then
spellId = select(7, GetSpellInfo(input:match('%[(.-)%]')))
local spellInfo = C_Spell.GetSpellInfo(input:match('%[(.-)%]'))
spellId = spellInfo and spellInfo.spellID
else
spellId = select(7, GetSpellInfo(input))
local spellInfo = C_Spell.GetSpellInfo(input)
spellId = spellInfo and spellInfo.spellID
end
if not spellId then
SUI:Print('Invalid spell name or ID')
Expand Down
14 changes: 8 additions & 6 deletions libs/oUF_Plugins/oUF_AuraBars.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ local infinity = math.huge

local _G = _G
local GetTime = GetTime
local UnitAura = UnitAura
local CreateFrame = CreateFrame
local UnitIsUnit = UnitIsUnit
local UnitIsEnemy = UnitIsEnemy
local UnitReaction = UnitReaction
local GameTooltip = GameTooltip
Expand Down Expand Up @@ -104,7 +102,11 @@ end
---@param auraData AuraData
---@return boolean
local function customFilter(element, unit, button, auraData)
if (element.onlyShowPlayer and button.isPlayer) or (not element.onlyShowPlayer and auraData.name) then return true end
if (element.onlyShowPlayer and button.isPlayer) or (not element.onlyShowPlayer and auraData.name) then
return true
else
return false
end
end

local function updateBar(element, bar)
Expand All @@ -128,7 +130,7 @@ local function updateBar(element, bar)
if bar.filter == 'HARMFUL' then
if not debuffType or debuffType == '' then debuffType = 'none' end

local color = _G.DebuffTypeColor[debuffType]
local color = _G['DebuffTypeColor'][debuffType]
r, g, b = color.r, color.g, color.b
end

Expand Down Expand Up @@ -158,14 +160,14 @@ local function updateAura(element, unit, index, offset, filter, isDebuff, visibl
element.active[position] = bar

bar.unit = unit
bar.count = auraData.charges or 1
bar.count = auraData.applications or 1
bar.index = index
bar.caster = auraData.sourceUnit
bar.filter = filter
bar.isDebuff = isDebuff
bar.texture = auraData.icon
bar.isStealable = auraData.isStealable
bar.isPlayer = auraData.sourceUnit == 'player' or auraData.sourceUnit == 'vehicle'
bar.isPlayer = auraData.isFromPlayerOrPlayerPet
bar.position = position
bar.duration = auraData.duration
bar.expiration = auraData.expirationTime
Expand Down

0 comments on commit b62c1f5

Please sign in to comment.