|
local function ComboPointsUpdate(self) |
if self.points and self.points > 0 then |
local size = (13 + ((18 - 13) / 5) * self.points) |
local blue = (1 - (1 / 5) * self.points) |
local i |
|
for i = 1,5 do |
if i <= self.points then |
self[i]:SetAlpha(1) |
else |
self[i]:SetAlpha(.3) |
end |
|
addon.SetFontSize(self, size) |
self[i]:SetVertexColor(unpack(self.colour)) |
end |
|
self:SetText(self.points) |
self:SetTextColor(1, 1, blue) |
self:Show() |
elseif self:GetText() then |
self:SetText('') |
elseif self:IsShown() then |
self:Hide() |
end |
end |
-------------------------------------------------------------- Event handlers -- |
function mod:UNIT_COMBO_POINTS(event, unit) |
if not unit then return end |
-- only works for player > target |
if not unit or unit ~= 'player' then return end |
|
local guid, name = UnitGUID(unit), UnitName(unit) |
-- TODO make sure UnitName() doesn't need to have realm names removed |
-- before GetNameplate will recognise them |
local guid, name = UnitGUID('target'), UnitName('target') |
local f = addon:GetNameplate(guid, name) |
|
if f then |
if f.cp then |
f.cp.points = GetComboPoints(unit, unit) |
f.cp:Update() |
if f and f.combopoints then |
local points = GetComboPoints('player', 'target') |
|
if points == 5 then |
f.combopoints.colour = { 1, 1, .1 } |
else |
f.combopoints.colour = { .79, .55, .18 } |
end |
|
f.combopoints.points = points |
f.combopoints:Update() |
end |
|
-- clear points on other frames |
local _, frame |
for _, frame in pairs(addon.frameList) do |
if frame.cp and frame ~= f then |
if frame.combopoints and frame ~= f then |
self:HideComboPoints(nil, frame) |
end |
end |
end |
---------------------------------------------------------------------- Create -- |
function mod:CreateComboPoints(msg, frame) |
frame.cp = frame:CreateFontString(frame.health, { |
font = addon.font, size = 'combopoints', outline = 'OUTLINE', shadow = true }) |
frame.cp:SetPoint('LEFT', frame.health, 'RIGHT', 5, 1) |
frame.cp.Update = ComboPointsUpdate |
frame.cp:Hide() |
-- create combo point icons |
frame.combopoints = CreateFrame('Frame', nil, frame.parent) |
frame.combopoints:Hide() |
|
local i, pcp |
for i=0,4 do |
local cp = frame.combopoints:CreateTexture(nil, 'ARTWORK') |
cp:SetDrawLayer('ARTWORK', 1) -- above overlay |
cp:SetTexture('Interface\\AddOns\\Kui_Nameplates\\combopoint') |
cp:SetTexCoord(0, .375, 0, .375) |
cp:SetSize(addon.sizes.combopoints, addon.sizes.combopoints) |
|
if i == 0 then |
cp:SetPoint('BOTTOM', frame.overlay, 'BOTTOM', |
-((addon.sizes.combopoints*2)+2), -3) |
else |
cp:SetPoint('LEFT', pcp, 'RIGHT', 1, 0) |
end |
|
tinsert(frame.combopoints, i+1, cp) |
pcp = cp -- store previous icon |
end |
|
frame.combopoints.Update = ComboPointsUpdate |
end |
------------------------------------------------------------------------ Hide -- |
function mod:HideComboPoints(msg, frame) |
if frame.cp then |
frame.cp.points = nil |
frame.cp:Update() |
if frame.combopoints then |
frame.combopoints.points = nil |
frame.combopoints:Update() |
end |
end |
---------------------------------------------------- Post db change functions -- |