WoWInterface SVN KuiNameplates

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk
    from Rev 128 to Rev 132
    Reverse comparison

Rev 128 → Rev 132

Kui_Nameplates/combopoints.lua File deleted
Kui_Nameplates/layout.lua
1,22 → 1,22
--[[
Kui Nameplates
Kesava-Auchindoun
 
TODO make option for friendly/enemy name text colour (defaults to white)
]]
 
local addon, ns = ...
local kui = LibStub('Kui-1.0')
local LSM = LibStub('LibSharedMedia-3.0')
local kn = KuiNameplates
 
KuiNameplates = {
f = CreateFrame('Frame'),
font = '', fontSizes = {}, sizes = {}
}
 
-- our frame, whee
kn.f = CreateFrame('Frame')
ns.f = kn.f
ns.f = KuiNameplates.f
 
kn.font = ''
kn.fontSizes = {}
kn.sizes = {}
kn.frameList = {}
 
-- Custom reaction colours
ns.r = {
{ .7, .2, .1 }, -- hated
25,65 → 25,22
{ .5, .5, .5 }, -- tapped
}
 
-- sizes of frame elements
local defaultSizes = {
frame = {
width = 110,
height = 11,
twidth = 55,
theight = 7,
cbheight = 4,
bgOffset = 4, -- inset offset for the frame glow (frame.bg)
icon = 16
},
font = {
combopoints = 13,
large = 10,
spellname = 9,
name = 9,
small = 8
},
}
local bgOffset = 4 -- inset offset for the frame glow (frame.bg)
local uiscale, prevuiscale
local loadedGUIDs, loadedNames, targetExists, profile = {}, {}
local origSizes, origFontSizes = {},{}
local font, sizes, fontSizes = '', {}, {}
 
local loadedGUIDs, loadedNames = {}, {}
local targetExists
local profile, uiscale
 
--------------------------------------------------------------------- globals --
local select, strfind, strsplit, pairs, ipairs, unpack, tinsert, type
= select, strfind, strsplit, pairs, ipairs, unpack, tinsert, type
local select, strfind, strsplit, pairs, ipairs, unpack
= select, strfind, strsplit, pairs, ipairs, unpack
 
------------------------------------------------------------ helper functions --
 
local function SetFontSize(fs, size)
if type(size) == 'string' and fs.size and kn.fontSizes[size] then
fs.size = size
size = kn.fontSizes[size]
end
 
local font, _, flags = fs:GetFont()
fs:SetFont(font, size, flags)
-- 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
 
local function CreateFontString(self, parent, obj)
-- size can be stored as a key of kn.fontSizes so that it can be set
-- correctly if fonts are scaled
local sizeKey = obj.size
 
if type(sizeKey) == 'string' then
obj.size = kn.fontSizes[sizeKey]
end
 
local fs = kui.CreateFontString(parent, obj)
fs.size = sizeKey
 
--fs.SetFontSize = SetFontSize
--fs.SetFontStyle = SetFontStyle
 
tinsert(self.fontObjects, fs)
return fs
end
 
-------------------------------------------------- External calling functions --
local modules = {}
local postFunctions = {
206,6 → 163,20
end
end
 
--------------------------------------------------------- Update 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)
 
self:SetText(self.points)
self:SetFont(font, size, 'OUTLINE')
self:SetTextColor(1, 1, blue)
elseif self:GetText() then
self:SetText('')
end
end
 
---------------------------------------------------- Update health bar & text --
local function OnHealthValueChanged(oldBar, curr)
local frame = oldBar:GetParent():GetParent()
233,10 → 204,8
condition = curr < max
elseif condition == '=' then
condition = curr == max
elseif condition == '<=' or condition == '=<' then
elseif condition == '<=' then
condition = curr <= max
else
condition = nil
end
 
if condition then
267,6 → 236,7
------------------------------------------------------- Frame script handlers --
local function OnFrameShow(self)
if self.carrier then
-- TODO or I could just make the positioning a function and call it here
self.carrier.DoShow = true
end
 
320,8 → 290,8
 
local w,h = self.parent:GetSize()
local x,y =
floor((w / 2) - (kn.sizes.twidth / 2)),
floor((h / 2) - (kn.sizes.theight / 2))
floor((w / 2) - (sizes.twidth / 2)),
floor((h / 2) - (sizes.theight / 2))
 
self.health:ClearAllPoints()
self.bg:ClearAllPoints()
335,20 → 305,21
self.health.mo:Hide()
end
 
SetFontSize(self.name, 'small')
SetFontSize(self.name, fontSizes.small)
self.name:SetJustifyH('CENTER')
 
self.name:SetPoint('BOTTOM', self.health, 'TOP', 0, -3)
self.name:SetPoint('BOTTOMLEFT', self.health, 'TOPLEFT', -10, -3)
self.name:SetPoint('BOTTOMRIGHT', self.health, 'TOPRIGHT', 10, -3)
 
self.bg.fill:SetSize(kn.sizes.twidth, kn.sizes.theight)
self.health:SetSize(kn.sizes.twidth-2, kn.sizes.theight-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-(kn.sizes.bgOffset-2), y-(kn.sizes.bgOffset-2))
self.bg:SetPoint('TOPRIGHT', self.parent, 'BOTTOMLEFT', x+kn.sizes.twidth+(kn.sizes.bgOffset-2), y+kn.sizes.theight+(kn.sizes.bgOffset-2))
self.bg:SetPoint('BOTTOMLEFT', x-(bgOffset-2), y-(bgOffset-2))
self.bg:SetPoint('TOPRIGHT', self.parent, 'BOTTOMLEFT', x+sizes.twidth+(bgOffset-2), y+sizes.theight+(bgOffset-2))
 
self.trivial = true
else
363,8 → 334,8
 
local w,h = self.parent:GetSize()
local x,y =
floor((w / 2) - (kn.sizes.width / 2)),
floor((h / 2) - (kn.sizes.height / 2))
floor((w / 2) - (sizes.width / 2)),
floor((h / 2) - (sizes.height / 2))
 
self.health:ClearAllPoints()
self.bg:ClearAllPoints()
377,7 → 348,7
self.health.mo:Show()
end
 
SetFontSize(self.name, 'name')
SetFontSize(self.name, fontSizes.name)
self.name:SetJustifyH('LEFT')
self.name:SetPoint('RIGHT', self.health.p, 'LEFT')
 
388,15 → 359,15
self.name:SetPoint('BOTTOMLEFT', self.health, 'TOPLEFT', 2, uiscale and -(2/uiscale) or -2)
end
 
self.bg.fill:SetSize(kn.sizes.width, kn.sizes.height)
self.health:SetSize(kn.sizes.width - 2, kn.sizes.height - 2)
self.bg.fill:SetSize(sizes.width, sizes.height)
self.health:SetSize(sizes.width - 2, sizes.height - 2)
 
self.health:SetPoint('BOTTOMLEFT', x+1, y+1)
 
self.bg.fill:SetPoint('BOTTOMLEFT', x, y)
 
self.bg:SetPoint('BOTTOMLEFT', x-kn.sizes.bgOffset, y-kn.sizes.bgOffset)
self.bg:SetPoint('TOPRIGHT', self.parent, 'BOTTOMLEFT', x+(kn.sizes.width)+kn.sizes.bgOffset, y+(kn.sizes.height)+kn.sizes.bgOffset)
self.bg:SetPoint('BOTTOMLEFT', x-bgOffset, y-bgOffset)
self.bg:SetPoint('TOPRIGHT', self.parent, 'BOTTOMLEFT', x+(sizes.width)+bgOffset, y+(sizes.height)+bgOffset)
 
self.trivial = nil
end
421,6 → 392,11
-- remove guid from the store and unset it
loadedGUIDs[self.guid] = nil
self.guid = nil
 
if self.cp then
self.cp.points = nil
self.cp:Update()
end
end
 
if loadedNames[self.name.text] == self then
477,6 → 453,7
x = (x / uiscale) * scale
y = (y / uiscale) * scale
 
self.carrier:ClearAllPoints()
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
529,7 → 506,7
else
(self.carrier and self.carrier or self):SetAlpha(self.currentAlpha)
end
 
 
-- call delayed updates
if self.elapsed > 1 then
self.elapsed = 0
560,6 → 537,11
 
-- Name text colour
self:SetNameColour()
 
if self.cp then
-- combo points
self.cp:Update()
end
end
 
-- stuff that needs to be updated often
689,8 → 671,7
 
function ns.f:InitFrame(frame)
frame.init = true
frame.fontObjects = {}
 
 
local overlayChild, nameTextChild = frame:GetChildren()
local healthBar, castBar = overlayChild:GetChildren()
 
732,11 → 713,10
 
frame.oldName = nameTextRegion
frame.oldName:Hide()
 
 
frame.oldHighlight = highlightRegion
 
--------------------------------------------------------- Frame functions --
frame.CreateFontString = CreateFontString
frame.UpdateFrame = UpdateFrame
frame.UpdateFrameCritical = UpdateFrameCritical
frame.SetHealthColour = SetHealthColour
751,10 → 731,7
frame.carrier:SetFrameStrata('BACKGROUND')
frame.carrier:SetSize(frame:GetWidth()/uiscale, frame:GetHeight()/uiscale)
frame.carrier:SetScale(uiscale)
 
frame.carrier:SetPoint('CENTER', UIParent)
frame.carrier:Hide()
 
 
-- [debug]
if _G['KuiNameplatesDebug'] then
frame.carrier:SetBackdrop({ bgFile = kui.m.t.solid })
773,8 → 750,8
local w,h = parent:GetSize()
local x,y
 
x = floor((w / 2) - (kn.sizes.width / 2))
y = floor((h / 2) - (kn.sizes.height / 2))
x = floor((w / 2) - (sizes.width / 2))
y = floor((h / 2) - (sizes.height / 2))
 
-- border ------------------------------------------------------------------
--frame.bg = (frame.carrier and frame.carrier or frame):CreateTexture(nil, 'BACKGROUND')
789,19 → 766,19
frame.bg.fill:SetVertexColor(0, 0, 0, .8)
frame.bg.fill:SetDrawLayer('ARTWORK', 1) -- (1 sub-layer above .bg)
 
frame.bg.fill:SetSize(kn.sizes.width, kn.sizes.height)
frame.bg.fill:SetSize(sizes.width, sizes.height)
frame.bg.fill:SetPoint('BOTTOMLEFT', x, y)
 
frame.bg:ClearAllPoints()
frame.bg:SetPoint('BOTTOMLEFT', x-kn.sizes.bgOffset, y-kn.sizes.bgOffset)
frame.bg:SetPoint('TOPRIGHT', parent, 'BOTTOMLEFT', x+kn.sizes.width+kn.sizes.bgOffset, y+kn.sizes.height+kn.sizes.bgOffset)
frame.bg:SetPoint('BOTTOMLEFT', x-bgOffset, y-bgOffset)
frame.bg:SetPoint('TOPRIGHT', parent, 'BOTTOMLEFT', x+sizes.width+bgOffset, y+sizes.height+bgOffset)
 
-- health bar --------------------------------------------------------------
frame.health = CreateFrame('StatusBar', nil, parent)
frame.health:SetStatusBarTexture(kui.m.t.bar)
 
frame.health:ClearAllPoints()
frame.health:SetSize(kn.sizes.width-2, kn.sizes.height-2)
frame.health:SetSize(sizes.width-2, sizes.height-2)
frame.health:SetPoint('BOTTOMLEFT', x+1, y+1)
 
if ns.SetValueSmooth then
837,14 → 814,15
end
 
-- health text -------------------------------------------------------------
frame.health.p = frame:CreateFontString(frame.overlay, {
font = kn.font, size = 'large', outline = "OUTLINE" })
frame.health.p = kui.CreateFontString(frame.overlay, {
font = font, size = fontSizes.large, outline = "OUTLINE" })
frame.health.p:SetJustifyH('RIGHT')
 
frame.health.p:SetPoint('BOTTOMRIGHT', frame.health, 'TOPRIGHT', -2, uiscale and -(3/uiscale) or -3)
 
 
if profile.hp.showalt then
frame.health.mo = frame:CreateFontString(frame.overlay, {
font = kn.font, size = 'small', outline = "OUTLINE" })
frame.health.mo = kui.CreateFontString(frame.overlay, {
font = font, size = fontSizes.small, outline = "OUTLINE" })
frame.health.mo:SetJustifyH('RIGHT')
 
frame.health.mo:SetPoint('BOTTOMRIGHT', frame.health, -2, uiscale and -(3/uiscale) or -3)
853,8 → 831,8
 
if profile.text.level then
-- level text ----------------------------------------------------------
frame.level = frame:CreateFontString(frame.level, { reset = true,
font = kn.font, size = 'name', outline = 'OUTLINE' })
frame.level = kui.CreateFontString(frame.level, { reset = true,
font = font, size = fontSizes.name, outline = 'OUTLINE' })
frame.level:SetParent(frame.overlay)
 
frame.level:ClearAllPoints()
865,12 → 843,12
end
 
-- name text ---------------------------------------------------------------
frame.name = frame:CreateFontString(frame.overlay, {
font = kn.font, size = 'name', outline = 'OUTLINE' })
frame.name = kui.CreateFontString(frame.overlay, {
font = font, size = fontSizes.name, outline = 'OUTLINE' })
frame.name:SetJustifyH('LEFT')
 
frame.name:SetHeight(13)
 
 
if frame.level.enabled then
frame.name:SetPoint('LEFT', frame.level, 'RIGHT', -2, 0)
else
878,7 → 856,16
end
 
frame.name:SetPoint('RIGHT', frame.health.p, 'LEFT')
 
 
-- combo point text --------------------------------------------------------
if profile.general.combopoints then
frame.cp = kui.CreateFontString(frame.health,
{ font = font, size = fontSizes.combopoints, outline = 'OUTLINE', shadow = true })
frame.cp:SetPoint('LEFT', frame.health, 'RIGHT', 5, 1)
 
frame.cp.Update = ComboPointsUpdate
end
 
----------------------------------------------------------------- Scripts --
frame:SetScript('OnShow', OnFrameShow)
frame:SetScript('OnHide', OnFrameHide)
891,16 → 878,16
frame:SetBackdrop({bgFile=kui.m.t.solid})
frame:SetBackdropColor(1, 1, 1, .5)
 
frame.isfriend = frame:CreateFontString(frame, {
font = kn.font, size = 10, outline = 'OUTLINE' })
frame.isfriend = kui.CreateFontString(frame, {
font = font, size = 10, outline = 'OUTLINE' })
frame.isfriend:SetPoint('BOTTOM', frame, 'TOP')
 
frame.guidtext = frame:CreateFontString(frame, {
font = kn.font, size = 10, outline = "OUTLINE" })
frame.guidtext = kui.CreateFontString(frame, {
font = font, size = 10, outline = "OUTLINE" })
frame.guidtext:SetPoint('TOP', frame, 'BOTTOM')
 
frame.nametext = frame:CreateFontString(frame, {
font = kn.font, size = 10, outline = "OUTLINE" })
frame.nametext = kui.CreateFontString(frame, {
font = font, size = 10, outline = "OUTLINE" })
frame.nametext:SetPoint('TOP', frame.guidtext, 'BOTTOM')
end
 
917,6 → 904,25
end
 
---------------------------------------------------------------------- Events --
function ns.f:UNIT_COMBO_POINTS()
local target = UnitGUID('target')
if not target or not loadedGUIDs[target] then return end
target = loadedGUIDs[target]
 
if target.cp then
target.cp.points = GetComboPoints('player', 'target')
target.cp:Update()
end
 
-- clear points on other frames
for guid, frame in pairs(loadedGUIDs) do
if frame.cp and guid ~= target.guid then
frame.cp.points = nil
frame.cp:Update()
end
end
end
 
function ns.f:PLAYER_TARGET_CHANGED()
targetExists = UnitExists('target')
end
951,7 → 957,6
f = select(i, WorldFrame:GetChildren())
if self:IsNameplate(f) and not f.init then
self:InitFrame(f)
tinsert(kn.frameList, f)
end
end
 
975,103 → 980,67
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
function ns.ToggleComboPoints(io)
if io then
ns.f:RegisterEvent('UNIT_COMBO_POINTS')
else
ns.f:UnregisterEvent('UNIT_COMBO_POINTS')
end
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
-------------------------------------------------- Listen for profile changes --
function ns:ProfileChanged()
profile = self.db.profile
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
-------------------------------------------------------------------- Finalise --
function ns:OnEnable()
profile = self.db.profile
KuiNameplates.profile = profile
 
kn.updateFunctions.fontscale = function(frame, val, runonce)
if runonce == 0 then
ns:ScaleFonts()
KuiNameplates.sizes, KuiNameplates.fontSizes = {
-- frame
width = 110,
height = 11,
twidth = 55,
theight= 7,
-- cast bar stuff
cbheight = 14,
icon = 16,
}, {
combopoints = 13,
large = 10,
spellname = 9,
name = 9,
small = 8,
}
 
sizes, fontSizes = KuiNameplates.sizes, KuiNameplates.fontSizes
 
for k,size in pairs(fontSizes) do
fontSizes[k] = size * profile.general.fontscale
end
 
local _, fontObject
for _, fontObject in pairs(frame.fontObjects) do
if type(fontObject.size) == 'string' then
SetFontSize(fontObject, kn.fontSizes[fontObject.size])
end
end
end
 
kn.updateFunctions.font = function(frame, val, runonce)
val = LSM:Fetch(LSM.MediaType.FONT, val)
if profile.general.fixaa then
uiscale, origSizes, origFontSizes =
UIParent:GetEffectiveScale(), sizes, fontSizes
 
if runonce == 0 then
kn.font = val
end
bgOffset = 5
origSizes.cbheight = 12
 
local _, fontObject
for _, fontObject in pairs(frame.fontObjects) do
local _, size, flags = fontObject:GetFont()
fontObject:SetFont(val, size, flags)
end
end
-- scale sizes up to "unscaled" values
for k,size in pairs(origSizes) do
sizes[k] = floor(size/uiscale)
end
 
-------------------------------------------------------------------- Finalise --
-- [initialise and] scale frame sizes
function ns:ScaleFrames()
for k, size in pairs(defaultSizes.frame) do
kn.sizes[k] = (uiscale and floor(size/uiscale) or size)
end
end
 
-- [initialise and] scale font sizes
function ns:ScaleFonts()
for k, size in pairs(defaultSizes.font) do
kn.fontSizes[k] = size * profile.fontoptions.fontscale
 
if uiscale then
kn.fontSizes[k] = kn.fontSizes[k] / uiscale
for k,size in pairs(origFontSizes) do
fontSizes[k] = size/uiscale
end
end
end
 
function ns:OnEnable()
kn.profile = self.db.profile
profile = kn.profile
 
if profile.general.fixaa then
uiscale = UIParent:GetEffectiveScale()
end
 
self:ScaleFrames()
self:ScaleFonts()
 
-- fetch font path from lsm
kn.font = LSM:Fetch(LSM.MediaType.FONT, profile.fontoptions.font)
KuiNameplates.font = LSM:Fetch(LSM.MediaType.FONT, profile.general.font)
font = KuiNameplates.font
 
-------------------------------------- Health bar smooth update functions --
-- (spoon-fed by oUF_Smooth)
1121,14 → 1090,12
if profile.castbar.warnings and modules.warnings then
modules.warnings:Enable()
end
if profile.general.combopoints and modules.combopoints then
modules.combopoints:Enable()
end
 
 
ns.f:SetScript('OnUpdate', self.OnUpdate)
ns.f:SetScript('OnEvent', self.OnEvent)
 
ns.f:RegisterEvent('PLAYER_TARGET_CHANGED')
 
self.ToggleCombatEvents(profile.general.combat)
self.ToggleComboPoints(profile.general.combopoints)
end
Kui_Nameplates/custom-rename-me.lua
20,13 → 20,7
-- Place code to be performed after a frame is hidden here.
end
 
---------------------------------------------------------------------- Target --
local function 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)
\ No newline at end of file +kn.RegisterPostFunction('hide', PostHide) \ No newline at end of file
Kui_Nameplates/castbar.lua
12,8 → 12,7
['UNIT_SPELLCAST_CHANNEL_STOP'] = true
}
 
local UnitGUID, GetUnitName, UnitChannelInfo, UnitCastingInfo, GetTime, format =
UnitGUID, GetUnitName, UnitChannelInfo, UnitCastingInfo, GetTime, format
local GetNameplate = KuiNameplates.GetNameplate
 
------------------------------------------------------------- Script handlers --
local function OnCastbarUpdate(bar, elapsed)
23,65 → 22,69
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))
if not bar.duration or
((not bar.channel and bar.progress >= bar.duration) or
(bar.channel and bar.progress <= 0))
then
-- hide the castbar
bar:Hide()
-- hide the castbar bg
bar:GetParent():Hide()
bar.progress = 0
return
end
 
-- display progress
if bar.max then
bar.curr:SetText(format("%.1f", bar.progress))
bar.curr:SetText(string.format("%.1f", bar.progress))
 
if bar.delay == 0 or not bar.delay then
bar.max:SetText(format("%.1f", bar.duration))
bar.max:SetText(string.format("%.1f", bar.duration))
else
-- display delay
if bar.channel then
-- time is removed
bar.max:SetText(format("%.1f", bar.duration)..
'|cffff0000-'..format("%.1f", bar.delay)..'|r')
bar.max:SetText(string.format("%.1f", bar.duration)..
'|cffff0000-'..string.format("%.1f", bar.delay)..'|r')
else
-- time is added
bar.max:SetText(format("%.1f", bar.duration)..
'|cffff0000+'..format("%.1f", bar.delay)..'|r')
bar.max:SetText(string.format("%.1f", bar.duration)..
'|cffff0000+'..string.format("%.1f", bar.delay)..'|r')
end
end
end
 
bar.bar:SetValue(bar.progress/bar.duration)
bar:SetValue(bar.progress/bar.duration)
end
 
---------------------------------------------------------------------- create --
cb.CreateCastbar = function(frame)
-- container ---------------------------------------------------------------
frame.castbar = CreateFrame('Frame', nil, frame.parent)
frame.castbar:Hide()
 
-- background --------------------------------------------------------------
frame.castbar.bg = frame.castbar:CreateTexture(nil, 'BACKGROUND')
frame.castbar.bg:SetTexture(kui.m.t.solid)
frame.castbar.bg:SetVertexColor(0, 0, 0, .85)
-- 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.castbar.bg:SetHeight(kn.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.castbarbg:SetBackdropColor(0, 0, 0, .85)
frame.castbarbg:SetBackdropBorderColor(1, .2, .1, 0)
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)
 
frame.castbarbg:Hide()
 
-- cast bar ------------------------------------------------------------
frame.castbar.bar = CreateFrame("StatusBar", nil, frame.castbar)
frame.castbar.bar:SetStatusBarTexture(kui.m.t.bar)
frame.castbar = CreateFrame("StatusBar", nil, frame.castbarbg)
frame.castbar:SetStatusBarTexture(kui.m.t.bar)
 
frame.castbar.bar:SetPoint('TOPLEFT', frame.castbar.bg, 'TOPLEFT', 1, -1)
frame.castbar.bar:SetPoint('BOTTOMLEFT', frame.castbar.bg, 'BOTTOMLEFT', 1, 1)
frame.castbar.bar:SetPoint('RIGHT', frame.castbar.bg, 'RIGHT', -1, 0)
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.bar:SetFrameLevel(2)
frame.castbar.bar:SetMinMaxValues(0, 1)
frame.castbar:SetMinMaxValues(0, 1)
 
-- uninterruptible cast shield -----------------------------------------
frame.castbar.shield = frame.castbar:CreateTexture(nil, 'ARTWORK')
89,7 → 92,7
frame.castbar.shield:SetTexCoord(0, .53125, 0, .6875)
 
frame.castbar.shield:SetSize(12, 17)
frame.castbar.shield:SetPoint('CENTER', frame.castbar.bg, 0, 1)
frame.castbar.shield:SetPoint('CENTER', frame.castbar, 0, 1)
 
frame.castbar.shield:SetBlendMode('BLEND')
frame.castbar.shield:SetDrawLayer('ARTWORK', 7)
99,29 → 102,25
 
-- cast bar text -------------------------------------------------------
if kn.profile.castbar.spellname then
frame.castbar.name = frame:CreateFontString(frame.castbar, {
font = kn.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')
frame.castbar.name = kui.CreateFontString(frame.castbar, {
font = kn.font, size = kn.fontSizes.name, outline = "OUTLINE" })
frame.castbar.name:SetPoint('TOPLEFT', frame.castbar, 'BOTTOMLEFT', 2, -2)
end
 
if kn.profile.castbar.casttime then
frame.castbar.max = frame:CreateFontString(frame.castbar, {
font = kn.font, size = 'name', outline = "OUTLINE" })
frame.castbar.max:SetPoint('TOPRIGHT', frame.castbar.bg, 'BOTTOMRIGHT', -2, -1)
frame.castbar.max = kui.CreateFontString(frame.castbar, {
font = kn.font, size = kn.fontSizes.name, outline = "OUTLINE" })
frame.castbar.max:SetPoint('TOPRIGHT', frame.castbar, 'BOTTOMRIGHT', -2, -1)
 
frame.castbar.curr = frame:CreateFontString(frame.castbar, {
font = kn.font, size = 'small', outline = "OUTLINE" })
frame.castbar.curr = kui.CreateFontString(frame.castbar, {
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)
 
frame.castbar.name:SetPoint('TOPRIGHT', frame.castbar.curr, 'TOPLEFT', -1, 0)
end
 
if frame.spell then
-- cast bar icon background ----------------------------------------
frame.spellbg = frame.castbar:CreateTexture(nil, 'BACKGROUND')
frame.spellbg = frame.castbarbg:CreateTexture(nil, 'BACKGROUND')
frame.spellbg:SetTexture(kui.m.t.solid)
frame.spellbg:SetSize(kn.sizes.icon, kn.sizes.icon)
 
131,7 → 130,7
 
-- cast bar icon ---------------------------------------------------
frame.spell:ClearAllPoints()
frame.spell:SetParent(frame.castbar)
frame.spell:SetParent(frame.castbarbg)
frame.spell:SetSize(kn.sizes.icon - 2, kn.sizes.icon - 2)
 
frame.spell:SetPoint('TOPRIGHT', frame.spellbg, -1, -1)
142,10 → 141,12
-- scripts -------------------------------------------------------------
frame.castbar:HookScript('OnShow', function(bar)
if bar.interruptible then
bar.bar:SetStatusBarColor(unpack(kn.profile.castbar.barcolour))
bar:SetStatusBarColor(unpack(kn.profile.castbar.barcolour))
bar:GetParent():SetBackdropBorderColor(0, 0, 0, .3)
bar.shield:Hide()
else
bar.bar:SetStatusBarColor(.8, .1, .1)
bar:SetStatusBarColor(.8, .1, .1)
bar:GetParent():SetBackdropBorderColor(1, .1, .2, .5)
bar.shield:Show()
end
end)
157,7 → 158,7
if frame.castbar then
frame.castbar.duration = nil
frame.castbar.id = nil
frame.castbar:Hide()
frame.castbarbg:Hide()
end
end
-------------------------------------------------------------- Event handlers --
202,7 → 203,7
end
 
if not name then
frame.castbar:Hide()
frame.castbarbg:Hide()
return
end
 
226,7 → 227,7
castbar.progress = GetTime() - (startTime/1000)
end
 
frame.castbar:Show()
frame.castbarbg:Show()
end
 
function cb:UNIT_SPELLCAST_DELAYED(frame, unit, channel)
262,16 → 263,16
end
 
function cb:UNIT_SPELLCAST_STOP(frame, unit)
frame.castbar:Hide()
frame.castbarbg:Hide()
end
function cb:UNIT_SPELLCAST_FAILED(frame, unit)
frame.castbar:Hide()
frame.castbarbg:Hide()
end
function cb:UNIT_SPELLCAST_INTERRUPTED(frame, unit)
frame.castbar:Hide()
frame.castbarbg:Hide()
end
function cb:UNIT_SPELLCAST_CHANNEL_STOP(frame, unit)
frame.castbar:Hide()
frame.castbarbg:Hide()
end
 
function cb.IsCasting(frame)
Kui_Nameplates/castwarnings.lua
62,11 → 62,11
-- fetch the spell's target's nameplate
guid, name = targetGUID, targetName
end
 
 
-- [[debug]]
--guid, name = UnitGUID('target'), GetUnitName('target')
 
local f = kn.f:GetNameplate(guid, name:gsub('%-.+$', ''))
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, ...)
91,8 → 91,8
---------------------------------------------------------------------- Create --
cw.CreateCastWarnings = function(frame)
-- casting spell name
frame.castWarning = frame:CreateFontString(frame.overlay, {
font = kn.font, size = 'spellname', outline = 'OUTLINE' })
frame.castWarning = kui.CreateFontString(frame.overlay, {
font = kn.font, size = kn.fontSizes.spellname, outline = 'OUTLINE' })
frame.castWarning:SetPoint('BOTTOMLEFT', frame.level, 'TOPLEFT', 0, 1)
frame.castWarning:Hide()
 
111,8 → 111,8
end)
 
-- incoming healing
frame.incWarning = frame:CreateFontString(frame.overlay, {
font = kn.font, size = 'small', outline = 'OUTLINE' })
frame.incWarning = kui.CreateFontString(frame.overlay, {
font = kn.font, size = kn.fontSizes.small, outline = 'OUTLINE' })
frame.incWarning:SetPoint('BOTTOMRIGHT', frame.health.p, 'TOPRIGHT', 1)
frame.incWarning:Hide()
 
Kui_Nameplates/Kui_Nameplates.toc
2,7 → 2,7
## Author: Kesava
## Title: |cff9900ffKui|r Nameplates
## Notes: Prettier, lightweight, configurable nameplates.
## SavedVariables: KuiNameplatesDB
## SavedVariables: KuiNameplatesGDB
 
lib\embeds.xml
 
12,6 → 12,5
 
castbar.lua
castwarnings.lua
combopoints.lua
 
custom.lua
\ No newline at end of file
Kui_Nameplates/config.lua
1,6 → 1,5
local addon, ns = ...
local kui = LibStub('Kui-1.0')
local kn = KuiNameplates
 
------------------------------------------------------------------ Ace config --
local AceConfig = LibStub('AceConfig-3.0')
47,10 → 46,26
},
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',
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 = 4
},
font = {
name = 'Font',
desc = 'The font used for all text on frames',
type = 'select',
dialogControl = 'LSM30_Font',
values = AceGUIWidgetLSMlists.font,
order = 5
},
fontscale = {
name = 'Font scale',
desc = 'The scale of all fonts displayed on nameplates',
type = 'range',
min = 0.01,
softMax = 2,
order = 6
}
}
},
fade = {
269,86 → 284,6
}
}
 
local fontsOptions = {
name = 'Fonts',
handler = handler,
type = 'group',
get = 'Get',
set = 'Set',
args = {
fontoptions = {
name = 'Global font settings',
type = 'group',
inline = true,
args = {
font = {
name = 'Font',
desc = 'The font used for all text on nameplates',
type = 'select',
dialogControl = 'LSM30_Font',
values = AceGUIWidgetLSMlists.font,
},
fontscale = {
name = 'Font scale',
desc = 'The scale of all fonts displayed on nameplates',
type = 'range',
min = 0.01,
softMax = 2,
},
outline = {
name = 'Outline',
desc = 'Dsiplay an outline on all fonts',
type = 'toggle',
},
monochrome = {
name = 'Monochrome',
desc = 'Don\'t anti-alias fonts',
type = 'toggle'
},
}
},
fontsizes = {
name = 'Sizes',
type = 'group',
inline = true,
args = {
combopoints = {
name = 'Combo points',
type = 'range',
min = 1,
softMax = 20
},
large = {
name = 'Large',
desc = 'Used for health on normal nameplates',
type = 'range',
min = 1,
softMax = 20
},
spellname = {
name = 'Spell name',
type = 'range',
min = 1,
softMax = 20
},
name = {
name = 'Name & level',
type = 'range',
min = 1,
softMax = 20
},
small = {
name = 'Small',
desc = 'Used for contextual health on normal nameplates and name on trivial nameplates',
type = 'range',
min = 1,
softMax = 20
},
}
}
}
}
 
function handler:Get(info)
local k = ns.db.profile[info[1]][info[#info]]
 
365,16 → 300,10
else
ns.db.profile[info[1]][info[#info]] = val
end
 
--print(info[#info])
kn.updateFunctions.Call(info[#info], val)
end
 
AceConfig:RegisterOptionsTable('kuinameplates', options)
AceConfigDialog:AddToBlizOptions('kuinameplates', 'Kui Nameplates')
 
AceConfig:RegisterOptionsTable('kuinameplatesfonts', fontsOptions)
AceConfigDialog:AddToBlizOptions('kuinameplatesfonts', 'Fonts', 'Kui Nameplates')
end
 
--------------------------------------------------------------- Slash command --
Kui_Nameplates/core.lua
6,8 → 6,6
local kui = LibStub('Kui-1.0')
local LSM = LibStub('LibSharedMedia-3.0')
 
KuiNameplates = {}
 
LibStub('AceAddon-3.0'):NewAddon(ns, 'KuiNameplates')
 
-- add yanone kaffesatz and accidental presidency to LSM (only supports latin)
26,6 → 24,8
highlight = true, -- highlight plates on mouse-over
combopoints = true, -- display combo points
fixaa = true, -- attempt to make plates appear sharper (with some drawbacks)
font = (latin and 'Yanone Kaffesatz' or LSM:GetDefault(LSM.MediaType.FONT)), -- the font used for all text
fontscale = 1.0, -- the scale of all displayed font sizes
},
fade = {
smooth = true, -- smoothy fade plates (fading is instant if disabled)
59,27 → 59,14
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
usenames = false -- 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.
},
fontoptions = {
font = (latin and 'Yanone Kaffesatz' or LSM:GetDefault(LSM.MediaType.FONT)),
fontscale = 1.0,
outline = true,
monochrome = false,
},
fontsizes = {
combopoints = 13,
large = 10,
spellname = 9,
name = 9,
small = 8
},
}
}
 
------------------------------------------------------------------------ init --
function ns:OnInitialize()
self.db = LibStub('AceDB-3.0'):New('KuiNameplatesDB', defaults)
self.db = LibStub('AceDB-3.0'):New('KuiNameplatesGDB', defaults)
 
LibStub('AceConfig-3.0'):RegisterOptionsTable('kuinameplates-profiles', LibStub('AceDBOptions-3.0'):GetOptionsTable(self.db))
LibStub('AceConfigDialog-3.0'):AddToBlizOptions('kuinameplates-profiles', 'Profiles', 'Kui Nameplates')