Commit 6ebc0024 authored by Blazeflack's avatar Blazeflack

Added new name abbreviation tags

[name:abbreviate]
[name:veryshort:abbreviate]
[name:short:abbreviate]
[name:medium:abbreviate]
[name:long:abbreviate]

Reference: #1
parent 52f8b907
......@@ -9,20 +9,21 @@ local _G = _G
local unpack, pairs, assert = unpack, pairs, assert
local twipe = table.wipe
local ceil, sqrt, floor, abs = math.ceil, math.sqrt, math.floor, math.abs
local format, strupper = string.format, strupper
local format, strupper, len = string.format, strupper, string.len
--WoW API
local GetNumGroupMembers = GetNumGroupMembers
local IsInGroup = IsInGroup
local IsInRaid = IsInRaid
local UnitIsUnit = UnitIsUnit
local UnitIsGhost = UnitIsGhost
local UnitIsDead = UnitIsDead
local GetNumGroupMembers = GetNumGroupMembers
local UnitClass = UnitClass
local UnitHealth = UnitHealth
local UnitHealthMax = UnitHealthMax
local UnitPowerType = UnitPowerType
local UnitIsDead = UnitIsDead
local UnitIsGhost = UnitIsGhost
local UnitIsUnit = UnitIsUnit
local UnitName = UnitName
local UnitPower = UnitPower
local UnitPowerMax = UnitPowerMax
local UnitClass = UnitClass
local UnitPowerType = UnitPowerType
--GLOBALS: _TAGS, Hex, _COLORS
......@@ -535,6 +536,61 @@ ElvUF.Tags.Methods['name:caps'] = function(unit)
return name ~= nil and strupper(name) or ''
end
ElvUF.Tags.Events['name:abbreviate'] = 'UNIT_NAME_UPDATE'
ElvUF.Tags.Methods['name:abbreviate'] = function(unit)
local name = UnitName(unit)
if name then
name = name:gsub('(%S+) ', function(t) return t:sub(1,1)..'. ' end)
end
return name
end
ElvUF.Tags.Events['name:veryshort:abbreviate'] = 'UNIT_NAME_UPDATE'
ElvUF.Tags.Methods['name:veryshort:abbreviate'] = function(unit)
local name = UnitName(unit)
if name and len(name) > 5 then
name = name:gsub('(%S+) ', function(t) return t:sub(1,1)..'. ' end)
end
return name
end
ElvUF.Tags.Events['name:short:abbreviate'] = 'UNIT_NAME_UPDATE'
ElvUF.Tags.Methods['name:short:abbreviate'] = function(unit)
local name = UnitName(unit)
if name and len(name) > 10 then
name = name:gsub('(%S+) ', function(t) return t:sub(1,1)..'. ' end)
end
return name
end
ElvUF.Tags.Events['name:medium:abbreviate'] = 'UNIT_NAME_UPDATE'
ElvUF.Tags.Methods['name:medium:abbreviate'] = function(unit)
local name = UnitName(unit)
if name and len(name) > 15 then
name = name:gsub('(%S+) ', function(t) return t:sub(1,1)..'. ' end)
end
return name
end
ElvUF.Tags.Events['name:long:abbreviate'] = 'UNIT_NAME_UPDATE'
ElvUF.Tags.Methods['name:long:abbreviate'] = function(unit)
local name = UnitName(unit)
if name and len(name) > 20 then
name = name:gsub('(%S+) ', function(t) return t:sub(1,1)..'. ' end)
end
return name
end
ElvUF.Tags.Methods["classcolor:player"] = function()
local _, unitClass = UnitClass("player")
local String
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment