Creating a GUI
by Tom Whitaker · in Torque Game Engine · 07/02/2004 (9:20 am) · 6 replies
I've got a GuiFadeInBitmapCtrl that fades in and fades out, of course, but once it's done doing that, I don't know how to make my main menu pop up. I've looked through the stock scripts that come with the Torque demo, but I haven't seen anything that specifically would demonstrate. Any ideas?
#2
);
or if you want to pop up a dialog above the main content(as set above):
Canvas.pushDialog();
and to close it:
Canvas.popDialog();
Hope that helps
07/02/2004 (10:10 am)
Canvas.setContent(or if you want to pop up a dialog above the main content(as set above):
Canvas.pushDialog(
and to close it:
Canvas.popDialog(
Hope that helps
#3
07/10/2004 (9:54 am)
I got the Canvas.pushDialog(); function to work, but I can't figure out how to make it "pop the dialog", as it were, after it's done fading out. I looked through the "stock" init.cs and startup.gui scripts, and couldn't see anything in there that would make it wait, and then execute the command. Any ideas?
#4
When you looked though startup.gui did you see the following function?
Note how the canvas is set to StartupGui which is a GuiFadeInBitmapCtrl. Also note that a schedule has been setup to run in 100 milliseconds.
Now lets go to the checkStartupDone function that is also in the file.
Note how the StartupGui.done is checked? This 'done' is either set by the control, or by code. (See function above this one in the code file for setting 'done' by mouse click)
So if 'done' is true, load the mainmenu, else schedule another check.
If you want to use dialog, then you will need to change the setContent to pushDialog and just before the call to loadMainMenu you will need to popDialog.
The definition of the GuiFadeinBitmapCtrl(StartupGui) has the following three lines.
fadeinTime = "125";
waitTime = "3000";
fadeoutTime = "125";
This means that the control will fade in fast, wait 3 seconds, fade out fast. So total wait time is 3.25 seconds, and that is when the 'done' will be set to true.
07/10/2004 (10:28 am)
Did you know how schedule works?When you looked though startup.gui did you see the following function?
function loadStartup()
{
StartupGui.done = false;
Canvas.setContent( StartupGui );
schedule(100, 0, checkStartupDone );
alxPlay(AudioStartup);
}Note how the canvas is set to StartupGui which is a GuiFadeInBitmapCtrl. Also note that a schedule has been setup to run in 100 milliseconds.
Now lets go to the checkStartupDone function that is also in the file.
function checkStartupDone()
{
if (StartupGui.done)
{
echo ("*** Load Main Menu");
loadMainMenu();
}
else
schedule(100, 0, checkStartupDone );
}Note how the StartupGui.done is checked? This 'done' is either set by the control, or by code. (See function above this one in the code file for setting 'done' by mouse click)
So if 'done' is true, load the mainmenu, else schedule another check.
If you want to use dialog, then you will need to change the setContent to pushDialog and just before the call to loadMainMenu you will need to popDialog.
The definition of the GuiFadeinBitmapCtrl(StartupGui) has the following three lines.
fadeinTime = "125";
waitTime = "3000";
fadeoutTime = "125";
This means that the control will fade in fast, wait 3 seconds, fade out fast. So total wait time is 3.25 seconds, and that is when the 'done' will be set to true.
#5
One more question: in the schedule function, it receives three parameters; 100, 0, and checkStartupDone. What does the 0 refer to?
07/10/2004 (11:57 am)
Aha, that makes tons more sense, thanks a ton Simon. I had looked through that script and recognized that's what that bit of code is supposed to do, but damned if I couldn't make it do it again elsewhere, even after copying the function prototypes into init.cs in my files.One more question: in the schedule function, it receives three parameters; 100, 0, and checkStartupDone. What does the 0 refer to?
#6
it is either 0 (NULL) or the pointer to a refobject.
07/10/2004 (10:12 pm)
This is the help for the console function definition of schedule as in simBase.ccschedule(time, refobject|0, command, <arg1...argN>)
it is either 0 (NULL) or the pointer to a refobject.
EG: myObject.schedule( 1000, doSomething ); can also be written as schedule( 1000, myObject, doSomething ); which would call function myObject::doSomething( blah, blah, blah ) so using 0 would mean calling just a function of function doSomething( blah, blah, blah )
Torque Owner CdnGater
Duggan Software Studio
take a look at the two following 'stock' script files
starter.fps/client/ui/startup.gui
starter.fps/client/init.cs