I've decided not to update the builds this month. The main reason is the 43 errors and 18 warnings stopping the game from compiling over the weekend. The actual reason is LAN gameplay is not working and the content management system is being swapped over.
To make up for the lack of an update, I will try to post some more blog articles this month. If you have a suggestion, just drop me an email.
This post goes into the new content manager. LAN will come later on this month. WARNING! this post has great chunks of text. If you'd like to see some nice images, just scroll down to the bottom.
The main reason for replacing the content manager was to streamline loading assets. If you've browsed around the game files at all, you'll see the assets are spread over 12 separate data archives. Each asset too is spread of multiple files. Animations for example are spread over three files. This makes loading assets quite a bit of effort.
The main delay has been migrating the game over to use the new content manager. The project is quite large so pieces were replaced a chunk at a time.
XNA allows you to have more than one CM but I don't like it. I don't want more than one. I'd rather one central store and one central controller loading assets. To me, it's like having two project managers or two architects on a building site and we all know what Kevin McCloud would think of that.
The old system wasn't dodgy, it was patched onto again and again as more of the original content was needed. The end result was a content manager that only really loaded the archive files, loaded an image file or loaded a colour palette. That was it. The sound class loaded sounds. The animation class loaded an animation. Basically, loading content was spread out over the entire project.
This has all changed now. All assets are loaded through the content manger and textures are by default cached, so are the colour palettes and sound effects. Previously, you'd have to know which of the 12 data files the asset was located in. Not anymore; you just say what the asset ID or name is and it will automagically scan all the data files and find the asset you want. Perhaps not very efficient on the HDD but it greatly simplifies loading Presage assets.
I've modelled the way the CM is used on the XNA content manager. The same methods exist but I've added a couple of extra 'Unload' methods so any cached asset can be disposed of when I want it to be.
Loading an image: contentManager.Load(Of Texture2D)(assetId)
This will take care of loading the Presage image file and combining them into a texture. If the Presage image file header is not valid, it will check to see if it is a PNG and load that instead. To do this, I just check the first four bytes in the PNG header.
Loading an animation: contentMander.Load(Of Animation)(assetId)
This will take care of loading the two animation files and creating the texture.
Loading a sound effect: contentManager.Load(Of SoundEffect)(assetId)
Loads a Presage sound effect, converts it to 16bit and loads it as sound effect.
Loading a colour palette: contentManager.Load(Of ColorLookupTable)(assetId)
There are quite a few more asset types for the game but you get the general idea.
I've mentioned a few times in previous blog posts that I used the excellent and free Bitmap Font Generator by AngelCode to create the fonts used in the game. When exporting the font you have a choice of three formats; binary, text or XML. When I added tooltips I used XML format but switched it for text before the first build was uploaded (middle of last year I think). Well I've gone back to XML now to make it easier to load and parse the font file.
Exporting the font resulted in a different bitmap being generated in a different order. Not sure why. Below is what happened when the bitmap wasn't updated.
Alien text - reminds me of the text in Commander Keen
Below are two examples of the new content manager handing out the wrong cached image.
Accessing a disposed texture