TGB/Level Builder/CustomCreateTab
From TDN
|
[edit] Introduction
[edit] Adding Tooltips
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 );
}
You might have noticed that a %toolTip variable gets passed to this function now. Let's edit some other scripts to give this variable some meaning. [edit] Static Sprites
function LBOTStaticSprite::refresh(%this)
{
%this.destroy();
%this.scenegraph = new t2dSceneGraph();
$LB::ObjectLibraryGroup.add( %this.scenegraph );
%datablockSet = getT2DDatablockSet();
%datablockCount = %datablockSet.getCount();
// Find objectList
%objectList = %this.findObjectByInternalName("ObjectList");
for (%i = 0; %i < %datablockCount; %i++ )
{
%object = %datablockSet.getObject( %i );
if( %object.getClassName() $= "t2dImageMapDatablock" )
{
// Create Sprite Object
%staticSprite = new t2dStaticSprite() { scenegraph = %this.SceneGraph; };
%staticSprite.setImageMap( %object.getName() );
%staticSprite.setSize( %object.getFrameSize(0) );
%caption = "";
%toolTip = %object.getName();
%imageMode = %object.getImageMapMode();
if( (%imageMode $= "CELL") || (%imageMode $= "LINK") || (%imageMode $= "KEY") )
{
%totalFrames = %object.getFrameCount();
%caption = "1/" @ %totalFrames;
}
%objectList.AddT2DObject( %staticSprite, %object.getName(), "t2dStaticSprite", %caption, %toolTip );
}
}
}
If you wish to change the tooltip to something else, you can naturally do this by changing what %toolTip refers to. [edit] Particle Effects
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 );
}
}
Not only was %toolTip added, but also a blank %caption to keep the variables in order when AddT2DObject is run. |





