WoWInterface SVN KuiNameplates

Compare Revisions

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

Rev 132 → Rev 128

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)
local f = kn.f:GetNameplate(guid, name:gsub('%-.+$', ''))
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 = kui.CreateFontString(frame.overlay, {
font = kn.font, size = kn.fontSizes.spellname, outline = 'OUTLINE' })
frame.castWarning = frame:CreateFontString(frame.overlay, {
font = kn.font, size = 'spellname', outline = 'OUTLINE' })
frame.castWarning:SetPoint('BOTTOMLEFT', frame.level, 'TOPLEFT', 0, 1)
frame.castWarning:Hide()
 
111,8 → 111,8
end)
 
-- incoming healing
frame.incWarning = kui.CreateFontString(frame.overlay, {
font = kn.font, size = kn.fontSizes.small, outline = 'OUTLINE' })
frame.incWarning = frame:CreateFontString(frame.overlay, {
font = kn.font, size = '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: KuiNameplatesGDB
## SavedVariables: KuiNameplatesDB
 
lib\embeds.xml
 
12,5 → 12,6
 
castbar.lua
castwarnings.lua
combopoints.lua
 
custom.lua
\ No newline at end of file
Kui_Nameplates/config.lua
1,5 → 1,6
local addon, ns = ...
local kui = LibStub('Kui-1.0')
local kn = KuiNameplates
 
------------------------------------------------------------------ Ace config --
local AceConfig = LibStub('AceConfig-3.0')
46,26 → 47,10
},
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.',
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',
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 = {
284,6 → 269,86
}
}
 
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]]
 
300,10 → 365,16
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,6 → 6,8
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)
24,8 → 26,6
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,14 → 59,27
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 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.
usenames = false -- use unit names to display cast warnings
},
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('KuiNameplatesGDB', defaults)
self.db = LibStub('AceDB-3.0'):New('KuiNameplatesDB', 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')
Kui_Nameplates/combopoints.lua New file
0,0 → 1,92
local kui = LibStub('Kui-1.0')
local kn = KuiNameplates
local cp = CreateFrame('Frame')
 
local ComboPointsUpdate = function(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)
 
self:SetText(self.points)
self:SetTextColor(1, 1, blue)
self:Show()
elseif self:GetText() then
self:SetText('')
self:Hide()
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)
 
if f then
if f.cp then
f.cp.points = GetComboPoints(unit, 'target')
f.cp:Update()
end
end
 
-- clear points on other frames
local _, frame
for _, frame in pairs(kn.frameList) do
if frame.cp and frame ~= f then
frame.cp.points = nil
frame.cp:Update()
end
end
end
---------------------------------------------------------------------- Create --
cp.CreateComboPoints = function(frame)
frame.cp = frame:CreateFontString(frame.health, {
font = kn.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()
end
-------------------------------------------------------------------- Register --
kn.updateFunctions.combopoints = function(frame, val, runonce)
if not val then
-- disable
if runonce == 0 then
cp:Disable()
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
 
if not frame.cp then
-- create combo points frame on existing frames
cp.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)
self:UnregisterEvent('UNIT_COMBO_POINTS')
end
 
kn.RegisterModule('combopoints', cp)
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
ns.f = KuiNameplates.f
kn.f = CreateFrame('Frame')
ns.f = kn.f
 
kn.font = ''
kn.fontSizes = {}
kn.sizes = {}
kn.frameList = {}
 
-- Custom reaction colours
ns.r = {
{ .7, .2, .1 }, -- hated
25,22 → 25,65
{ .5, .5, .5 }, -- tapped
}
 
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 = '', {}, {}
-- 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 loadedGUIDs, loadedNames = {}, {}
local targetExists
local profile, uiscale
 
--------------------------------------------------------------------- globals --
local select, strfind, strsplit, pairs, ipairs, unpack
= select, strfind, strsplit, pairs, ipairs, unpack
local select, strfind, strsplit, pairs, ipairs, unpack, tinsert, type
= select, strfind, strsplit, pairs, ipairs, unpack, tinsert, type
 
-- helper for setting a given fontstring's font size
local function SetFontSize(fontstring, size)
local font, _, flags = fontstring:GetFont()
fontstring:SetFont(font, size, flags)
------------------------------------------------------------ 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)
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 = {
163,20 → 206,6
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()
204,8 → 233,10
condition = curr < max
elseif condition == '=' then
condition = curr == max
elseif condition == '<=' then
elseif condition == '<=' or condition == '=<' then
condition = curr <= max
else
condition = nil
end
 
if condition then
236,7 → 267,6
------------------------------------------------------- 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
 
290,8 → 320,8
 
local w,h = self.parent:GetSize()
local x,y =
floor((w / 2) - (sizes.twidth / 2)),
floor((h / 2) - (sizes.theight / 2))
floor((w / 2) - (kn.sizes.twidth / 2)),
floor((h / 2) - (kn.sizes.theight / 2))
 
self.health:ClearAllPoints()
self.bg:ClearAllPoints()
305,21 → 335,20
self.health.mo:Hide()
end
 
SetFontSize(self.name, fontSizes.small)
SetFontSize(self.name, 'small')
self.name:SetJustifyH('CENTER')
 
self.name:SetPoint('BOTTOMLEFT', self.health, 'TOPLEFT', -10, -3)
self.name:SetPoint('BOTTOMRIGHT', self.health, 'TOPRIGHT', 10, -3)
self.name:SetPoint('BOTTOM', self.health, 'TOP', 0, -3)
 
self.bg.fill:SetSize(sizes.twidth, sizes.theight)
self.health:SetSize(sizes.twidth-2, sizes.theight-2)
self.bg.fill:SetSize(kn.sizes.twidth, kn.sizes.theight)
self.health:SetSize(kn.sizes.twidth-2, kn.sizes.theight-2)
 
self.health:SetPoint('BOTTOMLEFT', x+1, y+1)
 
self.bg.fill:SetPoint('BOTTOMLEFT', x, y)
 
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.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.trivial = true
else
334,8 → 363,8
 
local w,h = self.parent:GetSize()
local x,y =
floor((w / 2) - (sizes.width / 2)),
floor((h / 2) - (sizes.height / 2))
floor((w / 2) - (kn.sizes.width / 2)),
floor((h / 2) - (kn.sizes.height / 2))
 
self.health:ClearAllPoints()
self.bg:ClearAllPoints()
348,7 → 377,7
self.health.mo:Show()
end
 
SetFontSize(self.name, fontSizes.name)
SetFontSize(self.name, 'name')
self.name:SetJustifyH('LEFT')
self.name:SetPoint('RIGHT', self.health.p, 'LEFT')
 
359,15 → 388,15
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)
self.bg.fill:SetSize(kn.sizes.width, kn.sizes.height)
self.health:SetSize(kn.sizes.width - 2, kn.sizes.height - 2)
 
self.health:SetPoint('BOTTOMLEFT', x+1, y+1)
 
self.bg.fill:SetPoint('BOTTOMLEFT', x, y)
 
self.bg:SetPoint('BOTTOMLEFT', x-bgOffset, y-bgOffset)
self.bg:SetPoint('TOPRIGHT', self.parent, 'BOTTOMLEFT', x+(sizes.width)+bgOffset, y+(sizes.height)+bgOffset)
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.trivial = nil
end
392,11 → 421,6
-- 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
453,7 → 477,6
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
506,7 → 529,7
else
(self.carrier and self.carrier or self):SetAlpha(self.currentAlpha)
end
 
 
-- call delayed updates
if self.elapsed > 1 then
self.elapsed = 0
537,11 → 560,6
 
-- Name text colour
self:SetNameColour()
 
if self.cp then
-- combo points
self.cp:Update()
end
end
 
-- stuff that needs to be updated often
671,7 → 689,8
 
function ns.f:InitFrame(frame)
frame.init = true
 
frame.fontObjects = {}
 
local overlayChild, nameTextChild = frame:GetChildren()
local healthBar, castBar = overlayChild:GetChildren()
 
713,10 → 732,11
 
frame.oldName = nameTextRegion
frame.oldName:Hide()
 
 
frame.oldHighlight = highlightRegion
 
--------------------------------------------------------- Frame functions --
frame.CreateFontString = CreateFontString
frame.UpdateFrame = UpdateFrame
frame.UpdateFrameCritical = UpdateFrameCritical
frame.SetHealthColour = SetHealthColour
731,7 → 751,10
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 })
750,8 → 773,8
local w,h = parent:GetSize()
local x,y
 
x = floor((w / 2) - (sizes.width / 2))
y = floor((h / 2) - (sizes.height / 2))
x = floor((w / 2) - (kn.sizes.width / 2))
y = floor((h / 2) - (kn.sizes.height / 2))
 
-- border ------------------------------------------------------------------
--frame.bg = (frame.carrier and frame.carrier or frame):CreateTexture(nil, 'BACKGROUND')
766,19 → 789,19
frame.bg.fill:SetVertexColor(0, 0, 0, .8)
frame.bg.fill:SetDrawLayer('ARTWORK', 1) -- (1 sub-layer above .bg)
 
frame.bg.fill:SetSize(sizes.width, sizes.height)
frame.bg.fill:SetSize(kn.sizes.width, kn.sizes.height)
frame.bg.fill:SetPoint('BOTTOMLEFT', x, y)
 
frame.bg:ClearAllPoints()
frame.bg:SetPoint('BOTTOMLEFT', x-bgOffset, y-bgOffset)
frame.bg:SetPoint('TOPRIGHT', parent, 'BOTTOMLEFT', x+sizes.width+bgOffset, y+sizes.height+bgOffset)
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)
 
-- health bar --------------------------------------------------------------
frame.health = CreateFrame('StatusBar', nil, parent)
frame.health:SetStatusBarTexture(kui.m.t.bar)
 
frame.health:ClearAllPoints()
frame.health:SetSize(sizes.width-2, sizes.height-2)
frame.health:SetSize(kn.sizes.width-2, kn.sizes.height-2)
frame.health:SetPoint('BOTTOMLEFT', x+1, y+1)
 
if ns.SetValueSmooth then
814,15 → 837,14
end
 
-- health text -------------------------------------------------------------
frame.health.p = kui.CreateFontString(frame.overlay, {
font = font, size = fontSizes.large, outline = "OUTLINE" })
frame.health.p = frame:CreateFontString(frame.overlay, {
font = kn.font, size = '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 = kui.CreateFontString(frame.overlay, {
font = font, size = fontSizes.small, outline = "OUTLINE" })
frame.health.mo = frame:CreateFontString(frame.overlay, {
font = kn.font, size = 'small', outline = "OUTLINE" })
frame.health.mo:SetJustifyH('RIGHT')
 
frame.health.mo:SetPoint('BOTTOMRIGHT', frame.health, -2, uiscale and -(3/uiscale) or -3)
831,8 → 853,8
 
if profile.text.level then
-- level text ----------------------------------------------------------
frame.level = kui.CreateFontString(frame.level, { reset = true,
font = font, size = fontSizes.name, outline = 'OUTLINE' })
frame.level = frame:CreateFontString(frame.level, { reset = true,
font = kn.font, size = 'name', outline = 'OUTLINE' })
frame.level:SetParent(frame.overlay)
 
frame.level:ClearAllPoints()
843,12 → 865,12
end
 
-- name text ---------------------------------------------------------------
frame.name = kui.CreateFontString(frame.overlay, {
font = font, size = fontSizes.name, outline = 'OUTLINE' })
frame.name = frame:CreateFontString(frame.overlay, {
font = kn.font, size = '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
856,16 → 878,7
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)
878,16 → 891,16
frame:SetBackdrop({bgFile=kui.m.t.solid})
frame:SetBackdropColor(1, 1, 1, .5)
 
frame.isfriend = kui.CreateFontString(frame, {
font = font, size = 10, outline = 'OUTLINE' })
frame.isfriend = frame:CreateFontString(frame, {
font = kn.font, size = 10, outline = 'OUTLINE' })
frame.isfriend:SetPoint('BOTTOM', frame, 'TOP')
 
frame.guidtext = kui.CreateFontString(frame, {
font = font, size = 10, outline = "OUTLINE" })
frame.guidtext = frame:CreateFontString(frame, {
font = kn.font, size = 10, outline = "OUTLINE" })
frame.guidtext:SetPoint('TOP', frame, 'BOTTOM')
 
frame.nametext = kui.CreateFontString(frame, {
font = font, size = 10, outline = "OUTLINE" })
frame.nametext = frame:CreateFontString(frame, {
font = kn.font, size = 10, outline = "OUTLINE" })
frame.nametext:SetPoint('TOP', frame.guidtext, 'BOTTOM')
end
 
904,25 → 917,6
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
957,6 → 951,7
f = select(i, WorldFrame:GetChildren())
if self:IsNameplate(f) and not f.init then
self:InitFrame(f)
tinsert(kn.frameList, f)
end
end
 
980,67 → 975,103
end
end
 
function ns.ToggleComboPoints(io)
if io then
ns.f:RegisterEvent('UNIT_COMBO_POINTS')
else
ns.f:UnregisterEvent('UNIT_COMBO_POINTS')
-------------------------------------------------- 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
end
 
-------------------------------------------------- Listen for profile changes --
function ns:ProfileChanged()
profile = self.db.profile
-- 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
end
 
-------------------------------------------------------------------- Finalise --
function ns:OnEnable()
profile = self.db.profile
KuiNameplates.profile = profile
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
 
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
kn.updateFunctions.fontscale = function(frame, val, runonce)
if runonce == 0 then
ns:ScaleFonts()
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
 
if profile.general.fixaa then
uiscale, origSizes, origFontSizes =
UIParent:GetEffectiveScale(), sizes, fontSizes
kn.updateFunctions.font = function(frame, val, runonce)
val = LSM:Fetch(LSM.MediaType.FONT, val)
 
bgOffset = 5
origSizes.cbheight = 12
if runonce == 0 then
kn.font = val
end
 
-- scale sizes up to "unscaled" values
for k,size in pairs(origSizes) do
sizes[k] = floor(size/uiscale)
end
local _, fontObject
for _, fontObject in pairs(frame.fontObjects) do
local _, size, flags = fontObject:GetFont()
fontObject:SetFont(val, size, flags)
end
end
 
for k,size in pairs(origFontSizes) do
fontSizes[k] = size/uiscale
-------------------------------------------------------------------- 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
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
KuiNameplates.font = LSM:Fetch(LSM.MediaType.FONT, profile.general.font)
font = KuiNameplates.font
kn.font = LSM:Fetch(LSM.MediaType.FONT, profile.fontoptions.font)
 
-------------------------------------- Health bar smooth update functions --
-- (spoon-fed by oUF_Smooth)
1090,12 → 1121,14
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,7 → 20,13
-- 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)
\ No newline at end of file +kn.RegisterPostFunction('hide', PostHide) +kn.RegisterPostFunction('target', PostTarget) \ No newline at end of file
Kui_Nameplates/castbar.lua
12,7 → 12,8
['UNIT_SPELLCAST_CHANNEL_STOP'] = true
}
 
local GetNameplate = KuiNameplates.GetNameplate
local UnitGUID, GetUnitName, UnitChannelInfo, UnitCastingInfo, GetTime, format =
UnitGUID, GetUnitName, UnitChannelInfo, UnitCastingInfo, GetTime, format
 
------------------------------------------------------------- Script handlers --
local function OnCastbarUpdate(bar, elapsed)
22,69 → 23,65
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 bg
bar:GetParent():Hide()
-- hide the castbar
bar:Hide()
bar.progress = 0
return
end
 
-- display progress
if bar.max then
bar.curr:SetText(string.format("%.1f", bar.progress))
bar.curr:SetText(format("%.1f", bar.progress))
 
if bar.delay == 0 or not bar.delay then
bar.max:SetText(string.format("%.1f", bar.duration))
bar.max:SetText(format("%.1f", bar.duration))
else
-- display delay
if bar.channel then
-- time is removed
bar.max:SetText(string.format("%.1f", bar.duration)..
'|cffff0000-'..string.format("%.1f", bar.delay)..'|r')
bar.max:SetText(format("%.1f", bar.duration)..
'|cffff0000-'..format("%.1f", bar.delay)..'|r')
else
-- time is added
bar.max:SetText(string.format("%.1f", bar.duration)..
'|cffff0000+'..string.format("%.1f", bar.delay)..'|r')
bar.max:SetText(format("%.1f", bar.duration)..
'|cffff0000+'..format("%.1f", bar.delay)..'|r')
end
end
end
 
bar:SetValue(bar.progress/bar.duration)
bar.bar:SetValue(bar.progress/bar.duration)
end
 
---------------------------------------------------------------------- create --
cb.CreateCastbar = function(frame)
-- 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
}
})
-- 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)
 
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()
 
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)
 
-- cast bar ------------------------------------------------------------
frame.castbar = CreateFrame("StatusBar", nil, frame.castbarbg)
frame.castbar:SetStatusBarTexture(kui.m.t.bar)
frame.castbar.bar = CreateFrame("StatusBar", nil, frame.castbar)
frame.castbar.bar:SetStatusBarTexture(kui.m.t.bar)
 
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: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:SetMinMaxValues(0, 1)
frame.castbar.bar:SetFrameLevel(2)
frame.castbar.bar:SetMinMaxValues(0, 1)
 
-- uninterruptible cast shield -----------------------------------------
frame.castbar.shield = frame.castbar:CreateTexture(nil, 'ARTWORK')
92,7 → 89,7
frame.castbar.shield:SetTexCoord(0, .53125, 0, .6875)
 
frame.castbar.shield:SetSize(12, 17)
frame.castbar.shield:SetPoint('CENTER', frame.castbar, 0, 1)
frame.castbar.shield:SetPoint('CENTER', frame.castbar.bg, 0, 1)
 
frame.castbar.shield:SetBlendMode('BLEND')
frame.castbar.shield:SetDrawLayer('ARTWORK', 7)
102,25 → 99,29
 
-- cast bar text -------------------------------------------------------
if kn.profile.castbar.spellname then
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)
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')
end
 
if kn.profile.castbar.casttime then
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.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.curr = kui.CreateFontString(frame.castbar, {
font = kn.font, size = kn.fontSizes.small, outline = "OUTLINE" })
frame.castbar.curr = frame:CreateFontString(frame.castbar, {
font = kn.font, size = '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.castbarbg:CreateTexture(nil, 'BACKGROUND')
frame.spellbg = frame.castbar:CreateTexture(nil, 'BACKGROUND')
frame.spellbg:SetTexture(kui.m.t.solid)
frame.spellbg:SetSize(kn.sizes.icon, kn.sizes.icon)
 
130,7 → 131,7
 
-- cast bar icon ---------------------------------------------------
frame.spell:ClearAllPoints()
frame.spell:SetParent(frame.castbarbg)
frame.spell:SetParent(frame.castbar)
frame.spell:SetSize(kn.sizes.icon - 2, kn.sizes.icon - 2)
 
frame.spell:SetPoint('TOPRIGHT', frame.spellbg, -1, -1)
141,12 → 142,10
-- scripts -------------------------------------------------------------
frame.castbar:HookScript('OnShow', function(bar)
if bar.interruptible then
bar:SetStatusBarColor(unpack(kn.profile.castbar.barcolour))
bar:GetParent():SetBackdropBorderColor(0, 0, 0, .3)
bar.bar:SetStatusBarColor(unpack(kn.profile.castbar.barcolour))
bar.shield:Hide()
else
bar:SetStatusBarColor(.8, .1, .1)
bar:GetParent():SetBackdropBorderColor(1, .1, .2, .5)
bar.bar:SetStatusBarColor(.8, .1, .1)
bar.shield:Show()
end
end)
158,7 → 157,7
if frame.castbar then
frame.castbar.duration = nil
frame.castbar.id = nil
frame.castbarbg:Hide()
frame.castbar:Hide()
end
end
-------------------------------------------------------------- Event handlers --
203,7 → 202,7
end
 
if not name then
frame.castbarbg:Hide()
frame.castbar:Hide()
return
end
 
227,7 → 226,7
castbar.progress = GetTime() - (startTime/1000)
end
 
frame.castbarbg:Show()
frame.castbar:Show()
end
 
function cb:UNIT_SPELLCAST_DELAYED(frame, unit, channel)
263,16 → 262,16
end
 
function cb:UNIT_SPELLCAST_STOP(frame, unit)
frame.castbarbg:Hide()
frame.castbar:Hide()
end
function cb:UNIT_SPELLCAST_FAILED(frame, unit)
frame.castbarbg:Hide()
frame.castbar:Hide()
end
function cb:UNIT_SPELLCAST_INTERRUPTED(frame, unit)
frame.castbarbg:Hide()
frame.castbar:Hide()
end
function cb:UNIT_SPELLCAST_CHANNEL_STOP(frame, unit)
frame.castbarbg:Hide()
frame.castbar:Hide()
end
 
function cb.IsCasting(frame)