Saturday, April 28, 2007

More on GUI

in the last weeks, i was working on the gui, it is more complicated then i thought but i'm now supporting almost all the features. the best way to explain what this .gui file can do is by giving an example so here is one:
windowDef Desktop
rect 0,0,640,480
backcolor 0,0,0,1
visible 1
windowDef raven
rect 120,40,400,400
visible 1
background "gfx/guis/mainmenu/raven_1"
matcolor 0,0,0,1

the system based on nested windows and events. there is one top level window called 'Desktop' then one or more windows that are 'children' of the desktop, then zero or more windows that are children of the children, etc... (every window/event has it own params)
here we define the top must window 'Desktop' positioned at 0,0 with size of 640 n 480 (width and height), we set his background color to black and make sure he is visible.
we then create a second window, which is child on desktop positioned at 120,40 with size 400,400, make sure this one also visible and also set his background image to some texture.
'matcolor' is texture color, so here we set it to black so later we could create a transition effect so it fades in and out.
the lines below define transitions on texture color of raven window (they should be inside 'Desktop' brackets)
windowDef anim_credits
rect 0,0,1,1
visible 1
notime 0

onTime 0 {
transition "raven::matcolor" "0,0,0,1" "0.839,1,0.658,1" "1000" ;

onTime +3000 {
transition "raven::matcolor" "0.839,1,0.658,1" "0,0,0,1" "1000" ;

ok, i said we could define some events so here we define the 'onTime' events which runs the actions/sets inside is brackets every T+

Saturday, April 7, 2007

GUI files

this week i added GUI so i could use it for displaying hud/weapons ammo/power ups etc.
id uses .gui files which basically a script that allows you to define elements to display on the gui such as windows/text boxs/images etc, you can also set there properties like rect, color, text, font and more - this is very easy and fast way to create GUI's.
after you have the GUI script you can render the GUI on a 3d surface in the game.
for example: you can use it to display player info like health, power ups (on 2d screen), or on 3d surface of a weapon to show ammo info.
here is a screen shots of .gui files from id quake4 folder that i'm loading from my engine, for now its rendered on the screen, but next time i will show it inside the game.