Loop through GUI Children from engine code (C++)
by James Laker (BurNinG) · in Torque Game Engine · 05/02/2007 (6:25 am) · 6 replies
Hey again everyone.
I'm working with the CommanderMap and have Radio buttons added where the spawn points are for my game. This allows the player to select where he wants to spawn when he dies. The code for adding gui elements / controls is simple:
My problem is that I need to move all these gui controls / elements when the User zooms, but can't get to their handles. I guess I also need this when I delete em.
So my question to you is, how to I loop through all the children GUI elements of a GUi Control in code (c++)?
I'm working with the CommanderMap and have Radio buttons added where the spawn points are for my game. This allows the player to select where he wants to spawn when he dies. The code for adding gui elements / controls is simple:
//CREATE NEW CONTROL
guiCommanderRadioCtrl* radio = new guiCommanderRadioCtrl();
if(radio)
{
radio->setPosition(Point2I(DestCoord.x,DestCoord.y));
radio->setSpawnX(spawnsphere->getPosition().x);
radio->setSpawnY(spawnsphere->getPosition().y);
radio->setSpawnZ(spawnsphere->getPosition().z);
radio->setField("profile", "guiRadioProfile");
//txt->setField("position", "2 2");
//radio->setField("extent", "15 15");
radio->registerObject();
GuiCommanderHud * commandermap;
Sim::findObject("guiBattleMap", commandermap);
if(commandermap)
{
commandermap->addObject(radio);
}
}//New GuiControlNOTE: As you can see here, I extended the guiRadioCtrl to guiCommanderRadioCtrl which excepts coordinates.My problem is that I need to move all these gui controls / elements when the User zooms, but can't get to their handles. I guess I also need this when I delete em.
So my question to you is, how to I loop through all the children GUI elements of a GUi Control in code (c++)?
#2
05/02/2007 (8:03 am)
Heya. a side note, but it looks like you might be interested in the Gui3DProjectionCtrl resource i wrote a while ago.
#3
05/04/2007 (4:09 am)
Thanx Orion. I had a look at it, and dont think it will be suitable for my use. When a person zooms the CommanderMap, the RadioButtons move. Or maybe I'm not understanding how I should use your resource.
#4
cheers!
05/04/2007 (8:33 am)
It's possible it's not a good fit. i just saw the call to project() in your code and assumed you're aligning GUI controls with points in the 3D world.cheers!
#6
05/04/2007 (1:01 pm)
Michael... I got that bookmarked ;) Still have to sort some kinks with the creation of the guiRadioCtrls on the CommanderMap. But ur resource will come in soon, thanx.
Torque Owner James Laker (BurNinG)
SimSet * commandermap = dynamic_cast<SimSet*>(Sim::findObject("guiBattleMap")); //Loop through all Missiongroup Objects for(SimSetIterator itr(commandermap); *itr; ++itr) { if (dStrstr((*itr)->getClassName(),"guiCommanderRadioCtrl") != NULL) { //Cast the Iteration Object to a ShapeBase guiCommanderRadioCtrl* spawnctrl = static_cast<guiCommanderRadioCtrl*>(*itr); Point3F moveCoord; moveCoord.x = spawnctrl->getSpawnX(); moveCoord.y = spawnctrl->getSpawnY(); moveCoord.z = spawnctrl->getSpawnZ(); Point3F DestCoord; if (!project(moveCoord, &DestCoord)) continue; spawnctrl->setPosition(Point2I((S32)DestCoord.x,(S32)DestCoord.y)); } }Hope this can help someone in the future.