Arghitecture, More Modal Gadgets and SDL Updates

Following some fast-paced discussion regarding the last set of changes, I’ve made some more alterations.

The Woopsi class now uses the new modal system to run its own loop. This is only of interest if you’re following the old design pattern of writing your own main loop. You should replace a call to woopsiApplication->run() or woopsiApplication->play() with a call to woopsiApplication->goModal().

I realised that having a custom loop within the Woopsi class is a bit daft when that class already has built-in functionality to run a loop courtesy of the Gadget class. This change has let me take out the custom loop code.

Gadgets are now only modal whilst the Woopsi instance is itself modal. The upshot of this is that calling woopsiApplication->stopModal(), in order to quit Woopsi, will now force any other modal gadgets to cede control back to the main loop so that it can exit.

I’ve added a few bugfixes. All attempts to dereference woopsiApplication are now guarded within NULL checks, which should prevent any NULL pointer-related crashes.

The SDL code has seen some improvements, too. I’ve merged the SDL quit code into the Woopsi::shutdown() method. This method should be called last in any overrides, unless you don’t want to quit SDL, in which case it’s your own responsibility to shut down SDL.

Quitting an SDL Woopsi application now stops Woopsi being modal, which means (aha!) all gadgets stop being modal and the application exits correctly.

The SDL event pump is now part of Woopsi::processOneVBL(), which means that as long as VBLs are getting processed, Woopsi will listen for quit events.

Lastly, I’ve merged the DS and SDL versions of the woopsifuncs files. This means that the SDL and DS “woopsi” folders are now identical. In fact, the only difference between a DS Woopsi project and an SDL Woopsi project is the need to include the supplied “sdl/nds.h” file in the SDL project. This includes a “USING_SDL” define again, since switching to a check for “_SDLH” didn’t work for me.