Thursday, February 24, 2005

Thursday 24th

Tackled the remainder of the Brush I/O code today, which involves saving the entire collection of brush buffers (as well as the Brush currently being used, the user can store up to 8 Brushes in temporary buffers and thus have a 'library' of commonly-used Brushes).

As has been the case all week, however, I struggled with this code making tweak after tweak; the problem with I/O is knowing what's going wrong - if you save a file and it won't load back in, has the save routine messed up or the load routine? The only way to work through the issues is edit the routines side by side to ensure that everything is read/written in the correct order.

With progress slow, I decided to turn my attention to my To-Do list, rather than waste valuable time pouring over what could turn out to be a very simple problem (I'm hoping a fresh look at the code tomorrow will yield some results).

* * *

The biggest remaining task on my list - something I'd been dreading for some time - was the Tileset integration. Currently, the code already contains commands that load in a default set of tiles when the program is run. While this is obviously fine for me - I merely tweak a line of code to use an alternative Tileset - it limits the Editor's functionality for anyone else wishing to create maps.

After careful tinkering, the user can now load in a Tileset to any one of the eight "slots" designated for Tilesets. As an added bonus, the program even handles Tilesets that aren't in the correct format; although the results are clearly bad, the program doesn't crash, which means that I don't have to write a lengthy routine to validate each file. As a final tweak, I added a refresh facility so that the tiles can be tweaked simultaneously in another package and 're-loaded' with a single click.

The next task was an idea that only occurred to me yesterday: the user can currently dump the screen or the entire Map to a BMP file - so why not the current Brush? A quick amendment to the Brush routine, and this was in and working beautifully. Far too many Editors overlook the facility to save graphics out from the editor, but in my experience this has been invaluable for the artist creating the tiles - it's easier to track down mistakes, and they can even tweak the tiles on the screen dump then slice this up into tiles again and re-import them.

Still in Brush territory, I expanded the Exchange Tile code to encompass Brushes as well (if you recall, the user can highlight a Tile with the Left button, then the replacement Tile with the Right button, then press a key to exchange all instances of the Left tile with the Right). It seemed a natural evolution to apply this to Brushes, since it now allows you to perform 'localised' tile exchanges.

Flushed with my progress, I also tackled another pretty big routine that displays a Static backdrop behind the map window. Though this probably isn't something I'll be using for Citadel, it will come in handy for other projects, especially those that utilise a static or parallax backdrop. The basic routine was up and running fairly quickly, but may need further refinement as things progress.

The final job for the night came as a result of adding the Static backdrop code: originally, when the Editor was first put into its GUI, one of the Layers had been reserved specifically for the Static backdrop. As this has now changed slightly (and given that I want to avoid restricting what sort of data a Layer can hold), I made the Static backdrop independent of the actual Layers, and expanded the number of Layers from six to eight.