Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LibCustomNames support #4480

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion WeakAuras/AuraEnvironment.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,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
13 changes: 8 additions & 5 deletions WeakAuras/Types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -626,14 +626,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 @@ -644,7 +644,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 @@ -655,7 +655,7 @@ Private.format_types = {
if not unit then
return ""
end
local name, realm = WeakAuras.UnitNameWithRealm(unit)
local name, realm = WeakAuras.UnitNameWithRealmCustomName(unit)
return name .. "-" .. realm
end
end
Expand Down Expand Up @@ -751,24 +751,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
19 changes: 19 additions & 0 deletions WeakAuras/WeakAuras.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,19 @@ local LDBIcon = LibStub("LibDBIcon-1.0")
local LCG = LibStub("LibCustomGlow-1.0")
local LGF = LibStub("LibGetFrame-1.0")

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

local timer = WeakAurasTimers
WeakAuras.timer = timer

Expand Down Expand Up @@ -6041,6 +6054,12 @@ do
local name, realm = UnitFullName(unit)
return name or "", realm or ownRealm or ""
end

function WeakAuras.UnitNameWithRealmCustomName(unit)
ownRealm = ownRealm or select(2, UnitFullName("player"))
local name, realm = WeakAuras.UnitFullName(unit)
return name or "", realm or ownRealm or ""
end
end

function Private.ExecEnv.ParseNameCheck(name)
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-3.0, LibDBIcon-1.0, LibGetFrame-1.0, LibSpecialization, !LibUIDropDownMenu, !!AddonLocale, BigWigs, DBM-Core
## OptionalDeps: Ace3, LibCompress, LibSharedMedia-3.0, AceGUI-3.0-SharedMediaWidgets, Masque, GTFO, LibButtonGlow-1.0, LibSpellRange-1.0, LibRangeCheck-3.0, LibDBIcon-1.0, LibGetFrame-1.0, LibSpecialization, !LibUIDropDownMenu, !!AddonLocale, CustomNames, BigWigs, DBM-Core

# External code + initialization
embeds.xml
Expand Down
2 changes: 1 addition & 1 deletion WeakAuras/WeakAuras_Cata.toc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,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-3.0, LibDBIcon-1.0, LibGetFrame-1.0, !LibUIDropDownMenu, !!AddonLocale, BigWigs, DBM-Core
## OptionalDeps: Ace3, LibCompress, LibSharedMedia-3.0, AceGUI-3.0-SharedMediaWidgets, Masque, GTFO, LibButtonGlow-1.0, LibSpellRange-1.0, LibRangeCheck-3.0, LibDBIcon-1.0, LibGetFrame-1.0, !LibUIDropDownMenu, !!AddonLocale, CustomNames, BigWigs, DBM-Core
## AllowLoadGameType: cata

# External code + initialization
Expand Down
2 changes: 1 addition & 1 deletion WeakAuras/WeakAuras_Vanilla.toc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,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-3.0, LibDBIcon-1.0, LibGetFrame-1.0, !LibUIDropDownMenu, !!AddonLocale, BigWigs, DBM-Core
## OptionalDeps: Ace3, LibCompress, LibSharedMedia-3.0, AceGUI-3.0-SharedMediaWidgets, Masque, GTFO, LibButtonGlow-1.0, LibSpellRange-1.0, LibRangeCheck-3.0, LibDBIcon-1.0, LibGetFrame-1.0, !LibUIDropDownMenu, !!AddonLocale, CustomNames, BigWigs, DBM-Core

# External code + initialization
embeds.xml
Expand Down