View Single Post
03-21-13, 08:39 PM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
SetTextColor only affects the individual font string object it's called on. The text and the color are not intriniscally connected, so if you take the text from that font string object, and display it on another font string object, or pass it to a function -- like print() -- you only get the text, not the color or alignment or size or any other properties of the original font string object.

If you got a color when print()-ing the item level line, that means that the item level line uses inline color codes (eg. "|cffffd000Item Level: 496|r") which override the text color set on the font object.

Also, based on what you described, you will need to use string matching on the actual text content, as that green text can be "Heroic" -- or it can be "Raid Finder", or it could be something else. Fortunately, you don't need to do any of the work translating the string; you can just use the pre-defined Blizzard global strings. For example:

Code:
if GameTooltipTextLeft2:GetText() == ITEM_HEROIC then
    -- text is "Heroic" in an English client, "Heroisch" in a German client, etc.
end
Finally, the values returned by GetTextColor can be a bit odd. If you need to match them to detect something, you can "fix" them via rounding to the nearest 100th, like so:

Code:
local r, g, b = GameTooltipTextLeft2:GetTextColor()
r = floor(r * 100 + 0.5) / 100
g = floor(g * 100 + 0.5) / 100
g = floor(b * 100 + 0.5) / 100
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.

Last edited by Phanx : 03-21-13 at 08:42 PM.
  Reply With Quote