/
local kui = LibStub('Kui-1.0') |
local kn = KuiNameplates |
local cp = CreateFrame('Frame') |
local addon = LibStub('AceAddon-3.0'):GetAddon('KuiNameplates') |
local mod = addon:NewModule('ComboPoints', 'AceEvent-3.0') |
local ComboPointsUpdate = function(self) |
mod.uiName = 'Combo points' |
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) |
kn.SetFontSize(self, size) |
addon.SetFontSize(self, size) |
self:SetText(self.points) |
self:SetTextColor(1, 1, blue) |
end |
end |
-------------------------------------------------------------- Event handlers -- |
function cp:UNIT_COMBO_POINTS(event, unit) |
local guid, name = UnitGUID('target'), UnitName('target') |
local f = kn.f:GetNameplate(guid, name) |
function mod:UNIT_COMBO_POINTS(event, unit) |
if not unit then return end |
local guid, name = UnitGUID(unit), UnitName(unit) |
local f = addon:GetNameplate(guid, name) |
if f then |
if f.cp then |
f.cp.points = GetComboPoints(unit, 'target') |
f.cp.points = GetComboPoints(unit, unit) |
f.cp:Update() |
end |
end |
-- clear points on other frames |
local _, frame |
for _, frame in pairs(kn.frameList) do |
for _, frame in pairs(addon.frameList) do |
if frame.cp and frame ~= f then |
frame.cp.points = nil |
frame.cp:Update() |
self:HideComboPoints(frame) |
end |
end |
end |
---------------------------------------------------------------------- Create -- |
cp.CreateComboPoints = function(frame) |
function mod:CreateComboPoints(frame) |
frame.cp = frame:CreateFontString(frame.health, { |
font = kn.font, size = 'combopoints', outline = 'OUTLINE', shadow = true }) |
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() |
end |
------------------------------------------------------------------------ Hide -- |
cp.HideComboPoints = function(frame) |
frame.cp.points = nil |
frame.cp:Update() |
function mod:HideComboPoints(frame) |
if frame.cp then |
frame.cp.points = nil |
frame.cp:Update() |
end |
end |
-------------------------------------------------------------------- Register -- |
kn.updateFunctions.combopoints = function(frame, val, runonce) |
if not val then |
-- disable |
if runonce == 0 then |
cp:Disable() |
end |
function mod:GetOptions() |
return { |
enabled = { |
name = 'Show combo points', |
desc = 'Show combo points on the target', |
type = 'toggle' |
}, |
} |
end |
if frame.cp then |
-- hide combo points which are already displayed |
frame.cp.points = nil |
frame.cp:Update() |
end |
else |
-- enable |
if runonce == 0 then |
cp:Enable() |
end |
function mod:OnInitialize() |
self.db = addon.db:RegisterNamespace(self.moduleName, { |
profile = { |
enabled = true, |
} |
}) |
end |
function mod:OnEnable() |
addon:RegisterPostFunction('create', self, 'CreateComboPoints') |
addon:RegisterPostFunction('hide', self, 'HideComboPoints') |
self:RegisterEvent('UNIT_COMBO_POINTS') |
local _, frame |
for _, frame in pairs(addon.frameList) do |
if not frame.cp then |
-- create combo points frame on existing frames |
cp.CreateComboPoints(frame) |
self:CreateComboPoints(frame) |
end |
end |
end |
cp.Enable = function(self) |
kn.RegisterPostFunction('create', self.CreateComboPoints) |
kn.RegisterPostFunction('hide', self.HideComboPoints) |
self:SetScript('OnEvent', cp.UNIT_COMBO_POINTS) |
self:RegisterEvent('UNIT_COMBO_POINTS') |
end |
cp.Disable = function(self) |
function mod:OnDisable() |
self:UnregisterEvent('UNIT_COMBO_POINTS') |
end |
kn.RegisterModule('combopoints', cp) |
local _, frame |
for _, frame in pairs(addon.frameList) do |
self:HideComboPoints(frame) |
end |
end |
local addon, ns = ... |
local kui = LibStub('Kui-1.0') |
local LSM = LibStub('LibSharedMedia-3.0') |
local kn = KuiNameplates |
local kn = LibStub('AceAddon-3.0'):GetAddon('KuiNameplates') |
-- our frame, whee |
-- frame to run OnUpdate |
kn.f = CreateFrame('Frame') |
ns.f = kn.f |
kn.font = '' |
kn.fontSizes = {} |
kn.frameList = {} |
-- Custom reaction colours |
ns.r = { |
kn.r = { |
{ .7, .2, .1 }, -- hated |
{ 1, .8, 0 }, -- neutral |
{ .2, .6, .1 }, -- friendly |
end |
-------------------------------------------------- External calling functions -- |
local modules = {} |
local postFunctions = { |
target = {}, -- upon becoming the target |
create = {}, -- post creation |
local function CallPostFunction(typ, frame) |
if postFunctions[typ] then |
local _, func |
for _, func in ipairs(postFunctions[typ]) do |
func(frame) |
local _, mod |
for _, mod in ipairs(postFunctions[typ]) do |
mod[1][mod[2]](mod[1], frame) |
end |
end |
end |
KuiNameplates.RegisterPostFunction = function(typ, func) |
if postFunctions[typ] then |
table.insert(postFunctions[typ], func) |
end |
function kn:RegisterPostFunction(typ, mod, func) |
if not postFunctions[typ] then return end |
tinsert(postFunctions[typ], { mod, func }) |
end |
KuiNameplates.RegisterModule = function(name, obj) |
if not modules[name] then |
modules[name] = obj |
end |
end |
------------------------------------------------------------- Frame functions -- |
-- set colour of health bar according to reaction/threat |
local function SetHealthColour(self) |
if g > .9 and r == 0 and b == 0 then |
-- friendly NPC |
self.friend = true |
r, g, b = unpack(ns.r[3]) |
r, g, b = unpack(kn.r[3]) |
elseif b > .9 and r == 0 and g == 0 then |
-- friendly player |
self.friend = true |
r, g, b = 0, .3, .6 |
elseif r > .9 and g == 0 and b == 0 then |
-- enemy NPC |
r, g, b = unpack(ns.r[1]) |
r, g, b = unpack(kn.r[1]) |
elseif (r + g) > 1.8 and b == 0 then |
-- neutral NPC |
r, g, b = unpack(ns.r[2]) |
r, g, b = unpack(kn.r[2]) |
elseif b > .9 and (r+g) > 1.06 and (r+g) < 1.1 then |
-- tapped NPC |
if profile.hp.tapped then |
-- use grey... |
r, g, b = unpack(ns.r[4]) |
r, g, b = unpack(kn.r[4]) |
else |
-- or don't change |
return |
self.state:Hide() |
end |
if profile.castbar.usenames and |
not loadedNames[self.name.text] and |
not self.guid |
if not loadedNames[self.name.text] and |
not self.guid |
then |
-- store this frame's name |
loadedNames[self.name.text] = self |
-- stuff that can be updated less often |
local function UpdateFrame(self) |
if profile.castbar.usenames and |
not loadedNames[self.name.text] and |
if not loadedNames[self.name.text] and |
not self.guid |
then |
-- ensure a frame is still stored for this name, as name conflicts cause |
end |
--------------------------------------------------------------- KNP functions -- |
function ns.f:GetNameplate(guid, name) |
function kn:GetNameplate(guid, name) |
local gf, nf = loadedGUIDs[guid], loadedNames[name] |
if gf then |
end |
end |
function ns.f:IsNameplate(frame) |
function kn:IsNameplate(frame) |
if frame:GetName() and strfind(frame:GetName(), '^NamePlate%d') then |
local nameTextChild = select(2, frame:GetChildren()) |
if nameTextChild then |
end |
end |
function ns.f:InitFrame(frame) |
function kn:InitFrame(frame) |
frame.init = true |
frame.fontObjects = {} |
frame.state = stateIconRegion |
frame.level = levelTextRegion |
frame.icon = raidIconRegion |
frame.spell = spellIconRegion |
if profile.castbar.spellicon then |
frame.spell = spellIconRegion |
end |
frame.oldHealth = healthBar |
frame.oldHealth:Hide() |
frame.health:SetSize(kn.sizes.width-2, kn.sizes.height-2) |
frame.health:SetPoint('BOTTOMLEFT', x+1, y+1) |
if ns.SetValueSmooth then |
if kn.SetValueSmooth then |
-- smooth bar |
frame.health.OrigSetValue = frame.health.SetValue |
frame.health.SetValue = ns.SetValueSmooth |
frame.health.SetValue = kn.SetValueSmooth |
end |
-- raid icon --------------------------------------------------------------- |
end |
---------------------------------------------------------------------- Events -- |
function ns.f:PLAYER_TARGET_CHANGED() |
function kn:PLAYER_TARGET_CHANGED() |
targetExists = UnitExists('target') |
end |
-- automatic toggling of enemy frames |
function ns.f:PLAYER_REGEN_ENABLED() |
function kn:PLAYER_REGEN_ENABLED() |
SetCVar('nameplateShowEnemies', 0) |
end |
function ns.f:PLAYER_REGEN_DISABLED() |
function kn:PLAYER_REGEN_DISABLED() |
SetCVar('nameplateShowEnemies', 1) |
end |
------------------------------------------------------------- Script handlers -- |
ns.frames = 0 |
kn.numFrames = 0 |
do |
local WorldFrame, lastUpdate |
= WorldFrame, 1 |
function ns.OnUpdate(self, elapsed) |
function kn.f:OnUpdate(elapsed) |
lastUpdate = lastUpdate + elapsed |
if lastUpdate >= .1 then |
local frames = select('#', WorldFrame:GetChildren()) |
if frames ~= ns.frames then |
if frames ~= kn.numFrames then |
local i, f |
for i = 1, frames do |
f = select(i, WorldFrame:GetChildren()) |
if self:IsNameplate(f) and not f.init then |
self:InitFrame(f) |
if kn:IsNameplate(f) and not f.init then |
kn:InitFrame(f) |
tinsert(kn.frameList, f) |
end |
end |
ns.frames = frames |
kn.numFrames = frames |
end |
end |
end |
end |
function ns.OnEvent(self, event, ...) |
self[event](self, ...) |
end |
function ns.ToggleCombatEvents(io) |
function kn:ToggleCombatEvents(io) |
if io then |
ns.f:RegisterEvent('PLAYER_REGEN_ENABLED') |
ns.f:RegisterEvent('PLAYER_REGEN_DISABLED') |
kn:RegisterEvent('PLAYER_REGEN_ENABLED') |
kn:RegisterEvent('PLAYER_REGEN_DISABLED') |
else |
ns.f:UnregisterEvent('PLAYER_REGEN_ENABLED') |
ns.f:UnregisterEvent('PLAYER_REGEN_DISABLED') |
kn:UnregisterEvent('PLAYER_REGEN_ENABLED') |
kn:UnregisterEvent('PLAYER_REGEN_DISABLED') |
end |
end |
-------------------------------------------------- Listen for profile changes -- |
function ns:ProfileChanged() |
kn.profile = self.db.profile |
profile = kn.profile |
-- call all updateFunctions |
local groupname, group |
for groupname, group in pairs(profile) do |
local settingname, value |
for settingname, value in pairs(group) do |
kn.updateFunctions.Call(settingname, value) |
end |
end |
function kn:ProfileChanged() |
profile = self.db.profile |
end |
-- TODO move all this crap into config.lua (or maybe not, create.lua?) |
-------------------------------------------------------------------- Finalise -- |
-- [initialise and] scale frame sizes |
function ns:ScaleFrames() |
function kn:ScaleFrameSizes() |
local k, size |
for k, size in pairs(defaultSizes.frame) do |
kn.sizes[k] = (uiscale and floor(size/uiscale) or size) |
self.sizes[k] = (uiscale and floor(size/uiscale) or size) |
end |
end |
-- [initialise and] scale font sizes |
function ns:ScaleFonts() |
function kn:ScaleFontSizes() |
local k, size |
for k, size in pairs(defaultSizes.font) do |
kn.fontSizes[k] = size * profile.fontoptions.fontscale |
self.fontSizes[k] = size * profile.fontoptions.fontscale |
if uiscale then |
kn.fontSizes[k] = kn.fontSizes[k] / uiscale |
self.fontSizes[k] = self.fontSizes[k] / uiscale |
end |
end |
end |
function ns:OnEnable() |
kn.profile = self.db.profile |
profile = kn.profile |
function kn:OnEnable() |
profile = self.db.profile |
if profile.general.fixaa then |
uiscale = UIParent:GetEffectiveScale() |
end |
self:ScaleFrames() |
self:ScaleFonts() |
self:ScaleFrameSizes() |
self:ScaleFontSizes() |
-- fetch font path from lsm |
kn.font = LSM:Fetch(LSM.MediaType.FONT, profile.fontoptions.font) |
self.font = LSM:Fetch(LSM.MediaType.FONT, profile.fontoptions.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 |
local f, smoothing, GetFramerate, min, max, abs |
= CreateFrame('Frame'), {}, GetFramerate, math.min, math.max, math.abs |
function ns.SetValueSmooth(self, value) |
function kn.SetValueSmooth(self, value) |
local _, maxv = self:GetMinMaxValues() |
if value == self:GetValue() or (self.prevMax and self.prevMax ~= maxv) then |
end |
-- enable packed modules |
--[[ |
if profile.castbar.enabled and modules.castbar then |
modules.castbar:Enable() |
end |
end |
if profile.general.combopoints and modules.combopoints then |
modules.combopoints:Enable() |
end |
end]] |
ns.f:SetScript('OnUpdate', self.OnUpdate) |
ns.f:SetScript('OnEvent', self.OnEvent) |
ns.f:RegisterEvent('PLAYER_TARGET_CHANGED') |
self.f:SetScript('OnUpdate', self.f.OnUpdate) |
self:RegisterEvent('PLAYER_TARGET_CHANGED') |
self.ToggleCombatEvents(profile.general.combat) |
end |
local kui = LibStub('Kui-1.0') |
local kn = KuiNameplates |
local cb = CreateFrame('Frame') |
local addon = LibStub('AceAddon-3.0'):GetAddon('KuiNameplates') |
local mod = addon:NewModule('CastBar', 'AceEvent-3.0') |
mod.uiName = 'Cast bars' |
local castEvents = { |
['UNIT_SPELLCAST_START'] = true, |
['UNIT_SPELLCAST_FAILED'] = true, |
end |
---------------------------------------------------------------------- create -- |
cb.CreateCastbar = function(frame) |
function mod:CreateCastbar(frame) |
-- container --------------------------------------------------------------- |
frame.castbar = CreateFrame('Frame', nil, frame.parent) |
frame.castbar:Hide() |
frame.castbar.bg:SetTexture(kui.m.t.solid) |
frame.castbar.bg:SetVertexColor(0, 0, 0, .85) |
frame.castbar.bg:SetHeight(kn.sizes.cbheight) |
frame.castbar.bg:SetHeight(addon.sizes.cbheight) |
frame.castbar.bg:SetPoint('TOPLEFT', frame.bg.fill, 'BOTTOMLEFT', 0, -1) |
frame.castbar.bg:SetPoint('TOPRIGHT', frame.bg.fill, 'BOTTOMRIGHT', 0, 0) |
frame.castbar.shield:Hide() |
-- cast bar text ------------------------------------------------------- |
if kn.profile.castbar.spellname then |
if self.db.profile.spellname then |
frame.castbar.name = frame:CreateFontString(frame.castbar, { |
font = kn.font, size = 'name', outline = "OUTLINE" }) |
font = addon.font, size = 'name', outline = "OUTLINE" }) |
frame.castbar.name:SetPoint('TOPLEFT', frame.castbar.bg, 'BOTTOMLEFT', 2, -2) |
frame.castbar.name:SetPoint('TOPRIGHT', frame.castbar.bg, 'BOTTOMRIGHT', -2, 0) |
frame.castbar.name:SetJustifyH('LEFT') |
end |
if kn.profile.castbar.casttime then |
if self.db.profile.casttime then |
frame.castbar.max = frame:CreateFontString(frame.castbar, { |
font = kn.font, size = 'name', outline = "OUTLINE" }) |
font = addon.font, size = 'name', outline = "OUTLINE" }) |
frame.castbar.max:SetPoint('TOPRIGHT', frame.castbar.bg, 'BOTTOMRIGHT', -2, -1) |
frame.castbar.curr = frame:CreateFontString(frame.castbar, { |
font = kn.font, size = 'small', outline = "OUTLINE" }) |
font = addon.font, size = 'small', outline = "OUTLINE" }) |
frame.castbar.curr:SetAlpha(.5) |
frame.castbar.curr:SetPoint('TOPRIGHT', frame.castbar.max, 'TOPLEFT', -1, -1) |
-- cast bar icon background ---------------------------------------- |
frame.spellbg = frame.castbar:CreateTexture(nil, 'BACKGROUND') |
frame.spellbg:SetTexture(kui.m.t.solid) |
frame.spellbg:SetSize(kn.sizes.icon, kn.sizes.icon) |
frame.spellbg:SetSize(addon.sizes.icon, addon.sizes.icon) |
frame.spellbg:SetVertexColor(0, 0, 0, .85) |
-- cast bar icon --------------------------------------------------- |
frame.spell:ClearAllPoints() |
frame.spell:SetParent(frame.castbar) |
frame.spell:SetSize(kn.sizes.icon - 2, kn.sizes.icon - 2) |
frame.spell:SetSize(addon.sizes.icon - 2, addon.sizes.icon - 2) |
frame.spell:SetPoint('TOPRIGHT', frame.spellbg, -1, -1) |
-- scripts ------------------------------------------------------------- |
frame.castbar:HookScript('OnShow', function(bar) |
if bar.interruptible then |
bar.bar:SetStatusBarColor(unpack(kn.profile.castbar.barcolour)) |
bar.bar:SetStatusBarColor(unpack(self.db.profile.barcolour)) |
bar.shield:Hide() |
else |
bar.bar:SetStatusBarColor(.8, .1, .1) |
frame.castbar:SetScript('OnUpdate', OnCastbarUpdate) |
end |
------------------------------------------------------------------------ Hide -- |
cb.HideCastbar = function(frame) |
function mod:HideCastbar(frame) |
if frame.castbar then |
frame.castbar.duration = nil |
frame.castbar.id = nil |
end |
end |
-------------------------------------------------------------- Event handlers -- |
function cb:UnitCastEvent(e, unit, ...) |
function mod.UnitCastEvent(e, unit, ...) |
if unit == 'player' then return end |
local guid, name, f = UnitGUID(unit), GetUnitName(unit), nil |
--guid, name = UnitGUID('target'), GetUnitName('target') |
--print('CastEvent: ['..e..'] from ['..unit..'] (GUID: ['..(guid or 'nil')..']) (Name: ['..(name or 'nil')..'])') |
-- fetch the unit's nameplate |
f = kn.f:GetNameplate(guid, name) |
f = addon:GetNameplate(guid, name) |
if f then |
if not f.castbar or f.trivial then return end |
if e == 'UNIT_SPELLCAST_STOP' or |
end |
end |
self[e](self, f, unit) |
mod[e](mod, f, unit) |
end |
end |
function cb:UNIT_SPELLCAST_START(frame, unit, channel) |
function mod:UNIT_SPELLCAST_START(frame, unit, channel) |
local castbar = frame.castbar |
local name, _, text, texture, startTime, endTime, _, castID, |
notInterruptible |
frame.castbar:Show() |
end |
function cb:UNIT_SPELLCAST_DELAYED(frame, unit, channel) |
function mod:UNIT_SPELLCAST_DELAYED(frame, unit, channel) |
local castbar = frame.castbar |
local _, name, startTime, endTime |
castbar.progress = newProgress |
end |
function cb:UNIT_SPELLCAST_CHANNEL_START(frame, unit) |
function mod:UNIT_SPELLCAST_CHANNEL_START(frame, unit) |
self:UNIT_SPELLCAST_START(frame, unit, true) |
end |
function cb:UNIT_SPELLCAST_CHANNEL_UPDATE(frame, unit) |
function mod:UNIT_SPELLCAST_CHANNEL_UPDATE(frame, unit) |
self:UNIT_SPELLCAST_DELAYED(frame, unit, true) |
end |
function cb:UNIT_SPELLCAST_STOP(frame, unit) |
function mod:UNIT_SPELLCAST_STOP(frame, unit) |
frame.castbar:Hide() |
end |
function cb:UNIT_SPELLCAST_FAILED(frame, unit) |
function mod:UNIT_SPELLCAST_FAILED(frame, unit) |
frame.castbar:Hide() |
end |
function cb:UNIT_SPELLCAST_INTERRUPTED(frame, unit) |
function mod:UNIT_SPELLCAST_INTERRUPTED(frame, unit) |
frame.castbar:Hide() |
end |
function cb:UNIT_SPELLCAST_CHANNEL_STOP(frame, unit) |
function mod:UNIT_SPELLCAST_CHANNEL_STOP(frame, unit) |
frame.castbar:Hide() |
end |
function cb.IsCasting(frame) |
function mod:IsCasting(frame) |
-- TODO update this for other units (party1target etc) |
if not frame.castbar or not frame.target then return end |
if name then |
-- if they're casting or channeling, try to show a castbar |
cb:UNIT_SPELLCAST_START(frame, 'target', channel) |
self:UNIT_SPELLCAST_START(frame, 'target', channel) |
end |
end |
-------------------------------------------------------------------- Register -- |
local function OnEvent(self, event, ...) |
cb:UnitCastEvent(event, ...) |
function mod:GetOptions() |
return { |
enabled = { |
name = 'Enable cast bar', |
desc = 'Show cast bars (at all)', |
type = 'toggle', |
order = 0, |
disabled = false |
}, |
casttime = { |
name = 'Show cast time', |
desc = 'Show cast time and time remaining', |
type = 'toggle', |
order = 4 |
}, |
spellname = { |
name = 'Show spell name', |
type = 'toggle', |
order = 3 |
}, |
spellicon = { |
name = 'Show spell icon', |
type = 'toggle', |
order = 2 |
}, |
barcolour = { |
name = 'Bar colour', |
desc = 'The colour of the cast bar (during interruptible casts)', |
type = 'color', |
width = 'double', |
order = 1 |
}, |
} |
end |
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) |
function mod:OnInitialize() |
self.db = addon.db:RegisterNamespace(self.moduleName, { |
profile = { |
enabled = true, |
casttime = true, |
spellname = true, |
spellicon = true, |
barcolour = { .43, .47, .55, 1 }, |
} |
}) |
end |
function mod:OnEnable() |
addon:RegisterPostFunction('create', self, 'CreateCastbar') |
addon:RegisterPostFunction('hide', self, 'HideCastbar') |
addon:RegisterPostFunction('show', self, 'IsCasting') |
addon:RegisterPostFunction('target', self, 'IsCasting') |
for event,_ in pairs(castEvents) do |
self:RegisterEvent(event) |
self:RegisterEvent(event, self.UnitCastEvent) |
end |
end |
kn.RegisterModule('castbar', cb) |
end |
local kui = LibStub('Kui-1.0') |
local kn = KuiNameplates |
local cw = CreateFrame('Frame') |
local addon = LibStub('AceAddon-3.0'):GetAddon('KuiNameplates') |
local mod = addon:NewModule('CastWarnings', 'AceEvent-3.0') |
mod.uiName = 'Cast warnings' |
-- combat log events to listen to for cast warnings/healing |
local warningEvents = { |
['SPELL_CAST_START'] = true, |
['SPELL_PERIODIC_HEAL'] = true |
} |
------------------------------------------------------------- Frame functions -- |
local function SetCastWarning(self, spellName, spellSchool) |
self.castWarning.ag:Stop() |
end |
-------------------------------------------------------------- Event handlers -- |
local function OnEvent(self, event, ...) |
function mod:COMBAT_LOG_EVENT_UNFILTERED(evant, ...) |
local castTime, event, _, guid, name, _, _, targetGUID, targetName |
= ... |
guid, name = targetGUID, targetName |
end |
-- [[debug]] |
--guid, name = UnitGUID('target'), GetUnitName('target') |
--guid, name = UnitGUID('target'), GetUnitName('target') -- [DEBUG] |
local f = kn.f:GetNameplate(guid, name:gsub('%-.+$', '')) |
if self.db.profile.useNames then |
if not guid and not name then |
return |
end |
name = name and name:gsub('%-.+$', '') -- remove realm names |
else |
if not guid then |
return |
end |
name = nil |
end |
local f = addon:GetNameplate(guid, name) |
if f then |
if not f.SetIncomingWarning or f.trivial then return end |
local spName, spSch = select(13, ...) |
end |
---------------------------------------------------------------------- Create -- |
cw.CreateCastWarnings = function(frame) |
function mod:CreateCastWarnings(frame) |
-- casting spell name |
frame.castWarning = frame:CreateFontString(frame.overlay, { |
font = kn.font, size = 'spellname', outline = 'OUTLINE' }) |
font = addon.font, size = 'spellname', outline = 'OUTLINE' }) |
frame.castWarning:SetPoint('BOTTOMLEFT', frame.level, 'TOPLEFT', 0, 1) |
frame.castWarning:Hide() |
-- incoming healing |
frame.incWarning = frame:CreateFontString(frame.overlay, { |
font = kn.font, size = 'small', outline = 'OUTLINE' }) |
font = addon.font, size = 'small', outline = 'OUTLINE' }) |
frame.incWarning:SetPoint('BOTTOMRIGHT', frame.health.p, 'TOPRIGHT', 1) |
frame.incWarning:Hide() |
frame.SetIncomingWarning = SetIncomingWarning |
end |
------------------------------------------------------------------------ Hide -- |
cw.HideCastWarnings = function(frame) |
function mod:HideCastWarnings(frame) |
if frame.castWarning then |
frame.castWarning:SetText() |
frame.castWarning.ag:Stop() |
end |
end |
-------------------------------------------------------------------- Register -- |
cw.Enable = function(self) |
kn.RegisterPostFunction('create', self.CreateCastWarnings) |
kn.RegisterPostFunction('hide', self.HideCastWarnings) |
self:SetScript('OnEvent', OnEvent) |
function mod:GetOptions() |
return { |
warnings = { |
name = 'Show cast warnings', |
desc = 'Display cast and healing warnings on plates', |
type = 'toggle', |
order = 1, |
disabled = false |
}, |
useNames = { |
name = "Use names for warnings", |
desc = 'Use character names to decide which frame to display warnings on. May increase memory usage and may cause warnings to be displayed on incorrect frames when there are many units with the same name. Reccommended on for PvP, off for PvE.', |
type = 'toggle', |
order = 2 |
} |
} |
end |
function mod:OnInitialize() |
self.db = addon.db:RegisterNamespace(self.moduleName, { |
profile = { |
warnings = false, |
useNames = false |
} |
}) |
end |
function mod:OnEnable() |
-- TODO replace this with RegisterMessage etc from AceEvent |
addon:RegisterPostFunction('create', self, 'CreateCastWarnings') |
addon:RegisterPostFunction('hide', self, 'HideCastWarnings') |
self:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED') |
end |
kn.RegisterModule('warnings', cw) |
local addon, ns = ... |
local kui = LibStub('Kui-1.0') |
local kn = KuiNameplates |
local kn = LibStub('AceAddon-3.0'):GetAddon('KuiNameplates') |
------------------------------------------------------------------ Ace config -- |
local AceConfig = LibStub('AceConfig-3.0') |
--------------------------------------------------------------- Options table -- |
do |
local handler = {} |
local handlers = {} |
local handlerProto = {} |
local handlerMeta = { __index = handlerProto } |
function handlerProto:ResolveInfo(info) |
local p = self.dbPath.db.profile |
local child, k |
for i = 1, #info do |
k = info[i] |
if i < #info then |
if not child then |
child = p[k] |
else |
child = child[k] |
end |
end |
end |
return child or p, k |
end |
function handlerProto:Get(info, ...) |
local p, k = self:ResolveInfo(info) |
if info.type == 'color' then |
return unpack(p[k]) |
else |
return p[k] |
end |
end |
function handlerProto:Set(info, val, ...) |
local p, k = self:ResolveInfo(info) |
if info.type == 'color' then |
p[k] = { val, ... } |
else |
p[k] = val |
end |
end |
function kn:GetOptionHandler(mod) |
if not handlers[mod] then |
handlers[mod] = setmetatable({ dbPath = mod }, handlerMeta) |
end |
return handlers[mod] |
end |
local options = { |
name = 'Kui Nameplates', |
handler = handler, |
handler = kn:GetOptionHandler(kn), |
type = 'group', |
get = 'Get', |
set = 'Set', |
type = 'toggle', |
order = 1 |
}, |
combopoints = { |
name = 'Combo points', |
desc = 'Show combo points', |
type = 'toggle', |
order = 3 |
}, |
fixaa = { |
name = 'Fix aliasing', |
desc = 'Attempt to make plates appear sharper. Has a positive effect on FPS, but will make plates appear a bit "loose", especially at low frame rates. Works best when uiscale is disabled and at good resolutions.\n|cffff0000UI reload required to take effect.|r', |
softMax = 5, |
order = 3, |
disabled = function(info) |
return not ns.db.profile.fade.smooth |
return not kn.db.profile.fade.smooth |
end |
} |
} |
inline = true, |
order = 5, |
disabled = function(info) |
return not ns.db.profile.tank.enabled |
return not kn.db.profile.tank.enabled |
end, |
args = { |
enabled = { |
}, |
} |
}, |
castbar = { |
name = 'Cast bars', |
type = 'group', |
inline = true, |
order = 6, |
disabled = function(info) |
return not ns.db.profile.castbar.enabled |
end, |
args = { |
enabled = { |
name = 'Enable cast bar', |
desc = 'Show cast bars (at all)', |
type = 'toggle', |
order = 0, |
disabled = false |
}, |
casttime = { |
name = 'Show cast time', |
desc = 'Show cast time and time remaining', |
type = 'toggle', |
order = 4 |
}, |
spellname = { |
name = 'Show spell name', |
type = 'toggle', |
order = 3 |
}, |
spellicon = { |
name = 'Show spell icon', |
type = 'toggle', |
order = 2 |
}, |
barcolour = { |
name = 'Bar colour', |
desc = 'The colour of the cast bar (during interruptible casts)', |
type = 'color', |
width = 'double', |
order = 1 |
}, |
warnings = { |
name = 'Show cast warnings', |
desc = 'Display cast and healing warnings on plates', |
type = 'toggle', |
order = 5, |
disabled = false |
}, |
usenames = { |
name = 'Use names for warnings', |
desc = 'Use unit names to decide which frame to display warnings on. May increase memory usage and may cause warnings to be displayed on incorrect frames when there are many units with the same name. Reccommended on for PvP, off for PvE.', |
type = 'toggle', |
order = 6, |
disabled = function(info) |
return not ns.db.profile.castbar.warnings |
end |
}, |
}, |
}, |
reload = { |
name = 'Reload UI', |
type = 'execute', |
local fontsOptions = { |
name = 'Fonts', |
handler = handler, |
handler = kn:GetOptionHandler(kn), |
type = 'group', |
get = 'Get', |
set = 'Set', |
} |
} |
function handler:Get(info) |
local k = ns.db.profile[info[1]][info[#info]] |
-- create an options table for the given module |
function kn:InitModuleOptions(module) |
if not module.GetOptions then return end |
local opts = module:GetOptions() |
local name = module.uiName or module.moduleName |
if info.type == 'color' then |
return unpack(k) |
else |
return k |
end |
end |
--[[ |
AceConfig:RegisterOptionsTable('kuinameplates'..name, { |
name = name, |
handler = self:GetOptionHandler(module), |
type = 'group', |
get = 'Get', |
set = 'Set', |
args = opts |
}) |
function handler:Set(info, val, ...) |
if info.type == 'color' then |
ns.db.profile[info[1]][info[#info]] = { val, ... } |
else |
ns.db.profile[info[1]][info[#info]] = val |
end |
--print(info[#info]) |
kn.updateFunctions.Call(info[#info], val) |
AceConfigDialog:AddToBlizOptions('kuinameplates'..name, name, 'Kui Nameplates')]] |
options.args[name] = { |
name = name, |
handler = self:GetOptionHandler(module), |
type = 'group', |
inline = true, |
order = 50+#handlers, |
get = 'Get', |
set = 'Set', |
args = opts |
} |
end |
AceConfig:RegisterOptionsTable('kuinameplates', options) |
AceConfigDialog:AddToBlizOptions('kuinameplates', 'Kui Nameplates') |
function SlashCmdList.KUINAMEPLATES() |
InterfaceOptionsFrame_OpenToCategory('Kui Nameplates') |
end |
end |
<Include file="Ace3\CallbackHandler-1.0\CallbackHandler-1.0.xml"/> |
<Include file="Ace3\AceAddon-3.0\AceAddon-3.0.xml"/> |
<Include file="Ace3\AceEvent-3.0\AceEvent-3.0.xml"/> |
<Include file="Ace3\AceDB-3.0\AceDB-3.0.xml"/> |
<Include file="Ace3\AceDBOptions-3.0\AceDBOptions-3.0.xml"/> |
<Include file="Ace3\AceGUI-3.0\AceGUI-3.0.xml"/> |
local MAJOR, MINOR = 'Kui-1.0', 2 |
local MAJOR, MINOR = 'Kui-1.0', 3 |
local kui = LibStub:NewLibrary(MAJOR, MINOR) |
if not kui then |
kui.m = { |
t = { |
-- borders |
square = media .. 't\\simpleSquare', |
shadow = media .. 't\\shadowBorder', |
rounded = media .. 't\\solidRoundedBorder', |
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ |
..\FrameXML\UI.xsd"> |
<Script file="AceEvent-3.0.lua"/> |
</Ui> |
--- AceEvent-3.0 provides event registration and secure dispatching. |
-- All dispatching is done using **CallbackHandler-1.0**. AceEvent is a simple wrapper around |
-- CallbackHandler, and dispatches all game events or addon message to the registrees. |
-- |
-- **AceEvent-3.0** can be embeded into your addon, either explicitly by calling AceEvent:Embed(MyAddon) or by |
-- specifying it as an embeded library in your AceAddon. All functions will be available on your addon object |
-- and can be accessed directly, without having to explicitly call AceEvent itself.\\ |
-- It is recommended to embed AceEvent, otherwise you'll have to specify a custom `self` on all calls you |
-- make into AceEvent. |
-- @class file |
-- @name AceEvent-3.0 |
-- @release $Id: AceEvent-3.0.lua 975 2010-10-23 11:26:18Z nevcairiel $ |
local MAJOR, MINOR = "AceEvent-3.0", 3 |
local AceEvent = LibStub:NewLibrary(MAJOR, MINOR) |
if not AceEvent then return end |
-- Lua APIs |
local pairs = pairs |
local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0") |
AceEvent.frame = AceEvent.frame or CreateFrame("Frame", "AceEvent30Frame") -- our event frame |
AceEvent.embeds = AceEvent.embeds or {} -- what objects embed this lib |
-- APIs and registry for blizzard events, using CallbackHandler lib |
if not AceEvent.events then |
AceEvent.events = CallbackHandler:New(AceEvent, |
"RegisterEvent", "UnregisterEvent", "UnregisterAllEvents") |
end |
function AceEvent.events:OnUsed(target, eventname) |
AceEvent.frame:RegisterEvent(eventname) |
end |
function AceEvent.events:OnUnused(target, eventname) |
AceEvent.frame:UnregisterEvent(eventname) |
end |
-- APIs and registry for IPC messages, using CallbackHandler lib |
if not AceEvent.messages then |
AceEvent.messages = CallbackHandler:New(AceEvent, |
"RegisterMessage", "UnregisterMessage", "UnregisterAllMessages" |
) |
AceEvent.SendMessage = AceEvent.messages.Fire |
end |
--- embedding and embed handling |
local mixins = { |
"RegisterEvent", "UnregisterEvent", |
"RegisterMessage", "UnregisterMessage", |
"SendMessage", |
"UnregisterAllEvents", "UnregisterAllMessages", |
} |
--- Register for a Blizzard Event. |
-- The callback will be called with the optional `arg` as the first argument (if supplied), and the event name as the second (or first, if no arg was supplied) |
-- Any arguments to the event will be passed on after that. |
-- @name AceEvent:RegisterEvent |
-- @class function |
-- @paramsig event[, callback [, arg]] |
-- @param event The event to register for |
-- @param callback The callback function to call when the event is triggered (funcref or method, defaults to a method with the event name) |
-- @param arg An optional argument to pass to the callback function |
--- Unregister an event. |
-- @name AceEvent:UnregisterEvent |
-- @class function |
-- @paramsig event |
-- @param event The event to unregister |
--- Register for a custom AceEvent-internal message. |
-- The callback will be called with the optional `arg` as the first argument (if supplied), and the event name as the second (or first, if no arg was supplied) |
-- Any arguments to the event will be passed on after that. |
-- @name AceEvent:RegisterMessage |
-- @class function |
-- @paramsig message[, callback [, arg]] |
-- @param message The message to register for |
-- @param callback The callback function to call when the message is triggered (funcref or method, defaults to a method with the event name) |
-- @param arg An optional argument to pass to the callback function |
--- Unregister a message |
-- @name AceEvent:UnregisterMessage |
-- @class function |
-- @paramsig message |
-- @param message The message to unregister |
--- Send a message over the AceEvent-3.0 internal message system to other addons registered for this message. |
-- @name AceEvent:SendMessage |
-- @class function |
-- @paramsig message, ... |
-- @param message The message to send |
-- @param ... Any arguments to the message |
-- Embeds AceEvent into the target object making the functions from the mixins list available on target:.. |
-- @param target target object to embed AceEvent in |
function AceEvent:Embed(target) |
for k, v in pairs(mixins) do |
target[v] = self[v] |
end |
self.embeds[target] = true |
return target |
end |
-- AceEvent:OnEmbedDisable( target ) |
-- target (object) - target object that is being disabled |
-- |
-- Unregister all events messages etc when the target disables. |
-- this method should be called by the target manually or by an addon framework |
function AceEvent:OnEmbedDisable(target) |
target:UnregisterAllEvents() |
target:UnregisterAllMessages() |
end |
-- Script to fire blizzard events into the event listeners |
local events = AceEvent.events |
AceEvent.frame:SetScript("OnEvent", function(this, event, ...) |
events:Fire(event, ...) |
end) |
--- Finally: upgrade our old embeds |
for target, v in pairs(AceEvent.embeds) do |
AceEvent:Embed(target) |
end |
local kui = LibStub('Kui-1.0') |
local LSM = LibStub('LibSharedMedia-3.0') |
KuiNameplates = {} |
local kn = LibStub('AceAddon-3.0'):NewAddon('KuiNameplates', 'AceEvent-3.0') |
LibStub('AceAddon-3.0'):NewAddon(ns, 'KuiNameplates') |
-- add yanone kaffesatz and accidental presidency to LSM (only supports latin) |
LSM:Register(LSM.MediaType.FONT, 'Yanone Kaffesatz', kui.m.f.yanone) |
LSM:Register(LSM.MediaType.FONT, 'Accidental Presidency', kui.m.f.accid) |
general = { |
combat = false, -- automatically show hostile plates upon entering combat |
highlight = true, -- highlight plates on mouse-over |
combopoints = true, -- display combo points |
fixaa = true, -- attempt to make plates appear sharper (with some drawbacks) |
}, |
fade = { |
tapped = true, -- use grey health bar colour for tapped units |
smooth = true -- smoothly animate health bar changes |
}, |
castbar = { |
enabled = true, -- show a castbar (at all) |
casttime = true, -- display cast time and time remaining |
spellname = true, -- display spell name |
spellicon = true, -- display spell icon |
barcolour = { .43, .47, .55, 1 }, -- the colour of the spell bar (interruptible casts) |
warnings = false, -- display spell cast warnings on any plates |
usenames = false -- use unit names to display cast warnings |
}, |
fontoptions = { |
font = (latin and 'Yanone Kaffesatz' or LSM:GetDefault(LSM.MediaType.FONT)), |
fontscale = 1.0, |
} |
------------------------------------------------------------------------ init -- |
function ns:OnInitialize() |
function kn:OnInitialize() |
self.db = LibStub('AceDB-3.0'):New('KuiNameplatesGDB', defaults) |
for name, module in self:IterateModules() do |
self:InitModuleOptions(module) |
end |
-- enable ace3 profiles |
LibStub('AceConfig-3.0'):RegisterOptionsTable('kuinameplates-profiles', LibStub('AceDBOptions-3.0'):GetOptionsTable(self.db)) |
LibStub('AceConfigDialog-3.0'):AddToBlizOptions('kuinameplates-profiles', 'Profiles', 'Kui Nameplates') |