View Single Post
04-29-09, 09:14 AM   #1
Druidicbeast
A Fallenroot Satyr
Join Date: Feb 2008
Posts: 24
Converting DogTag for use with oUF

So I am in the process of transitioning from PitBull to oUF. One thing I had setup in my PitBull layout was a DogTag that I got from a DogTag thread on the Elitist Jerks UI forums.

Code:
[(if  ((Abbreviate(Name) ~= Name) and (Length(Name) > 10)) then
    Abbreviate(Name):Substring(1, (Length(Abbreviate(Name)) - 1)):Append(". "):Upper:ClassColor
    Name:Replace(" ", "                            "):Substring(-15, -1):Replace(" ", ""):Truncate(10, nil):Upper:ClassColor
else
    Name:Truncate(10, nil):Upper:ClassColor
end)]
This is the explanation of the code that the author posted as well.

Code:
[(if  ((Abbreviate(Name) ~= Name) and (Length(Name) > 10)) then

-- Checks if the name can be abbreviated (at least one space present),
-- and that the total name length is greater than [10]. 10 can be replaced with
-- any number, that would properly fit your unit frame with no issue.
-- I included this because if there's an ultra short multi-word name, such
-- as "The Dog", it will just display the entire thing.

Abbreviate(Name):Substring(1, (Length(Abbreviate(Name)) - 1)):Append(". "):Upper:ClassColor

-- This creates the abbreviation. Abbreviates the name down,
-- uses substring to start at the first character and pulls out every letter
-- except the last one. Achieved by checking length of the abbreviated name,
-- and subtracting 1 (1 because that's the first letter of the last word that will
-- actually be displayed.) Appends a period for clarity.

Name:Replace(" ", "                            "):Substring(-15, -1):Replace(" ", ""):Truncate(10, nil):Upper:ClassColor

-- This pulls the last word out, using some mega-trickery.
-- Takes the full name, bloats single spaces into twenty.
-- Uses substring to start at the last letter, then pulls out
-- the previous 15 characters, which results in "       Name".
-- Then replaces spaces, nulling them out. If the last word is
-- somehow still too long, it truncates it from the last letters.

else
    Name:Truncate(10, nil):Upper:ClassColor

-- If the name can't be abbreviated (one word), but it's still over the display limit,
-- truncates it to 10 characters.

-- Ta-da! Again, there may be better ways to do this, but this
-- achieves what I was wanting to do!
I was wondering if there was a way to get this implemented into my oUF layout. If someone could point me in the right direction on how to convert this over to oUF it would be greatly appreciated. Thanks in advance.
  Reply With Quote