Skip to content
This repository has been archived by the owner on Apr 3, 2022. It is now read-only.
Rainrider edited this page Feb 6, 2018 · 10 revisions

Element: ArtifactPower

Displays the artifact power for the player's equipped artifact weapon as a status bar.

Widget

ArtifactPower - represents the artifact power bar (StatusBar)

Options

  • .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)

Attributes

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. Use powerForNextTrait - 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)

Notes

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.

Callbacks/Hooks

:PreUpdate(event) - Called before the element has been updated.

  1. self - the ArtifactPower widget
  2. event - the event that triggered the update (string)

:PostUpdate(event, isShow) - Called after the element has been updated.

  1. self - the ArtifactPower widget
  2. event - the event that triggered the update (string)
  3. show - indicates whether the element is shown (boolean)

:UpdateColor(isUsable) - Used to update the widget's color based whether the equipped artifact is usable.

  1. self - the ArtifactPower widget
  2. isUsable - indicates whether the equipped artifact is usable (boolean)

.Override(self, event, ...) - Used to completely override the internal update function.

  1. self - the parent of the ArtifactPower widget
  2. event - the event that triggered the update (string)
  3. ... - the arguments accompanying the event

:OnEnter() - The OnEnter script handler when the element is mouse-enabled.

  1. self - the ArtifactPower widget

:OnLeave() - The OnLeave script handler when the element is mouse-enabled.

  1. self - the ArtifactPower widget

:OnMouseUp() - The OnMouseUp script handler when the element is mouse-enabled.

  1. self - the ArtifactPower widget

Example

-- 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
Clone this wiki locally