FPS Starter Kit\n"@ ""@ getCompileTimeString() @", "@ getBuildString() @"Build\n\n"@ " I just have to say.... | Torque Game Engine | Forums | Community | GarageGames.com

Game Development Community

I just have to say....

by Clint S. Brewer · in Torque Game Engine · 02/01/2005 (2:08 am) · 9 replies

I just discovered all the text formatting tags available...

just look at this:

%text="<just:center><font:Arial Bold:20>FPS Starter Kit\n"@
         "<font:Arial:12>"@ getCompileTimeString() @", "@ getBuildString() @"Build\n\n"@
         "<font:Arial:16>Copyright (c) 2001 <a:www.garagegames.com>GarageGames.Com</a>\n"@
         "<bitmap:rw/client/ui/gglogo150.png>";

jeeeeeeebus! that's some hot s.....


it's really nice to have stuff like this just working, made doing my object interaction dialogs very easy today.

this is with the GuiMLTextCtrl.

and by the way in case anyone is curious about what the URL color codes are for that baby,
the link color is hard coded to fontColor[4]
and the link highlight color is hard coded to fontColor[5]


I'm jumping the gun a little bit as I'm hoping i'll be able to use multiple bitmaps in a single line of text and have them render at the right place...we'll see if that works.

ok that works too....
it's nice to have moments like this when you struggle with some seemingly simple things for so long.

it'll take a little bit to get the formatting correct, but I can easily embed images in the text stream. nice!

#1
02/01/2005 (2:45 am)
Clint im always interested of the crazy stuff you doing :)
#2
02/01/2005 (8:59 am)
Nice catch!!!

This is very usefull, thanks for sharing

Sascha
#3
02/01/2005 (10:17 am)
Hehehe...
You can also add new tag parsing to it in scripts.
package GuiMLTextHelper
{

function GuiMLTextCtrl::setText(%this, %text)
{
   // Do your tag processing here...
   ...
   // Then call the set-text function
   Parent::setText(%this, %text);
}
};
activatePackage(GuiMLTextHelper);
In Marble Blast, there is a ML tag called '
There's also very useful tags like '' and '' for formatting.
#4
02/01/2005 (11:09 am)
@Billy I can't wait until things are together enough to show you guys more.

@Pat

Quote:In Marble Blast, there is a ML tag called '
that sounds very useful! in fact exactly one of the things I was thinking about using. would you mind sharing a code snippet?

hmmm...
I don't think my GuiMLTextCtrl is the same as yours though, unless you were doing a derived class. in my code it looks like I would have to add it to
void GuiMLTextCtrl::reflow() ...and also in GuiMLTextCtrl::stripControlChars


Is there someplace that has documentation about how to use all the tags? I feel like I've seen it before but couldn't find it last night.
for instance I would like to get the "..." rendering like it appears it should be able to do:
//if the atom was "clipped", see if we need to draw a "..." at the end
      if (atom->isClipped)
      {
         Point2I p2 = drawPoint;
         p2.x += font->getStrNWidthPrecise(mTextBuffer + start, end - start);
         dglDrawTextN(font, p2, "...", 3, mAllowColorChars ? mProfile->mFontColors : NULL);
      }

perhaps I have to use the tags somehow. I guess I expected it to just work automatically since the text was clipped by it's scroll container. ..ahh but it auto resizes to fit the text, so I probably need to set up a clip region...yes. yes...hmmm...looks like setting the margins might do it.
#5
02/01/2005 (12:16 pm)
Ok, I'm just going to post here with other things I find out for now.

if it's not clear I'm using this for a generic interaction dialog, this could be a conversation with an NPC, inspecting a wild mushroom, or providing any ole choice to the player.

I'm using the url's to let the player make their choice.

in your .gui or .cs for your ML Text control you can then add something like this
function InteractDlgMLTextCtrl::onURL(%this, %url)
{
   if(firstword(%url)$="gamelink")
   {
	   %seq = getWord(%url,1);
	  // error("you chose a gamelink: " @ %seq);
 	   commandToServer( 'OnInteractDlgChoice' , %seq);
   }
   else //might be a normal url
   {
     error("unknown URL on interact dialog gamelink: "@%url);
   }
   
}

if you want to have the url's not be underlined, then you need to use the gamelink tag. if you use anything else TGE 1.3 will render the url with an underline

so Choice1

will render a url that is not underlined.

now I want the URLs to highlight when you mouse over them so the player is really clear that if they click there it will do something.

I'm going to add that code now and post how I did it in a sec.
#6
02/01/2005 (12:44 pm)
Ok this will make urls highlight when you mouse over them

in GuiMLTextCtrl.h--------------

add this right after all the other OnMouse* functions...
void onMouseMove(const GuiEvent &event);
   void onMouseLeave(const GuiEvent &event);
   void ClearMouseOverURLs();
   URL *lastMouseOverURL;//used to highlight the url

in GuiMLTextCtrl.cc--------------

add to the constructor
lastMouseOverURL = 0;

then add these functions
// Mousing events...

void GuiMLTextCtrl::ClearMouseOverURLs()
{
   if(lastMouseOverURL != 0)
   {
	   lastMouseOverURL = 0;
	   setUpdate();
   }

}
void GuiMLTextCtrl::onMouseLeave(const GuiEvent &event)
{
	//currently this will just set the url's to be highlighted
   if(!mActive)
      return;

   //if we are leaving then clear out the lastMouseOverURL
  
    ClearMouseOverURLs();
}

void GuiMLTextCtrl::onMouseMove(const GuiEvent &event)
{
	//currently this will just set the url's to be highlighted
   if(!mActive)
      return;

   Atom *hitAtom = findHitAtom(globalToLocalCoord(event.mousePoint));

   if(hitAtom && !mIsEditCtrl)
   {
      mHitURL = hitAtom->url;
      if (mHitURL)
	  {
		  lastMouseOverURL = mHitURL;
 		  setUpdate(); 
		  return;
	  }
   }
   //if we made it here then we are not over a URL
   ClearMouseOverURLs();
}

and finally in GuiMLTextCtrl::drawAtomText
modify the url part and add the check to see if the lastMouseOverURL is the url we are drawing like so
if(atom->url->mouseDown || lastMouseOverURL == atom->url )
         color = atom->style->linkColorHL;
      else
         color = atom->style->linkColor;

it would be pretty easy to carry this further and have a mouse over color, but I'm happy with just using the Highlight color for now.
#7
03/08/2006 (12:19 pm)
Clint, this was sweet! you rock!
#8
03/08/2006 (12:36 pm)
Thanks Dave, glad to help!
#9
05/06/2006 (9:24 pm)
Wow, this opened alot of doors for me.
Thank you!

Ari