Commit af69dfab authored by Tukz's avatar Tukz

Update oUF

parent 2b297485
This diff is collapsed.
--[[
# Element: Quest Indicator
# Element: Phasing Indicator
Handles the visibility and updating of an indicator based on the unit's involvement in a quest.
Toggles the visibility of an indicator based on the unit's phasing relative to the player.
## Widget
QuestIndicator - Any UI widget.
PhaseIndicator - Any UI widget.
## Notes
......@@ -14,74 +14,72 @@ A default texture will be applied if the widget is a Texture and doesn't have a
## Examples
-- Position and size
local QuestIndicator = self:CreateTexture(nil, 'OVERLAY')
QuestIndicator:SetSize(16, 16)
QuestIndicator:SetPoint('TOPRIGHT', self)
local PhaseIndicator = self:CreateTexture(nil, 'OVERLAY')
PhaseIndicator:SetSize(16, 16)
PhaseIndicator:SetPoint('TOPLEFT', self)
-- Register it with oUF
self.QuestIndicator = QuestIndicator
self.PhaseIndicator = PhaseIndicator
--]]
local _, ns = ...
local oUF = ns.oUF
local function Update(self, event, unit)
if(unit ~= self.unit) then return end
local function Update(self, event)
local element = self.PhaseIndicator
local element = self.QuestIndicator
--[[ Callback: QuestIndicator:PreUpdate()
--[[ Callback: PhaseIndicator:PreUpdate()
Called before the element has been updated.
* self - the QuestIndicator element
* self - the PhaseIndicator element
--]]
if(element.PreUpdate) then
element:PreUpdate()
end
local isQuestBoss = UnitIsQuestBoss(unit)
if(isQuestBoss) then
local isInSamePhase = UnitInPhase(self.unit) and not UnitIsWarModePhased(self.unit)
if(not isInSamePhase and UnitIsPlayer(self.unit) and UnitIsConnected(self.unit)) then
element:Show()
else
element:Hide()
end
--[[ Callback: QuestIndicator:PostUpdate(isQuestBoss)
--[[ Callback: PhaseIndicator:PostUpdate(isInSamePhase)
Called after the element has been updated.
* self - the QuestIndicator element
* isQuestBoss - indicates if the element is shown (boolean)
* self - the PhaseIndicator element
* isInSamePhase - indicates whether the unit is in the same phase as the player (boolean)
--]]
if(element.PostUpdate) then
return element:PostUpdate(isQuestBoss)
return element:PostUpdate(isInSamePhase)
end
end
local function Path(self, ...)
--[[ Override: QuestIndicator.Override(self, event, ...)
--[[ Override: PhaseIndicator.Override(self, event, ...)
Used to completely override the internal update function.
* self - the parent object
* event - the event triggering the update (string)
* ... - the arguments accompanying the event
--]]
return (self.QuestIndicator.Override or Update) (self, ...)
return (self.PhaseIndicator.Override or Update) (self, ...)
end
local function ForceUpdate(element)
return Path(element.__owner, 'ForceUpdate', element.__owner.unit)
return Path(element.__owner, 'ForceUpdate')
end
local function Enable(self)
local element = self.QuestIndicator
local element = self.PhaseIndicator
if(element) then
element.__owner = self
element.ForceUpdate = ForceUpdate
self:RegisterEvent('UNIT_CLASSIFICATION_CHANGED', Path)
self:RegisterEvent('UNIT_PHASE', Path, true)
if(element:IsObjectType('Texture') and not element:GetTexture()) then
element:SetTexture([[Interface\TargetingFrame\PortraitQuestBadge]])
element:SetTexture([[Interface\TargetingFrame\UI-PhasingIcon]])
end
return true
......@@ -89,12 +87,12 @@ local function Enable(self)
end
local function Disable(self)
local element = self.QuestIndicator
local element = self.PhaseIndicator
if(element) then
element:Hide()
self:UnregisterEvent('UNIT_CLASSIFICATION_CHANGED', Path)
self:UnregisterEvent('UNIT_PHASE', Path)
end
end
oUF:AddElement('QuestIndicator', Path, Enable, Disable)
oUF:AddElement('PhaseIndicator', Path, Enable, Disable)
--[[
# Element: Power Prediction Bar
Handles the visibility and updating of power cost prediction.
## Widget
PowerPrediction - A `table` containing the sub-widgets.
## Sub-Widgets
mainBar - A `StatusBar` used to represent power cost of spells on top of the Power element.
altBar - A `StatusBar` used to represent power cost of spells on top of the AdditionalPower element.
## Notes
A default texture will be applied if the widget is a StatusBar and doesn't have a texture set.
## Examples
-- Position and size
local mainBar = CreateFrame('StatusBar', nil, self.Power)
mainBar:SetReverseFill(true)
mainBar:SetPoint('TOP')
mainBar:SetPoint('BOTTOM')
mainBar:SetPoint('RIGHT', self.Power:GetStatusBarTexture(), 'RIGHT')
mainBar:SetWidth(200)
local altBar = CreateFrame('StatusBar', nil, self.AdditionalPower)
altBar:SetReverseFill(true)
altBar:SetPoint('TOP')
altBar:SetPoint('BOTTOM')
altBar:SetPoint('RIGHT', self.AdditionalPower:GetStatusBarTexture(), 'RIGHT')
altBar:SetWidth(200)
-- Register with oUF
self.PowerPrediction = {
mainBar = mainBar,
altBar = altBar
}
--]]
local _, ns = ...
local oUF = ns.oUF
-- sourced from FrameXML/AlternatePowerBar.lua
local ADDITIONAL_POWER_BAR_INDEX = ADDITIONAL_POWER_BAR_INDEX or 0
local ALT_MANA_BAR_PAIR_DISPLAY_INFO = ALT_MANA_BAR_PAIR_DISPLAY_INFO
local _, playerClass = UnitClass('player')
local function Update(self, event, unit)
if(self.unit ~= unit) then return end
local element = self.PowerPrediction
--[[ Callback: PowerPrediction:PreUpdate(unit)
Called before the element has been updated.
* self - the PowerPrediction element
* unit - the unit for which the update has been triggered (string)
--]]
if(element.PreUpdate) then
element:PreUpdate(unit)
end
local _, _, _, startTime, endTime, _, _, _, spellID = UnitCastingInfo(unit)
local mainPowerType = UnitPowerType(unit)
local hasAltManaBar = ALT_MANA_BAR_PAIR_DISPLAY_INFO[playerClass] and ALT_MANA_BAR_PAIR_DISPLAY_INFO[playerClass][mainPowerType]
local mainCost, altCost = 0, 0
if(event == 'UNIT_SPELLCAST_START' or startTime ~= endTime) then
local costTable = GetSpellPowerCost(spellID)
for _, costInfo in pairs(costTable) do
-- costInfo content:
-- - name: string (powerToken)
-- - type: number (powerType)
-- - cost: number
-- - costPercent: number
-- - costPerSec: number
-- - minCost: number
-- - hasRequiredAura: boolean
-- - requiredAuraID: number
if(costInfo.type == mainPowerType) then
mainCost = costInfo.cost
break
elseif(costInfo.type == ADDITIONAL_POWER_BAR_INDEX) then
altCost = costInfo.cost
break
end
end
end
if(element.mainBar) then
element.mainBar:SetMinMaxValues(0, UnitPowerMax(unit, mainPowerType))
element.mainBar:SetValue(mainCost)
element.mainBar:Show()
end
if(element.altBar and hasAltManaBar) then
element.altBar:SetMinMaxValues(0, UnitPowerMax(unit, ADDITIONAL_POWER_BAR_INDEX))
element.altBar:SetValue(altCost)
element.altBar:Show()
end
--[[ Callback: PowerPrediction:PostUpdate(unit, mainCost, altCost, hasAltManaBar)
Called after the element has been updated.
* self - the PowerPrediction element
* unit - the unit for which the update has been triggered (string)
* mainCost - the main power type cost of the cast ability (number)
* altCost - the secondary power type cost of the cast ability (number)
* hasAltManaBar - indicates if the unit has a secondary power bar (boolean)
--]]
if(element.PostUpdate) then
return element:PostUpdate(unit, mainCost, altCost, hasAltManaBar)
end
end
local function Path(self, ...)
--[[ Override: PowerPrediction.Override(self, event, unit, ...)
Used to completely override the internal update function.
* self - the parent object
* event - the event triggering the update (string)
* unit - the unit accompanying the event (string)
* ... - the arguments accompanying the event
--]]
return (self.PowerPrediction.Override or Update) (self, ...)
end
local function ForceUpdate(element)
return Path(element.__owner, 'ForceUpdate', element.__owner.unit)
end
local function Enable(self)
local element = self.PowerPrediction
if(element) then
element.__owner = self
element.ForceUpdate = ForceUpdate
self:RegisterEvent('UNIT_SPELLCAST_START', Path)
self:RegisterEvent('UNIT_SPELLCAST_STOP', Path)
self:RegisterEvent('UNIT_SPELLCAST_FAILED', Path)
self:RegisterEvent('UNIT_SPELLCAST_SUCCEEDED', Path)
self:RegisterEvent('UNIT_DISPLAYPOWER', Path)
if(element.mainBar) then
if(element.mainBar:IsObjectType('StatusBar') and not element.mainBar:GetStatusBarTexture()) then
element.mainBar:SetStatusBarTexture([[Interface\TargetingFrame\UI-StatusBar]])
end
end
if(element.altBar) then
if(element.altBar:IsObjectType('StatusBar') and not element.altBar:GetStatusBarTexture()) then
element.altBar:SetStatusBarTexture([[Interface\TargetingFrame\UI-StatusBar]])
end
end
return true
end
end
local function Disable(self)
local element = self.PowerPrediction
if(element) then
if(element.mainBar) then
element.mainBar:Hide()
end
if(element.altBar) then
element.altBar:Hide()
end
self:UnregisterEvent('UNIT_SPELLCAST_START', Path)
self:UnregisterEvent('UNIT_SPELLCAST_STOP', Path)
self:UnregisterEvent('UNIT_SPELLCAST_FAILED', Path)
self:UnregisterEvent('UNIT_SPELLCAST_SUCCEEDED', Path)
self:UnregisterEvent('UNIT_DISPLAYPOWER', Path)
end
end
oUF:AddElement('PowerPrediction', Path, Enable, Disable)
--[[
# Element: Monk Stagger Bar
Handles the visibility and updating of the Monk's stagger bar.
## Widget
Stagger - A `StatusBar` used to represent the current stagger level.
## Sub-Widgets
.bg - A `Texture` used as a background. It will inherit the color of the main StatusBar.
## Notes
A default texture will be applied if the widget is a StatusBar and doesn't have a texture set.
## Sub-Widgets Options
.multiplier - Used to tint the background based on the main widgets R, G and B values. Defaults to 1 (number)[0-1]
## Examples
local Stagger = CreateFrame('StatusBar', nil, self)
Stagger:SetSize(120, 20)
Stagger:SetPoint('TOPLEFT', self, 'BOTTOMLEFT', 0, 0)
-- Register with oUF
self.Stagger = Stagger
--]]
if(select(2, UnitClass('player')) ~= 'MONK') then return end
local _, ns = ...
local oUF = ns.oUF
-- sourced from FrameXML/Constants.lua
local SPEC_MONK_BREWMASTER = SPEC_MONK_BREWMASTER or 1
-- sourced from FrameXML/MonkStaggerBar.lua
local BREWMASTER_POWER_BAR_NAME = BREWMASTER_POWER_BAR_NAME or 'STAGGER'
-- percentages at which bar should change color
local STAGGER_YELLOW_TRANSITION = STAGGER_YELLOW_TRANSITION or 0.3
local STAGGER_RED_TRANSITION = STAGGER_RED_TRANSITION or 0.6
-- table indices of bar colors
local STAGGER_GREEN_INDEX = STAGGER_GREEN_INDEX or 1
local STAGGER_YELLOW_INDEX = STAGGER_YELLOW_INDEX or 2
local STAGGER_RED_INDEX = STAGGER_RED_INDEX or 3
local function UpdateColor(element, cur, max)
local colors = element.__owner.colors.power[BREWMASTER_POWER_BAR_NAME]
local perc = cur / max
local t
if(perc >= STAGGER_RED_TRANSITION) then
t = colors and colors[STAGGER_RED_INDEX]
elseif(perc > STAGGER_YELLOW_TRANSITION) then
t = colors and colors[STAGGER_YELLOW_INDEX]
else
t = colors and colors[STAGGER_GREEN_INDEX]
end
local r, g, b
if(t) then
r, g, b = t[1], t[2], t[3]
if(b) then
element:SetStatusBarColor(r, g, b)
local bg = element.bg
if(bg and b) then
local mu = bg.multiplier or 1
bg:SetVertexColor(r * mu, g * mu, b * mu)
end
end
end
end
local function Update(self, event, unit)
if(unit and unit ~= self.unit) then return end
local element = self.Stagger
--[[ Callback: Stagger:PreUpdate()
Called before the element has been updated.
* self - the Stagger element
--]]
if(element.PreUpdate) then
element:PreUpdate()
end
-- Blizzard code has nil checks for UnitStagger return
local cur = UnitStagger('player') or 0
local max = UnitHealthMax('player')
element:SetMinMaxValues(0, max)
element:SetValue(cur)
--[[ Override: Stagger:UpdateColor(cur, max)
Used to completely override the internal function for updating the widget's colors.
* self - the Stagger element
* cur - the amount of staggered damage (number)
* max - the player's maximum possible health value (number)
--]]
element:UpdateColor(cur, max)
--[[ Callback: Stagger:PostUpdate(cur, max)
Called after the element has been updated.
* self - the Stagger element
* cur - the amount of staggered damage (number)
* max - the player's maximum possible health value (number)
--]]
if(element.PostUpdate) then
element:PostUpdate(cur, max)
end
end
local function Path(self, ...)
--[[ Override: Stagger.Override(self, event, unit)
Used to completely override the internal update function.
* self - the parent object
* event - the event triggering the update (string)
* unit - the unit accompanying the event (string)
--]]
return (self.Stagger.Override or Update)(self, ...)
end
local function Visibility(self, event, unit)
if(SPEC_MONK_BREWMASTER ~= GetSpecialization() or UnitHasVehiclePlayerFrameUI('player')) then
if(self.Stagger:IsShown()) then
self.Stagger:Hide()
self:UnregisterEvent('UNIT_AURA', Path)
end
else
if(not self.Stagger:IsShown()) then
self.Stagger:Show()
self:RegisterEvent('UNIT_AURA', Path)
end
return Path(self, event, unit)
end
end
local function VisibilityPath(self, ...)
--[[ Override: Stagger.OverrideVisibility(self, event, unit)
Used to completely override the internal visibility toggling function.
* self - the parent object
* event - the event triggering the update (string)
* unit - the unit accompanying the event (string)
--]]
return (self.Stagger.OverrideVisibility or Visibility)(self, ...)
end
local function ForceUpdate(element)
return VisibilityPath(element.__owner, 'ForceUpdate', element.__owner.unit)
end
local function Enable(self)
local element = self.Stagger
if(element) then
element.__owner = self
element.ForceUpdate = ForceUpdate
self:RegisterEvent('UNIT_DISPLAYPOWER', VisibilityPath)
self:RegisterEvent('PLAYER_TALENT_UPDATE', VisibilityPath, true)
if(element:IsObjectType('StatusBar') and not element:GetStatusBarTexture()) then
element:SetStatusBarTexture([[Interface\TargetingFrame\UI-StatusBar]])
end
if(not element.UpdateColor) then
element.UpdateColor = UpdateColor
end
MonkStaggerBar:UnregisterEvent('PLAYER_ENTERING_WORLD')
MonkStaggerBar:UnregisterEvent('PLAYER_SPECIALIZATION_CHANGED')
MonkStaggerBar:UnregisterEvent('UNIT_DISPLAYPOWER')
MonkStaggerBar:UnregisterEvent('UNIT_EXITED_VEHICLE')
MonkStaggerBar:UnregisterEvent('UPDATE_VEHICLE_ACTIONBAR')
element:Hide()
return true
end
end
local function Disable(self)
local element = self.Stagger
if(element) then
element:Hide()
self:UnregisterEvent('UNIT_AURA', Path)
self:UnregisterEvent('UNIT_DISPLAYPOWER', VisibilityPath)
self:UnregisterEvent('PLAYER_TALENT_UPDATE', VisibilityPath)
MonkStaggerBar:RegisterEvent('PLAYER_ENTERING_WORLD')
MonkStaggerBar:RegisterEvent('PLAYER_SPECIALIZATION_CHANGED')
MonkStaggerBar:RegisterEvent('UNIT_DISPLAYPOWER')
MonkStaggerBar:RegisterEvent('UNIT_EXITED_VEHICLE')
MonkStaggerBar:RegisterEvent('UPDATE_VEHICLE_ACTIONBAR')
end
end
oUF:AddElement('Stagger', VisibilityPath, Enable, Disable)
--[[
# Element: SummonIndicator
Handles the visibility and updating of an indicator based on the unit's incoming summon status.
## Widget
SummonIndicator - A `Texture` used to display if the unit has an incoming summon.
## Notes
This element updates by changing the texture.
## Examples
-- Position and size
local SummonIndicator = self:CreateTexture(nil, 'OVERLAY')
SummonIndicator:SetSize(32, 32)
SummonIndicator:SetPoint('TOPRIGHT', self)
-- Register it with oUF
self.SummonIndicator = SummonIndicator
--]]
local _, ns = ...
local oUF = ns.oUF
-- sourced from Blizzard_APIDocumentation/IncomingSummonDocumentation.lua
local SUMMON_STATUS_NONE = Enum.SummonStatus.None or 0
local SUMMON_STATUS_PENDING = Enum.SummonStatus.Pending or 1
local SUMMON_STATUS_ACCEPTED = Enum.SummonStatus.Accepted or 2
local SUMMON_STATUS_DECLINED = Enum.SummonStatus.Declined or 3
local function Update(self, event, unit)
if(self.unit ~= unit) then return end
local element = self.SummonIndicator
--[[ Callback: SummonIndicator:PreUpdate()
Called before the element has been updated.
* self - the SummonIndicator element
--]]
if(element.PreUpdate) then
element:PreUpdate()
end
local status = C_IncomingSummon.IncomingSummonStatus(unit)
if(status ~= SUMMON_STATUS_NONE) then
if(status == SUMMON_STATUS_PENDING) then
element:SetAtlas('Raid-Icon-SummonPending')
elseif(status == SUMMON_STATUS_ACCEPTED) then
element:SetAtlas('Raid-Icon-SummonAccepted')
elseif(status == SUMMON_STATUS_DECLINED) then
element:SetAtlas('Raid-Icon-SummonDeclined')
end
element:Show()
else
element:Hide()
end
--[[ Callback: SummonIndicator:PostUpdate(status)
Called after the element has been updated.
* self - the SummonIndicator element
* status - the unit's incoming summon status (number)[0-3]
--]]
if(element.PostUpdate) then
return element:PostUpdate(status)
end
end
local function Path(self, ...)
--[[ Override: SummonIndicator.Override(self, event)
Used to completely override the internal update function.
* self - the parent object
* event - the event triggering the update (string)
* ... - the arguments accompanying the event
--]]
return (self.SummonIndicator.Override or Update) (self, ...)
end
local function ForceUpdate(element)
return Path(element.__owner, 'ForceUpdate', element.__owner.unit)
end
local function Enable(self)
local element = self.SummonIndicator
if(element) then
element.__owner = self
element.ForceUpdate = ForceUpdate
self:RegisterEvent('INCOMING_SUMMON_CHANGED', Path)
return true
end
end
local function Disable(self)
local element = self.SummonIndicator
if(element) then
element:Hide()
self:UnregisterEvent('INCOMING_SUMMON_CHANGED', Path)
end
end
oUF:AddElement('SummonIndicator', Path, Enable, Disable)
......@@ -14,17 +14,18 @@
<Script file="elements\classpower.lua"/>
<Script file="elements\combatindicator.lua"/>
<Script file="elements\health.lua"/>
<Script file="elements\healthprediction.lua"/>
<Script file="elements\leaderindicator.lua"/>
<Script file="elements\phaseindicator.lua"/>
<Script file="elements\portrait.lua"/>
<Script file="elements\power.lua"/>
<Script file="elements\powerprediction.lua"/>
<Script file="elements\pvpindicator.lua"/>
<Script file="elements\questindicator.lua"/>
<Script file="elements\raidtargetindicator.lua"/>
<Script file="elements\range.lua"/>
<Script file="elements\readycheckindicator.lua"/>
<Script file="elements\restingindicator.lua"/>
<Script file="elements\resurrectindicator.lua"/>
<Script file="elements\stagger.lua"/>
<Script file="elements\tags.lua"/>
<Script file="finalize.lua"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment