function (self, unitId, unitFrame, envTable)
--settings
local anchors = {
{"bottom", unitFrame.healthBar, "top", 45, -30},
}
local sizes = {
width = 20,
height = 20,
scale = .6,
}
local textures = {
backgroundTexture = [[InterfacePLAYERFRAMEMonkNoPower]],
backgroundTexCoords = {0,1,0,1},
comboPointTexture = [[InterfaceUNITPOWERBARALTPandarenTraining_Circular_Fill]],
comboPointTexCoords = {0,1,0,1},
}
local frameLevel = 1000
local frameStrata = "high"
--private
do
--store combo points frames on this table
envTable.ComboPoints = {}
--save when the player changed talents or spec
envTable.LastPlayerTalentUpdate = GetTime()
--save when this nameplate got a combo point amount and alignment update
--build combo points frame anchor (combo point are anchored to this)
if (not unitFrame.PlaterComboPointFrame) then
local hostFrame = CreateFrame ("frame", nil, unitFrame)
hostFrame.ComboPointFramesPool = {}
unitFrame.PlaterComboPointFrame = hostFrame
envTable.ComboPointFrame = hostFrame
envTable.ComboPointFrame:SetScale (sizes.scale)
--DetailsFramework:ApplyStandardBackdrop (envTable.ComboPointFrame) --debug anchor size
--animations
local onPlayShowAnimation = function (animation)
--stop the hide animation if it's playing
if (animation:GetParent():GetParent().HideAnimation:IsPlaying()) then
animation:GetParent():GetParent().HideAnimation:Stop()
end
animation:GetParent():Show()
end
local onPlayHideAnimation = function (animation)
--stop the show animation if it's playing
if (animation:GetParent():GetParent().ShowAnimation:IsPlaying()) then
animation:GetParent():GetParent().ShowAnimation:Stop()
end
end
local onStopHideAnimation = function (animation)
animation:GetParent():Hide()
end
local createAnimations = function (comboPoint)
--on show
comboPoint.ShowAnimation = Plater:CreateAnimationHub (comboPoint.comboPointTexture, onPlayShowAnimation, nil)
Plater:CreateAnimation (comboPoint.ShowAnimation, "scale", 1, 0.1, 0, 0, 1, 1)
Plater:CreateAnimation (comboPoint.ShowAnimation, "alpha", 1, 0.1, .5, 1)
Plater:CreateAnimation (comboPoint.ShowAnimation, "scale", 2, 0.1, 1.2, 1.2, 1, 1)
--on hide
comboPoint.HideAnimation = Plater:CreateAnimationHub (comboPoint.comboPointTexture, onPlayHideAnimation, onStopHideAnimation)
Plater:CreateAnimation (comboPoint.HideAnimation, "scale", 1, 0.1, 1, 1, 0, 0)
Plater:CreateAnimation (comboPoint.HideAnimation, "alpha", 1, 0.1, 1, 0)
end
--build combo point frame
for i =1, 10 do
local f = CreateFrame ("frame", nil, envTable.ComboPointFrame)
f:SetSize (sizes.width, sizes.height)
tinsert (envTable.ComboPoints, f)
tinsert (unitFrame.PlaterComboPointFrame.ComboPointFramesPool, f)
local backgroundTexture = f:CreateTexture (nil, "background")
backgroundTexture:SetTexture (textures.backgroundTexture)
backgroundTexture:SetTexCoord (unpack (textures.backgroundTexCoords))
backgroundTexture:SetSize (sizes.width, sizes.height)
backgroundTexture:SetPoint ("center")
local comboPointTexture = f:CreateTexture (nil, "artwork")
comboPointTexture:SetTexture (textures.comboPointTexture)
comboPointTexture:SetTexCoord (unpack (textures.comboPointTexCoords))
comboPointTexture:SetSize (sizes.width, sizes.height)
comboPointTexture:SetPoint ("center")
comboPointTexture:Hide()
f.IsActive = false
f.backgroundTexture = backgroundTexture
f.comboPointTexture = comboPointTexture
createAnimations (f)
end
else
envTable.ComboPointFrame = unitFrame.PlaterComboPointFrame
envTable.ComboPointFrame:SetScale (sizes.scale)
envTable.ComboPoints = unitFrame.PlaterComboPointFrame.ComboPointFramesPool
end
envTable.ComboPointFrame:SetFrameLevel (frameLevel)
envTable.ComboPointFrame:SetFrameStrata (frameStrata)
function envTable.UpdateComboPoints()
local comboPoints = UnitPower ("player", Enum.PowerType.HolyPower)
for i = 1, envTable.TotalComboPoints do
local thisComboPoint = envTable.ComboPoints [i]
if (i <= comboPoints ) then
--combo point enabled
if (not thisComboPoint.IsActive) then
thisComboPoint.ShowAnimation:Play()
thisComboPoint.IsActive = true
end
else
--combo point disabled
if (thisComboPoint.IsActive) then
thisComboPoint.HideAnimation:Play()
thisComboPoint.IsActive = false
end
end
end
end
function envTable.UpdateComboPointAmount()
local namePlateWidth = 80
local comboPoints = UnitPowerMax ("player", Enum.PowerType.HolyPower)
local reservedSpace = (namePlateWidth - sizes.width * comboPoints) / comboPoints
--store the total amount of combo points
envTable.TotalComboPoints = comboPoints
--update anchor frame
envTable.ComboPointFrame:SetWidth (namePlateWidth)
envTable.ComboPointFrame:SetHeight (20)
envTable.ComboPointFrame:ClearAllPoints()
for i = 1, #anchors do
local anchor = anchors[i]
envTable.ComboPointFrame:SetPoint (unpack (anchor))
end
--
for i = 1, #envTable.ComboPoints do
envTable.ComboPoints[i]:Hide()
envTable.ComboPoints[i]:ClearAllPoints()
end
for i = 1, comboPoints do
local comboPoint = envTable.ComboPoints[i]
if i == 1 then
comboPoint:SetPoint ("left", envTable.ComboPointFrame, "left", reservedSpace/2, 0)
else
comboPoint:SetPoint ("left", envTable.ComboPoints[i-1], "right", reservedSpace, 0)
end
comboPoint:Show()
end
envTable.LastUpdate = GetTime()
envTable.UpdateComboPoints()
end
--initialize
envTable.UpdateComboPointAmount()
envTable.ComboPointFrame:Hide()
end
end