WoWInterface SVN KuiNameplates

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /branches
    from Rev 142 to Rev 143
    Reverse comparison

Rev 142 → Rev 143

v4/castwarnings.lua
101,7 → 101,7
function mod:CreateCastWarnings(msg, frame)
-- casting spell name
frame.castWarning = frame:CreateFontString(frame.overlay, {
font = addon.font, size = 'spellname', outline = 'OUTLINE' })
size = 'spellname', outline = 'OUTLINE' })
frame.castWarning:SetPoint('BOTTOMLEFT', frame.level, 'TOPLEFT', 0, 1)
frame.castWarning:Hide()
 
121,7 → 121,7
 
-- incoming healing
frame.incWarning = frame:CreateFontString(frame.overlay, {
font = addon.font, size = 'small', outline = 'OUTLINE' })
size = 'small', outline = 'OUTLINE' })
frame.incWarning:SetPoint('BOTTOMRIGHT', frame.health.p, 'TOPRIGHT', 1)
frame.incWarning:Hide()
 
v4/create.lua
59,7 → 59,7
 
----------------------------------------------------------------- Health text --
function addon:CreateHealthText(frame)
frame.health.p = addon.CreateFontString(frame, frame.overlay, {
frame.health.p = frame:CreateFontString(frame.overlay, {
font = addon.font, size = 'large', outline = "OUTLINE" })
frame.health.p:SetJustifyH('RIGHT')
frame.health.p:SetPoint('BOTTOMRIGHT', frame.health, 'TOPRIGHT',
75,7 → 75,7
 
------------------------------------------------------------- Alt health text --
function addon:CreateAltHealthText(frame)
frame.health.mo = addon.CreateFontString(frame, frame.overlay, {
frame.health.mo = frame:CreateFontString(frame.overlay, {
font = addon.font, size = 'small', outline = "OUTLINE" })
frame.health.mo:SetJustifyH('RIGHT')
frame.health.mo:SetPoint('BOTTOMRIGHT', frame.health,
97,7 → 97,7
function addon:CreateLevel(frame)
if not frame.level then return end
 
frame.level = addon.CreateFontString(frame, frame.level, { reset = true,
frame.level = frame:CreateFontString(frame.level, { reset = true,
font = addon.font, size = 'name', outline = 'OUTLINE' })
frame.level:SetParent(frame.overlay)
 
122,7 → 122,7
 
------------------------------------------------------------------- Name text --
function addon:CreateName(frame)
frame.name = addon.CreateFontString(frame, frame.overlay, {
frame.name = frame:CreateFontString(frame.overlay, {
font = addon.font, size = 'name', outline = 'OUTLINE' })
frame.name:SetHeight(13)
 
v4/config.lua
190,14 → 190,9
name = 'Smooth health bar',
desc = 'Smoothly animate health bar value updates',
type = 'toggle',
width = 'double',
order = 3
},
tapped = {
name = 'Use tapped colour',
desc = 'Give tapped units a grey health bar',
type = 'toggle',
order = 4
},
friendly = {
name = 'Friendly health format',
desc = 'The health display pattern for friendly units',
264,18 → 259,18
softMax = 2,
},
outline = {
name = 'NYI Outline',
desc = 'Dsiplay an outline on all fonts [NYI doesn\'t reapply]',
name = 'Outline',
desc = 'Display an outline on all fonts',
type = 'toggle',
},
monochrome = {
name = 'NYI Monochrome',
desc = 'Don\'t anti-alias fonts. [NYI doesn\'t reapply]',
name = 'Monochrome',
desc = 'Don\'t anti-alias fonts',
type = 'toggle'
},
onesize = {
name = 'NYI Use one font size',
desc = 'Use the same font size for all strings. Useful if using a pixel font',
name = 'Use one font size',
desc = 'Use the same font size for all strings. Useful when using a pixel font.',
type = 'toggle'
},
}
v4/lib/Kui/main.lua
1,4 → 1,4
local MAJOR, MINOR = 'Kui-1.0', 3
local MAJOR, MINOR = 'Kui-1.0', 4
local kui = LibStub:NewLibrary(MAJOR, MINOR)
 
if not kui then
105,6 → 105,21
return level, classification, diff
end
 
kui.ModifyFontFlags = function(fs, io, flag)
local font, size, flags = fs:GetFont()
local flagStart,flagEnd = strfind(flags, flag)
 
if io and not flagStart then
-- add flag
flags = flags..' '..flag
elseif not val and flagStart then
-- remove flag
flags = strsub(flags, 0, flagStart-1) .. strsub(flags, flagEnd+1)
end
 
fs:SetFont(font, size, flags)
end
 
kui.CreateFontString = function(parent, args)
local ob, font, size, outline, alpha, shadow
args = args or {}
119,12 → 134,16
font = args.font or NAMEPLATE_FONT
size = args.size or 12
outline = args.outline or nil
mono = args.mono or args.monochrome or nil
alpha = args.alpha or 1
shadow = args.shadow or false
 
ob:SetFont(font, size, outline)
 
ob:SetFont(font, size)
ob:SetAlpha(alpha)
 
kui.ModifyFontFlags(ob, outline, 'OUTLINE')
kui.ModifyFontFlags(ob, mono, 'MONOCHROME')
 
if shadow then
ob:SetShadowColor(0, 0, 0, 1)
ob:SetShadowOffset(type(shadow) == 'table' and unpack(shadow) or 1, -1)
v4/core.lua
44,7 → 44,6
hostile = '<:p;', -- health display pattern for hostile/neutral units
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
},
fonts = {
v4/layout.lua
25,15 → 25,13
}
 
-- sizes of frame elements
local defaultSizes = {
kn.defaultSizes = {
frame = {
width = 110,
height = 11,
twidth = 55,
theight = 7,
cbheight = 4,
bgOffset = 4, -- inset offset for the frame glow (frame.bg)
icon = 16
bgOffset = 4 -- inset offset for the frame glow (frame.bg)
},
font = {
combopoints = 13,
55,6 → 53,10
------------------------------------------------------------ helper functions --
 
local function SetFontSize(fs, size)
if profile.fonts.options.onesize then
size = kn.fontSizes['name']
end
 
if type(size) == 'string' and fs.size and kn.fontSizes[size] then
fs.size = size
size = kn.fontSizes[size]
64,28 → 66,25
fs:SetFont(font, size, flags)
end
 
local function ModifyFontFlags(fs, io, flag)
local font, size, flags = fs:GetFont()
local flagStart,flagEnd = strfind(flags, flag)
local function CreateFontString(self, parent, obj)
-- store size as a key of kn.fontSizes so that it can be recalled & scaled
-- correctly. Used by SetFontSize.
local sizeKey
 
obj.mono = profile.fonts.options.monochrome
obj.outline = profile.fonts.options.outline
 
if io and not flagStart then
-- add flag
flags = flags..' '..flag
elseif not val and flagStart then
-- remove flag
flags = strsub(flags, 0, flagStart-1) .. strsub(flags, flagEnd+1)
if type(obj.size) == 'string' then
sizeKey = obj.size
obj.size = kn.fontSizes[sizeKey]
end
 
fs:SetFont(font, size, flags)
end
if profile.fonts.options.onesize then
obj.size = kn.fontSizes['name']
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]
if not obj.font then
obj.font = kn.font
end
 
local fs = kui.CreateFontString(parent, obj)
99,7 → 98,6
end
 
kn.SetFontSize = SetFontSize
kn.ModifyFontFlags = ModifyFontFlags
kn.CreateFontString = CreateFontString
 
------------------------------------------------------------- Frame functions --
138,13 → 136,7
r, g, b = unpack(kn.r[2])
elseif b > .9 and (r+g) > 1.06 and (r+g) < 1.1 then
-- tapped NPC
if profile.hp.tapped then
-- use grey...
r, g, b = unpack(kn.r[4])
else
-- or don't change
return
end
r, g, b = unpack(kn.r[4])
else
-- enemy player, use default UI colour
self.player = true
909,14 → 901,14
kn.configChangedFuncs.outline = function(frame, val)
local _, fontObject
for _, fontObject in pairs(frame.fontObjects) do
ModifyFontFlags(fontObject, val, 'OUTLINE')
kui.ModifyFontFlags(fontObject, val, 'OUTLINE')
end
end
 
kn.configChangedFuncs.monochrome = function(frame, val)
local _, fontObject
for _, fontObject in pairs(frame.fontObjects) do
ModifyFontFlags(fontObject, val, 'MONOCHROME')
kui.ModifyFontFlags(fontObject, val, 'MONOCHROME')
end
end
 
928,6 → 920,7
end
end
end
kn.configChangedFuncs.onesize = kn.configChangedFuncs.fontscale
 
kn.configChangedFuncs.Health = function(frame)
if frame:IsShown() then
950,26 → 943,51
end
 
-------------------------------------------------------------------- Finalise --
-- scale a frame/font size to keep it relatively the same with any uiscale
function ScaleFrameSize(key)
local size = kn.defaultSizes.frame[key]
kn.sizes[key] = (uiscale and floor(size/uiscale) or size)
end
 
function ScaleFontSize(key)
local size = kn.defaultSizes.font[key]
kn.fontSizes[key] = size * profile.fonts.options.fontscale
 
if uiscale then
kn.fontSizes[key] = kn.fontSizes[key] / uiscale
end
end
 
-- [initialise and] scale frame sizes
function kn:ScaleFrameSizes()
local k, size
for k, size in pairs(defaultSizes.frame) do
self.sizes[k] = (uiscale and floor(size/uiscale) or size)
local k,_
for k,_ in pairs(kn.defaultSizes.frame) do
ScaleFrameSize(k)
end
end
 
-- [initialise and] scale font sizes
function kn:ScaleFontSizes()
local k, size
for k, size in pairs(defaultSizes.font) do
self.fontSizes[k] = size * profile.fonts.options.fontscale
 
if uiscale then
self.fontSizes[k] = self.fontSizes[k] / uiscale
end
local k,_
for k,_ in pairs(kn.defaultSizes.font) do
ScaleFontSize(k)
end
end
 
-- modules must use this to add correctly scaled sizes
-- font sizes can then be called as a key in kn.CreateFontString
function kn:RegisterSize(type, key, size)
if type ~= 'frame' and type ~= 'font' then return end
 
kn.defaultSizes[type][key] = size
 
if type == 'frame' then
ScaleFrameSize(key)
else
ScaleFontSize(key)
end
end
 
function kn:OnEnable()
profile = self.db.profile
 
v4/castbar.lua
103,7 → 103,7
-- cast bar text -------------------------------------------------------
if self.db.profile.display.spellname then
frame.castbar.name = frame:CreateFontString(frame.castbar, {
font = addon.font, size = 'name', outline = "OUTLINE" })
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')
111,11 → 111,11
 
if self.db.profile.display.casttime then
frame.castbar.max = frame:CreateFontString(frame.castbar, {
font = addon.font, size = 'name', outline = "OUTLINE" })
size = 'name', outline = "OUTLINE" })
frame.castbar.max:SetPoint('TOPRIGHT', frame.castbar.bg, 'BOTTOMRIGHT', -2, -1)
 
frame.castbar.curr = frame:CreateFontString(frame.castbar, {
font = addon.font, size = 'small', outline = "OUTLINE" })
size = 'small', outline = "OUTLINE" })
frame.castbar.curr:SetAlpha(.5)
frame.castbar.curr:SetPoint('TOPRIGHT', frame.castbar.max, 'TOPLEFT', -1, -1)
 
353,16 → 353,26
}
})
 
addon:RegisterSize('frame', 'cbheight', 4)
addon:RegisterSize('frame', 'icon', 16)
 
addon:InitModuleOptions(self)
end
 
function mod:OnEnable()
self:RegisterMessage('create', 'CreateCastbar')
self:RegisterMessage('hide', 'HideCastbar')
self:RegisterMessage('show', 'IsCasting')
self:RegisterMessage('target', 'IsCasting')
 
self:RegisterMessage('KuiNameplates_PostCreate', 'CreateCastbar')
self:RegisterMessage('KuiNameplates_PostHide', 'HideCastbar')
self:RegisterMessage('KuiNameplates_PostShow', 'IsCasting')
self:RegisterMessage('KuiNameplates_PostTarget', 'IsCasting')
 
for event,_ in pairs(castEvents) do
self:RegisterEvent(event, self.UnitCastEvent)
end
 
local _,frame
for _, frame in pairs(addon.frameList) do
if not frame.castbar then
self:CreateCastbar(nil, frame)
end
end
end
\ No newline at end of file