Skip to content
Rainrider edited this page Feb 6, 2018 · 7 revisions

Element: Dispellable

Highlights debuffs that are dispellable by the player

Widget

  • .Dispellable - A table to hold the sub-widgets.

Sub-Widgets

  • .dispelIcon - A Button to represent the icon of a dispellable debuff.
  • .dispelTexture - A Texture to be colored according to the debuff type.

Notes

At least one of the sub-widgets should be present for the element to work.

The .dispelTexture sub-widget is updated by setting its color and alpha. It is always shown to allow the use on non-texture widgets without the need to override the internal update function.

If mouse interactivity is enabled for the .dispelIcon sub-widget, 'OnEnter' and/or 'OnLeave' handlers will be set to display a tooltip.

If .dispelIcon and .dispelIcon.cd are defined without a global name, one will be set accordingly by the element to prevent /fstack errors.

The element uses oUF's debuff colors table to apply colors to the sub-widgets.

.dispelIcon Sub-Widgets

  • .cd - used to display the cooldown spiral for the remaining debuff duration (Cooldown)
  • .count - used to display the stack count of the dispellable debuff (FontString)
  • .icon - used to show the icon's texture (Texture)
  • .overlay - used to represent the icon's border. Will be colored according to the debuff type color (Texture)

.dispelIcon Options

  • .tooltipAnchor - anchor for the widget's tooltip if it is mouse-enabled. Defaults to 'ANCHOR_BOTTOMRIGHT' (string)

.dispelIcon Attributes

  • .id - the aura index of the dispellable debuff displayed by the widget (number)
  • .unit - the unit on which the dispellable dubuff has been found (string)

.dispelTexture Options

  • .dispelAlpha - alpha value for the widget when a dispellable debuff is found. Defaults to 1 (number)[0-1]
  • .noDispelAlpha - alpha value for the widget when no dispellable debuffs are found. Defaults to 0 (number)[0-1]

Callbacks and Overrides

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

  1. self - the Dispellable element

:PostUpdate(dispelType, texture, count, duration, expiration) - Called after the element has been updated.

  1. self - the Dispellable element
  2. dispelType - the type of the dispellable debuff (string?)['Curse', 'Disease', 'Magic', 'Poison']
  3. texture - the texture representing the debuff icon (number?)
  4. count - the stack count of the dispellable debuff (number?)
  5. duration - the duration of the dispellable debuff in seconds (number?)
  6. expiration - the point in time when the debuff will expire. Can be compared to GetTime() (number?)

:Override(event, unit) - Used to override the internal update function.

  1. self - the Dispellable element
  2. event - the event triggering the update (string)
  3. unit - the unit accompaning the event (string)

.dispelIcon:UpdateTooltip() - Called to update the widget's tooltip.

  1. self - the dispelIcon sub-widget

.dispelTexture:UpdateColor(dispelType, r, g, b, a) - Called to update the widget's color.

  1. self - the dispelTexture sub-widget
  2. dispelType - the type of the dispellable debuff (string?)['Curse', 'Disease', 'Magic', 'Poison']
  3. r - the red color component (number)[0-1]
  4. g - the green color component (number)[0-1]
  5. b - the blue color component (number)[0-1]
  6. a - the alpha color component (number)[0-1]

Examples

All supported widgets:

-- Position and size
local button = CreateFrame('Button', 'LayoutName_Dispel', self.Health)
button:SetPoint('CENTER')
button:SetSize(22, 22)
button:SetToplevel(true)

local cd = CreateFrame('Cooldown', '$parentCooldown', button, 'CooldownFrameTemplate')
cd:SetHideCountdownNumbers(false) -- set to true to disable cooldown numbers on the cooldown spiral
cd:SetAllPoints()

local icon = button:CreateTexture(nil, 'ARTWORK')
icon:SetAllPoints()

local overlay = button:CreateTexture(nil, 'OVERLAY')
overlay:SetTexture('Interface\\Buttons\\UI-Debuff-Overlays')
overlay:SetTexCoord(0.296875, 0.5703125, 0, 0.515625)
overlay:SetAllPoints()

local count = button:CreateFontString(nil, 'OVERLAY', 'NumberFontNormal', 1)
count:SetPoint('BOTTOMRIGHT', -1, 1)

local texture = self.Health:CreateTexture(nil, 'OVERLAY')
texture:SetTexture('Interface\\ChatFrame\\ChatFrameBackground')
texture:SetAllPoints()
texture:SetVertexColor(1, 1, 1, 0) -- hide in case the class can't dispel at all

button.cd = cd
button.icon = icon
button.overlay = overlay
button.count = count
button:Hide() -- hide in case the class can't dispel at all

-- Register with oUF
self.Dispellable = {
	dispelIcon = button,
	dispelTexture = texture,
}

Using the unit frame's backdrop:

local texture = {} -- create a dummy "texture"
texture.frame = self -- attach the unit frame to the "texture"
texture.UpdateColor = function(dispelTexture, dispelType, r, g, b)
	if (dispelType) then
		dispelTexture.frame:SetBackdropBorderColor(r, g, b)
	else
		-- set original colors
		dispelTexture.frame:SetBackdropBorderColor(0, 0, 0)
	end
end

-- Register with oUF
self.Dispellable = {
	dispelTexture = texture,
}