-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Displays the artifact power for the player's equipped artifact weapon as a status bar.
ArtifactPower
- represents the artifact power bar (StatusBar)
-
.color
- the RGB values for the widget. Defaults to {.901, .8, .601} (table) -
.onAlpha
- alpha value of the widget when it is mouse enabled and hovered. Defaults to 1 (number)[0-1] -
.offAlpha
- alpha value of the widget when it is mouse enabled and not hovered. Defaults to 1 (number)[0-1] -
.tooltipAnchor
- anchor point for the tooltip. Defaults to 'ANCHOR_BOTTOMRIGHT' (string) -
.unusableColor
- the RGB values for the widget when the equipped artifact is unusable. Defaults to {1, 0, 0} (table)
The element adds the following keys to the ArtifactPower widget table, which can be used for a custom tooltip or bar text.
-
.name
- the name of the equipped artifact weapon (string) -
.power
- the current value of the status bar (number) -
.powerForNextTrait
- the max value of the status bar. UsepowerForNextTrait - power
to calculate the power needed to learn the next trait (number) -
.totalPower
- the amount of unspent artifact power (number) -
.numTraitsLearnable
- the number of artifact traits that could be purchased with the amount of unspent power (number) -
.traitsLearned
- the number of traits the player has already purchased (number)
A default texture will be applied if the widget is a StatusBar
and doesn't have a texture or color set.
OnEnter
and OnLeave
script handlers to display a tooltip will be set on the widget if it is mouse enabled.
OnMouseUp
handler to show the artifact UI will be set on the widget if it is mouse-enabled and the script is not set
by the layout.
:PreUpdate(event)
- Called before the element has been updated.
-
self
- the ArtifactPower widget -
event
- the event that triggered the update (string)
:PostUpdate(event, isShow)
- Called after the element has been updated.
-
self
- the ArtifactPower widget -
event
- the event that triggered the update (string) -
show
- indicates whether the element is shown (boolean)
:UpdateColor(isUsable)
- Used to update the widget's color based whether the equipped artifact is usable.
-
self
- the ArtifactPower widget -
isUsable
- indicates whether the equipped artifact is usable (boolean)
.Override(self, event, ...)
- Used to completely override the internal update function.
-
self
- the parent of the ArtifactPower widget -
event
- the event that triggered the update (string) -
...
- the arguments accompanying the event
:OnEnter()
- The OnEnter
script handler when the element is mouse-enabled.
-
self
- the ArtifactPower widget
:OnLeave()
- The OnLeave
script handler when the element is mouse-enabled.
-
self
- the ArtifactPower widget
:OnMouseUp()
- The OnMouseUp
script handler when the element is mouse-enabled.
-
self
- the ArtifactPower widget
-- Position and size
local ArtifactPower = CreateFrame("StatusBar", nil, self)
ArtifactPower:SetSize(200, 5)
ArtifactPower:SetPoint("TOP", self, "BOTTOM")
-- Enable the tooltip
ArtifactPower:EnableMouse(true)
-- Enable fading
ArtifactPower.offAlpha = 0
-- Add status bar text
local text = ArtifactPower:CreateFontString(nil, "OVERLAY")
text:SetPoint("CENTER")
text:SetFontObject(GameFontHighlight)
ArtifactPower.text = text
-- Update the status bar text
ArtifactPower.PostUpdate = function(self, event, isShown)
if (not isShown) then return end
-- unspent power / missing power for next trait
self.text:SetFormattedText("%d / %d", self.totalPower, self.powerForNextTrait - self.power)
end
-- Register with oUF
self.ArtifactPower = ArtifactPower