Progress bars

Monkey Forums/Monkey Programming/Progress bars

siread(Posted 2011) [#1]
At various times my game takes a while to process information (loading/saving game state, processing football match results etc). I would like to display a progress bar (or at least a 'Please Wait' screen) whilst it is working through the data. In BlitzMax I would simply draw my screen and call Flip at various points in the process but it seems you cannot make a call to OnRender whilst the game is updating. Is there a way around this?


Nobuyuki(Posted 2011) [#2]
You could explicitly wait to load resources based on a counter in the OnUpdate portion, requiring several update loops to load all the resources. This should give you enough time to update the OnRender loop at least somewhat. Use your master OnUpdate resource loading loop counter to base your OnRender progress bar on....


siread(Posted 2011) [#3]
Yes, but I'm talking about processing data, not loading resources. The program is going through hundreds of objects and calculating results. It's not the sort of thing I can break down into separate parts.


Nobuyuki(Posted 2011) [#4]
if it is a "black box" function that goes out to an Extern, and takes significant time during an OnUpdate cycle to the point where you'd need a loading bar and yet can't do an OnRender cycle, then you might have a problem. Otherwise, your processes should be split into smaller parts if you want to insert updates to your progress bar in between them. Note that how often you'll want to split the process and update the bar will make an impact on how much extra overhead you'll be introducing into the loading process.......

But seriously, other than I/O ops, I can't imagine very many cases where you'd want a loading bar which needs to be updated. You can display a "Please Wait" screen before explicitly calling your operations on the update loop before by having some sort of boolean switch to draw it on the next render cycle, and I believe you can force the next update cycle in the OnRender method once your "loadwhatevernext" switch is True. Before that point in the render cycle, display your "Please Wait" graphic. On the update cycle after that, do your intensive processes and flip the loading screen graphic switch back to False. To the program, it will appear to have rendered only 1 frame (1 update actually), but it should display for as long as is needed for the update cycle to complete.