Saturday, October 4, 2008

Loading Screen

hi, this time i added loading screen feature so we see when the loading process while level data is loaded and cached.
i also added the feature to load new maps on runtime via cvar, so i could check other maps while the core engine i initialize and cached so i wont need to stop and run the project every time i want to check other/new map.
this was mainly an engine redesign process so everything related to level map could be released and initialized on demand.
the loading screen i based on my gui system so its just a matter of designing the loading script and load it and update the variable and call triggers when needed.
here is some of the code in the loading gui script:
windowDef p_load_bar
{
rect 235,431,( "gui::map_loading" * 405 ),26
visible 1
windowDef load_bar
{
rect 0,0,405,26
visible 1
background "gfx/guis/mainmenu/load_bar"
matcolor 0.878,0.423,0,0.5
}
}
this window i the loading progress bar we see while we wait for the level to start, notice the 'gui::map_loading' variable in the rect definition of the window 'p_load_bar', this variable used to control the visibility of window 'load_bar'.
because i have parent/child design, the parent window also scissor his child, that means the child windows can be visible only inside their parent rect.
when i'm loading level/map data i'm setting this variable to the right value [0..1] and when i'm finished i'm triggering the event 'FinishedLoading' that changed the text near the loading to
'click to continue'
also i added script file per map, so i could define map related parameters such as the loading image. thumb image etc.
when i need to load specific map i'm checking if the map has a script file, if so i'm getting the image that i need to load and set it as 'gui::loading_bkgnd' in the loading gui, here is the loadimg window declared inside the script:
windowDef loadimg
{
rect 0,0,640,480
visible 1
background "gui::loading_bkgnd"
matcolor 1,1,1,1
}
the window is responsible to display the loading background image.
here is a screenshot of one of my test levels:

map doesn't have loading image
notice the click to continue text which shown when the map finished loading

No comments: