Quick GUI question...
by Joe Kauffman · in Torque Game Builder · 08/25/2006 (2:55 pm) · 3 replies
Hey,
i'm trying to get this straight...
In addition to being holders for pop-up dialogs and such, are GUIs the main "holders" for ALL of the content?
i.e, does the level that i create in the Level Builder (myLevel.t2d) get placed in the mainScreen.gui?
so therefore i would have splashscreen1.gui, splashscreen2.gui, mapScreen.gui, gameOver.gui etc....?
and i switch between the different GUIs to change the screen?
i.e to go from the game screen to the game over screen to the main menu screen, i would switch out the GUIs?
I'm just trying to get the hierarchy down.
thanks!
joe
i'm trying to get this straight...
In addition to being holders for pop-up dialogs and such, are GUIs the main "holders" for ALL of the content?
i.e, does the level that i create in the Level Builder (myLevel.t2d) get placed in the mainScreen.gui?
so therefore i would have splashscreen1.gui, splashscreen2.gui, mapScreen.gui, gameOver.gui etc....?
and i switch between the different GUIs to change the screen?
i.e to go from the game screen to the game over screen to the main menu screen, i would switch out the GUIs?
I'm just trying to get the hierarchy down.
thanks!
joe
#2
Thank you for responding.
For a beginner to TGB, It gets a little confusing with all the "containers" or viewports...
There's the canvas, GUIs, scenewindow2Ds, scenegraphs, levels, multiple camera views...
(Coming from Flash, we only have the stage...what is on the stage rectangle is what you see.)
Okay, so i have some more questions...
(thanks if you can answer them or point me in the right direction)
1. Is the Canvas the master "container" that everything gets drawn onto?
2. Does a sceneWindow2D need to get drawn onto a GUI, or can they get drawn directly to the Canvas?
3. Is the basic heirarchy: Canvas --> GUI --> sceneWindow2D --> level --> cameraView?
Thanks again!
Joe
08/26/2006 (2:27 pm)
Yes! Thanks Trevor! That totally helps.Thank you for responding.
For a beginner to TGB, It gets a little confusing with all the "containers" or viewports...
There's the canvas, GUIs, scenewindow2Ds, scenegraphs, levels, multiple camera views...
(Coming from Flash, we only have the stage...what is on the stage rectangle is what you see.)
Okay, so i have some more questions...
(thanks if you can answer them or point me in the right direction)
1. Is the Canvas the master "container" that everything gets drawn onto?
2. Does a sceneWindow2D need to get drawn onto a GUI, or can they get drawn directly to the Canvas?
3. Is the basic heirarchy: Canvas --> GUI --> sceneWindow2D --> level --> cameraView?
Thanks again!
Joe
#3
1. That is a pretty good way to think of the Canvas. Here is some comments I've copied straight out of the guiCanvas header file in the source code, a very good and more technical description.
2. sceneWindow2D is a "t2dSceneWindow" which is a GUI control... you can create just that scene window gui control and set the canvas content to just that since it is a GUI control.
3. Sort of... though SceneWindow2D is a Gui Control...
08/28/2006 (2:18 pm)
Thanks for helping Joe out Trevor, some great anwers!1. That is a pretty good way to think of the Canvas. Here is some comments I've copied straight out of the guiCanvas header file in the source code, a very good and more technical description.
Quote:/// A canvas on which rendering occurs.
///
///
/// @section GuiCanvas_contents What a GUICanvas Can Contain...
///
/// @subsection GuiCanvas_content_contentcontrol Content Control
/// A content control is the top level GuiControl for a screen. This GuiControl
/// will be the parent control for all other GuiControls on that particular
/// screen.
///
/// @subsection GuiCanvas_content_dialogs Dialogs
///
/// A dialog is essentially another screen, only it gets overlaid on top of the
/// current content control, and all input goes to the dialog. This is most akin
/// to the "Open File" dialog box found in most operating systems. When you
/// choose to open a file, and the "Open File" dialog pops up, you can no longer
/// send input to the application, and must complete or cancel the open file
/// request. Torque keeps track of layers of dialogs. The dialog with the highest
/// layer is on top and will get all the input, unless the dialog is
/// modeless, which is a profile option.
///
/// @see GuiControlProfile
///
/// @section GuiCanvas_dirty Dirty Rectangles
///
/// The GuiCanvas is based on dirty regions.
///
/// Every frame the canvas paints only the areas of the canvas that are 'dirty'
/// or need updating. In most cases, this only is the area under the mouse cursor.
/// This is why if you look in guiCanvas.cc the call to glClear is commented out.
/// If you want a really good idea of what exactly dirty regions are and how they
/// work, un-comment that glClear line in the renderFrame method of guiCanvas.cc
///
/// What you will see is a black screen, except in the dirty regions, where the
/// screen will be painted normally. If you are making an animated GuiControl
/// you need to add your control to the dirty areas of the canvas.
2. sceneWindow2D is a "t2dSceneWindow" which is a GUI control... you can create just that scene window gui control and set the canvas content to just that since it is a GUI control.
3. Sort of... though SceneWindow2D is a Gui Control...
Torque 3D Owner Trevor Lanz
Default Studio Name
So, in short -- a GUI doesn't necessarily have to have a scene window in it at all (for instance, a Splash screen, main menu screen, etc. might not have a scene window). If you create an entirely new GUI and wish to have your level displayed within it, just make sure you create a t2dSceneWindow control within the new GUI and have that scene window load your level.
You can also "push" and "pop" guis on top of other guis. An example of this might be a simple dialog gui, an overlay, etc.
As far as your questions, yes -- you could just switch between the different GUIs (if you wish to comepletely change what's up on the screen), such as:
Canvas.setContent(brandNewGui);
OR, in the case of a simple "overlay" gui (like a dialog, etc.), you could just use something like:
Canvas.pushDialog(myDialogGui);
Hope this clears things up a bit?