Skip to content

Commit

Permalink
Add support for TWW
Browse files Browse the repository at this point in the history
  • Loading branch information
jordonwow committed Aug 14, 2024
1 parent e562169 commit 5aea54d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 12 deletions.
33 changes: 28 additions & 5 deletions OmniBar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ local GetSpecialization = GetSpecialization
local GetSpecializationInfo = GetSpecializationInfo
local GetSpecializationInfoByID = GetSpecializationInfoByID
local GetSpecializationInfoForClassID = GetSpecializationInfoForClassID
local GetSpellInfo = GetSpellInfo
local GetSpellInfo = C_Spell and C_Spell.GetSpellInfo or GetSpellInfo
local GetSpellTexture = C_Spell and C_Spell.GetSpellTexture or GetSpellTexture
local GetTime = GetTime
local GetUnitName = GetUnitName
local GetZonePVPInfo = GetZonePVPInfo
Expand Down Expand Up @@ -64,6 +65,14 @@ local tinsert = tinsert
local wipe = wipe
local tContains = tContains

local function GetSpellName(id)
if C_Spell and C_Spell.GetSpellName then
return C_Spell.GetSpellName(id)
else
return GetSpellInfo(id)
end
end

OmniBar = LibStub("AceAddon-3.0"):NewAddon("OmniBar", "AceEvent-3.0", "AceComm-3.0", "AceSerializer-3.0")
local L = LibStub("AceLocale-3.0"):GetLocale("OmniBar")

Expand Down Expand Up @@ -197,7 +206,14 @@ function OmniBar:OnInitialize()

-- Populate cooldowns with spell names and icons
for spellId,_ in pairs(self.cooldowns) do
local name, _, icon = GetSpellInfo(spellId)
local name, icon
if C_Spell and C_Spell.GetSpellInfo then
local spellInfo = C_Spell.GetSpellInfo(spellId)
name = spellInfo and spellInfo.name
icon = spellInfo and spellInfo.iconID
else
name, _, icon = GetSpellInfo(spellId)
end
self.cooldowns[spellId].icon = self.cooldowns[spellId].icon or icon
self.cooldowns[spellId].name = name
end
Expand Down Expand Up @@ -404,7 +420,7 @@ local SPELL_ID_BY_NAME
if WOW_PROJECT_ID == WOW_PROJECT_CLASSIC then
SPELL_ID_BY_NAME = {}
for id, value in pairs(addon.Cooldowns) do
if (not value.parent) then SPELL_ID_BY_NAME[GetSpellInfo(id)] = id end
if (not value.parent) then SPELL_ID_BY_NAME[GetSpellName(id)] = id end
end
end

Expand All @@ -416,7 +432,14 @@ function OmniBar:AddCustomSpells()

-- Add custom spells
for k,v in pairs(self.db.global.cooldowns) do
local name, _, icon = GetSpellInfo(k)
local name, _, icon
if C_Spell and C_Spell.GetSpellInfo then
local spellInfo = C_Spell.GetSpellInfo(k)
name = spellInfo and spellInfo.name
icon = spellInfo and spellInfo.iconID
else
name, _, icon = GetSpellInfo(k)
end
if name then
-- Backup if we are going to override
if addon.Cooldowns[k] and (not addon.Cooldowns[k].custom) and (not self.BackupCooldowns[k]) then
Expand Down Expand Up @@ -915,7 +938,7 @@ function OmniBar:AddSpellCast(event, sourceGUID, sourceName, sourceFlags, spellI
sourceGUID = sourceGUID,
sourceName = sourceName,
spellID = spellID,
spellName = GetSpellInfo(spellID),
spellName = GetSpellName(spellID),
timestamp = now,
}

Expand Down
2 changes: 1 addition & 1 deletion OmniBar.toc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Interface: 100207, 110000
## Interface: 100207, 110000, 110002
## Title: OmniBar
## Notes: Tracks enemy cooldowns
## Version: @project-version@
Expand Down
20 changes: 14 additions & 6 deletions Options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ local DELETE = DELETE
local GENERAL = GENERAL
local GetAddOnMetadata = GetAddOnMetadata
local GetSpecializationInfoByID = GetSpecializationInfoByID
local GetSpellDescription = GetSpellDescription
local GetSpellInfo = GetSpellInfo
local GetSpellTexture = GetSpellTexture
local GetSpellDescription = C_Spell and C_Spell.GetSpellDescription or GetSpellDescription
local GetSpellInfo = C_Spell and C_Spell.GetSpellInfo or GetSpellInfo
local GetSpellTexture = C_Spell and C_Spell.GetSpellTexture or GetSpellTexture
local LOCALIZED_CLASS_NAMES_MALE = LOCALIZED_CLASS_NAMES_MALE
local LibStub = LibStub
local MAX_CLASSES = MAX_CLASSES
Expand All @@ -36,6 +36,14 @@ local YES = YES
local format = format
local nop = nop

local function GetSpellName(id)
if C_Spell and C_Spell.GetSpellName then
return C_Spell.GetSpellName(id)
else
return GetSpellInfo(id)
end
end

local OmniBar = LibStub("AceAddon-3.0"):GetAddon("OmniBar")
local L = LibStub("AceLocale-3.0"):GetLocale("OmniBar")

Expand Down Expand Up @@ -182,7 +190,7 @@ local function GetSpells()

for spellID, spell in pairs(addon.Cooldowns) do
if spell.class and spell.class == CLASS_SORT_ORDER_WITH_GENERAL[i] then
local spellName = GetSpellInfo(spellID)
local spellName = GetSpellName(spellID)
if spellName then
local spellTexture = OmniBar:GetSpellTexture(spellID) or ""
if string.len(spellName) > 25 then
Expand Down Expand Up @@ -945,7 +953,7 @@ local customSpells = {
type = "input",
set = function(info, state, data)
local spellId = tonumber(state)
local name = GetSpellInfo(spellId)
local name = GetSpellName(spellId)
if OmniBar.db.global.cooldowns[spellId] then return end
if spellId and name then
OmniBar.db.global.cooldowns[spellId] = data or addon.Cooldowns[spellId] or { custom = true, duration = { default = 30 } , class = "GENERAL" }
Expand Down Expand Up @@ -1092,7 +1100,7 @@ function OmniBar:SetupOptions()

for spellId, spell in pairs(OmniBar.db.global.cooldowns) do
customSpells[tostring(spellId)] = {
name = GetSpellInfo(spellId),
name = GetSpellName(spellId),
type = "group",
childGroups = "tab",
args = customSpellInfo,
Expand Down

0 comments on commit 5aea54d

Please sign in to comment.