Game Development Community

Colored Text in Text boxes

by Sebastien Bourgon · in Torque Game Engine · 03/02/2003 (7:12 pm) · 8 replies

Hey,

I'm working on the irc client. The GUI uses a MessageVector for the text box. Since this project was originally by someone else, they had included colored text using \c# to get a color.
0 is black, 1 is gray, 2 is red, 3 is teal, 5 is blue (I may have hte order wrong...) but in anycase it goes up to 9 except 6 through 9 are white (or possibly undefined and defaulting to white)

Does anyone know where these values are set? I've tried to backtrack the pushBackLine function that I'm using to display the text but I tend to get lost after a while and never run into anything that remotely looks like it setting colors.

As anyone whos used a chat program can imagine, it'd really help if there was a way to set the last 4 colors so that I can differentiate between various things like joining, leaving, notices, messages, private messages, actions, errors. Errors get the redish pink that it has and as everyone would tell me if I did otherwise, you cant have errors sharing colors, that would confuse people on whats an irc error and what isn't.

So any help is appreciated in helping me solve the mystery of the colored text

Seb
TheAce-MGO

About the author

Former Indie Game Developer for Max Gaming Technologies. I then spent a couple years doing mobile work for Capcom Interactive Canada, the highlight being Mega Man II for iPhone. Now doing various mobile contract jobs (mostly iPhone)


#1
03/02/2003 (7:33 pm)
Color is set in dglDrawText
#2
03/03/2003 (1:23 pm)
Entirely possible I'm blind (or maybe I need to update my build) but I dont see what your refering to. I found the function no problem. Just cant see where the colors are set
#3
03/03/2003 (1:37 pm)
dglDrawTextN

It scans through the string and looks for color codes right after the renderstate settings, and before it actually renders the character.
// first build the point, color, and coord arrays
it then sets the color inside that loop like:
currentColor = sg_bitmapModulation = clr;
and when it builds the vertex array, it sets the color in the constructor of the vertex
struct TextVertex
{
   Point3F p;
   Point2F t;
   ColorI c;
   void set(F32 x, F32 y, F32 tx, F32 ty, ColorI color)
   {
      p.x = x;
      p.y = y;
      p.z = 0;
      t.x = tx;
      t.y = ty;
      c = color;
   }
};
like so...
vert[currentPt++].set(screenLeft, screenBottom, texLeft, texBottom, currentColor);
vert[currentPt++].set(screenRight, screenBottom, texRight, texBottom, currentColor);
vert[currentPt++].set(screenRight, screenTop, texRight, texTop, currentColor);
vert[currentPt++].set(screenLeft, screenTop, texLeft, texTop, currentColor);

Then it draws that array.
#4
03/03/2003 (1:43 pm)
Would anyone happen to know how to get the background area of a text to change color like a highlight effect?
#5
03/03/2003 (1:53 pm)
You're going to have to draw a that covers the area you want to highlight right before you draw the text on top of it. I'd say that you'd want to look at the editable text GUI control.
#6
03/05/2003 (7:20 pm)
Ace... That should be set in the GUI profiles.

I'll edit this post with the information when I get a chance to look it up.
#7
03/09/2003 (10:40 am)
Thanks for the help guys.
The actual color values are set in the profiles.
Although the default ones dont seem to include the colors I was using.

If you want your own colors in a GUI object add this to your profile
fontColors[1] = "150 50 50";
   fontColors[2] = "50 150 50";
   ....

Of course you may not want to mess with the defaultProfiles, and can just make your own. There is a max color set at 9. So only fontColors 1 through 9. Putting colors in the actual profile used also gets around the "restricted" colors used for the console which are 6-9
#8
03/09/2003 (12:11 pm)
Also if you're using a MLtextbox you can use the Markup Language to pick any color you want.

Red

for example