Thread Tools Display Modes
10/09/14, 09:54 PM   #1
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Quality Colors

How do you output text to the chat window using item quality colors?

I know you can get item quality colors to use on a lable like this:
Lua Code:
  1. _cControl:SetColor(GetInterfaceColor(INTERFACE_COLOR_TYPE_ITEM_QUALITY_COLORS, _tData.quality))

But GetInterfaceColor outputs a decimal. I tried googling some formula so I could just convert it, but I had no luck.
Is there another function or a way to convert that decimal it so I could do something like:
Lua Code:
  1. local LegendaryColor = GetInterfaceColor(INTERFACE_COLOR_TYPE_ITEM_QUALITY_COLORS, ITEM_QUALITY_LEGENDARY)
  2. d(LegendaryColor.."whatever message")
  Reply With Quote
10/10/14, 04:04 AM   #2
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
You can use ZO_ColorDef class:
Lua Code:
  1. local color = ZO_ColorDef:FromInterfaceColor(INTERFACE_COLOR_TYPE_ITEM_QUALITY_COLORS, _tData.quality)
  2. d(color:Colorize("whatever"))
  3. -- or
  4. d("|c" .. color:ToHex() .. "whatever|r")

or write the conversion out yourself:
Lua Code:
  1. local r, g, b = GetInterfaceColor(INTERFACE_COLOR_TYPE_ITEM_QUALITY_COLORS, _tData.quality)
  2. d(("|c%02x%02x%02x%s|r"):format(r*255, g*255, b*255, "whatever"))
  Reply With Quote
10/10/14, 04:41 AM   #3
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Function GetItemQualityColor(index) returns ZO_ColorDef objects. When you have color, you can use its method :Colorize(text). Something like this:
Lua Code:
  1. for i = ITEM_QUALITY_TRASH, ITEM_QUALITY_LEGENDARY do --for i = 0, 5 do
  2.    local color = GetItemQualityColor(i)
  3.    local qualName = GetString("SI_ITEMQUALITY", i)
  4.    d(color:Colorize(qualName))
  5. end

Last edited by Garkin : 10/10/14 at 08:07 AM.
  Reply With Quote
10/10/14, 07:59 AM   #4
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Awesome, thanks to you both.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Quality Colors


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off