diff --git a/modules/gui.lua b/modules/gui.lua index 9d734bd9..c5c4a82c 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -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") diff --git a/modules/nameplates.lua b/modules/nameplates.lua index ef61ae79..0858d7e9 100644 --- a/modules/nameplates.lua +++ b/modules/nameplates.lua @@ -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