/trunk/Kui_Nameplates
--[[ |
For Kui Nameplates |
Rename this file to custom.lua to attach custom code to the addon. |
]] |
---------------------------------------------------------------------- Create -- |
local function PostCreate(frame) |
-- Place code to be performed after a frame is created here. |
end |
------------------------------------------------------------------------ Show -- |
local function PostShow(frame) |
-- Place code to be performed after a frame is shown here. |
end |
------------------------------------------------------------------------ Hide -- |
local function PostHide(frame) |
-- Place code to be performed after a frame is hidden here. |
end |
-------------------------------------------------------------------- Register -- |
KuiNameplates.RegisterPostFunction('create', PostCreate) |
KuiNameplates.RegisterPostFunction('show', PostShow) |
KuiNameplates.RegisterPostFunction('hide', PostHide) |
local kui = LibStub('Kui-1.0') |
local profile, font, sizes, fontSizes |
local cb = CreateFrame('Frame') |
local castEvents = { |
['UNIT_SPELLCAST_START'] = true, |
['UNIT_SPELLCAST_FAILED'] = true, |
['UNIT_SPELLCAST_STOP'] = true, |
['UNIT_SPELLCAST_INTERRUPTED'] = true, |
['UNIT_SPELLCAST_DELAYED'] = true, |
['UNIT_SPELLCAST_CHANNEL_START'] = true, |
['UNIT_SPELLCAST_CHANNEL_UPDATE'] = true, |
['UNIT_SPELLCAST_CHANNEL_STOP'] = true |
} |
local GetNameplate = KuiNameplates.GetNameplate |
------------------------------------------------------------- Script handlers -- |
local function OnCastbarUpdate(bar, elapsed) |
if bar.channel then |
bar.progress = bar.progress - elapsed |
else |
bar.progress = bar.progress + elapsed |
end |
if not bar.duration or |
((not bar.channel and bar.progress >= bar.duration) or |
(bar.channel and bar.progress <= 0)) |
then |
-- hide the castbar bg |
bar:GetParent():Hide() |
bar.progress = 0 |
return |
end |
-- display progress |
if bar.max then |
bar.curr:SetText(string.format("%.1f", bar.progress)) |
if bar.delay == 0 or not bar.delay then |
bar.max:SetText(string.format("%.1f", bar.duration)) |
else |
-- display delay |
if bar.channel then |
-- time is removed |
bar.max:SetText(string.format("%.1f", bar.duration).. |
'|cffff0000-'..string.format("%.1f", bar.delay)..'|r') |
else |
-- time is added |
bar.max:SetText(string.format("%.1f", bar.duration).. |
'|cffff0000+'..string.format("%.1f", bar.delay)..'|r') |
end |
end |
end |
bar:SetValue(bar.progress/bar.duration) |
end |
---------------------------------------------------------------------- create -- |
cb.CreateCastbar = function(frame) |
-- cast bar background ------------------------------------------------- |
frame.castbarbg = CreateFrame("Frame", nil, frame.parent) |
frame.castbarbg:SetFrameStrata('BACKGROUND'); |
frame.castbarbg:SetBackdrop({ |
bgFile = kui.m.t.solid, edgeFile = kui.m.t.shadow, |
edgeSize = 5, insets = { |
top = 5, left = 5, bottom = 5, right = 5 |
} |
}) |
frame.castbarbg:SetBackdropColor(0, 0, 0, .85) |
frame.castbarbg:SetBackdropBorderColor(1, .2, .1, 0) |
frame.castbarbg:SetHeight(sizes.cbheight) |
frame.castbarbg:SetPoint('TOPLEFT', frame.bg.fill, 'BOTTOMLEFT', -5, 4) |
frame.castbarbg:SetPoint('TOPRIGHT', frame.bg.fill, 'BOTTOMRIGHT', 5, 0) |
frame.castbarbg:Hide() |
-- cast bar ------------------------------------------------------------ |
frame.castbar = CreateFrame("StatusBar", nil, frame.castbarbg) |
frame.castbar:SetStatusBarTexture(kui.m.t.bar) |
frame.castbar:SetPoint('TOPLEFT', frame.castbarbg, 'TOPLEFT', 6, -6) |
frame.castbar:SetPoint('BOTTOMLEFT', frame.castbarbg, 'BOTTOMLEFT', 6, 6) |
frame.castbar:SetPoint('RIGHT', frame.castbarbg, 'RIGHT', -6, 0) |
frame.castbar:SetMinMaxValues(0, 1) |
-- uninterruptible cast shield ----------------------------------------- |
frame.castbar.shield = frame.castbar:CreateTexture(nil, 'ARTWORK') |
frame.castbar.shield:SetTexture('Interface\\AddOns\\Kui_Nameplates\\Shield') |
frame.castbar.shield:SetTexCoord(0, .53125, 0, .6875) |
frame.castbar.shield:SetSize(12, 17) |
frame.castbar.shield:SetPoint('CENTER', frame.castbar, 0, 1) |
frame.castbar.shield:SetBlendMode('BLEND') |
frame.castbar.shield:SetDrawLayer('ARTWORK', 7) |
frame.castbar.shield:SetVertexColor(1, .1, .1) |
frame.castbar.shield:Hide() |
-- cast bar text ------------------------------------------------------- |
if profile.castbar.spellname then |
frame.castbar.name = kui.CreateFontString(frame.castbar, { |
font = font, size = fontSizes.name, outline = "OUTLINE" }) |
frame.castbar.name:SetPoint('TOPLEFT', frame.castbar, 'BOTTOMLEFT', 2, -2) |
end |
if profile.castbar.casttime then |
frame.castbar.max = kui.CreateFontString(frame.castbar, { |
font = font, size = fontSizes.name, outline = "OUTLINE" }) |
frame.castbar.max:SetPoint('TOPRIGHT', frame.castbar, 'BOTTOMRIGHT', -2, -1) |
frame.castbar.curr = kui.CreateFontString(frame.castbar, { |
font = font, size = fontSizes.small, outline = "OUTLINE" }) |
frame.castbar.curr:SetAlpha(.5) |
frame.castbar.curr:SetPoint('TOPRIGHT', frame.castbar.max, 'TOPLEFT', -1, -1) |
end |
if frame.spell then |
-- cast bar icon background ---------------------------------------- |
frame.spellbg = frame.castbarbg:CreateTexture(nil, 'BACKGROUND') |
frame.spellbg:SetTexture(kui.m.t.solid) |
frame.spellbg:SetSize(sizes.icon, sizes.icon) |
frame.spellbg:SetVertexColor(0, 0, 0, .85) |
frame.spellbg:SetPoint('TOPRIGHT', frame.health, 'TOPLEFT', -2, 1) |
-- cast bar icon --------------------------------------------------- |
frame.spell:ClearAllPoints() |
frame.spell:SetParent(frame.castbarbg) |
frame.spell:SetSize(sizes.icon - 2, sizes.icon - 2) |
frame.spell:SetPoint('TOPRIGHT', frame.spellbg, -1, -1) |
frame.spell:SetTexCoord(.1, .9, .1, .9) |
end |
-- scripts ------------------------------------------------------------- |
frame.castbar:HookScript('OnShow', function(bar) |
if bar.interruptible then |
bar:SetStatusBarColor(unpack(profile.castbar.barcolour)) |
bar:GetParent():SetBackdropBorderColor(0, 0, 0, .3) |
bar.shield:Hide() |
else |
bar:SetStatusBarColor(.8, .1, .1) |
bar:GetParent():SetBackdropBorderColor(1, .1, .2, .5) |
bar.shield:Show() |
end |
end) |
frame.castbar:SetScript('OnUpdate', OnCastbarUpdate) |
end |
------------------------------------------------------------------------ Hide -- |
cb.HideCastbar = function(frame) |
if frame.castbar then |
frame.castbar.duration = nil |
frame.castbar.id = nil |
frame.castbarbg:Hide() |
end |
end |
-------------------------------------------------------------- Event handlers -- |
function cb:UnitCastEvent(e, unit, ...) |
if unit == 'player' then return end |
local guid, name, f = UnitGUID(unit), GetUnitName(unit), nil |
--guid, name = UnitGUID('target'), GetUnitName('target') |
-- [debug] |
--print('CastEvent: ['..e..'] from ['..unit..'] (GUID: ['..(guid or 'nil')..']) (Name: ['..(name or 'nil')..'])') |
-- fetch the unit's nameplate |
f = GetNameplate(guid, name) |
if f then |
if not f.castbar or f.trivial then return end |
if e == 'UNIT_SPELLCAST_STOP' or |
e == 'UNIT_SPELLCAST_FAILED' or |
e == 'UNIT_SPELLCAST_INTERRUPTED' |
then |
-- these occasionally fire after a new _START |
local _, _, castID = ... |
if f.castbar.id ~= castID then |
return |
end |
end |
self[e](self, f, unit) |
end |
end |
function cb:UNIT_SPELLCAST_START(frame, unit, channel) |
local castbar = frame.castbar |
local name, _, text, texture, startTime, endTime, _, castID, |
notInterruptible |
if channel then |
name, _, text, texture, startTime, endTime, _, castID, notInterruptible |
= UnitChannelInfo(unit) |
else |
name, _, text, texture, startTime, endTime, _, castID, notInterruptible |
= UnitCastingInfo(unit) |
end |
if not name then |
frame.castbarbg:Hide() |
return |
end |
castbar.id = castID |
castbar.channel = channel |
castbar.interruptible = not notInterruptible |
castbar.duration = (endTime/1000) - (startTime/1000) |
castbar.delay = 0 |
if frame.spell then |
frame.spell:SetTexture(texture) |
end |
if castbar.name then |
castbar.name:SetText(name) |
end |
if castbar.channel then |
castbar.progress = (endTime/1000) - GetTime() |
else |
castbar.progress = GetTime() - (startTime/1000) |
end |
frame.castbarbg:Show() |
end |
function cb:UNIT_SPELLCAST_DELAYED(frame, unit, channel) |
local castbar = frame.castbar |
local _, name, startTime, endTime |
if channel then |
name, _, _, _, startTime, endTime = UnitChannelInfo(unit) |
else |
name, _, _, _, startTime, endTime = UnitCastingInfo(unit) |
end |
if not name then |
return |
end |
local newProgress |
if castbar.channel then |
newProgress = (endTime/1000) - GetTime() |
else |
newProgress = GetTime() - (startTime/1000) |
end |
castbar.delay = (castbar.delay or 0) + castbar.progress - newProgress |
castbar.progress = newProgress |
end |
function cb:UNIT_SPELLCAST_CHANNEL_START(frame, unit) |
self:UNIT_SPELLCAST_START(frame, unit, true) |
end |
function cb:UNIT_SPELLCAST_CHANNEL_UPDATE(frame, unit) |
self:UNIT_SPELLCAST_DELAYED(frame, unit, true) |
end |
function cb:UNIT_SPELLCAST_STOP(frame, unit) |
frame.castbarbg:Hide() |
end |
function cb:UNIT_SPELLCAST_FAILED(frame, unit) |
frame.castbarbg:Hide() |
end |
function cb:UNIT_SPELLCAST_INTERRUPTED(frame, unit) |
frame.castbarbg:Hide() |
end |
function cb:UNIT_SPELLCAST_CHANNEL_STOP(frame, unit) |
frame.castbarbg:Hide() |
end |
-------------------------------------------------------------------- Register -- |
local function OnEvent(self, event, ...) |
cb:UnitCastEvent(event, ...) |
end |
cb.Enable = function(self) |
profile = KuiNameplates.profile |
font, sizes, fontSizes |
= KuiNameplates.font, KuiNameplates.sizes, KuiNameplates.fontSizes |
KuiNameplates.RegisterPostFunction('create', self.CreateCastbar) |
KuiNameplates.RegisterPostFunction('hide', self.HideCastbar) |
self:SetScript('OnEvent', OnEvent) |
for event,_ in pairs(castEvents) do |
self:RegisterEvent(event) |
end |
end |
KuiNameplates.RegisterModule('castbar', cb) |
local kui = LibStub('Kui-1.0') |
local profile, font, sizes, fontSizes, GetNameplate |
local cw = CreateFrame('Frame') |
-- combat log events to listen to for cast warnings/healing |
local warningEvents = { |
['SPELL_CAST_START'] = true, |
['SPELL_CAST_SUCCESS'] = true, |
['SPELL_INTERRUPT'] = true, |
['SPELL_HEAL'] = true, |
['SPELL_PERIODIC_HEAL'] = true |
} |
local function SetCastWarning(self, spellName, spellSchool) |
self.castWarning.ag:Stop() |
if spellName == nil then |
-- hide the warning instantly (i.e. when interrupted) |
self.castWarning:SetAlpha(0) |
else |
local col = COMBATLOG_DEFAULT_COLORS.schoolColoring[spellSchool] or |
{r = 1, g = 1, b = 1} |
self.castWarning:SetText(spellName) |
self.castWarning:SetTextColor(col.r, col.g, col.b) |
self.castWarning:SetAlpha(1) |
self.castWarning.ag:Play() |
end |
end |
local function SetIncomingWarning(self, amount) |
if amount == 0 then return end |
self.incWarning.ag:Stop() |
if amount > 0 then |
-- healing |
amount = '+'..amount |
self.incWarning:SetTextColor(0, 1, 0) |
else |
-- damage (nyi) |
self.incWarning:SetTextColor(1, 0, 0) |
end |
self.incWarning:SetText(amount) |
self.incWarning:SetAlpha(1) |
self.incWarning.ag.fade:SetEndDelay(.5) |
self.incWarning.ag:Play() |
end |
-------------------------------------------------------------- Event handlers -- |
local function OnEvent(self, event, ...) |
local castTime, event, _, guid, name, _, _, targetGUID, targetName |
= ... |
if warningEvents[event] then |
if event == 'SPELL_HEAL' or |
event == 'SPELL_PERIODIC_HEAL' |
then |
-- fetch the spell's target's nameplate |
guid, name = targetGUID, targetName |
end |
--guid, name = UnitGUID('target'), GetUnitName('target') |
local f = GetNameplate(guid, name) |
if f then |
if not f.SetIncomingWarning or f.trivial then return end |
local spName, spSch = select(13, ...) |
if event == 'SPELL_HEAL' or |
event == 'SPELL_PERIODIC_HEAL' |
then |
-- display heal warning |
local amount = select(15, ...) |
f:SetIncomingWarning(amount) |
elseif event == 'SPELL_INTERRUPT' then |
-- hide the warning |
f:SetCastWarning(nil) |
else |
-- or display it for this spell |
f:SetCastWarning(spName, spSch) |
end |
end |
end |
end |
---------------------------------------------------------------------- Create -- |
cw.CreateCastWarnings = function(frame) |
-- casting spell name |
frame.castWarning = kui.CreateFontString(frame.overlay, { |
font = font, size = fontSizes.spellname, outline = 'OUTLINE' }) |
frame.castWarning:SetPoint('BOTTOMLEFT', frame.level, 'TOPLEFT', 0, 1) |
frame.castWarning:Hide() |
frame.castWarning.ag = frame.castWarning:CreateAnimationGroup() |
frame.castWarning.fade = frame.castWarning.ag:CreateAnimation('Alpha') |
frame.castWarning.fade:SetSmoothing('IN') |
frame.castWarning.fade:SetDuration(3) |
frame.castWarning.fade:SetChange(-1) |
frame.castWarning.ag:SetScript('OnPlay', function(self) |
self:GetParent():Show() |
end) |
frame.castWarning.ag:SetScript('OnFinished', function(self) |
self:GetParent():Hide() |
end) |
-- incoming healing |
frame.incWarning = kui.CreateFontString(frame.overlay, { |
font = font, size = fontSizes.small, outline = 'OUTLINE' }) |
frame.incWarning:SetPoint('BOTTOMRIGHT', frame.health.p, 'TOPRIGHT', 1) |
frame.incWarning:Hide() |
frame.incWarning.ag = frame.incWarning:CreateAnimationGroup() |
frame.incWarning.ag.fade = frame.incWarning.ag:CreateAnimation('Alpha') |
frame.incWarning.ag.fade:SetSmoothing('IN') |
frame.incWarning.ag.fade:SetDuration(.5) |
frame.incWarning.ag.fade:SetChange(-.5) |
frame.incWarning.ag:SetScript('OnPlay', function(self) |
self:GetParent():Show() |
end) |
frame.incWarning.ag:SetScript('OnFinished', function(self) |
if self.fade:GetEndDelay() > 0 then |
-- fade out fully |
self:GetParent():SetAlpha(.5) |
self.fade:SetEndDelay(0) |
self:Play() |
else |
self:GetParent():Hide() |
end |
end) |
-- handlers |
frame.SetCastWarning = SetCastWarning |
frame.SetIncomingWarning = SetIncomingWarning |
end |
------------------------------------------------------------------------ Hide -- |
cw.HideCastWarnings = function(frame) |
if frame.castWarning then |
frame.castWarning:SetText() |
frame.castWarning.ag:Stop() |
frame.incWarning:SetText() |
end |
end |
-------------------------------------------------------------------- Register -- |
cw.Enable = function(self) |
profile = KuiNameplates.profile |
GetNameplate = KuiNameplates.f.GetNameplate |
font, sizes, fontSizes |
= KuiNameplates.font, KuiNameplates.sizes, KuiNameplates.fontSizes |
KuiNameplates.RegisterPostFunction('create', self.CreateCastWarnings) |
KuiNameplates.RegisterPostFunction('hide', self.HideCastWarnings) |
self:SetScript('OnEvent', OnEvent) |
self:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED') |
end |
KuiNameplates.RegisterModule('warnings', cw) |
core.lua |
config.lua |
layout.lua |
name = 'Friendly health format', |
desc = 'The health display pattern for friendly units', |
type = 'input', |
pattern = '([<=]:[dmcp];)', |
pattern = '([<=]:[dmcpb];)', |
order = 5 |
}, |
hostile = { |
name = 'Hostile health format', |
desc = 'The health display pattern for hostile or neutral units', |
type = 'input', |
pattern = '([<=]:[dmcp];)', |
pattern = '([<=]:[dmcpb];)', |
order = 6 |
} |
} |
local kui = LibStub('Kui-1.0') |
local LSM = LibStub('LibSharedMedia-3.0') |
KuiNameplates = { |
font = '', fontSizes = {}, sizes = {} |
} |
-- our frame, whee |
ns.f = CreateFrame('Frame') |
KuiNameplates.f = CreateFrame('Frame') |
ns.f = KuiNameplates.f |
-- Custom reaction colours |
ns.r = { |
{ .5, .5, .5 }, -- tapped |
} |
-- combat log events to listen to for cast warnings/healing |
local warningEvents = { |
['SPELL_CAST_START'] = true, |
['SPELL_CAST_SUCCESS'] = true, |
['SPELL_INTERRUPT'] = true, |
['SPELL_HEAL'] = true, |
['SPELL_PERIODIC_HEAL'] = true |
} |
local font, uiscale, prevuiscale |
local uiscale, prevuiscale |
local bgOffset = 4 -- inset offset for the frame glow (frame.bg) |
local loadedGUIDs, loadedNames, targetExists, profile = {}, {} |
local origSizes, origFontSizes, sizes, fontSizes = {},{},{},{} |
local origSizes, origFontSizes = {},{} |
local font, sizes, fontSizes = '', {}, {} |
--------------------------------------------------------------------- globals -- |
local strsplit, pairs, ipairs, unpack |
= strsplit, pairs, ipairs, unpack |
local function SetFontSize(fontstring, size) |
-- helper function for setting a FontString's font size |
local font, _, flags = fontstring:GetFont() |
fontstring:SetFont(font, size, flags) |
end |
-------------------------------------------------- External calling functions -- |
local modules = {} |
local postFunctions = { |
create = {}, |
show = {}, |
hide = {} |
} |
local function CallPostFunction(typ, frame) |
if postFunctions[typ] then |
local _, func |
for _, func in ipairs(postFunctions[typ]) do |
func(frame) |
end |
end |
end |
KuiNameplates.RegisterPostFunction = function(typ, func) |
if postFunctions[typ] then |
table.insert(postFunctions[typ], func) |
end |
end |
KuiNameplates.RegisterModule = function(name, obj) |
if not modules[name] then |
print('registered: '..name) |
modules[name] = obj |
end |
end |
------------------------------------------------------------- Frame functions -- |
-- set colour of health bar according to reaction/threat |
local function SetHealthColour(self) |
r, g, b = unpack(ns.r[4]) |
else |
-- or don't change |
r, g, b = self.health:GetStatusBarColor() |
return |
end |
end |
-- enemy player, use default UI colour |
self.bg:SetVertexColor(r, g, b, a) |
end |
local function SetCastWarning(self, spellName, spellSchool) |
self.castWarning.ag:Stop() |
if spellName == nil then |
-- hide the warning instantly (i.e. when interrupted) |
self.castWarning:SetAlpha(0) |
else |
local col = COMBATLOG_DEFAULT_COLORS.schoolColoring[spellSchool] or |
{r = 1, g = 1, b = 1} |
self.castWarning:SetText(spellName) |
self.castWarning:SetTextColor(col.r, col.g, col.b) |
self.castWarning:SetAlpha(1) |
self.castWarning.ag:Play() |
end |
end |
local function SetIncomingWarning(self, amount) |
if amount == 0 then return end |
self.incWarning.ag:Stop() |
if amount > 0 then |
-- healing |
amount = '+'..amount |
self.incWarning:SetTextColor(0, 1, 0) |
else |
-- damage (nyi) |
self.incWarning:SetTextColor(1, 0, 0) |
end |
self.incWarning:SetText(amount) |
self.incWarning:SetAlpha(1) |
self.incWarning.ag.fade:SetEndDelay(.5) |
self.incWarning.ag:Play() |
end |
-- Show the frame's castbar if it is casting |
-- TODO update this for other units (party1target etc) |
local function IsFrameCasting(self) |
end |
end |
----------------------------------------------------- Castbar script handlers -- |
local function OnCastbarUpdate(bar, elapsed) |
if bar.channel then |
bar.progress = bar.progress - elapsed |
else |
bar.progress = bar.progress + elapsed |
end |
if not bar.duration or |
((not bar.channel and bar.progress >= bar.duration) or |
(bar.channel and bar.progress <= 0)) |
then |
-- hide the castbar bg |
bar:GetParent():Hide() |
bar.progress = 0 |
return |
end |
-- display progress |
if bar.max then |
bar.curr:SetText(string.format("%.1f", bar.progress)) |
if bar.delay == 0 or not bar.delay then |
bar.max:SetText(string.format("%.1f", bar.duration)) |
else |
-- display delay |
if bar.channel then |
-- time is removed |
bar.max:SetText(string.format("%.1f", bar.duration).. |
'|cffff0000-'..string.format("%.1f", bar.delay)..'|r') |
else |
-- time is added |
bar.max:SetText(string.format("%.1f", bar.duration).. |
'|cffff0000+'..string.format("%.1f", bar.delay)..'|r') |
end |
end |
end |
bar:SetValue(bar.progress/bar.duration) |
end |
---------------------------------------------------- Update health bar & text -- |
local function OnHealthValueChanged(oldBar, curr) |
local frame = oldBar:GetParent():GetParent() |
frame.health:SetMinMaxValues(min, max) |
frame.health:SetValue(curr) |
-- select correct health display pattern |
if frame.friend then |
pattern = profile.hp.friendly |
local w,h = self.parent:GetSize() |
local x,y = |
floor((w / 2) - ((sizes.width/2) / 2)), |
floor((h / 2) - ((sizes.height/2) / 2)) |
floor((w / 2) - (sizes.twidth / 2)), |
floor((h / 2) - (sizes.theight / 2)) |
self.health:ClearAllPoints() |
self.bg:ClearAllPoints() |
self.health.mo:Hide() |
end |
self.name = kui.CreateFontString(self.name, {reset = true, |
font = font, size = fontSizes.small, outline = 'OUTLINE' }) |
SetFontSize(self.name, fontSizes.small) |
self.name:SetJustifyH('CENTER') |
self.name:SetPoint('BOTTOMLEFT', self.health, 'TOPLEFT', -10, 0) |
self.name:SetPoint('BOTTOMRIGHT', self.health, 'TOPRIGHT', 10, 0) |
self.bg.fill:SetSize(sizes.width/2, sizes.height/2) |
self.health:SetSize((sizes.width/2)-2, (sizes.height/2)-2) |
self.bg.fill:SetSize(sizes.twidth, sizes.theight) |
self.health:SetSize(sizes.twidth-2, sizes.theight-2) |
self.health:SetPoint('BOTTOMLEFT', x+1, y+1) |
self.bg.fill:SetPoint('BOTTOMLEFT', x, y) |
self.bg:SetPoint('BOTTOMLEFT', x-(bgOffset-2), y-(bgOffset-2)) |
self.bg:SetPoint('TOPRIGHT', self.parent, 'BOTTOMLEFT', x+(sizes.width/2)+(bgOffset-2), y+(sizes.height/2)+(bgOffset-2)) |
self.bg:SetPoint('TOPRIGHT', self.parent, 'BOTTOMLEFT', x+sizes.twidth+(bgOffset-2), y+sizes.theight+(bgOffset-2)) |
self.trivial = true |
else |
-- (performed each time a trivial frame is shown) |
self.health.mo:Show() |
end |
self.name = kui.CreateFontString(self.name, {reset = true, |
font = font, size = fontSizes.name, outline = 'OUTLINE' }) |
SetFontSize(self.name, fontSizes.name) |
self.name:SetJustifyH('LEFT') |
self.name:SetPoint('LEFT', self.level, 'RIGHT', -2, 0) |
self:SetGlowColour() |
self:IsCasting() |
CallPostFunction('show', 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 |
if self.castbar then |
-- reset cast bar |
self.castbar.duration = nil |
self.castbar.id = nil |
self.castbarbg:Hide() |
end |
if self.castWarning then |
-- reset cast warning |
self.castWarning:SetText() |
self.castWarning.ag:Stop() |
self.incWarning:SetText() |
end |
CallPostFunction('hide', self) |
end |
local function OnFrameEnter(self) |
self.carrier:SetPoint('BOTTOMLEFT', UIParent, 'BOTTOMLEFT', floor(x-(self.carrier:GetWidth()/2)), floor(y)) |
-- show the frame after it's been moved so it doesn't flash |
-- .DoShow is set OnFrameShow |
if self.carrier.DoShow then |
self.carrier:Show() |
self.carrier.DoShow = nil |
self.defaultAlpha = self:GetAlpha() |
------------------------------------------------------------------- Alpha -- |
--[[ |
if self.currentAlpha and self.defaultAlpha ~= self.currentAlpha then |
-- ignore default UI's alpha changes |
self.parent:SetAlpha(self.currentAlpha) |
end |
]] |
if (self.defaultAlpha == 1 and |
targetExists) or |
(profile.fade.fademouse and |
-- Health bar colour |
self:SetHealthColour() |
-- force health update (as self.friend is managed by SetHealthColour) |
--OnHealthValueChanged(self.oldHealth, self.oldHealth:GetValue()) |
if self.cp then |
-- combo points |
self.cp:Update() |
end |
-- [debug] |
--[[ |
if self.guid and loadedGUIDs[self.guid] == self then |
self.guidtext:SetText(self.guid) |
else |
self.guidtext:SetText(nil) |
end |
if _G['KuiNameplatesDebug'] then |
if self.guid and loadedGUIDs[self.guid] == self then |
self.guidtext:SetText(self.guid) |
else |
self.guidtext:SetText(nil) |
end |
if self.name.text and loadedNames[self.name.text] == self then |
self.nametext:SetText('Has name') |
else |
self.nametext:SetText(nil) |
if self.name.text and loadedNames[self.name.text] == self then |
self.nametext:SetText('Has name') |
else |
self.nametext:SetText(nil) |
end |
if self.friend then |
self.isfriend:SetText('friendly') |
else |
self.isfriend:SetText('not friendly') |
end |
end |
if self.friend then |
self.isfriend:SetText('friendly') |
else |
self.isfriend:SetText('not friendly') |
end |
]] |
-- [end debug] |
end |
-- Update sizes of child frames, fonts and the position of .bg in this nameplate |
-- To be used when UIScale is changed (i.e. hardly ever) |
-- TODO I don't think I actually use this at the moment |
--[[ |
local function UpdateScales(self) |
self.carrier:SetScale(uiscale) |
self.carrier:SetSize(self:GetWidth()/uiscale, self:GetHeight()/uiscale) |
SetFontSize(self.cp, fontSizes.combopoints) |
end |
if self.castbarbg then |
self.castbarbg:SetHeight(sizes.cbheight) |
if self.castbar.name then |
SetFontSize(self.castbar.name, fontSizes.name) |
end |
if self.castbar.max then |
SetFontSize(self.castbar.max, fontSizes.name) |
SetFontSize(self.castbar.curr, fontSizes.small) |
end |
if self.spellbg then |
self.spellbg:SetSize(sizes.icon, sizes.icon) |
self.spell:SetSize(sizes.icon-2, sizes.icon-2) |
end |
end |
if self.castWarning then |
SetFontSize(self.castWarning, fontSizes.spellname) |
SetFontSize(self.incWarning, fontSizes.small) |
end |
self.bg:ClearAllPoints() |
self.bg:SetPoint('BOTTOMLEFT', 22-5, 16-5) |
self.bg:SetPoint('TOPRIGHT', self.carrier, 'BOTTOMLEFT', 22+sizes.width+5, 16+sizes.height+5) |
end |
]] |
--------------------------------------------------------------- KNP functions -- |
function ns.f:GetNameplate(guid, name) |
frame.oldHighlight = highlightRegion |
---------------------------------------------------------- Frame functions-- |
--------------------------------------------------------- Frame functions -- |
frame.UpdateFrame = UpdateFrame |
frame.UpdateFrameCritical = UpdateFrameCritical |
frame.SetHealthColour = SetHealthColour |
frame.carrier:SetScale(uiscale) |
-- [debug] |
--[[ |
frame.carrier:SetBackdrop({ bgFile = kui.m.t.solid }) |
frame.carrier:SetBackdropColor(0,0,0,.5) |
]] |
if _G['KuiNameplatesDebug'] then |
frame.carrier:SetBackdrop({ bgFile = kui.m.t.solid }) |
frame.carrier:SetBackdropColor(0,0,0,.5) |
end |
parent = frame.carrier |
else |
frame.health:SetSize(sizes.width-2, sizes.height-2) |
frame.health:SetPoint('BOTTOMLEFT', x+1, y+1) |
if profile.hp.smooth then |
if ns.SetValueSmooth then |
-- smooth bar |
frame.health.OrigSetValue = frame.health.SetValue |
frame.health.SetValue = ns.SetValueSmooth |
frame.cp.Update = ComboPointsUpdate |
end |
if profile.castbar.enabled then |
-- TODO move this (and similar things) into functions |
-- cast bar background ------------------------------------------------- |
frame.castbarbg = CreateFrame("Frame", nil, parent) |
frame.castbarbg:SetFrameStrata('BACKGROUND'); |
frame.castbarbg:SetBackdrop({ |
bgFile = kui.m.t.solid, edgeFile = kui.m.t.shadow, |
edgeSize = 5, insets = { |
top = 5, left = 5, bottom = 5, right = 5 |
} |
}) |
frame.castbarbg:SetBackdropColor(0, 0, 0, .85) |
frame.castbarbg:SetBackdropBorderColor(1, .2, .1, 0) |
frame.castbarbg:SetHeight(sizes.cbheight) |
frame.castbarbg:SetPoint('TOPLEFT', frame.bg.fill, 'BOTTOMLEFT', -5, 4) |
frame.castbarbg:SetPoint('TOPRIGHT', frame.bg.fill, 'BOTTOMRIGHT', 5, 0) |
frame.castbarbg:Hide() |
-- cast bar ------------------------------------------------------------ |
frame.castbar = CreateFrame("StatusBar", nil, frame.castbarbg) |
frame.castbar:SetStatusBarTexture(kui.m.t.bar) |
frame.castbar:SetPoint('TOPLEFT', frame.castbarbg, 'TOPLEFT', 6, -6) |
frame.castbar:SetPoint('BOTTOMLEFT', frame.castbarbg, 'BOTTOMLEFT', 6, 6) |
frame.castbar:SetPoint('RIGHT', frame.castbarbg, 'RIGHT', -6, 0) |
frame.castbar:SetMinMaxValues(0, 1) |
-- uninterruptible cast shield ----------------------------------------- |
frame.castbar.shield = frame.castbar:CreateTexture(nil, 'ARTWORK') |
frame.castbar.shield:SetTexture('Interface\\AddOns\\Kui_Nameplates\\Shield') |
frame.castbar.shield:SetTexCoord(0, .53125, 0, .6875) |
frame.castbar.shield:SetSize(12, 17) |
frame.castbar.shield:SetPoint('CENTER', frame.castbar, 0, 1) |
frame.castbar.shield:SetBlendMode('BLEND') |
frame.castbar.shield:SetDrawLayer('ARTWORK', 7) |
frame.castbar.shield:SetVertexColor(1, .1, .1) |
frame.castbar.shield:Hide() |
-- cast bar text ------------------------------------------------------- |
if profile.castbar.spellname then |
frame.castbar.name = kui.CreateFontString(frame.castbar, { |
font = font, size = fontSizes.name, outline = "OUTLINE" }) |
frame.castbar.name:SetPoint('TOPLEFT', frame.castbar, 'BOTTOMLEFT', 2, -2) |
end |
if profile.castbar.casttime then |
frame.castbar.max = kui.CreateFontString(frame.castbar, { |
font = font, size = fontSizes.name, outline = "OUTLINE" }) |
frame.castbar.max:SetPoint('TOPRIGHT', frame.castbar, 'BOTTOMRIGHT', -2, -1) |
frame.castbar.curr = kui.CreateFontString(frame.castbar, { |
font = font, size = fontSizes.small, outline = "OUTLINE" }) |
frame.castbar.curr:SetAlpha(.5) |
frame.castbar.curr:SetPoint('TOPRIGHT', frame.castbar.max, 'TOPLEFT', -1, -1) |
end |
if frame.spell then |
-- cast bar icon background ---------------------------------------- |
frame.spellbg = frame.castbarbg:CreateTexture(nil, 'BACKGROUND') |
frame.spellbg:SetTexture(kui.m.t.solid) |
frame.spellbg:SetSize(sizes.icon, sizes.icon) |
frame.spellbg:SetVertexColor(0, 0, 0, .85) |
frame.spellbg:SetPoint('TOPRIGHT', frame.health, 'TOPLEFT', -2, 1) |
-- cast bar icon --------------------------------------------------- |
frame.spell:ClearAllPoints() |
frame.spell:SetParent(frame.castbarbg) |
frame.spell:SetSize(sizes.icon - 2, sizes.icon - 2) |
frame.spell:SetPoint('TOPRIGHT', frame.spellbg, -1, -1) |
frame.spell:SetTexCoord(.1, .9, .1, .9) |
end |
-- scripts ------------------------------------------------------------- |
frame.castbar:HookScript('OnShow', function(bar) |
if bar.interruptible then |
bar:SetStatusBarColor(unpack(profile.castbar.barcolour)) |
bar:GetParent():SetBackdropBorderColor(0, 0, 0, .3) |
bar.shield:Hide() |
else |
bar:SetStatusBarColor(.8, .1, .1) |
bar:GetParent():SetBackdropBorderColor(1, .1, .2, .5) |
bar.shield:Show() |
end |
end) |
frame.castbar:SetScript('OnUpdate', OnCastbarUpdate) |
end |
-- cast warning ------------------------------------------------------------ |
if profile.castbar.warnings then |
-- casting spell name |
frame.castWarning = kui.CreateFontString(frame.overlay, { |
font = font, size = fontSizes.spellname, outline = 'OUTLINE' }) |
frame.castWarning:SetPoint('BOTTOMLEFT', frame.level, 'TOPLEFT', 0, 1) |
frame.castWarning:Hide() |
frame.castWarning.ag = frame.castWarning:CreateAnimationGroup() |
frame.castWarning.fade = frame.castWarning.ag:CreateAnimation('Alpha') |
frame.castWarning.fade:SetSmoothing('IN') |
frame.castWarning.fade:SetDuration(3) |
frame.castWarning.fade:SetChange(-1) |
frame.castWarning.ag:SetScript('OnPlay', function(self) |
self:GetParent():Show() |
end) |
frame.castWarning.ag:SetScript('OnFinished', function(self) |
self:GetParent():Hide() |
end) |
-- incoming healing |
frame.incWarning = kui.CreateFontString(frame.overlay, { |
font = font, size = fontSizes.small, outline = 'OUTLINE' }) |
frame.incWarning:SetPoint('BOTTOMRIGHT', frame.health.p, 'TOPRIGHT', 1) |
frame.incWarning:Hide() |
frame.incWarning.ag = frame.incWarning:CreateAnimationGroup() |
frame.incWarning.ag.fade = frame.incWarning.ag:CreateAnimation('Alpha') |
frame.incWarning.ag.fade:SetSmoothing('IN') |
frame.incWarning.ag.fade:SetDuration(.5) |
frame.incWarning.ag.fade:SetChange(-.5) |
frame.incWarning.ag:SetScript('OnPlay', function(self) |
self:GetParent():Show() |
end) |
frame.incWarning.ag:SetScript('OnFinished', function(self) |
if self.fade:GetEndDelay() > 0 then |
-- fade out fully |
self:GetParent():SetAlpha(.5) |
self.fade:SetEndDelay(0) |
self:Play() |
else |
self:GetParent():Hide() |
end |
end) |
-- handlers |
frame.SetCastWarning = SetCastWarning |
frame.SetIncomingWarning = SetIncomingWarning |
end |
----------------------------------------------------------------- Scripts -- |
frame:SetScript('OnShow', OnFrameShow) |
frame:SetScript('OnHide', OnFrameHide) |
frame.oldHealth:SetScript('OnValueChanged', OnHealthValueChanged) |
-- [debug] |
--[[ |
frame:SetBackdrop({bgFile=kui.m.t.solid}) |
frame:SetBackdropColor(1, 1, 1, .5) |
if _G['KuiNameplatesDebug'] then |
frame:SetBackdrop({bgFile=kui.m.t.solid}) |
frame:SetBackdropColor(1, 1, 1, .5) |
frame.isfriend = kui.CreateFontString(frame, { |
font = font, size = 10, outline = 'OUTLINE' }) |
frame.isfriend:SetPoint('BOTTOM', frame, 'TOP') |
frame.guidtext = kui.CreateFontString(frame, { |
font = font, size = 10, outline = "OUTLINE" }) |
frame.guidtext:SetPoint('TOP', frame, 'BOTTOM') |
frame.isfriend = kui.CreateFontString(frame, { |
font = font, size = 10, outline = 'OUTLINE' }) |
frame.isfriend:SetPoint('BOTTOM', frame, 'TOP') |
frame.guidtext = kui.CreateFontString(frame, { |
font = font, size = 10, outline = "OUTLINE" }) |
frame.guidtext:SetPoint('TOP', frame, 'BOTTOM') |
frame.nametext = kui.CreateFontString(frame, { |
font = font, size = 10, outline = "OUTLINE" }) |
frame.nametext:SetPoint('TOP', frame.guidtext, 'BOTTOM') |
]] |
frame.nametext = kui.CreateFontString(frame, { |
font = font, size = 10, outline = "OUTLINE" }) |
frame.nametext:SetPoint('TOP', frame.guidtext, 'BOTTOM') |
end |
------------------------------------------------------------ Finishing up -- |
frame.UpdateScales = UpdateScales |
--frame.UpdateScales = UpdateScales |
frame.elapsed = 0 |
frame.critElap = 0 |
CallPostFunction('create', frame) |
-- force OnShow |
OnFrameShow(frame) |
end |
SetCVar('nameplateShowEnemies', 1) |
end |
-- custom cast bar events ------------------------------------------------------ |
function ns.f:UNIT_SPELLCAST_START(frame, unit, channel) |
local cb = frame.castbar |
local name, _, text, texture, startTime, endTime, _, castID, |
notInterruptible |
if channel then |
name, _, text, texture, startTime, endTime, _, castID, notInterruptible |
= UnitChannelInfo(unit) |
else |
name, _, text, texture, startTime, endTime, _, castID, notInterruptible |
= UnitCastingInfo(unit) |
end |
if not name then |
frame.castbarbg:Hide() |
return |
end |
cb.id = castID |
cb.channel = channel |
cb.interruptible = not notInterruptible |
cb.duration = (endTime/1000) - (startTime/1000) |
cb.delay = 0 |
if frame.spell then |
frame.spell:SetTexture(texture) |
end |
if cb.name then |
cb.name:SetText(name) |
end |
if cb.channel then |
cb.progress = (endTime/1000) - GetTime() |
else |
cb.progress = GetTime() - (startTime/1000) |
end |
frame.castbarbg:Show() |
end |
function ns.f:UNIT_SPELLCAST_DELAYED(frame, unit, channel) |
local cb = frame.castbar |
local _, name, startTime, endTime |
if channel then |
name, _, _, _, startTime, endTime = UnitChannelInfo(unit) |
else |
name, _, _, _, startTime, endTime = UnitCastingInfo(unit) |
end |
if not name then |
return |
end |
local newProgress |
if cb.channel then |
newProgress = (endTime/1000) - GetTime() |
else |
newProgress = GetTime() - (startTime/1000) |
end |
cb.delay = (cb.delay or 0) + cb.progress - newProgress |
cb.progress = newProgress |
end |
function ns.f:UNIT_SPELLCAST_CHANNEL_START(frame, unit) |
self:UNIT_SPELLCAST_START(frame, unit, true) |
end |
function ns.f:UNIT_SPELLCAST_CHANNEL_UPDATE(frame, unit) |
self:UNIT_SPELLCAST_DELAYED(frame, unit, true) |
end |
function ns.f:UNIT_SPELLCAST_STOP(frame, unit) |
frame.castbarbg:Hide() |
end |
function ns.f:UNIT_SPELLCAST_FAILED(frame, unit) |
frame.castbarbg:Hide() |
end |
function ns.f:UNIT_SPELLCAST_INTERRUPTED(frame, unit) |
frame.castbarbg:Hide() |
end |
function ns.f:UNIT_SPELLCAST_CHANNEL_STOP(frame, unit) |
frame.castbarbg:Hide() |
end |
-- custom cast bar event handler ----------------------------------------------- |
function ns.f:UnitCastEvent(e, unit, ...) |
if unit == 'player' then return end |
local guid, name, f = UnitGUID(unit), GetUnitName(unit), nil |
--guid, name = UnitGUID('target'), GetUnitName('target') |
-- DEBUG |
--print('CastEvent: ['..e..'] from ['..unit..'] (GUID: ['..(guid or 'nil')..']) (Name: ['..(name or 'nil')..'])') |
-- fetch the unit's nameplate |
f = self:GetNameplate(guid, name) |
if f then |
if not f.castbar or f.trivial then return end |
if e == 'UNIT_SPELLCAST_STOP' or |
e == 'UNIT_SPELLCAST_FAILED' or |
e == 'UNIT_SPELLCAST_INTERRUPTED' |
then |
-- these occasionally fire after a new _START |
local _, _, castID = ... |
if f.castbar.id ~= castID then |
return |
end |
end |
self[e](self, f, unit) |
end |
end |
-- cast warning handler -------------------------------------------------------- |
function ns.f:CastWarningEvent(...) |
-- _ = COMBAT_LOG_EVENT_UNFILTERED |
local castTime, event, _, guid, name, _, _, targetGUID, targetName |
= ... |
if warningEvents[event] then |
if event == 'SPELL_HEAL' or |
event == 'SPELL_PERIODIC_HEAL' |
then |
-- fetch the spell's target's nameplate |
guid, name = targetGUID, targetName |
end |
--guid, name = UnitGUID('target'), GetUnitName('target') |
local f = self:GetNameplate(guid, name) |
if f then |
if not f.SetIncomingWarning or f.trivial then return end |
local spName, spSch = select(13, ...) |
if event == 'SPELL_HEAL' or |
event == 'SPELL_PERIODIC_HEAL' |
then |
-- display heal warning |
local amount = select(15, ...) |
f:SetIncomingWarning(amount) |
elseif event == 'SPELL_INTERRUPT' then |
-- hide the warning |
f:SetCastWarning(nil) |
else |
-- or display it for this spell |
f:SetCastWarning(spName, spSch) |
end |
end |
end |
end |
------------------------------------------ Health bar smooth update functions -- |
-- (spoon-fed by oUF_Smooth) |
do |
local f, smoothing, GetFramerate, min, max, abs |
= CreateFrame('Frame'), {}, GetFramerate, math.min, math.max, math.abs |
function ns.SetValueSmooth(self, value) |
local _, maxv = self:GetMinMaxValues() |
if value == self:GetValue() or (self.prevMax and self.prevMax ~= maxv) then |
-- finished smoothing/max health updated |
smoothing[self] = nil |
self:OrigSetValue(value) |
else |
smoothing[self] = value |
end |
self.prevMax = maxv |
end |
f:SetScript('OnUpdate', function() |
local limit = 30/GetFramerate() |
for bar, value in pairs(smoothing) do |
local cur = bar:GetValue() |
local new = cur + min((value-cur)/3, max(value-cur, limit)) |
if new ~= new then |
new = value |
end |
bar:OrigSetValue(new) |
if cur == value or abs(new - value) < 2 then |
bar:OrigSetValue(value) |
smoothing[bar] = nil |
end |
end |
end) |
end |
------------------------------------------------------------- Script handlers -- |
ns.frames = 0 |
ns.frameList = {} |
for i = 1, frames do |
f = select(i, WorldFrame:GetChildren()) |
if self:IsNameplate(f) and not f.init then |
self:InitFrame(f) |
if profile.general.fixaa then |
end |
end |
do -- events for custom cast bar |
local castEvents = { |
['UNIT_SPELLCAST_START'] = true, |
['UNIT_SPELLCAST_FAILED'] = true, |
['UNIT_SPELLCAST_STOP'] = true, |
['UNIT_SPELLCAST_INTERRUPTED'] = true, |
['UNIT_SPELLCAST_DELAYED'] = true, |
['UNIT_SPELLCAST_CHANNEL_START'] = true, |
['UNIT_SPELLCAST_CHANNEL_UPDATE'] = true, |
['UNIT_SPELLCAST_CHANNEL_STOP'] = true |
} |
function ns.OnEvent(self, event, ...) |
if event == 'COMBAT_LOG_EVENT_UNFILTERED' then |
-- send to cast warnings handler |
self:CastWarningEvent(...) |
elseif castEvents[event] then |
-- send to cast event handler |
self:UnitCastEvent(event, ...) |
else |
self[event](self, ...) |
end |
end |
------------------------------------------------------- Event ... registerers -- |
-- here as it needs access to castEvents |
function ns.ToggleCastbar(io) |
if io then |
for event,_ in pairs(castEvents) do |
ns.f:RegisterEvent(event) |
end |
else |
for event,_ in pairs(castEvents) do |
ns.f:UnregisterEvent(event) |
end |
end |
end |
function ns.OnEvent(self, event, ...) |
self[event](self, ...) |
end |
function ns.ToggleWarnings(io) |
if io then |
ns.f:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED') |
else |
ns.f:UnregisterEvent('COMBAT_LOG_EVENT_UNFILTERED') |
end |
end |
function ns.ToggleCombatEvents(io) |
if io then |
ns.f:RegisterEvent('PLAYER_REGEN_ENABLED') |
-------------------------------------------------------------------- Finalise -- |
function ns:OnEnable() |
profile = self.db.profile |
KuiNameplates.profile = profile |
sizes, fontSizes = { |
KuiNameplates.sizes, KuiNameplates.fontSizes = { |
-- frame |
width = 110, |
height = 11, |
twidth = 55, |
theight= 7, |
-- cast bar stuff |
cbheight = 14, |
icon = 16, |
name = 9, |
small = 8, |
} |
sizes, fontSizes = KuiNameplates.sizes, KuiNameplates.fontSizes |
for k,size in pairs(fontSizes) do |
fontSizes[k] = size * profile.general.fontscale |
end |
if profile.general.fixaa then |
uiscale, origSizes, origFontSizes = |
sizes[k] = floor(size/uiscale) |
end |
-- fonts don't need to be pixel perfect, they just need to be scaled |
for k,size in pairs(origFontSizes) do |
fontSizes[k] = size/uiscale |
end |
end |
-- fetch font path from lsm |
KuiNameplates.font = LSM:Fetch(LSM.MediaType.FONT, profile.general.font) |
font = KuiNameplates.font |
-------------------------------------- Health bar smooth update functions -- |
-- (spoon-fed by oUF_Smooth) |
if profile.hp.smooth then |
local f, smoothing, GetFramerate, min, max, abs |
= CreateFrame('Frame'), {}, GetFramerate, math.min, math.max, math.abs |
for k,size in pairs(fontSizes) do |
fontSizes[k] = size * profile.general.fontscale |
function ns.SetValueSmooth(self, value) |
local _, maxv = self:GetMinMaxValues() |
if value == self:GetValue() or (self.prevMax and self.prevMax ~= maxv) then |
-- finished smoothing/max health updated |
smoothing[self] = nil |
self:OrigSetValue(value) |
else |
smoothing[self] = value |
end |
self.prevMax = maxv |
end |
f:SetScript('OnUpdate', function() |
local limit = 30/GetFramerate() |
for bar, value in pairs(smoothing) do |
local cur = bar:GetValue() |
local new = cur + min((value-cur)/3, max(value-cur, limit)) |
if new ~= new then |
new = value |
end |
bar:OrigSetValue(new) |
if cur == value or abs(new - value) < 2 then |
bar:OrigSetValue(value) |
smoothing[bar] = nil |
end |
end |
end) |
end |
-- fetch font path from lsm |
font = LSM:Fetch(LSM.MediaType.FONT, profile.general.font) |
-- enable packed modules |
if profile.castbar.enabled and modules.castbar then |
modules.castbar:Enable() |
end |
if profile.castbar.warnings and modules.warnings then |
modules.warnings:Enable() |
end |
ns.f:SetScript('OnUpdate', self.OnUpdate) |
ns.f:SetScript('OnEvent', self.OnEvent) |
ns.f:RegisterEvent('PLAYER_TARGET_CHANGED') |
self.ToggleCastbar(profile.castbar.enabled) |
self.ToggleWarnings(profile.castbar.warnings) |
self.ToggleCombatEvents(profile.general.combat) |
self.ToggleComboPoints(profile.general.combopoints) |
end |