Refactoring

This week, I’m working on extracting the components of the WAGE engine that are reusable to other engines (such as… you guessed it, MacVenture), specifically that old and lovely black and white Macintosh GUI.

This, in addition to easing the burden of having to create these components myself, has served to give me insight about how an engine is structured. After this, I have a much clearer idea of how I should implement MacVenture. It mught be worth to revisit the order in which I planned to write the components.

However, as with every time that you touch other people’s code, there is a constant fear that you might have broken something, even more so if we take into account the lack of tests for engines. However, little by little, I think that I arrived to a working solution.

The Constant Struggle for Style (that’s a pun)

As it turns out, not all Macintosh GUIs were created equal, and thus they need different style constants (hence the pun) to adjust fun things like border width, border color, border pattern, window border, window frame border… well, you get the idea.

For comparison’s sake, here are two screensoths. One is from a WAGE game (Another Fine Mess), and the other is from a MacVenture game (Uninvited):

Since the styles are so different, for now at least every engine will hold to it’s own constants, and they will be isolated from the rest. If any of the common files (macwindow.cpp, I’m looking at you) would need any constants, these will be defined in the implementation, and not in the interface, so as to keep things nice and tidy. For me in particular, this has several ramifications:

  • Obviously, I’ll have to tinker my fair share with the constants when I’m implementing MacVenture.
  • If and when I implement the Apple II graphics, I will have to do it inside MacVenture also, or spend a very sizeable portion of the schedule making the system abstract enough to handle it.

The rest of the week

“But it’s still just Thursday”, you say. “What are you going to do with the rest of the week?”

Well, my goal is to submit the code I already have in my fork to review by my mentor and anybody else that wants to see it, and then get it ready to issue a PR. There are still a couple of things I’m unclear on, I think I can make a general style work. We’ll see.