Toiled for a while trying to get the Brush rotate commands to work; after 10 minutes I realised there were a couple of parameters the wrong way round. Fired it up and it worked beautifully, except that I kept getting an error on exit (which usually points to memory being overwritten by a leaky array).
After a bit of subtle investigation I realised a temporary buffer I was using wasn't big enough (this ties into the fact that arrays are created using whole numbers starting at 1, while variables start at 0). A couple of key presses (and several sweary words) later, everything was working, and means that all the Brush-related tools are finished. All I have to include now is the facility to "save" a brush to one of 8 buffers, and load the brush back again.
* * *
Work continued slowly but consistently this evening; I added the controls to scroll the Tile window (and widened the window slightly in the process), ready for the cleanup of my Main Loop. I also Took the liberty of tweaking my test tileset to include numbers in all the blank / unused tiles (this helps with debugging, allowing me to see a little more clearly when things go wrong).
I then tweaked the Toolbar, removing the Insert / Delete Column / Row buttons (it's more intuitive to do this using keypresses as you need to keep the cursor in the correct spot on-screen - selecting the option from the Toolbar meant the cursor was never in the right position), as well as adding icons for the Brush rotation functions. I then coded a small routine which checks the map and reports the occurrences of each tile - this will be used in the Info panel at some point.
While tinkering with some of the drawing functions, I realised that it's annoying when certain tiles are accidentally drawn over (particularly as I've yet to code an Undo function). I thus hit upon the idea of having "masked" tiles - akin to the Stencil mode from Deluxe Paint - where the user can "lock" certain tiles to prevent them being drawn over. This mask is exclusive to a particular tileset, can be tweaked as required, and turned on and off at will. In theory. :)
The next big task was to tweak my Main Loop, something which I've been dreading, and something which could have a knock-on effect to many areas of the code. Thankfully, things went pretty smoothly, and I now have a slightly more organised program. Further tweaks are required, such as the calling of key functions, but these will be handled as I finish things off.
* * *
Whenever you create a program, such as an Editor, the abundance of extra features often tends to swamp the little "what ifs" that may not readily become apparent. I'd jotted down on my notepad something to do with variable map sizes - specifically, what happens if a map is smaller than the screen? Surely the drawing tools have to be tweaked? Thankfully, all it required was a small initialisation routine which changes a couple of universal values.
However, one thing became readily apparent: I now needed clipping routines for the Brush (which, if you recall, I removed from the code yesterday!). The actual Brush clipping was easy enough, but the outline which surrounds the brush was a little trickier, if only because I'd mis-labelled my code. There also remains the issue of fixing the Mini-Map, which doesn't seem to like maps smaller than the screen and throws a small wobbly, but as the system needs finishing anyway I can do this as I go along.
