GuiTheoraCtrl Callback...?
by Chad Kilgore · in Torque Game Engine · 04/24/2007 (2:08 pm) · 8 replies
I want to play a video using the GuiTheoraCtrl. Once the video is done, I would like it to remove itself and restore the previous ActionMap. Basically, I need to create cutscenes.
Is there a callback like GuiTheoraCtrl::onStop() that I could use to do this? If not, could anybody help me add this functionality to the engine? Or am I going about this completely wrong? Thanks.
Is there a callback like GuiTheoraCtrl::onStop() that I could use to do this? If not, could anybody help me add this functionality to the engine? Or am I going about this completely wrong? Thanks.
#2
And GuiTheoraCtrl::onRender() should read as:
This addition will allow you to use GuiTheoraCtrl::onStop in the script. For example,
However, if you attempt to add the TheoraCtrl as a a pushDialog and you try to popDialog in the onStop() function, Torque will crash. I could not figure out why this occurs.
04/30/2007 (8:06 pm)
So I think I have it figured out. GuiTheoraCtrl::stop() should read as:void GuiTheoraCtrl::stop()
{
if( !mDone )
{
mDone = true;
mTheoraTexture.stop();
if( isMethod("onStop") )
Con::executef( this, 1, "onStop" );
}
}And GuiTheoraCtrl::onRender() should read as:
void GuiTheoraCtrl::onRender(Point2I offset, const RectI &updateRect)
{
const RectI rect(offset, mBounds.extent);
if(mTheoraTexture.isReady() && mTheoraTexture.isPlaying())
{
mTheoraTexture.refresh();
dglClearBitmapModulation();
dglDrawBitmapStretch(mTheoraTexture, rect);
}
else
{
if(mTheoraTexture.isReady())
stop();
dglDrawRectFill(rect, mBackgroundColor); // black rect
}
renderChildControls(offset, updateRect);
}This addition will allow you to use GuiTheoraCtrl::onStop in the script. For example,
function GuiTheoraCtrl::onStop(%this)
{
moveMap.push();
Canvas.setContent( PlayGui );
}However, if you attempt to add the TheoraCtrl as a a pushDialog and you try to popDialog in the onStop() function, Torque will crash. I could not figure out why this occurs.
#3
04/30/2007 (8:28 pm)
Torque is not thread safe. I believe Theora is multi threaded so attempting to call script functions will result in unexpected results.
#4
04/30/2007 (8:55 pm)
Do you have any solutions to do what I want to then? Basically, I was trying to avoid creating a function in the script that would continuously call itself every second and check to determine if the playback was done.
#5
When the playing is done. set a variable on the main thread to true, and in the process tick, check if that variable is true and if so, do your callback.
04/30/2007 (8:58 pm)
Not really familiar with the Theora control, but what I would do is something like this:When the playing is done. set a variable on the main thread to true, and in the process tick, check if that variable is true and if so, do your callback.
#6
04/30/2007 (9:15 pm)
TheoraCtrl has a variable done. Would this be sufficient? For example:function GuiTheoraCtrl::onStop(%this)
{
if( %this.done )
{
moveMap.push();
Canvas.setContent( PlayGui );
}
}
#7
Wouldn't this remedy this problem altogether?
05/01/2007 (8:11 am)
Because the source contains:void GuiTheoraCtrl::stop()
{
if( !mDone )
{
mDone = true;
mTheoraTexture.stop();
if( isMethod("onStop") )
Con::executef( this, 1, "onStop" );
}
}Wouldn't this remedy this problem altogether?
#8
02/06/2010 (4:27 pm)
Did you ever find out the answer to this question?
Torque 3D Owner Chad Kilgore
if( isMethod("onStop") ) Con::executef(this, 1, "onStop");It successfully compiles and when GuiTheoraCtrl.stop() is called in the console, the GuiTheora.onStop() is successfully called. However, when the Theora movie is left to complete itself, TGE crashes. Can anybody help me out?