Game Development Community

Combining GuiMLTextCtrl with GuiTextList?

by Robert Fritzen · in Torque Game Engine Advanced · 05/25/2011 (3:30 pm) · 1 replies

Hello, I'm trying to combine the GuiMLTextCtrl with the GuiTextList so I can use the features of the MLTextCtrl in my TextList.

This is for my player listing and other parts of my game. Mainly to use multicolored and different fonts in a textList.

What I've done so far is this:

1. I've copied the entire code for the text list into a new file, and named it (obviously) GuiMLTextListCtrl

2. In the following struct, I've swapped const char * text, with GuiMLTextCtrl *item;
struct Entry
   {
      GuiMLTextCtrl *item;
      U32 id;
      bool active;
   };

3. I made code switches, all references to "text" in the get methods have been replaced by:
mList[i].item->getTextContent()

and, all set items have been swapped with:
mList[e].item->setScriptValue(text);

Now this is where my problem is currently. What I want to do is instead of using the GuiTextList's usual rendering of just the text objects, I want to replace all of those text objects with GuiMLTextCtrl objects, therefore just being directly able to apply the settings of that gui control in my text list.

How do I go about doing this? has this already been done before?

#1
06/13/2011 (6:26 pm)
I'm still lost here, my main concern out of this is trying to access the <color> tag in the textList (I plan on having clan tag colors) for my lobby and in game scoreboards, ect (I don't want to use profiles, could be different colored tags).

Is there is an easier way to be able to just have the <color> tag in the textList, or am I just doing something stupid in my custom object?

I'm aware that if I try to make different font sizes in the text list, the cells may be off a bit, so the goal is to only apply coloration.

void GuiMLTextListCtrl::onRenderCell(Point2I offset, Point2I cell, bool selected, bool mouseOver)
{
   if ( mList[cell.y].active )
   {
      if (selected || (mProfile->mMouseOverSelected && mouseOver))
      {
         RectI highlightRect = RectI(offset.x, offset.y, mCellSize.x, mCellSize.y);
         highlightRect.inset( 0, -1 );
         renderFilledBorder( highlightRect, mProfile->mBorderColorHL, mProfile->mFillColorHL);
         GFX->getDrawUtil()->setBitmapModulation(mProfile->mFontColorHL);
      }
      else
         GFX->getDrawUtil()->setBitmapModulation(mouseOver ? mProfile->mFontColorHL : mProfile->mFontColor);
   }
   else
      GFX->getDrawUtil()->setBitmapModulation( mProfile->mFontColorNA );

   //const char *text = mList[cell.y].text;
   GuiMLTextCtrl *mlText = mList[cell.y].item;
   for(U32 index = 0; index < mColumnOffsets.size(); index++)
   {
	   Point2I pos(offset.x + 4 + mColumnOffsets[index], offset.y);
	   mlText->setPosition(pos);   //set position of the guiMLTextCTRL
       //render it
	   mlText->setVisible(true);
   }
}