Game Development Community

Chat hud - second line of text not same color as first

by thud · in Game Design and Creative Issues · 07/26/2007 (1:50 pm) · 3 replies

Need help with a GUI chat hud bug.

I want to setup two different colors of text to be used depending on which chat mode is used, global or team. So, I set the colors that I want to use. Yellow for one, orange for the other.

new GuiControlProfile ("ChatHudMessageProfile")
{
   fontType = "Arial";
   fontSize = 16;
   fontColor = "44 172 181";      // default color (death msgs, scoring, inventory) //blue-green 44 172 181
   fontColors[1] = "4 235 105";   // client join/drop, tournament mode
   fontColors[2] = "219 200 128"; // gameplay, admin/voting, pack/deployable
   fontColors[3] = "255 114 0";   // team chat, spam protection message, client tasks // orange 255 114 0
   fontColors[4] = "255 223 0";  // global chat  // yellow 255 223 0
   fontColors[5] = "200 200 50 200";  // used in single player game
   // WARNING! Colors 6-9 are reserved for name coloring 
   autoSizeWidth = true;
   autoSizeHeight = true;
};

And those colors work all fine and dandy to begin with. However, if the string of text exceeds the character limit, or wraps to a second line, then the yellow/orange custom text color reverts back to the default blue-green color. Here is what my Gui controls look like:

new GuiControl(MessageHud)
{
   profile = "GuiDefaultProfile";
   horizSizing = "relative";
   vertSizing = "relative";
   position = "0 0";
   extent = "640 480";
   minExtent = "8 8";
   visible = "0";
   noCursor = true;

   new GuiBitmapBorderCtrl(MessageHud_Frame) {
      profile = "ChatHudBorderProfile";
      horizSizing = "relative";
      vertSizing = "relative";
      position = "120 375";
      extent = "400 40";
      minExtent = "8 8";
      visible = "1";

      new GuiBitmapCtrl() {
         profile = "GuiDefaultProfile";
         horizSizing = "relative";
         vertSizing = "relative";
         position = "8 4";
         extent = "362 34";
         minExtent = "8 8";
         visible = "1";
         helpTag = "0";
         bitmap = "./hudfill";
         wrap = "0";
      };

      new GuiTextCtrl(MessageHud_Text)
      {
         profile = "ChatHudTextProfile"; //this is for the "Comment:" in the chat bar e.g. "global: or team:"
         horizSizing = "relative";
         vertSizing = "relative";
         position = "14 12";
         extent = "10 22";
         minExtent = "8 8";
         visible = "1";
      };

      new GuiTextEditCtrl(MessageHud_Edit)
      {
         profile = "ChatHudEditProfile"; //this is for the text color in chat bar
         horizSizing = "relative";
         vertSizing = "relative";
         position = "0 13";
         extent = "10 22";
         minExtent = "8 8";
         visible = "1";
         altCommand = "$ThisControl.eval();";
         escapeCommand = "MessageHud_Edit.onEscape();";
         historySize = "5";
         maxLength = "50"; //120
      };
   };
};

I have had some success by limiting the character length to 50. If the words are typed out and then hit "return" they will all show in the correct color. However, if I type less than 50 characters and then hold down a key, "m" for example, it will allow more than the specified 50 characters to appear and will split the line in two...with the default blue-green text showing up again.

Any ideas on how to control this? I have to assume that many people use different colored text in their chat huds. Yet, searches on forums yielded no results. (maybe I'm the only one having trouble)

Any help would be greatly appreciated!

*thud*

#1
07/26/2007 (1:54 pm)
Try reworking it as a GuiMLTextCtrl ?
a couple cool things about GuiMLTextCtrl's:
  • colors are not limited to the ones you call out in the profile
  • ditto fonts
  • color and other styel changes survive line breaks
  • images
  • clickable links (eg, click a player's name to bring up their info)
  • bold, strikethrough, etc.
#2
07/26/2007 (2:06 pm)
Orion, thanks for the speedy reply!

I fooled around with the GuiML controls and the colors did carry over to the next line. The only thing I couldn't figure out was how to end the string and commit the text to the game chat. Each time I hit enter, it just kept going to the next line without posting to the chat hud in-game. Eventually, I just had to hit escape to get out of it.

Thoughts?
#3
07/26/2007 (2:09 pm)
I haven't looked at the stock chat hud for a long time, so i can't really help you much with the details there.
as with many things, it may be a task for the talents of a programmer.