/branches
self.castWarning.ag:Stop() |
if spellName == nil then |
-- hide the warning instantly (i.e. when interrupted) |
self.castWarning:SetAlpha(0) |
-- hide the warning instantly |
self.castWarning.ag:Stop() |
self.castWarning:SetText() |
self.castWarning:Hide() |
else |
local col = COMBATLOG_DEFAULT_COLORS.schoolColoring[spellSchool] or |
{r = 1, g = 1, b = 1} |
end |
-------------------------------------------------------------- Event handlers -- |
function mod:COMBAT_LOG_EVENT_UNFILTERED(evant, ...) |
local castTime, event, _, guid, name, _, _, targetGUID, targetName |
= ... |
function mod:COMBAT_LOG_EVENT_UNFILTERED(event, ...) |
local castTime, event, _, guid, name, _, _, targetGUID, targetName = ... |
if not guid then return end |
if warningEvents[event] then |
if event == 'SPELL_HEAL' or |
--guid, name = UnitGUID('target'), GetUnitName('target') -- [DEBUG] |
if self.db.profile.useNames then |
if not guid and not name then |
return |
end |
if self.db.profile.useNames and name then |
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 |
if not f.castWarning or f.trivial then return end |
local spName, spSch = select(13, ...) |
if event == 'SPELL_HEAL' or |
frame.SetCastWarning = SetCastWarning |
frame.SetIncomingWarning = SetIncomingWarning |
end |
------------------------------------------------------------------------ Hide -- |
function mod:HideCastWarnings(frame) |
function mod:Hide(frame) |
if frame.castWarning then |
frame.castWarning.ag:Stop() |
frame.castWarning:SetText() |
frame.castWarning.ag:Stop() |
frame.castWarning:Hide() |
frame.incWarning.ag:Stop() |
frame.incWarning:SetText() |
frame.incWarning:Hide() |
end |
end |
---------------------------------------------------- Post db change functions -- |
mod.configChangedFuncs = { runOnce = {} } |
mod.configChangedFuncs.runOnce.warnings = function(val) |
if val then |
mod:Enable() |
else |
mod:Disable() |
end |
end |
-------------------------------------------------------------------- Register -- |
function mod:GetOptions() |
return { |
useNames = false |
} |
}) |
addon:InitModuleOptions(self) |
mod:SetEnabledState(self.db.profile.warnings) |
end |
function mod:OnEnable() |
-- TODO replace this with RegisterMessage etc from AceEvent |
addon:RegisterPostFunction('create', self, 'CreateCastWarnings') |
addon:RegisterPostFunction('hide', self, 'HideCastWarnings') |
addon:RegisterPostFunction('hide', self, 'Hide') |
self:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED') |
local _,frame |
for _, frame in pairs(addon.frameList) do |
if not frame.castWarning then |
self:CreateCastWarnings(frame) |
end |
end |
end |
function mod:OnDisable() |
self:UnregisterEvent('COMBAT_LOG_EVENT_UNFILTERED') |
local _,frame |
for _, frame in pairs(addon.frameList) do |
self:Hide(frame) |
end |
end |
## Interface: 50100 |
## Interface: 50200 |
## Author: Kesava |
## Title: |cff9900ffKui|r Nameplates |
## Notes: Prettier, lightweight, configurable nameplates. |
local addon, ns = ... |
local kn = LibStub('AceAddon-3.0'):GetAddon('KuiNameplates') |
local addon = LibStub('AceAddon-3.0'):GetAddon('KuiNameplates') |
------------------------------------------------------------------ Ace config -- |
local AceConfig = LibStub('AceConfig-3.0') |
else |
p[k] = val |
end |
if self.dbPath.ConfigChanged then |
-- inform module of configuration change |
self.dbPath.ConfigChanged(k, p) |
end |
end |
function kn:GetOptionHandler(mod) |
function addon:GetOptionHandler(mod) |
if not handlers[mod] then |
handlers[mod] = setmetatable({ dbPath = mod }, handlerMeta) |
end |
local options = { |
name = 'Kui Nameplates', |
handler = kn:GetOptionHandler(kn), |
handler = addon:GetOptionHandler(addon), |
type = 'group', |
get = 'Get', |
set = 'Set', |
general = { |
name = 'General display', |
type = 'group', |
inline = true, |
order = 1, |
args = { |
combat = { |
fade = { |
name = 'Frame fading', |
type = 'group', |
inline = true, |
order = 2, |
args = { |
fadedalpha = { |
softMax = 5, |
order = 3, |
disabled = function(info) |
return not kn.db.profile.fade.smooth |
return not addon.db.profile.fade.smooth |
end |
} |
} |
text = { |
name = 'Text', |
type = 'group', |
inline = true, |
order = 3, |
args = { |
level = { |
hp = { |
name = 'Health display', |
type = 'group', |
inline = true, |
order = 4, |
args = { |
showalt = { |
tank = { |
name = 'Tank mode', |
type = 'group', |
inline = true, |
order = 5, |
disabled = function(info) |
return not kn.db.profile.tank.enabled |
end, |
args = { |
enabled = { |
name = 'Enable tank mode', |
desc = 'Change the colour of a plate\'s health bar and border when you have threat on its unit', |
type = 'toggle', |
order = 0, |
disabled = false |
order = 0 |
}, |
barcolour = { |
name = 'Bar colour', |
local fontsOptions = { |
name = 'Fonts', |
handler = kn:GetOptionHandler(kn), |
handler = addon:GetOptionHandler(addon), |
type = 'group', |
get = 'Get', |
set = 'Set', |
} |
} |
-- create module.ConfigChanged function |
-- TODO cycle these when changing profiles (or something) |
function addon:CreateConfigChangedListener(module) |
if module.configChangedFuncs and not module.ConfigChanged then |
module.ConfigChanged = function(key, profile) |
if module.configChangedFuncs.runOnce and |
module.configChangedFuncs.runOnce[key] |
then |
-- call runOnce function |
module.configChangedFuncs.runOnce[key](profile[key]) |
end |
if module.configChangedFuncs[key] then |
-- iterate frames and call |
for _, frame in pairs(addon.frameList) do |
module.configChangedFuncs[key](frame, profile[key]) |
end |
end |
end |
end |
end |
-- create an options table for the given module |
function kn:InitModuleOptions(module) |
function addon:InitModuleOptions(module) |
if not module.GetOptions then return end |
local opts = module:GetOptions() |
local name = module.uiName or module.moduleName |
--[[ |
AceConfig:RegisterOptionsTable('kuinameplates'..name, { |
name = name, |
handler = self:GetOptionHandler(module), |
type = 'group', |
get = 'Get', |
set = 'Set', |
args = opts |
}) |
self:CreateConfigChangedListener(module) |
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', |
} |
end |
addon.configChangedFuncs = { runOnce = {} } |
addon:CreateConfigChangedListener(addon) |
AceConfig:RegisterOptionsTable('kuinameplates', options) |
AceConfigDialog:AddToBlizOptions('kuinameplates', 'Kui Nameplates') |
Kui Nameplates |
Kesava-Auchindoun EU |
]] |
local addon, ns = ... |
local addon = LibStub('AceAddon-3.0'):NewAddon('KuiNameplates', 'AceEvent-3.0') |
local kui = LibStub('Kui-1.0') |
local LSM = LibStub('LibSharedMedia-3.0') |
local kn = LibStub('AceAddon-3.0'):NewAddon('KuiNameplates', 'AceEvent-3.0') |
-- 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) |
} |
------------------------------------------------------------------------ init -- |
function kn:OnInitialize() |
function addon: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') |
frame.cp:Update() |
end |
end |
---------------------------------------------------- Post db change functions -- |
mod.configChangedFuncs = { runOnce = {} } |
mod.configChangedFuncs.runOnce.enabled = function(val) |
if val then |
mod:Enable() |
else |
mod:Disable() |
end |
end |
-------------------------------------------------------------------- Register -- |
function mod:GetOptions() |
return { |
enabled = true, |
} |
}) |
addon:InitModuleOptions(self) |
mod:SetEnabledState(self.db.profile.enabled) |
end |
function mod:OnEnable() |
profile = self.db.profile |
end |
-- TODO move all this crap into config.lua (or maybe not, create.lua?) |
---------------------------------------------------- Post db change functions -- |
-- for changes which require traversal of all frames |
kn.updateFunctions = {} |
kn.updateFunctions.Call = function(func, val) |
if not kn.updateFunctions[func] then return end |
local runonce, _, frame = 0 |
for _, frame in pairs(kn.frameList) do |
kn.updateFunctions[func](frame, val, runonce) |
runonce = runonce + 1 |
end |
kn.configChangedFuncs.runOnce.fontscale = function(val) |
kn:ScaleFontSizes() |
end |
kn.updateFunctions.Health = function(frame) |
if frame:IsShown() then |
-- update health display |
OnHealthValueChanged(frame.oldHealth, frame.oldHealth:GetValue()) |
end |
end |
kn.updateFunctions.friendly = kn.updateFunctions.Health |
kn.updateFunctions.hostile = kn.updateFunctions.Health |
kn.updateFunctions.fontscale = function(frame, val, runonce) |
if runonce == 0 then |
ns:ScaleFonts() |
end |
kn.configChangedFuncs.fontscale = function(frame, val) |
local _, fontObject |
for _, fontObject in pairs(frame.fontObjects) do |
if type(fontObject.size) == 'string' then |
end |
end |
kn.updateFunctions.font = function(frame, val, runonce) |
val = LSM:Fetch(LSM.MediaType.FONT, val) |
if runonce == 0 then |
kn.font = val |
kn.configChangedFuncs.Health = function(frame) |
if frame:IsShown() then |
-- update health display |
OnHealthValueChanged(frame.oldHealth, frame.oldHealth:GetValue()) |
end |
end |
kn.configChangedFuncs.friendly = kn.configChangedFuncs.Health |
kn.configChangedFuncs.hostile = kn.configChangedFuncs.Health |
kn.configChangedFuncs.runOnce.font = function(val) |
kn.font = LSM:Fetch(LSM.MediaType.FONT, val) |
end |
kn.configChangedFuncs.font = function(frame, val) |
local _, fontObject |
for _, fontObject in pairs(frame.fontObjects) do |
local _, size, flags = fontObject:GetFont() |
fontObject:SetFont(val, size, flags) |
fontObject:SetFont(kn.font, size, flags) |
end |
end |
For Kui Nameplates |
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. |
Updated 24/12/12: |
* all functions are now inside the table `c` |
* RegisterPostFunction calls have been updated, copy and paste the last 4 |
lines into your custom.lua, overwriting the previous 4 lines. |
* kn is now set using an AceAddon call rather than a global. Copy and paste |
the topmost line into your custom.lua, overwriting the previous line. |
]] |
local kn = KuiNameplates |
local kn = LibStub('AceAddon-3.0'):GetAddon('KuiNameplates') |
local c = {} |
---------------------------------------------------------------------- Create -- |
local function PostCreate(frame) |
function c:PostCreate(frame) |
-- Place code to be performed after a frame is created here. |
end |
------------------------------------------------------------------------ Show -- |
local function PostShow(frame) |
function c:PostShow(frame) |
-- Place code to be performed after a frame is shown here. |
end |
------------------------------------------------------------------------ Hide -- |
local function PostHide(frame) |
function c:PostHide(frame) |
-- Place code to be performed after a frame is hidden here. |
end |
---------------------------------------------------------------------- Target -- |
local function PostTarget(frame) |
function c:PostTarget(frame) |
-- Place code to be performed when a frame becomes the player's target here. |
end |
-------------------------------------------------------------------- Register -- |
kn.RegisterPostFunction('create', PostCreate) |
kn.RegisterPostFunction('show', PostShow) |
kn.RegisterPostFunction('hide', PostHide) |
kn.RegisterPostFunction('target', PostTarget) |
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 |
}, |
display = { |
name = 'Display', |
type = 'group', |
inline = true, |
disabled = function(info) |
return not self.db.profile.enabled |
end, |
args = { |
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', |
order = 1 |
}, |
} |
} |
} |
end |
barcolour = { .43, .47, .55, 1 }, |
} |
}) |
addon:InitModuleOptions(self) |
end |
function mod:OnEnable() |