Skip to content

Instantly share code, notes, and snippets.

@Meorawr
Created March 31, 2023 20:59
Show Gist options
  • Save Meorawr/8579a9fdb7648cd3191a4ae08dd790b3 to your computer and use it in GitHub Desktop.
Save Meorawr/8579a9fdb7648cd3191a4ae08dd790b3 to your computer and use it in GitHub Desktop.
Private Auras API Examples
-- This example will configure an anchor to display the first private aura that
-- gets applied to the player.
--
-- Multiple calls for the same aura index can be made. This will in effect
-- create multiple distinct displays for the same aura index.
local AuraFrame1 = CreateFrame("Frame", UIParent);
AuraFrame1:SetPoint("CENTER");
AuraFrame1:SetSize(48, 48);
AuraFrame1.Background = AuraFrame1:CreateTexture(nil, "BACKGROUND");
AuraFrame1.Background:SetAllPoints(AuraFrame1);
AuraFrame1.Background:SetColorTexture(0.5, 0, 1);
local auraAnchor = {
unitToken = "player",
auraIndex = 1,
-- The parent frame of an aura anchor must have a valid rect with a non-zero
-- size. Each private aura will anchor to all points on its parent,
-- providing a tooltip when mouseovered.
parent = AuraFrame1,
-- An optional cooldown spiral can be configured to represent duration.
showCountdownFrame = true,
showCountdownNumbers = true,
-- An optional icon can be created and shown for the aura. Omitting this
-- will display no icon.
iconInfo = {
iconWidth = 32,
iconHeight = 32,
iconAnchor = {
point = "CENTER",
relativeTo = AuraFrame1,
relativePoint = "CENTER",
offsetX = 0,
offsetY = 0,
},
},
-- An optional icon duration fontstring can also be configured.
durationAnchor = {
point = "BOTTOM",
relativeTo = AuraFrame1,
relativePoint = "BOTTOM",
offsetX = 0,
offsetY = 0,
},
}
-- Anchors can be removed (and the aura hidden) via the RemovePrivateAuraAnchor
-- API, passing it the anchor index returned from the Add function.
local anchorIndex = C_UnitAuras.AddPrivateAuraAnchor(auraAnchor)
-- An anchor for warning text (basically raid alerts) can be configured as
-- well. Unlike aura anchors this is a global resource - there is only one
-- warning text anchor to configure.
C_UnitAuras.SetPrivateWarningTextAnchor(UIParent, {
point = "TOP",
relativeTo = UIParent,
relativePoint = "TOP",
offsetX = 0,
offsetY = 0,
})
@Meorawr
Copy link
Author

Meorawr commented Mar 31, 2023

The aura anchor looks like the following:

Aura Anchor Example

The warning text when displayed looks like the following:

Aura Warning Text Example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment