video buttons for tge
by Benoit Touchette · 03/04/2007 (7:41 am) · 3 comments
Download Code File
Code to enable buttons that use ogg/theora video files instead of bitmaps. Included in the zip file are sample implementation and source code. Just drop the source files into engine/gui/controls, add them to your project and recompile.
A sample button would look like:
There is a need to create 4 files. One for normal, highlighted, depressed and inactive. When setting the filename do not add the extesion as these will be added in. The files for example would as so if the base name was test:
test_n.ogm
test_h.ogm
test_d.ogm
test_i.ogm
Available scriptable settings are:
setFilename = sets filename
stopOnSleep = stops videoplaback when asleep
enableBackground = enables a color background
done = tells the button its done but isn't used when looping
loop = tells the button to loop the video for each state
available scriptable functions are:
setFile = set an Ogg Theora file to play
stop = stop playback
getCurrentTime = return elapsed time in playback in seconds
You can find a video of it in action @ www.youtube.com/watch?v=SYgS0mRQRKI. (Note to due to capturing issues the video has some dropped frames, best try the sample implentation to really see it in action).
Unfortunately the full package can't be include with the resource but can be found @ www.graegoo.com/draekko/theorabutton_full.zip.
Code to enable buttons that use ogg/theora video files instead of bitmaps. Included in the zip file are sample implementation and source code. Just drop the source files into engine/gui/controls, add them to your project and recompile.
A sample button would look like:
new GuiTheoraButtonCtrl(theobutton)
{
profile = "GuiDefaultProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "21 82";
extent = "140 30";
minExtent = "8 2";
visible = "1";
done = "0";
stopOnSleep = "1";
loop = "1";
command = "canvas.pushDialog(\"playGameGui\");";
setFilename = "demo/data/video/test";
groupNum = "-1";
buttonType = "PushButton";
};There is a need to create 4 files. One for normal, highlighted, depressed and inactive. When setting the filename do not add the extesion as these will be added in. The files for example would as so if the base name was test:
test_n.ogm
test_h.ogm
test_d.ogm
test_i.ogm
Available scriptable settings are:
setFilename = sets filename
stopOnSleep = stops videoplaback when asleep
enableBackground = enables a color background
done = tells the button its done but isn't used when looping
loop = tells the button to loop the video for each state
available scriptable functions are:
setFile = set an Ogg Theora file to play
stop = stop playback
getCurrentTime = return elapsed time in playback in seconds
You can find a video of it in action @ www.youtube.com/watch?v=SYgS0mRQRKI. (Note to due to capturing issues the video has some dropped frames, best try the sample implentation to really see it in action).
Unfortunately the full package can't be include with the resource but can be found @ www.graegoo.com/draekko/theorabutton_full.zip.
About the author
#2
03/05/2007 (6:55 am)
Simon@ it would require some extra work to get it to start a clip from the timeframe of the last video clip. It should be doable though, i'll take a look at it when i get a chance later this week.
#3
04/06/2007 (9:43 pm)
This is kind of what I have been looking for except what i was in need of was a video that would load when the main menu gui is loaded. I would a video of a 10 second clip of lava splattering in the background of the menu. Any thoughts on how to convert this resource to what I need?
Torque Owner Simon Love
Only problem I can see so far is that when the button switches from idle to highlighted, the video starts back at the beginning. There are surely ways to circumvent this (Always wanted to use circumvent in a sentence), but overall, Frickin' sweet ressource.