Problems (¿what is life without problems?) with guiT2DObjectCtrl
by Oriol "Orgarus" Garcia · in Torque Game Builder · 08/16/2009 (6:34 pm) · 13 replies
Hello there,
I hope someone can help me with this:
I'm trying to use this kind of GUI but when I try to access its properties or console methods the message displayed is "unable to find object", it's confusing because one line before I'm able to access the properties of another GUIcontrol without problems, an example with two simple echoes:
echo("ID GUIMinimapa:" @ GUIMiniMapa.getId()); --> it runs OK!
echo("ID GUIMinimapaPopUp:" @ GUIMiniMapaPopUp.getId()); --> ouch! it kicks my ass
I added this controls using the same way (via the GUIeditor) and the script that produces the guiT2DObjectCtrl is:
new guiT2DObjectCtrl(GUIMiniMapaPopUp) {
canSaveDynamicFields = "0";
isContainer = "0";
Profile = "GuiDefaultProfile";
HorizSizing = "right";
VertSizing = "bottom";
Position = "290 108";
Extent = "464 441";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
hovertime = "1000";
groupNum = "-1";
buttonType = "RadioButton"; //O_o excuse me?
useMouseEvents = "0";
renderMargin = "0";
sceneObject = "MiniMapa"; /*MiniMapa is a tileMap added to the level (I suppose that as an object a tileMap can be assigned to this control... I tried to assign another kind of object and this control don't run either)*/
};
I tried to asign the object via script but if I can't access the object this is useless.
I've read this on http://www.garagegames.com/community/forums/viewthread/46221 thread:
"To use GuiT2DObjectCtrl you simple create a scenegraph, create an object assigned to that scenegraph, and set call .setSceneObject(%object) on the control."
The question is ¿why? anyway I'm already working with an object (the tilemap) created in a scenegraph.
I'm more lost than a son of a bitch in father's day, if someone, please, could help me.
Kind regards.
Thanks in advance.
I hope someone can help me with this:
I'm trying to use this kind of GUI but when I try to access its properties or console methods the message displayed is "unable to find object", it's confusing because one line before I'm able to access the properties of another GUIcontrol without problems, an example with two simple echoes:
echo("ID GUIMinimapa:" @ GUIMiniMapa.getId()); --> it runs OK!
echo("ID GUIMinimapaPopUp:" @ GUIMiniMapaPopUp.getId()); --> ouch! it kicks my ass
I added this controls using the same way (via the GUIeditor) and the script that produces the guiT2DObjectCtrl is:
new guiT2DObjectCtrl(GUIMiniMapaPopUp) {
canSaveDynamicFields = "0";
isContainer = "0";
Profile = "GuiDefaultProfile";
HorizSizing = "right";
VertSizing = "bottom";
Position = "290 108";
Extent = "464 441";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
hovertime = "1000";
groupNum = "-1";
buttonType = "RadioButton"; //O_o excuse me?
useMouseEvents = "0";
renderMargin = "0";
sceneObject = "MiniMapa"; /*MiniMapa is a tileMap added to the level (I suppose that as an object a tileMap can be assigned to this control... I tried to assign another kind of object and this control don't run either)*/
};
I tried to asign the object via script but if I can't access the object this is useless.
I've read this on http://www.garagegames.com/community/forums/viewthread/46221 thread:
"To use GuiT2DObjectCtrl you simple create a scenegraph, create an object assigned to that scenegraph, and set call .setSceneObject(%object) on the control."
The question is ¿why? anyway I'm already working with an object (the tilemap) created in a scenegraph.
I'm more lost than a son of a bitch in father's day, if someone, please, could help me.
Kind regards.
Thanks in advance.
About the author
Recent Threads
#2
You might try adding it to the TGBGame build and see if that helps.
08/17/2009 (12:45 am)
Are you trying to do this in your game? I was under the impression that this class was a TGB only class (meaning the game editor) and was not available in T2D (meaning the game executable).You might try adding it to the TGBGame build and see if that helps.
#3
@Tyler
Should I work with two scenegraphs then?
One for the game and another for the GUI?
The problem won't be the same? If I create my object in another scenegraph and build in my GUI, isn't the same case?
@William
About your reply and if I understand it well (I thing that not much) that I've just read in the last posts of this thread
http://www.garagegames.com/community/forums/viewthread/66025
the following:
"Simon, your problem is that guiT2DObjectCtrl is an editor-only object in 1.5/1.5.1. TGB by default does not build them into TGBGame.exe, only TorqueGameBuilder.exe
Go into Visual Studio and add engine\source\TGB\guiT2DObjectCtrl.h and .cc to the TGBGame project and rebuild "
is this what you are talking about?
Thanks again for your help, it's very much appreciated.
Kind regards.
08/17/2009 (2:08 am)
Hi Tyler and William, I'm grateful for your help, but I have to comment your replies@Tyler
Should I work with two scenegraphs then?
One for the game and another for the GUI?
The problem won't be the same? If I create my object in another scenegraph and build in my GUI, isn't the same case?
@William
About your reply and if I understand it well (I thing that not much) that I've just read in the last posts of this thread
http://www.garagegames.com/community/forums/viewthread/66025
the following:
"Simon, your problem is that guiT2DObjectCtrl is an editor-only object in 1.5/1.5.1. TGB by default does not build them into TGBGame.exe, only TorqueGameBuilder.exe
Go into Visual Studio and add engine\source\TGB\guiT2DObjectCtrl.h and .cc to the TGBGame project and rebuild "
is this what you are talking about?
Thanks again for your help, it's very much appreciated.
Kind regards.
#4
I took a quick glance at the class, and it looks like it has no depedencies on other editor code. It should be as simple as adding the .h/.cc to the TGBGame project.
(Warning: Statement made without actually testing it!)
08/17/2009 (5:01 am)
That's exactly what I'm remembering. It's the reason you are getting the "unable to find object" (it's probably even saying "unable to instantiate non-conobject").I took a quick glance at the class, and it looks like it has no depedencies on other editor code. It should be as simple as adding the .h/.cc to the TGBGame project.
(Warning: Statement made without actually testing it!)
#5
it seems that "habemus" bug then.
Now the question is ¿can I add this files to the Game Project if I have the "normal" TGB license (i.e, I haven't the source code)? if I'm able to do this ¿how I add this thing?
I don't know if you will be agree with me but I think that it's an unnecessary battle to fight, a GUIobject that was put there by the TGB developers it should work by itself.
Thanks again and kind regards William.
08/17/2009 (5:21 am)
Hi William,it seems that "habemus" bug then.
Now the question is ¿can I add this files to the Game Project if I have the "normal" TGB license (i.e, I haven't the source code)? if I'm able to do this ¿how I add this thing?
I don't know if you will be agree with me but I think that it's an unnecessary battle to fight, a GUIobject that was put there by the TGB developers it should work by itself.
Thanks again and kind regards William.
#6
You will not be able to add it without the source code license.
Are you just trying to render a tilemap onto a button? You can emulate this behavior with the following steps:
I don't really have time to check an in-depth example, but something like...
Parts 1, 2, and 5 could be done in the GUI editor if you aren't making a dynamic GUI. I'd use an ::onWake function to do Parts 3 and 4.
Hope that helps!
08/17/2009 (10:30 am)
:) Is "habemus bug" some kind of software decree?You will not be able to add it without the source code license.
Are you just trying to render a tilemap onto a button? You can emulate this behavior with the following steps:
- Create a GuiButtonCtrl of the dimensions you want.
- Create a t2dSceneWindow slightly smaller than the button.
- Either have the t2dSceneWindow point to your current scenegraph or have it point to a new scenegraph.
- If you have it point to a new scenegraph, add your tilemap to it. If you use an existing scenegraph, make sure the camera in the new t2dSceneWindow is covering your tilemap.
- Add the t2dSceneWindow to the GuiButtonCtrl.
I don't really have time to check an in-depth example, but something like...
// PARTS 1 & 2
%b = new GuiButtonCtrl()
{
...standard button fields...
Extent = "200 200";
};
%w = new t2dSceneWindow()
{
...standard scene window fields...
Extent = "190 190";
Position = "5 5";
};
// PARTS 3 & 4
%w.setSceneGraph( $lastLoadedScene ); // If using the existing scene
%w.setCurrentCameraArea( /*area of tile map*/ );
// PART 5
%b.add( %w );Parts 1, 2, and 5 could be done in the GUI editor if you aren't making a dynamic GUI. I'd use an ::onWake function to do Parts 3 and 4.
Hope that helps!
#7
A software decree? yes... even with a hammerblow(literal translated from the spanish) included!! :)
Thanks for your (quick... you are tireless, man!) suggestion, it's time to test it (when my "serious" job allows me) and to learn how to work with more than one scenegraph (up to now I still don't try this method of development).
Greetings and thanks again.
08/18/2009 (3:43 am)
Hi William!A software decree? yes... even with a hammerblow(literal translated from the spanish) included!! :)
Thanks for your (quick... you are tireless, man!) suggestion, it's time to test it (when my "serious" job allows me) and to learn how to work with more than one scenegraph (up to now I still don't try this method of development).
Greetings and thanks again.
#8
As for multiple scenegraphs, it's as easy as saying "%sg = new t2dSceneGraph();" and "%w.setSceneGraph( %sg );".
Or... my current favorite method is to create a new level in TGB, and for "Step 3", do "%w.loadLevel( <levelFileName> );". I'll warn you, though, that if you use the global variable "$lastLoadedScene", it gets replaced with the new scene.
Good luck!
08/18/2009 (4:17 am)
No problem... I'll keep this thread tagged in case you have future questions.As for multiple scenegraphs, it's as easy as saying "%sg = new t2dSceneGraph();" and "%w.setSceneGraph( %sg );".
Or... my current favorite method is to create a new level in TGB, and for "Step 3", do "%w.loadLevel( <levelFileName> );". I'll warn you, though, that if you use the global variable "$lastLoadedScene", it gets replaced with the new scene.
Good luck!
#9
I'm finally working with multiple scenegraphs and I'm building my multiple (too) GUIs, the question that comes to my mind now is if I'm working with several scenegraphs to put there some animations I will have to unload (¿using something like safeDelete?) its content to avoid render problems when the game, strictly speaking, starts.
Kind regards.
Thanks again.
PS.-I took a look to your site and the pair of links in the Made with torque section, and man you worked a "little"... wow :)
09/03/2009 (2:08 am)
Hi William,I'm finally working with multiple scenegraphs and I'm building my multiple (too) GUIs, the question that comes to my mind now is if I'm working with several scenegraphs to put there some animations I will have to unload (¿using something like safeDelete?) its content to avoid render problems when the game, strictly speaking, starts.
Kind regards.
Thanks again.
PS.-I took a look to your site and the pair of links in the Made with torque section, and man you worked a "little"... wow :)
#10
You can follow the flow in common/gameScripts/levelManagement.cs. In the "t2dSceneWindow::loadLevel" function, the first thing it does is call another function called "<sceneWindow>.endLevel();" which ultimately calls "t2dSceneGraph::endLevel". That last function removes all the objects in the current scene.
If I misudnerstood your question, just let me know.
And thanks for the kind words!
09/03/2009 (2:37 am)
If you use the loadLevel function to load a scene into a t2dSceneWinow, it will unload the previous scene for you.You can follow the flow in common/gameScripts/levelManagement.cs. In the "t2dSceneWindow::loadLevel" function, the first thing it does is call another function called "<sceneWindow>.endLevel();" which ultimately calls "t2dSceneGraph::endLevel". That last function removes all the objects in the current scene.
If I misudnerstood your question, just let me know.
And thanks for the kind words!
#11
Thanks for your response, but I think that my english expression and that I was just awaken, made that my question was not clear.
Let's see if I can't use my limited english as well as I can (man, as I learn to use TGB I'm learning "to use" english as well...:)).
I'm working with multiple scenegraphs but not with multiple levels, because I need to maintain some data (unit configurations and stuff like this) from a gui to another. If I'm not mistaken I can't pass values from a level to an other, or, at least I don't know how to (I must confess that the variables' scope in TGB its not totally clear for me yet).
The way I'm working with my GUIs is as follows:
I have several *.gui (Menu1.gui, Menu2.gui...) that I pop and push as I need.
I create as many t2dscenewindows as I need.
In each one of these *.gui I define a function where I create a scenegraph, therefore if I have three *.gui files I have three scenegraphs..
I assign the scenegraph to the t2dscenewindows that are setting in the *.gui.
To these scenewindows I create and assign animated sprites at the moment, my intention is to create and assign a tileMap, in fact this will be my next test.
I configure the camera of the scenewindow to the proper coordinates and the area wanted to show the animated sprites that I put on the scenegraph.
The question was if all the graphics loaded in these scenegraphs remain in memory causing possible render problems, because I show and hide the GUIs using the pop and push methods (yes, I didn't put this part in the previous post)...for this reason ¿have I to "delete" them, the graphics and the scenegraphs? what's the way to do this if there was some?
Thanks for your patience and help, and for stay there.
Greetings.
09/03/2009 (3:06 pm)
Hi William, how quick!!!Thanks for your response, but I think that my english expression and that I was just awaken, made that my question was not clear.
Let's see if I can't use my limited english as well as I can (man, as I learn to use TGB I'm learning "to use" english as well...:)).
I'm working with multiple scenegraphs but not with multiple levels, because I need to maintain some data (unit configurations and stuff like this) from a gui to another. If I'm not mistaken I can't pass values from a level to an other, or, at least I don't know how to (I must confess that the variables' scope in TGB its not totally clear for me yet).
The way I'm working with my GUIs is as follows:
I have several *.gui (Menu1.gui, Menu2.gui...) that I pop and push as I need.
I create as many t2dscenewindows as I need.
In each one of these *.gui I define a function where I create a scenegraph, therefore if I have three *.gui files I have three scenegraphs..
I assign the scenegraph to the t2dscenewindows that are setting in the *.gui.
To these scenewindows I create and assign animated sprites at the moment, my intention is to create and assign a tileMap, in fact this will be my next test.
I configure the camera of the scenewindow to the proper coordinates and the area wanted to show the animated sprites that I put on the scenegraph.
The question was if all the graphics loaded in these scenegraphs remain in memory causing possible render problems, because I show and hide the GUIs using the pop and push methods (yes, I didn't put this part in the previous post)...for this reason ¿have I to "delete" them, the graphics and the scenegraphs? what's the way to do this if there was some?
Thanks for your patience and help, and for stay there.
Greetings.
#12
In your current setup, it would probably be best to create the scene graph only when the matching scene window/GUI is up. After you are done with the GUI, you should unload the scene. (I don't have access to my computer right now, but I think it's just "<sceneWindowName>.endLevel();").
As to the variables, global variables and global namespaced variables will stay around for the life of the program.
In both cases above, $myPlayerData and PlayerStats will be around forever (or until you call $myPlayerData.delete() or PlayerStats.delete()). Even the names you give GUIs will be around forever unless you delete them.
The names you give sprites will be invalid if you use endLevel() or loadLevel().
09/03/2009 (4:09 pm)
Yes, they will all be in memory (using RAM). If the scene isn't visible, then it won't render (will not use much CPU).In your current setup, it would probably be best to create the scene graph only when the matching scene window/GUI is up. After you are done with the GUI, you should unload the scene. (I don't have access to my computer right now, but I think it's just "<sceneWindowName>.endLevel();").
As to the variables, global variables and global namespaced variables will stay around for the life of the program.
$myPlayerData = new ScriptObject(); $myPlayerData.dynamicVariable1 = "Toast"; $myPlayerData.dynamicVariable2 = "Jam"; new ScriptObject(PlayerStats); PlayerStats.dynamicVariable1 = "Toast"; PlayerStats.dynamicVariable2 = "Jam";
In both cases above, $myPlayerData and PlayerStats will be around forever (or until you call $myPlayerData.delete() or PlayerStats.delete()). Even the names you give GUIs will be around forever unless you delete them.
The names you give sprites will be invalid if you use endLevel() or loadLevel().
#13
Now is crystal clear.
Yes, you are right, to unload the sceneWindow I'll have to use the endLevel method. I'll try and see how it works. There's a lot of work to be done yet.
Thanks again, master :).
09/03/2009 (5:08 pm)
It's very useful information (again) for me, specially about the variables. Little by little I'm learning this stuff (and little by little my project grows).Now is crystal clear.
Yes, you are right, to unload the sceneWindow I'll have to use the endLevel method. I'll try and see how it works. There's a lot of work to be done yet.
Thanks again, master :).
Torque Owner Tyler Slabinski
I suggest doing the same thing, it should help you fairly well.