Thursday, December 22, 2005

Coding Windowed GUIS
Is much harder than you think. Of course, windows handles this brilliantly, and we all take it for granted, but when you have to re-code the whole thing for a game it's very tricky.
I have used the same ever-expanding engine for a lot of my games, but its mainly a 3D engine (used to draw 2D worlds), rather than a GUI. Little bits of GUI code have gradually slid from new games into the engine itself.
You might think windowed GUIs are simple but they arent:

For example, you need a concept of a window manager to render them in the right order. bottom window first, top window last.
But you need to process input in the reverse order, so that mouse clicks hit the top window first.
And you need a concept of child windows, so closing a window also closes any tooltips or sub-panes associated with it.
And you need to handle 'eating' input, so you dont get mouse clicks falling through windows onto the ones underneath.
Then you need to handle 'modal' windows, for when you restrict input to a new dialog box.
Then comes the clean handling of the escape key to close the top dialog.
Then (maybe) some render optimising to ensure you aren't drawing totally obscured windows.
And don't get me started on dynamically resized windows to cope for extra-long translated strings.
Still, its' all good fun I guess.

Went to the cattery to consider getting a new cat today. Jury still out.