Game Development Community

Images in ShapeNameHud

by Robert Fritzen · in Torque Game Engine Advanced · 03/09/2011 (12:58 pm) · 1 replies

Hello, I'm trying to accomplish something similar to Call of Duty, where a player's rank image (looks like an 80x80 PNG image) in multiplayer is shown to the left of their name in their representation of the ShapeNameHud (whatever they use for it).

How can I do this with the ShapeNameHud in Torque, or what kind of edits will be needed to make it work like this.?

#1
04/12/2011 (3:25 pm)
Just a little update on my current progress to doing this.

I have adapted the GuiShapeNameHud a bit to handle my image drawing using the GuiBitmapCtrl as a starting point.

void GuiShapeNameHud::drawName(Point2I offset, const char *name, F32 opacity, const char *pathToRank)
{
   // Center the name
   offset.x -= mProfile->mFont->getStrWidth((const UTF8 *)name) / 2; 
   offset.y -= mProfile->mFont->getHeight();

   // Deal with opacity and draw.
   mTextColor.alpha = opacity;
   GFX->getDrawUtil()->setBitmapModulation(mTextColor);
   GFX->getDrawUtil()->drawText(mProfile->mFont, offset, name);
   GFX->getDrawUtil()->clearBitmapModulation();

   //Phantom139: Images Mod
   //1. Make sure they specified an image!
     //IE: SinglePlayer, we don't need this? so set it to "" when using
   if(strcmp(pathToRank, "") != 0) {
      mBitmapName = StringTable->insert(pathToRank);
      mTextureObject.set( mBitmapName, &GFXDefaultGUIProfile, avar("%s() - mTextureObject (line %d)", __FUNCTION__, __LINE__) );

      GFXTextureObject* texture = mTextureObject;
      RectI srcRegion;
      RectI dstRegion;
      //force it to be an 80x80 image
      srcRegion.set(0,0,80,80);
      dstRegion.set(offset.x-80, offset.y-80, 80, 80);
      GFX->getDrawUtil()->drawBitmapStretchSR(texture, dstRegion, srcRegion, GFXBitmapFlip_None, GFXTextureFilterLinear);  
      //Done
   }
}

Quick question, does this appear correct? IE: should it place an 80x80 image just to the left of the Name?

I just need to figure out a method to get the correct image sent to the function now (I'm going to use a conn->getRankImage() method later.

Unfortunately, this does require my Number Storage system to work, and I cannot figure out what the problem on that is.