Game Development Community

ToolTip Modification query.. Will this create any problems?

by John "Mythic" Henry · in Torque Game Engine · 08/27/2009 (8:02 pm) · 0 replies

A minor tweak to GuiControl.cc ToolTips:

What this Does:
Adds the Ability to modify the Tooltip message on the fly
when you need to change what a Control is now for (Different Clans/Ranks/Whatever).
Example: Player Logins in, is in a specific clan, you show their Clan Icon and change
the tooltip to display the ClanName over the Clan Icon.

Add in the h file { Best spot after : virtual void onChildAdded( GuiControl *child ); }
//DEBUG Dynamic ToolTips
    void setToolTip(const char *argv);

Add in the cc file:
//Dynamic ToolTips
ConsoleMethod( GuiControl, setToolTip, void, 3, 3, "(string value)")
{
   object->setToolTip(argv[2]);
}
void GuiControl::setToolTip(const char *argv)
{
   mTooltip = StringTable->insert(argv);
}

Then in your Scripts you can Modify a Tooltip property of most objects that
are based on GuiControl by calling this:
$TeamARoomList[%i,1].setToolTip($clanNames[%teamASlot.charClan]);

In the above example:
$TeamARoomList[%i,1] Points to a GuiBitMapCtrl in a Menu
$clanNames[] is an Array of Static Names matching the
%teamASlot.charClan Index number to Array of Names...

The Big question is with so many changes that should (will) occur with

A: multiple rooms/clans/players
B: leaving/entering/creating rooms...

How much of a memory affect is this liable to create?
Max 72 BitMapCtrl's for various Icons in the Menus...

In all the years of working with GG, Stringtables has been last on my list
of studies as the other pats have taken so much time and effort :)

So far this is working like a champ, but I am still in a testbed for the GUI's
and havent tested this addition in the Live setting (Remote Server).

This setup would only occur on the Client side as the things like
Ranks can be static. Clan Names/Icons can be updated on login, etc..

There is no need to send anything but the correct index for the Rank/Clan/etc..
to the client to pull the correct Tooltip for that bitmap from its static list.

Ends up a very small size for ranks, but have to use a U32 for Clans,
unless you dont mind being limited to 255 clans. :)