Tuesday, May 23, 2006

Tuesday 23rd

Tackled the Brush Thumbnail system today, as there were still plenty of issues with several routines. The main problem was, what if the program tries to load a Tileset (as part of a Project file) but cannot find it? Ordinarily, after loading the Tileset, the thumbnails for any stored Brushes need to be calculated - this isn't possible if the Tileset isn't found. Plus, what happens if a Brush Thumbnail is defined, but then the user elects to close the Tileset?

Essentially, when a Brush is grabbed from a Layer and stored in a buffer, the thumbnail is generated from the Tileset assigned to the currently-selected Layer (and thus, each thumbnail could potentially be from a completely different Tileset). However, if the Tileset isn't loaded or gets closed, no thumbnail exists and thus, errors creep in.

The first task was to therefore add an array which tracks which Tileset was used to generate the thumbnail. Next, I added some checks to the thumbnail display code, which prevented any un-generated thumbnails from being displayed (along with an appropriate "Thumbnail Error" message). Next, I tweaked the thumbnail routine so that I can tell it precisely which Tileset to use (up until now, it had assumed the same Tileset). And finally, the Load Project code required a few tweaks to integrate these various checks and trap any errors.

The upshot of all this extra work yields the following results; a Brush grabbed from a given Layer and subsequently stored will generate a thumbnail image only if a Tileset is loaded - if not, the Brush is still stored, but an appropriate message is displayed. Should the user close a Tileset used to generate a thumbnail, again an appropriate message is displayed in place of the thumbnail. And finally, when the user loads a Project FIle but a Tileset is missing, any associated Brushes are loaded but not displayed. In any of these instances, as soon as a Tileset is loaded into the right spot, the thumbnails are generated and the error messages disappear. Phew!

Needless to say, today's session was very intense, and what I term an "out of your seat" day (i.e. you spend more time pacing and drinking tea than you do at the keyboard). Thankfully, it nudged me ever closer to getting the Editor out of the door, and threw out a couple of nice tweaks I want to include after Beta.

The final task of the night involved a few tweaks to the Drawing Modes, as I'd neglected to include error trapping if the user, for example, chooses Line Mode while in the middle of drawing a Box. Thankfully, this was as easy as clearing a few variables, and as an added bonus, it's rather nice to be able to change your mind after starting to draw something.