Upcoming Events
Unite 2010
11/10 - 11/12 @ Montréal, Canada

GDC China
12/5 - 12/7 @ Shanghai, China

Asia Game Show 2010
12/24 - 12/27  

GDC 2011
2/28 - 3/4 @ San Francisco, CA

More events...
Quick Stats
99 people currently visiting GDNet.
2406 articles in the reference section.

Help us fight cancer!
Join SETI Team GDNet!
Link to us Events 4 Gamers
Intel sponsors gamedev.net search:

  Contents

 Introduction
 Saving Windows
 Loading Windows
 Resource Editors
 Subclassing
 Speeding Up
 GUI Rendering

 Conclusion

 Printable version

 


  The Series

 Part I
 Part II
 Part III
 Part IV

 

Loading Windows

Loading windows is more difficult than saving them, primarily because you have to new each window, load it up, and then remember to delete it when it's no longer needed.

This function is recursive, and looks like this in PDL:

void gui_window:load(int filehandle) { // read window properties (colorsets, etc.) // read total number of children for this window // for each child… // read window ID from disk // new a gui_window derivative based on that ID // tell the newly created window to load itself (recurse!) // next child }

In other words, you'd load windows from disk exactly as you would expect. First, you take care of the base window: read in its properties. Then, read in the total number of children of the base window. For each child, read an ID byte, new up a window based on that ID, and then tell that new window to load itself (recurse down into it). Once all of your children are loaded, you're done.

Of course, it's also very important that your file structure mirrors this same layout. Make sure your save code saves things in the same order that you're loading them.


Next : Resource Editors