Yeah, we use both methods. Nine times out of ten, though, the ones in the constants work well enough, and you can always define more if you find yourself using the same color frequently. But the flexibility of the RGB method is crazy useful.
Here's some more functions from our color library (including some helper functions for coloring spoken strings and floating text). These work with either the constants method or the RGB method.
// COLOR_TOKEN by rdjparadis. Used to generate colors from RGB values. NEVER modify this string.
const string COLOR_TOKEN = " ##################$%&'()*+,-./0123456789:;;==?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[[]^_`abcdefghijklmnopqrstuvwxyz{|}~~€Â‚ƒ„…†‡ˆ‰Š‹ŒÂŽÂ‘’“â€â€¢â€“—˜™š›œÂžŸ¡¡¢£¤¥¦§¨©ª«¬¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓÔÕÖ×ØÙÚÛÜÃÞßà áâãäåæçèéêëìÃîïðñòóôõö÷øùúûüýþþ";
string GetStringColored(string sString, string sColor)
{
return sColor + sString + COLOR_END;
}
string GetColorCode(int nRed=255, int nGreen=255, int nBlue=255)
{
return "<c" + GetSubString(COLOR_TOKEN, nRed, 1) + GetSubString(COLOR_TOKEN, nGreen, 1) + GetSubString(COLOR_TOKEN, nBlue, 1) + ">";
}
string GetStringColoredRGB(string sString, int nRed=255, int nGreen=255, int nBlue=255)
{
return "<c" + GetSubString(COLOR_TOKEN, nRed, 1) + GetSubString(COLOR_TOKEN, nGreen, 1) + GetSubString(COLOR_TOKEN, nBlue, 1) + ">" + sString + "</c>";
}
void SpeakColorString(string sString, int nTalkVolume=TALKVOLUME_TALK, string sColor = COLOR_DEFAULT)
{
if (sColor != COLOR_DEFAULT) sString = sColor + sString + COLOR_END;
SpeakString(sString, nTalkVolume);
}
void FloatingColorText(string sStringToDisplay, object oCreatureToFloatAbove, int bBroadcastToFaction=TRUE, string sColor = COLOR_DEFAULT)
{
if (sColor != COLOR_DEFAULT) sStringToDisplay = sColor+sStringToDisplay+COLOR_END;
FloatingTextStringOnCreature(sStringToDisplay, oCreatureToFloatAbove, bBroadcastToFaction);
}
Modifié par Squatting Monk, 03 février 2013 - 08:06 .