Skip to content

Commit

Permalink
Add support for LibCustomNames
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbuds committed Jun 21, 2023
1 parent bbb5405 commit 3f22054
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion WeakAuras/AuraEnvironment.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ end
-- Wrapping a unit's name in its class colour is very common in custom Auras
local WA_ClassColorName = function(unit)
if unit and UnitExists(unit) then
local name = UnitName(unit)
local name = WeakAuras.UnitName(unit)
local _, class = UnitClass(unit)
if not class then
return name
Expand Down
12 changes: 8 additions & 4 deletions WeakAuras/Types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -494,14 +494,14 @@ Private.format_types = {

if realm == "never" then
nameFunc = function(unit)
return unit and UnitName(unit)
return unit and WeakAuras.UnitName(unit)
end
elseif realm == "star" then
nameFunc = function(unit)
if not unit then
return ""
end
local name, realm = UnitName(unit)
local name, realm = WeakAuras.UnitName(unit)
if realm then
return name .. "*"
end
Expand All @@ -512,7 +512,7 @@ Private.format_types = {
if not unit then
return ""
end
local name, realm = UnitName(unit)
local name, realm = WeakAuras.UnitName(unit)
if realm then
return name .. "-" .. realm
end
Expand All @@ -524,6 +524,7 @@ Private.format_types = {
return ""
end
local name, realm = WeakAuras.UnitNameWithRealm(unit)
name = WeakAuras.GetName(name)
return name .. "-" .. realm
end
end
Expand Down Expand Up @@ -619,24 +620,27 @@ Private.format_types = {

if realm == "never" then
nameFunc = function(name, realm)
return name
return WeakAuras.GetName(name)
end
elseif realm == "star" then
nameFunc = function(name, realm)
name = WeakAuras.GetName(name)
if realm ~= "" then
return name .. "*"
end
return name
end
elseif realm == "differentServer" then
nameFunc = function(name, realm)
name = WeakAuras.GetName(name)
if realm ~= "" then
return name .. "-" .. realm
end
return name
end
elseif realm == "always" then
nameFunc = function(name, realm)
name = WeakAuras.GetName(name)
if realm == "" then
realm = select(2, WeakAuras.UnitNameWithRealm("player"))
end
Expand Down
15 changes: 13 additions & 2 deletions WeakAuras/WeakAuras.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ local insert = table.insert

-- WoW APIs
local GetTalentInfo, IsAddOnLoaded, InCombatLockdown = GetTalentInfo, IsAddOnLoaded, InCombatLockdown
local LoadAddOn, UnitName, GetRealmName, UnitRace, UnitFactionGroup, IsInRaid
= LoadAddOn, UnitName, GetRealmName, UnitRace, UnitFactionGroup, IsInRaid
local LoadAddOn, GetRealmName, UnitRace, UnitFactionGroup, IsInRaid
= LoadAddOn, GetRealmName, UnitRace, UnitFactionGroup, IsInRaid
local UnitClass, UnitExists, UnitGUID, UnitAffectingCombat, GetInstanceInfo, IsInInstance
= UnitClass, UnitExists, UnitGUID, UnitAffectingCombat, GetInstanceInfo, IsInInstance
local UnitIsUnit, GetRaidRosterInfo, GetSpecialization, UnitInVehicle, UnitHasVehicleUI, GetSpellInfo
Expand Down Expand Up @@ -73,6 +73,17 @@ local LDBIcon = LibStub("LibDBIcon-1.0")
local LCG = LibStub("LibCustomGlow-1.0")
local LGF = LibStub("LibGetFrame-1.0")

local LibCustomNames = IsAddOnLoaded("LibCustomNames") and LibStub("LibCustomNames") -- optional addon
if LibCustomNames then
WeakAuras.GetName = LibCustomNames.Get
WeakAuras.UnitName = LibCustomNames.UnitName
WeakAuras.GetUnitName = LibCustomNames.GetUnitName
else
WeakAuras.GetName = function(name) return name end
WeakAuras.UnitName = UnitName
WeakAuras.GetUnitName = GetUnitName
end

local timer = WeakAurasTimers
WeakAuras.timer = timer

Expand Down
2 changes: 1 addition & 1 deletion WeakAuras/WeakAuras.toc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
## DefaultState: Enabled
## LoadOnDemand: 0
## SavedVariables: WeakAurasSaved
## OptionalDeps: Ace3, LibCompress, LibSharedMedia-3.0, AceGUI-3.0-SharedMediaWidgets, Masque, GTFO, LibButtonGlow-1.0, LibSpellRange-1.0, LibRangeCheck-2.0, LibDBIcon-1.0, LibClassicDurations, LibClassicCasterino, LibGetFrame-1.0, LibSpecialization, !LibUIDropDownMenu, !!AddonLocale
## OptionalDeps: Ace3, LibCompress, LibSharedMedia-3.0, AceGUI-3.0-SharedMediaWidgets, Masque, GTFO, LibButtonGlow-1.0, LibSpellRange-1.0, LibRangeCheck-2.0, LibDBIcon-1.0, LibClassicDurations, LibClassicCasterino, LibGetFrame-1.0, LibSpecialization, !LibUIDropDownMenu, !!AddonLocale, LibCustomNames

# External code + initialization
embeds.xml
Expand Down

0 comments on commit 3f22054

Please sign in to comment.