/trunk
## Author: Kesava |
## Title: |cff9900ffKui|r Nameplates |
## Notes: Prettier, lightweight, configurable nameplates. |
## SavedVariablesPerCharacter: KuiNameplatesDB |
## SavedVariables: KuiNameplatesDB |
lib\embeds.xml |
-------------------------------------------------- External calling functions -- |
local modules = {} |
local postFunctions = { |
create = {}, |
show = {}, |
hide = {} |
target = {}, -- upon becoming the target |
create = {}, -- post creation |
show = {}, -- post OnFrameShow |
hide = {} -- post OnFrameHide |
} |
local function CallPostFunction(typ, frame) |
KuiNameplates.RegisterModule = function(name, obj) |
if not modules[name] then |
print('registered: '..name) |
modules[name] = obj |
end |
end |
self.bg:SetVertexColor(r, g, b, a) |
end |
-- Show the frame's castbar if it is casting |
-- TODO update this for other units (party1target etc) |
local function IsFrameCasting(self) |
if not self.castbar or not self.target then return end |
local name = UnitCastingInfo('target') |
local channel = false |
if not name then |
name = UnitChannelInfo('target') |
channel = true |
end |
if name then |
-- if they're casting or channeling, try to show a castbar |
ns.f:UNIT_SPELLCAST_START(self, 'target', channel) |
end |
end |
local function StoreFrameGUID(self, guid) |
if not guid then return end |
if self.guid and loadedGUIDs[self.guid] then |
-- force health update |
OnHealthValueChanged(self.oldHealth, self.oldHealth:GetValue()) |
self:SetGlowColour() |
self:IsCasting() |
CallPostFunction('show', self) |
end |
self.health.p:Show() |
if self.health.mo then self.health.mo:Show() end |
end |
-- check if the frame is casting |
self:IsCasting() |
CallPostFunction('target', self) |
end |
elseif self.target then |
self.target = nil |
frame.SetHealthColour = SetHealthColour |
frame.SetNameColour = SetNameColour |
frame.SetGlowColour = SetGlowColour |
frame.IsCasting = IsFrameCasting |
frame.StoreGUID = StoreFrameGUID |
------------------------------------------------------------------ Layout -- |
--[[ |
For Kui Nameplates |
Rename this file to custom.lua to attach custom code to the addon. |
Rename this file to custom.lua to attach custom code to the addon. Once |
renamed, you'll need to completely restart WoW so that it detects the file. |
]] |
local kn = KuiNameplates |
---------------------------------------------------------------------- Create -- |
local function PostCreate(frame) |
end |
-------------------------------------------------------------------- Register -- |
KuiNameplates.RegisterPostFunction('create', PostCreate) |
KuiNameplates.RegisterPostFunction('show', PostShow) |
KuiNameplates.RegisterPostFunction('hide', PostHide) |
frame.castbarbg:Hide() |
end |
function cb.IsCasting(frame) |
-- TODO update this for other units (party1target etc) |
if not frame.castbar or not frame.target then return end |
local name = UnitCastingInfo('target') |
local channel = false |
if not name then |
name = UnitChannelInfo('target') |
channel = true |
end |
if name then |
-- if they're casting or channeling, try to show a castbar |
cb:UNIT_SPELLCAST_START(frame, 'target', channel) |
end |
end |
-------------------------------------------------------------------- Register -- |
local function OnEvent(self, event, ...) |
cb:UnitCastEvent(event, ...) |
cb.Enable = function(self) |
kn.RegisterPostFunction('create', self.CreateCastbar) |
kn.RegisterPostFunction('hide', self.HideCastbar) |
kn.RegisterPostFunction('show', self.IsCasting) |
kn.RegisterPostFunction('target', self.IsCasting) |
self:SetScript('OnEvent', OnEvent) |
for event,_ in pairs(castEvents) do |