/branches
}, |
small = { |
name = 'Small', |
desc = 'Used for contextual health on normal nameplates and name on trivial nameplates', |
desc = 'Used for contextual health', |
type = 'range', |
min = 1, |
softMax = 20 |
local _, frame |
for _, frame in pairs(addon.frameList) do |
if frame.cp and frame ~= f then |
self:HideComboPoints(frame) |
self:HideComboPoints(nil, frame) |
end |
end |
end |
---------------------------------------------------------------------- Create -- |
function mod:CreateComboPoints(frame) |
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:Hide() |
end |
------------------------------------------------------------------------ Hide -- |
function mod:HideComboPoints(frame) |
function mod:HideComboPoints(msg, frame) |
if frame.cp then |
frame.cp.points = nil |
frame.cp:Update() |
mod:Disable() |
end |
end |
-------------------------------------------------------------------- Register -- |
function mod:GetOptions() |
return { |
end |
function mod:OnEnable() |
addon:RegisterPostFunction('create', self, 'CreateComboPoints') |
addon:RegisterPostFunction('hide', self, 'HideComboPoints') |
self:RegisterMessage('KuiNameplates_PostCreate', 'CreateComboPoints') |
self:RegisterMessage('KuiNameplates_PostHide', 'HideComboPoints') |
self:RegisterEvent('UNIT_COMBO_POINTS') |
local _, frame |
for _, frame in pairs(addon.frameList) do |
if not frame.cp then |
self:CreateComboPoints(frame) |
self:CreateComboPoints(nil, frame) |
end |
end |
end |
local _, frame |
for _, frame in pairs(addon.frameList) do |
self:HideComboPoints(frame) |
self:HideComboPoints(nil, frame) |
end |
end |
fs:SetFont(font, size, flags) |
end |
local function ModifyFontFlags(fs, io, flag) |
local font, size, flags = fs:GetFont() |
local flagStart,flagEnd = strfind(flags, flag) |
if io and not flagStart then |
-- add flag |
flags = flags..' '..flag |
elseif not val and flagStart then |
-- remove flag |
flags = strsub(flags, 0, flagStart-1) .. strsub(flags, flagEnd+1) |
end |
fs:SetFont(font, size, flags) |
end |
local function CreateFontString(self, parent, obj) |
-- size can be stored as a key of kn.fontSizes so that it can be set |
-- correctly if fonts are scaled |
tinsert(self.fontObjects, fs) |
return fs |
end |
-------------------------------------------------- External calling functions -- |
local postFunctions = { |
target = {}, -- upon becoming the target |
create = {}, -- post creation |
show = {}, -- post OnFrameShow |
hide = {} -- post OnFrameHide |
} |
local function CallPostFunction(typ, frame) |
if postFunctions[typ] then |
local _, mod |
for _, mod in ipairs(postFunctions[typ]) do |
mod[1][mod[2]](mod[1], frame) |
end |
end |
end |
function kn:RegisterPostFunction(typ, mod, func) |
if not postFunctions[typ] then return end |
tinsert(postFunctions[typ], { mod, func }) |
end |
------------------------------------------------------------- Frame functions -- |
-- set colour of health bar according to reaction/threat |
local function SetHealthColour(self) |
self.health.mo:Hide() |
end |
SetFontSize(self.name, 'small') |
--SetFontSize(self.name, 'small') |
self.name:SetJustifyH('CENTER') |
self.name:SetPoint('BOTTOM', self.health, 'TOP', 0, -3) |
self.health.mo:Show() |
end |
SetFontSize(self.name, 'name') |
--SetFontSize(self.name, 'name') |
self.name:SetJustifyH('LEFT') |
self.name:SetPoint('RIGHT', self.health.p, 'LEFT') |
self:SetGlowColour() |
CallPostFunction('show', self) |
kn:SendMessage('KuiNameplates_PostShow', self) |
end |
local function OnFrameHide(self) |
-- unset stored health bar colours |
self.health.r, self.health.g, self.health.b, self.health.reset |
= nil, nil, nil, nil |
CallPostFunction('hide', self) |
kn:SendMessage('KuiNameplates_PostHide', self) |
end |
local function OnFrameEnter(self) |
if self.health.mo then self.health.mo:Show() end |
end |
CallPostFunction('target', self) |
kn:SendMessage('KuiNameplates_PostTarget', self) |
end |
elseif self.target then |
self.target = nil |
frame.elapsed = 0 |
frame.critElap = 0 |
CallPostFunction('create', frame) |
kn:SendMessage('KuiNameplates_PostCreate', frame) |
-- force OnShow |
OnFrameShow(frame) |
end |
end |
kn.configChangedFuncs.outline = function(frame, val) |
local _, fontObject |
for _, fontObject in pairs(frame.fontObjects) do |
ModifyFontFlags(fontObject, val, 'OUTLINE') |
end |
end |
kn.configChangedFuncs.monochrome = function(frame, val) |
local _, fontObject |
for _, fontObject in pairs(frame.fontObjects) do |
ModifyFontFlags(fontObject, val, 'MONOCHROME') |
end |
end |
kn.configChangedFuncs.fontscale = function(frame, val) |
local _, fontObject |
for _, fontObject in pairs(frame.fontObjects) do |
if type(fontObject.size) == 'string' then |
SetFontSize(fontObject, kn.fontSizes[fontObject.size]) |
end |
end |
end |
kn.configChangedFuncs.Health = function(frame) |
if frame:IsShown() then |
-- update health display |
end |
---------------------------------------------------------------------- create -- |
function mod:CreateCastbar(frame) |
function mod:CreateCastbar(msg, frame) |
-- container --------------------------------------------------------------- |
frame.castbar = CreateFrame('Frame', nil, frame.parent) |
frame.castbar:Hide() |
frame.castbar:SetScript('OnUpdate', OnCastbarUpdate) |
end |
------------------------------------------------------------------------ Hide -- |
function mod:HideCastbar(frame) |
function mod:HideCastbar(msg, frame) |
if frame.castbar then |
frame.castbar.duration = nil |
frame.castbar.id = nil |
frame.castbar:Hide() |
end |
function mod:IsCasting(frame) |
function mod:IsCasting(msg, frame) |
-- TODO update this for other units (party1target etc) |
if not frame.castbar or not frame.target then return end |
end |
function mod:OnEnable() |
addon:RegisterPostFunction('create', self, 'CreateCastbar') |
addon:RegisterPostFunction('hide', self, 'HideCastbar') |
addon:RegisterPostFunction('show', self, 'IsCasting') |
addon:RegisterPostFunction('target', self, 'IsCasting') |
self:RegisterMessage('create', 'CreateCastbar') |
self:RegisterMessage('hide', 'HideCastbar') |
self:RegisterMessage('show', 'IsCasting') |
self:RegisterMessage('target', 'IsCasting') |
for event,_ in pairs(castEvents) do |
self:RegisterEvent(event, self.UnitCastEvent) |
end |
---------------------------------------------------------------------- Create -- |
function mod:CreateCastWarnings(frame) |
function mod:CreateCastWarnings(msg, frame) |
-- casting spell name |
frame.castWarning = frame:CreateFontString(frame.overlay, { |
font = addon.font, size = 'spellname', outline = 'OUTLINE' }) |
frame.SetIncomingWarning = SetIncomingWarning |
end |
function mod:Hide(frame) |
function mod:Hide(msg, frame) |
if frame.castWarning then |
frame.castWarning.ag:Stop() |
frame.castWarning:SetText() |
function mod:OnEnable() |
-- TODO replace this with RegisterMessage etc from AceEvent |
addon:RegisterPostFunction('create', self, 'CreateCastWarnings') |
addon:RegisterPostFunction('hide', self, 'Hide') |
self:RegisterMessage('KuiNameplates_PostCreate', 'CreateCastWarnings') |
self:RegisterMessage('KuiNameplates_PostHide', 'Hide') |
self:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED') |
local _,frame |
for _, frame in pairs(addon.frameList) do |
if not frame.castWarning then |
self:CreateCastWarnings(frame) |
self:CreateCastWarnings(nil, frame) |
end |
end |
end |
local _,frame |
for _, frame in pairs(addon.frameList) do |
self:Hide(frame) |
self:Hide(nil, frame) |
end |
end |