T2D Simple Debug Button Gui
by Matthew Langley · 03/05/2005 (2:18 pm) · 5 comments
Just made a quick debug gui for T2D... gives you button interfaces to set the debug modes (makes it easier than typing it in each time) plus also put a hide button in there and a text input to change what you want to set debug modes for... have it loading the default sceneGraph (so if you didn't change anything you can leave the text alone to set global debug modes).
here is the code
create a new text file in your T2D client folder and name it "HelperGui.gui"... paste this code in there
now go to your "client.cs"
find
then add this right after it
thats how you add a gui so you can load it ... now go down a couple lines and find
and add this
this will add it to the main gui so you can use it at the same time... note the hide button that i will hide the buttons out of the way... and the text input box is for whatever you want to set debug modes for... leave it as default if you want to change all and haven't changed your sceneGraph name...
Some pics




here is the code
create a new text file in your T2D client folder and name it "HelperGui.gui"... paste this code in there
//--- OBJECT WRITE BEGIN ---
new GuiControl(HelperGui) {
profile = "GuiDefaultProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "0 20";
extent = "800 15";
minExtent = "8 2";
visible = "1";
new GuiControl(DebugControls) {
profile = "GuiDefaultProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "0 0";
extent = "800 200";
minExtent = "8 2";
visible = "1";
new GuiButtonCtrl() {
profile = "GuiButtonProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "0 0";
extent = "80 15";
minExtent = "8 2";
visible = "1";
text = "Bounding Box";
groupNum = "1";
buttonType = "PushButton";
command = "HelperGui.setMode(BB);";
};
new GuiButtonCtrl() {
profile = "GuiButtonProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "80 0";
extent = "80 15";
minExtent = "8 2";
visible = "1";
text = "Collision Poly";
groupNum = "1";
buttonType = "PushButton";
command = "HelperGui.setMode(ColPoly);";
};
new GuiButtonCtrl() {
profile = "GuiButtonProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "160 0";
extent = "80 15";
minExtent = "8 2";
visible = "1";
text = "Mount Nodes";
groupNum = "1";
buttonType = "PushButton";
command = "HelperGui.setMode(MNodes);";
};
new GuiButtonCtrl() {
profile = "GuiButtonProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "240 0";
extent = "70 15";
minExtent = "8 2";
visible = "1";
text = "Mount Link";
groupNum = "1";
buttonType = "PushButton";
command = "HelperGui.setMode(MLink);";
};
new GuiButtonCtrl() {
profile = "GuiButtonProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "310 0";
extent = "70 15";
minExtent = "8 2";
visible = "1";
text = "World Limit";
groupNum = "1";
buttonType = "PushButton";
command = "HelperGui.setMode(WLimit);";
};
new GuiButtonCtrl() {
profile = "GuiButtonProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "380 0";
extent = "40 15";
minExtent = "8 2";
visible = "1";
text = "ALL";
groupNum = "1";
buttonType = "PushButton";
command = "HelperGui.setMode(ALL);";
};
new GuiMLTextEditCtrl(sceneName) {
profile = "GuiMLTextEditProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "420 0";
extent = "120 18";
minExtent = "8 2";
visible = "1";
lineSpacing = "2";
allowColorChars = "0";
maxChars = "-1";
};
};
new GuiButtonCtrl() {
profile = "GuiButtonProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "540 0";
extent = "40 15";
minExtent = "8 2";
visible = "1";
text = "Hide";
groupNum = "-1";
buttonType = "PushButton";
command = "HelperGui.hide();";
};
};
//--- OBJECT WRITE END ---
function HelperGui::onWake(%this)
{
sceneName.setText("t2dSceneGraph");
%this.hidden = false;
%this.mode[%this.convertToNum(BB)] = false;
%this.mode[%this.convertToNum(ColPoly)] = false;
%this.mode[%this.convertToNum(MNodes)] = false;
%this.mode[%this.convertToNum(MLink)] = false;
%this.mode[%this.convertToNum(WLimit)] = false;
%this.mode[%this.convertToNum(All)] = false;
DebugControls.setVisible(true);
}
function HelperGui::convertToNum(%this, %char)
{
switch$(%char)
{
case "BB":
return 0;
case "ColPoly":
return 1;
case "MNodes":
return 2;
case "MLink":
return 3;
case "WLimit":
return 4;
case "ALL":
return 5;
}
}
function HelperGui::setMode(%this, %mode)
{
%this.scene = sceneName.getText();
if(%mode !$= "ALL")
if(%this.mode[%this.convertToNum(ALL)] $= true)
{
%this.mode[%this.convertToNum(ALL)] = false;
%this.turnDebugOff(ALL);
}
if(%this.mode[%this.convertToNum(%mode)] $= true)
{
%this.mode[%this.convertToNum(%mode)] = false;
echo("turning off:" SPC %mode);
%this.turnDebugOff(%mode);
} else
{
%this.mode[%this.convertToNum(%mode)] = true;
echo("turning on:" SPC %mode);
%this.turnDebugOn(%mode);
}
}
function HelperGui::turnDebugOn(%this, %mode)
{
switch$(%mode)
{
case "BB":
(%this.scene).setDebugOn(BIT(1));
case "ColPoly":
(%this.scene).setDebugOn(BIT(5));
case "MNodes":
(%this.scene).setDebugOn(BIT(2));
case "MLink":
(%this.scene).setDebugOn(BIT(3));
case "WLimit":
(%this.scene).setDebugOn(BIT(4));
case "ALL":
(%this.scene).setDebugOn(0xFFFFFF);
}
}
function HelperGui::turnDebugOff(%this, %mode)
{
switch$(%mode)
{
case "BB":
(%this.scene).setDebugOff(BIT(1));
case "ColPoly":
(%this.scene).setDebugOff(BIT(5));
case "MNodes":
(%this.scene).setDebugOff(BIT(2));
case "MLink":
(%this.scene).setDebugOff(BIT(3));
case "WLimit":
(%this.scene).setDebugOff(BIT(4));
case "ALL":
(%this.scene).setDebugOff(0xFFFFFF);
}
}
function HelperGui::hide(%this)
{
if(%this.hidden $= false)
{
DebugControls.setVisible(false);
%this.hidden = true;
} else
{
DebugControls.setVisible(true);
%this.hidden = false;
}
}now go to your "client.cs"
find
// Load-up Datablocks.
exec("./datablocks.cs");
// Load-up GUIs.
exec("./mainScreenGui.gui");then add this right after it
exec("./HelperGui.gui");thats how you add a gui so you can load it ... now go down a couple lines and find
// Set GUI. Canvas.setContent(mainScreenGui); // Set Cursor. Canvas.setCursor(DefaultCursor); //Canvas.pushDialog(HelperGui);
and add this
mainScreenGui.add(HelperGui);
this will add it to the main gui so you can use it at the same time... note the hide button that i will hide the buttons out of the way... and the text input box is for whatever you want to set debug modes for... leave it as default if you want to change all and haven't changed your sceneGraph name...
Some pics
About the author
Was a GG Associate and then joined GG in 2005. Lead tool dev for T2D and T3D. In 2011 joined mobile company ngmoco/DeNA and spent about 4 years working game and server tech. 2014 joined startup Merigo Games developing server technology.
#2
03/05/2005 (5:25 pm)
Nice! I use something similiar in my game. Another handy thing is set two buttons to change the global $timescale property. I have one labeled "SloMo" which, when hit, executes the command of "$timescale = 0.2;" that causes Torque to slow down. I use that to watch particle and mounts to make sure they are lined up properly, as doing this with fast-moving objects is pretty hard!
#3
btw love your work ! That robo-rat is very cool, was just thinking "I wonder how cuto outs of renders would look in T2D" and bam an awesome looking render of a robot pops up on the boards lol :)
03/06/2005 (12:18 am)
ooooh, good idea definately going to have to add that lol... still trying to find all the best debug functions to add so new users can have easy access to things they might not know exists...btw love your work ! That robo-rat is very cool, was just thinking "I wonder how cuto outs of renders would look in T2D" and bam an awesome looking render of a robot pops up on the boards lol :)
#4
03/28/2005 (9:56 am)
Nice job Matt!
#5
04/09/2005 (4:58 am)
excellent this should come with the torque 2d sdk for sure. 
Torque Owner Josh Williams
Default Studio Name