Author Topic: Using color tokens in conversation.  (Read 1126 times)

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Using color tokens in conversation.
« Reply #15 on: February 03, 2013, 07:54:04 pm »


               

Highv Priest wrote...

The problem is although that method DOES work, it also doesn't let you see the full scope of colors nwn can provide. There is 255^3 colors that exist in nwn.(although the human eye makes it mostly 200-300 or so).

...


So why not just use the one that already comes with the game?  It Allows for 343 colors.  

From x3_inc_string : 

// FILE: x3_inc_string      FUNCTION: StringToRGBString()
//
// This function will make sString be the specified color
// as specified in sRGB.  RGB is the Red, Green, and Blue
// components of the color.  Each color can have a value from
// 0 to 7.
// Ex: red   == "700"
//     green == "070"
//     blue  == "007"
//     white == "777"
//     black == "000"
// The STRING_COLOR_* constants may be used for sRGB.
string StringToRGBString(string sString, string sRGB); 
               
               

               


                     Modifié par Lightfoot8, 03 février 2013 - 07:54 .
                     
                  


            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
Using color tokens in conversation.
« Reply #16 on: February 03, 2013, 08:04:35 pm »


               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 .
                     
                  


            

Legacy_Sir Adril

  • Jr. Member
  • **
  • Posts: 96
  • Karma: +0/-0
Using color tokens in conversation.
« Reply #17 on: February 03, 2013, 11:12:28 pm »


               Honestly, speaking as an artist, I actually agree that just because a game can render all those colors, doesn't mean people can tell the difference. Colors that are very close in hue and/or saturation can be almost impossible for the human eye to distinguish. Now I'm sure you all know this, but for future benefit of other readers later, all you really need to do is to create a spectrum of colors, equally spaced, and subtly different from each other, and it will appear you've used the entire range of colors within the game.
               
               

               
            

Legacy_Highv Priest

  • Full Member
  • ***
  • Posts: 170
  • Karma: +0/-0
Using color tokens in conversation.
« Reply #18 on: February 04, 2013, 03:50:41 pm »


               I wanted to use the full spectrum of colors to allow players to color their chat text in any unique way as they saw fit(whether they made it visible or not). Also it wasn't particularly harder to use the full range then the normal range, quite the opposite in fact. It was easier to encompass all colors then to focus on a set of colors. Creating that function took me all of 3 minutes to accomplish whereas creating specific libraries of colors would of taken about 30, but to each his own.

EDIT = In response to Lightfoot, I was unaware such a function existed. 99% of the things I do are completely made from scratch because the time it takes to fix problems caused by using other people's work is more then it takes for me to make my own.
               
               

               


                     Modifié par Highv Priest, 04 février 2013 - 03:53 .