Game Development Community

T3D 1.1 Beta 2 - guiListBoxCtrl::AddItem broken and strange behaviour when fixed - RESOLVED

by Richard Marrevee · in Torque 3D Professional · 08/19/2010 (7:33 pm) · 5 replies

Build: 1.1 Beta 2

Platform: Windows XP, 32 bit

Target: Torsion, related to Visual Studio and possibly GUI-editor not checked)

Issues: The function guiListBoxCtrl::AddItem now needs 2 arguments: first the itemtext, second a color-string (in B1 it only needed the itemtext). Now when I add an initialized color-string like "0.0 1.0 1.0" like the description of the function describes I get a GuiListBoxCtrl::addItem() - Invalid number of parameters! error. Using an empty string for the color argument and everything works.

Steps to Repeat:
1. Create a GUI with a guiListBoxCtrl in it.
2. in Torsion add a guiListBoxCtrl.addItem("Test Item failure","0.0 1.0 1.0");
3. in Torsion add a guiListBoxCtrl.addItem("Test Item works","");
4. Run this gui and the item created in step 2 will fail with the error mentioned above.

Suggested Fix:
In guiListBoxCtrl.cpp the enginemethod fails, because the color-argument is tested twice.
"@see GuiControln"
   "@hide")
{
   if(dStricmp(color,"") == 0)
   {
      return object->addItem( newItem );
   }
   else if(dStricmp(color,"") == 0)//  <===========same condition as above
   {
      U32 elementCount = GuiListBoxCtrl::getStringElementCount(color);

	  if(elementCount == 3)

Fix by changing the second dStricmp into
"@see GuiControln"
   "@hide")
{
   if(dStricmp(color,"") == 0)
   {
      return object->addItem( newItem );
   }
   else if(dStricmp(color,"") > 0)//   <================== Fix
   {
      U32 elementCount = GuiListBoxCtrl::getStringElementCount(color);

	  if(elementCount == 3)

Edit:
Pressed Enter key but wasn't finished.

Now the function accepts the arguments, but when you add an item with a color you get a small rectangle with the specified color followed by the itemtext in black.

About the author

Started programming in 1984 on an Oric, when time progressed switched to MSX, Amiga and finally the Windows PC with T3D. Now developing an epic fantasy game: The Master's Eye. Creator of the DoorClass pack and VolumetricFog pack @ richardsgamestudio.com


#1
08/19/2010 (8:03 pm)
Richard ... try leaving a space (eg : "space_goes_here!" ) between the quote/speech marks ... just a thought, I had this issue with some TorqueScript.
#2
08/19/2010 (9:32 pm)
Steve:
Doesn't work. Thanks anyway.
#3
08/21/2010 (2:56 am)
Logged as TQA-855.
#4
09/03/2010 (10:00 pm)
Bug confirmed.

As of right now the invalid parameter part of this bug is fixed in 1.1 Beta 3. The colored bullet bit is not though.
#5
09/17/2010 (5:43 pm)
Fixed in 1.1 Beta 3.

The colorBullet field is now optional and defaults to on.