WoWInterface SVN KuiNameplates

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk
    from Rev 123 to Rev 124
    Reverse comparison

Rev 123 → Rev 124

Kui_Nameplates/castwarnings.lua
1,5 → 1,5
local kui = LibStub('Kui-1.0')
local profile, font, sizes, fontSizes, GetNameplate
local kn = KuiNameplates
local cw = CreateFrame('Frame')
 
-- combat log events to listen to for cast warnings/healing
63,13 → 63,14
guid, name = targetGUID, targetName
end
 
-- [[debug]]
--guid, name = UnitGUID('target'), GetUnitName('target')
 
local f = GetNameplate(guid, name)
local f = kn.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
91,7 → 92,7
cw.CreateCastWarnings = function(frame)
-- casting spell name
frame.castWarning = kui.CreateFontString(frame.overlay, {
font = font, size = fontSizes.spellname, outline = 'OUTLINE' })
font = kn.font, size = kn.fontSizes.spellname, outline = 'OUTLINE' })
frame.castWarning:SetPoint('BOTTOMLEFT', frame.level, 'TOPLEFT', 0, 1)
frame.castWarning:Hide()
 
111,7 → 112,7
 
-- incoming healing
frame.incWarning = kui.CreateFontString(frame.overlay, {
font = font, size = fontSizes.small, outline = 'OUTLINE' })
font = kn.font, size = kn.fontSizes.small, outline = 'OUTLINE' })
frame.incWarning:SetPoint('BOTTOMRIGHT', frame.health.p, 'TOPRIGHT', 1)
frame.incWarning:Hide()
 
149,17 → 150,12
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)
cw.Enable = function(self)
kn.RegisterPostFunction('create', self.CreateCastWarnings)
kn.RegisterPostFunction('hide', self.HideCastWarnings)
self:SetScript('OnEvent', OnEvent)
 
self:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
end
 
KuiNameplates.RegisterModule('warnings', cw)
kn.RegisterModule('warnings', cw)
Kui_Nameplates/config.lua
42,13 → 42,13
name = 'Combo points',
desc = 'Show combo points',
type = 'toggle',
order = 2
order = 3
},
fixaa = {
name = 'Fix aliasing',
desc = 'Attempt to make plates appear sharper, with some drawbacks',
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.',
type = 'toggle',
order = 3
order = 4
},
font = {
name = 'Font',
56,7 → 56,7
type = 'select',
dialogControl = 'LSM30_Font',
values = AceGUIWidgetLSMlists.font,
order = 4
order = 5
},
fontscale = {
name = 'Font scale',
64,7 → 64,7
type = 'range',
min = 0.01,
softMax = 2,
order = 5
order = 6
}
}
},
97,7 → 97,7
},
smooth = {
name = 'Smoothly fade',
desc = 'Smoothly fade plates in/out (fading is instant disabled)',
desc = 'Smoothly fade plates in/out (fading is instant when disabled)',
type = 'toggle',
order = 0
},
114,11 → 114,37
}
}
},
text = {
name = 'Text',
type = 'group',
inline = true,
order = 3,
args = {
level = {
name = 'Show levels',
desc = 'Show levels on nameplates',
type = 'toggle',
order = 2
},
friendlyname = {
name = 'Friendly name text colour',
desc = 'The colour of names of friendly units',
type = 'color',
order = 4,
},
enemyname = {
name = 'Enemy name text colour',
desc = 'The colour of names of enemy units',
type = 'color',
order = 5,
},
}
},
hp = {
name = 'Health display',
type = 'group',
inline = true,
order = 3,
order = 4,
args = {
showalt = {
name = 'Show contextual health',
164,7 → 190,7
name = 'Tank mode',
type = 'group',
inline = true,
order = 4,
order = 5,
disabled = function(info)
return not ns.db.profile.tank.enabled
end,
195,7 → 221,7
name = 'Cast bars',
type = 'group',
inline = true,
order = 5,
order = 6,
disabled = function(info)
return not ns.db.profile.castbar.enabled
end,
239,7 → 265,7
},
usenames = {
name = 'Use names for warnings',
desc = 'Use unit names to display cast warnings on their correct frames. 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.',
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)
251,6 → 277,8
reload = {
name = 'Reload UI',
type = 'execute',
width = 'triple',
order = 99,
func = ReloadUI
},
}
Kui_Nameplates/core.lua
39,10 → 39,15
barcolour = { .2, .9, .1, 1 }, -- the bar colour to use when you have threat
glowcolour = { 1, 0, 0, 1, 1 } -- the glow colour to use when you have threat
},
text = {
level = true, -- display levels
friendlyname = { 1, 1, 1 }, -- friendly name text colour
enemyname = { 1, 1, 1 } -- enemy name text colour
},
hp = {
friendly = '=:m;<:d;', -- health display pattern for friendly units
hostile = '<:p;', -- health display pattern for hostile/neutral units
showalt = true, -- show alternate (contextual) health values as well as main values
showalt = false, -- show alternate (contextual) health values as well as main values
mouseover = false, -- hide health values until you mouse over or target the plate
tapped = true, -- use grey health bar colour for tapped units
smooth = true -- smoothly animate health bar changes
Kui_Nameplates/layout.lua
10,11 → 10,11
local LSM = LibStub('LibSharedMedia-3.0')
 
KuiNameplates = {
f = CreateFrame('Frame'),
font = '', fontSizes = {}, sizes = {}
}
 
-- our frame, whee
KuiNameplates.f = CreateFrame('Frame')
ns.f = KuiNameplates.f
 
-- Custom reaction colours
25,22 → 25,22
{ .5, .5, .5 }, -- tapped
}
 
local bgOffset = 4 -- inset offset for the frame glow (frame.bg)
local uiscale, prevuiscale
local bgOffset = 4 -- inset offset for the frame glow (frame.bg)
local loadedGUIDs, loadedNames, targetExists, profile = {}, {}
local origSizes, origFontSizes = {},{}
 
local font, sizes, fontSizes = '', {}, {}
 
--------------------------------------------------------------------- globals --
local strsplit, pairs, ipairs, unpack
= strsplit, pairs, ipairs, unpack
local select, strfind, strsplit, pairs, ipairs, unpack
= select, strfind, strsplit, pairs, ipairs, unpack
 
-- helper for setting a given fontstring's font size
local function SetFontSize(fontstring, size)
local font, _, flags = fontstring:GetFont()
fontstring:SetFont(font, size, flags)
end
 
 
-------------------------------------------------- External calling functions --
local modules = {}
local postFunctions = {
88,7 → 88,7
then
-- store the default colour
self.health.r, self.health.g, self.health.b = r, g, b
self.health.reset, self.friend = nil, nil
self.health.reset, self.friend, self.player = nil, nil, nil
 
if g > .9 and r == 0 and b == 0 then
-- friendly NPC
97,6 → 97,7
elseif b > .9 and r == 0 and g == 0 then
-- friendly player
self.friend = true
self.player = true
r, g, b = 0, .3, .6
elseif r > .9 and g == 0 and b == 0 then
-- enemy NPC
113,13 → 114,23
-- or don't change
return
end
else
-- enemy player, use default UI colour
self.player = true
end
-- enemy player, use default UI colour
 
self.health:SetStatusBarColor(r, g, b)
end
end
 
local function SetNameColour(self)
if self.friend then
self.name:SetTextColor(unpack(profile.text.friendlyname))
else
self.name:SetTextColor(unpack(profile.text.enemyname))
end
end
 
local function SetGlowColour(self, r, g, b, a)
if not r then
-- set default colour
258,19 → 269,23
end
 
-- classifications
if self.boss:IsVisible() then
self.level:SetText('??b')
self.level:SetTextColor(1, 0, 0)
self.level:Show()
elseif self.state:IsVisible() then
if self.state:GetTexture() == "Interface\\Tooltips\\EliteNameplateIcon"
then
self.level:SetText(self.level:GetText()..'+')
else
self.level:SetText(self.level:GetText()..'r')
if self.level.enabled then
if self.boss:IsVisible() then
self.level:SetText('??b')
self.level:SetTextColor(1, 0, 0)
self.level:Show()
elseif self.state:IsVisible() then
if self.state:GetTexture() == "Interface\\Tooltips\\EliteNameplateIcon"
then
self.level:SetText(self.level:GetText()..'+')
else
self.level:SetText(self.level:GetText()..'r')
end
end
else
self.level:Hide()
end
 
 
if self.state:IsVisible() then
-- hide the elite/rare dragon
self.state:Hide()
312,8 → 327,8
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.name:SetPoint('BOTTOMLEFT', self.health, 'TOPLEFT', -10, -3)
self.name:SetPoint('BOTTOMRIGHT', self.health, 'TOPRIGHT', 10, -3)
 
self.bg.fill:SetSize(sizes.twidth, sizes.theight)
self.health:SetSize(sizes.twidth-2, sizes.theight-2)
346,8 → 361,7
self.bg.fill:ClearAllPoints()
self.name:ClearAllPoints()
 
self.level:Show()
self.health.p:Show()
self.health.p:Show()
 
if self.health.mo then
self.health.mo:Show()
355,10 → 369,15
 
SetFontSize(self.name, fontSizes.name)
self.name:SetJustifyH('LEFT')
 
self.name:SetPoint('LEFT', self.level, 'RIGHT', -2, 0)
self.name:SetPoint('RIGHT', self.health.p, 'LEFT')
 
if self.level.enabled then
self.name:SetPoint('LEFT', self.level, 'RIGHT', -2, 0)
self.level:Show()
else
self.name:SetPoint('BOTTOMLEFT', self.health, 'TOPLEFT', 2, uiscale and -(2/uiscale) or -2)
end
 
self.bg.fill:SetSize(sizes.width, sizes.height)
self.health:SetSize(sizes.width - 2, sizes.height - 2)
 
419,12 → 438,12
end
 
local function OnFrameEnter(self)
self:StoreGUID(UnitGUID('mouseover'))
 
if self.highlight then
self.highlight:Show()
end
 
self:StoreGUID(UnitGUID('mouseover'))
 
if profile.hp.mouseover then
self.health.p:Show()
if self.health.mo then self.health.mo:Show() end
535,6 → 554,9
 
-- Health bar colour
self:SetHealthColour()
 
-- Name text colour
self:SetNameColour()
 
if self.cp then
-- combo points
645,36 → 667,6
end
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)
 
self.bg.fill:SetSize(sizes.width, sizes.height)
self.health:SetSize(sizes.width-2, sizes.height-2)
 
SetFontSize(self.health.p, fontSizes.large)
 
if self.health.mo then
SetFontSize(self.health.mo, fontSizes.small)
end
 
SetFontSize(self.level, fontSizes.name)
SetFontSize(self.name, fontSizes.name)
 
if self.cp then
SetFontSize(self.cp, fontSizes.combopoints)
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)
local gf, nf = loadedGUIDs[guid], loadedNames[name]
689,11 → 681,12
end
 
function ns.f:IsNameplate(frame)
if frame:GetName() and string.find(frame:GetName(), '^NamePlate%d') then
--local healthbar = select(2, frame:GetChildren());
--local overlay = select(2, healthbar:GetRegions());
--return (overlayRegion and overlayRegion:GetObjectType() == 'Texture')
return true
if frame:GetName() and strfind(frame:GetName(), '^NamePlate%d') then
local nameTextChild = select(2, frame:GetChildren())
if nameTextChild then
local nameTextRegion = nameTextChild:GetRegions()
return (nameTextRegion and nameTextRegion:GetObjectType() == 'FontString')
end
end
end
 
748,6 → 741,7
frame.UpdateFrame = UpdateFrame
frame.UpdateFrameCritical = UpdateFrameCritical
frame.SetHealthColour = SetHealthColour
frame.SetNameColour = SetNameColour
frame.SetGlowColour = SetGlowColour
frame.IsCasting = IsFrameCasting
frame.StoreGUID = StoreFrameGUID
857,22 → 851,32
frame.health.mo:SetAlpha(.6)
end
 
-- level text --------------------------------------------------------------
frame.level = kui.CreateFontString(frame.level, { reset = true,
font = font, size = fontSizes.name, outline = 'OUTLINE' })
frame.level:SetParent(frame.overlay)
if profile.text.level then
-- level text ----------------------------------------------------------
frame.level = kui.CreateFontString(frame.level, { reset = true,
font = font, size = fontSizes.name, outline = 'OUTLINE' })
frame.level:SetParent(frame.overlay)
 
frame.level:ClearAllPoints()
frame.level:SetPoint('BOTTOMLEFT', frame.health, 'TOPLEFT', 2, uiscale and -(2/uiscale) or -2)
frame.level:ClearAllPoints()
frame.level:SetPoint('BOTTOMLEFT', frame.health, 'TOPLEFT', 2, uiscale and -(2/uiscale) or -2)
frame.level.enabled = true
else
frame.level:Hide()
end
 
-- name text ---------------------------------------------------------------
frame.name = kui.CreateFontString(frame.overlay, {
font = font, size = fontSizes.name, outline = 'OUTLINE' })
frame.name:SetJustifyH('LEFT')
 
frame.name:SetHeight(8)
frame.name:SetHeight(13)
 
frame.name:SetPoint('LEFT', frame.level, 'RIGHT', -2, 0)
if frame.level.enabled then
frame.name:SetPoint('LEFT', frame.level, 'RIGHT', -2, 0)
else
frame.name:SetPoint('BOTTOMLEFT', frame.health, 'TOPLEFT', 2, uiscale and -(2/uiscale) or -2)
end
 
frame.name:SetPoint('RIGHT', frame.health.p, 'LEFT')
 
-- combo point text --------------------------------------------------------
955,7 → 959,6
 
------------------------------------------------------------- Script handlers --
ns.frames = 0
ns.frameList = {}
 
do
local WorldFrame, lastUpdate
976,9 → 979,6
f = select(i, WorldFrame:GetChildren())
if self:IsNameplate(f) and not f.init then
self:InitFrame(f)
if profile.general.fixaa then
tinsert(ns.frameList, f)
end
end
end
 
Kui_Nameplates/castbar.lua
1,5 → 1,5
local kui = LibStub('Kui-1.0')
local profile, font, sizes, fontSizes
local kn = KuiNameplates
local cb = CreateFrame('Frame')
local castEvents = {
['UNIT_SPELLCAST_START'] = true,
69,7 → 69,7
 
frame.castbarbg:SetBackdropColor(0, 0, 0, .85)
frame.castbarbg:SetBackdropBorderColor(1, .2, .1, 0)
frame.castbarbg:SetHeight(sizes.cbheight)
frame.castbarbg:SetHeight(kn.sizes.cbheight)
 
frame.castbarbg:SetPoint('TOPLEFT', frame.bg.fill, 'BOTTOMLEFT', -5, 4)
frame.castbarbg:SetPoint('TOPRIGHT', frame.bg.fill, 'BOTTOMRIGHT', 5, 0)
101,19 → 101,19
frame.castbar.shield:Hide()
 
-- cast bar text -------------------------------------------------------
if profile.castbar.spellname then
if kn.profile.castbar.spellname then
frame.castbar.name = kui.CreateFontString(frame.castbar, {
font = font, size = fontSizes.name, outline = "OUTLINE" })
font = kn.font, size = kn.fontSizes.name, outline = "OUTLINE" })
frame.castbar.name:SetPoint('TOPLEFT', frame.castbar, 'BOTTOMLEFT', 2, -2)
end
 
if profile.castbar.casttime then
if kn.profile.castbar.casttime then
frame.castbar.max = kui.CreateFontString(frame.castbar, {
font = font, size = fontSizes.name, outline = "OUTLINE" })
font = kn.font, size = kn.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" })
font = kn.font, size = kn.fontSizes.small, outline = "OUTLINE" })
frame.castbar.curr:SetAlpha(.5)
frame.castbar.curr:SetPoint('TOPRIGHT', frame.castbar.max, 'TOPLEFT', -1, -1)
end
122,7 → 122,7
-- 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:SetSize(kn.sizes.icon, kn.sizes.icon)
 
frame.spellbg:SetVertexColor(0, 0, 0, .85)
 
131,7 → 131,7
-- cast bar icon ---------------------------------------------------
frame.spell:ClearAllPoints()
frame.spell:SetParent(frame.castbarbg)
frame.spell:SetSize(sizes.icon - 2, sizes.icon - 2)
frame.spell:SetSize(kn.sizes.icon - 2, kn.sizes.icon - 2)
 
frame.spell:SetPoint('TOPRIGHT', frame.spellbg, -1, -1)
 
141,7 → 141,7
-- scripts -------------------------------------------------------------
frame.castbar:HookScript('OnShow', function(bar)
if bar.interruptible then
bar:SetStatusBarColor(unpack(profile.castbar.barcolour))
bar:SetStatusBarColor(unpack(kn.profile.castbar.barcolour))
bar:GetParent():SetBackdropBorderColor(0, 0, 0, .3)
bar.shield:Hide()
else
171,7 → 171,7
--print('CastEvent: ['..e..'] from ['..unit..'] (GUID: ['..(guid or 'nil')..']) (Name: ['..(name or 'nil')..'])')
 
-- fetch the unit's nameplate
f = GetNameplate(guid, name)
f = kn.f:GetNameplate(guid, name)
if f then
if not f.castbar or f.trivial then return end
if e == 'UNIT_SPELLCAST_STOP' or
280,13 → 280,9
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)
cb.Enable = function(self)
kn.RegisterPostFunction('create', self.CreateCastbar)
kn.RegisterPostFunction('hide', self.HideCastbar)
self:SetScript('OnEvent', OnEvent)
 
for event,_ in pairs(castEvents) do
294,4 → 290,4
end
end
 
KuiNameplates.RegisterModule('castbar', cb)
kn.RegisterModule('castbar', cb)