nameplates: abbreviate unit names if option is set

This commit is contained in:
shagu
2024-09-03 22:20:51 +02:00
parent b8d23a0e28
commit b00dc9e33c
2 changed files with 24 additions and 2 deletions
+1 -1
View File
@@ -1463,6 +1463,7 @@ pfUI:RegisterModule("gui", "vanilla:tbc", function ()
CreateConfig(nil, T["Highlight Settings That Require Reload"], C.gui, "reloadmarker", "checkbox")
CreateConfig(nil, T["Show Incompatible Config Entries"], C.gui, "showdisabled", "checkbox")
CreateConfig(nil, T["Abbreviate Numbers (4200 -> 4.2k)"], C.unitframes, "abbrevnum", "checkbox")
CreateConfig(nil, T["Abbreviate Unit Names"], C.unitframes, "abbrevname", "checkbox")
CreateConfig(nil, T["Health Point Estimation"], nil, nil, "header")
CreateConfig(nil, T["Estimate Enemy Health Points"], C.global, "libhealth", "checkbox")
CreateConfig(nil, T["Threshold To Trust Health Estimation"], C.global, "libhealth_hit", "dropdown", pfUI.gui.dropdowns.uf_rangecheckinterval)
@@ -1591,7 +1592,6 @@ pfUI:RegisterModule("gui", "vanilla:tbc", function ()
CreateConfig(nil, T["Show Resting"], C.unitframes.player, "showRest", "checkbox")
CreateConfig(nil, T["Enable Energy Ticks"], C.unitframes.player, "energy", "checkbox")
CreateConfig(nil, T["Enable Mana Ticks"], C.unitframes.player, "manatick", "checkbox")
CreateConfig(nil, T["Abbreviate Unit Names"], C.unitframes, "abbrevname", "checkbox")
CreateConfig(nil, T["Detect Enemy Buffs"], C.unitframes, "buffdetect", "checkbox", nil, nil, nil, nil, "vanilla" )
CreateConfig(U[c], T["Font Options"], nil, nil, "header")
+23 -1
View File
@@ -94,6 +94,28 @@ pfUI:RegisterModule("nameplates", "vanilla:tbc", function ()
return nil
end
local function abbrevname(t)
return string.sub(t,1,1)..". "
end
local function GetNameString(name)
local abbrev = pfUI_config.unitframes.abbrevname == "1" or nil
local size = 20
-- first try to only abbreviate the first word
if abbrev and name and strlen(name) > size then
name = string.gsub(name, "^(%S+) ", abbrevname)
end
-- abbreviate all if it still doesn't fit
if abbrev and name and strlen(name) > size then
name = string.gsub(name, "(%S+) ", abbrevname)
end
return name
end
local function GetUnitType(red, green, blue)
if red > .9 and green < .2 and blue < .2 then
return "ENEMY_NPC"
@@ -613,7 +635,7 @@ pfUI:RegisterModule("nameplates", "vanilla:tbc", function ()
plate.totem:Hide()
end
plate.name:SetText(name)
plate.name:SetText(GetNameString(name))
plate.level:SetText(string.format("%s%s", level, (elitestrings[elite] or "")))
if guild and C.nameplates.showguildname == "1" then