Game Development Community

HowTo: Add tooltips to the Create Tab's Thumbnails

by Mike Lilligreen · in Torque Game Builder · 05/10/2006 (11:06 am) · 1 replies

Intro: If you've ever been annoyed at having to drop some of the particle effects into the sceneview to figure out what they are (because it's hard to tell from just their thumbnail image) - here is a fairly easy way to add a tooltip that displays the particle effects' file name when you hover the mouse over it.

Keep in mind this is editing the level builder script code. Do this at your own risk.

objectLibraryBaseType.ed.cs Script

Change the ObjectLibraryBaseType:.AddT2DObject function to this:
function ObjectLibraryBaseType::AddT2DObject( %this, %t2dObject, %datablockName, %toolType, %caption, %toolTip )
{
   // Validate Object (Should check to make sure it's a t2d object?)
   if( !isObject( %t2dObject ) )
   {
      error("ObjectBrowserDlg::AddT2DObject - Invalid Object!");
      return;
   }
   
   $LB::ObjectLibraryGroup.add( %t2dObject );
   
   if (isObject(%datablockName) && $ignoredDatablockSet.isMember(%datablockName))
      return;

   // Build T2D Object Container
   %t2dContainer = new guiT2DObjectCtrl()
   {
      class = "ObjectBrowserItem";
      Profile = ObjectBrowserThumbProfile;
      RenderMargin = 6;
      groupNum = 1337;
      datablockName = %datablockName;
      toolType = %toolType;
      tooltipprofile = "GuiToolTipProfile";
      ToolTip = %toolTip;
      hovertime = "100";
   };
   %t2dContainer.setSceneObject( %t2dObject );

   if( %caption !$= "" )
      %t2dContainer.setCaption( %caption );

   // Add to list.
   %this.add( %t2dContainer );
}

particleEffects.ed.cs Script

Change LBOTParticleEffect::refresh function to this:
function LBOTParticleEffect::refresh( %this )
{
   %this.destroy();
   
   %this.scenegraph = new t2dSceneGraph();
   
   $LB::ObjectLibraryGroup.add( %this.scenegraph );
   
   // Find objectList
   %objectList = %this.findObjectByInternalName("ObjectList");
   
   %fileSpec = $currentProject @ "/data/particles/*.eff";
   for (%file = findFirstFile(%fileSpec); %file !$= ""; %file = findNextFile(%fileSpec))
   {

	   // Create Effect Object
      %particleEffect = new t2dParticleEffect()  { scenegraph = %this.SceneGraph; };
      %particleEffect.loadEffect( %file );
      %particleEffect.setSize( "15 15" );
      
      %particleEffect.moveEffectTo(2.0, 0.5);
         
      %particleEffect.setPaused(true);
      
      %caption = "";
      %toolTip = %file;

      %objectList.AddT2DObject( %particleEffect, %file, "t2dParticleEffect", %caption, %toolTip );
   }

}

A similar sort of thing can be done for static sprites (tooltip to display the imagemap name), etc. Since version 1.1 is now feature complete, I can create a section in TDN for optional level builder enhancements, if people are interested in this sort of thing.

P.S. Thanks for releasing the tool code. :)

#1
05/10/2006 (12:00 pm)
A TDN article (even better: a namespace subtree) for editor script mods would be wonderful.

One of the difficulties of maintaining a game agnostic engine is that we can't always put in the neat/cool stuff that people come up with that may be specific to a game, game genre, or project, so we have to carefully select what goes into the full product, and what will be provided by the community as resources.

While this specific functionality is great and pretty agnostic, since we're feature locked it most likely won't go into the main product, but a TDN resource would be wonderful!