Tuesday, July 1, 2014

FMod - Another Refactor

Yay, Abiathar's New Project Wizard is finally complete! I made a few minor adjustments to it today, mainly incorporating the old Dependency Collector as an option. That actually required quite a bit of code to be added to the DC's finish procedure (to convert it to the new way of storing creation information), but it's now a valid third path on the NPW. With that finished, I can move on to refactoring the file loader to use a dependency file instead of a bunch of streams.

That is turning into quite the task. Besides what I expected - the level and tileinfo loaders - the graphics handlers everywhere need to be rewritten. With the promise of bitmap loading (and the infoplane override), I can't depend on the EGA graphics object to provide the tile counts. The settings, however (by some weird placement on my part), are still stored in the chunk settings structure. So, with a little adjustment to the state wrapper and some redirection to use that state wrapper, the tile counts should work again.

I don't think a lot of things use the graphics object directly, so that's nice. I'm replacing it with an interface, IAbiatharGraphics, that simply serves Bitmap objects from a tile ID and plane. Most of the logic from GetCachedTile has been moved into the EGA implementation, leaving that function appropriately named. The bitmap implementation is proving to be more tricky. Thanks to the multiple graphics exporters (mostly ModKeen and KeenGraph) and their various switches and add-ons (grouting for KeenGraph and the KeenGrout utility for ModKeen), there are quite a few configurations of tilesets. My loader has to detect and understand them all, which thankfully can be done simply by looking at the width of the image. It uses that to select a function to find the position of a tile in the tileset image and then uses Graphics.DrawImage to copy that tile out of the set. There are also various transform functions in use to make everything be transparent in the right places (yay, explicit masking).

Currently, it can't do anything because the file loaders and graphics managers are totally broken. I think I'll be able to get most of the pieces tied together tomorrow, and then I just need to clean up the edge cases.

No comments:

Post a Comment