ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Quality Colors (https://www.esoui.com/forums/showthread.php?t=2317)

circonian 10/09/14 09:54 PM

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")

merlight 10/10/14 04:04 AM

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"))

Garkin 10/10/14 04:41 AM

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

circonian 10/10/14 07:59 AM

Awesome, thanks to you both.


All times are GMT -6. The time now is 08:39 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI