Save and Load have been added!!

I told you I could do it! It wasn’t easy — I had to rewrite four other classes to make this work. My code is a lottttt cleaner than before. Some highlights of tasks I undertook to get this working:

  • Reworking the State machine that drives Tile functionality
  • Reconfiguring the base tile dictionary to feature key value pairs of <int, BoardTile>, instead of <int, PersistableObject>, then extending my BoardTile class from PersistableTile, which is where the save functionality is stored. (This may move to BoardTile later, it’s kind of a weird setup and it feels needlessly complicated at the moment.
  • Redesigning the workflow of instantiating tiles. Gone are ButtonTileHandler’s heavy responsibilities. Now I have a BoardTileFactory for that.
  • Rewriting the Save functionality to do a foreach(KeyValuePair<int, BoardTile> tile in mapTiles) loop rather than a for loop — the latter was causing inconsistencies when tiles were deleted, where gaps in numbers existed in Tile ID / mapTiles.Keys.
  • Writing a function that nicely reorders the dictionary when you reload it, in the event of Tile ID gaps. This can be enabled or disabled by the user.

It’s been a busy few hours! The next task on my list is adding ‘are you sure’-type UI prompts, as well as a Save As dialogue for saving and an Open dialogue for loading maps. Once these are done….the UI will need redesigning.

The work continues-

A new repo for a revamped project.

In my first post, I mentioned that I’d consider posting hobby stuff. Well….consider this the first such post.
I’ve finally created a repo for the new version of my board map editor. It’s almost fully-functional: you can create a board, then place, edit, and delete tiles, As of the today’s push, save and load hasn’t been implemented yet. I’ve been sorta dancing around that by making everything else work first…which is still important work but save and load is a little bit of a pain in the ass. I’m up to the task, though!
Soon…