OpenSAGE Dev Diary #4 (2017-12-24)
OpenSAGE is an open-source re-implementation of the SAGE game engine. SAGE was the game engine used in C&C Generals, C&C Generals Zero Hour, Battle for Middle-earth and its sequels, C&C 3 and its sequel, and Red Alert 3 and its sequel. I’ve been working on OpenSAGE for 6 months, and made some good progress, so I’ve started this series of blog posts to talk about what is happening in the project each week. You can also star or watch the OpenSAGE GitHub repo for a more real-time view of things.
Progress this week
This week in OpenSAGE:
I’ve worked on UI rendering, in particular the main menu. The main menu now responds to mouse input, and you can click buttons. C&C Generals
.wndfiles use a callback system, and those callbacks are implemented in engine code, so I’m having to guess at their implementations just from observing behaviour in the running game. For example, when you first see the main menu, only the logo is visible, but then after any mouse (or keyboard) input, the border and buttons animate in. As far as I can tell that is done in the
MainMenuInputcallback. Every UI element (or “window” as they’re called in
.wndfiles) has an input callback and a system callback. If it’s not specified in the
.wndfile, then the engine appears to use default callbacks based on window type (button, textbox, etc.). The input callback receives mouse and keyboard messages, and turns them into “system” messages like “the skirmish button was pressed”, and these system messages are passed to the system callback. One of the system callbacks is
PassMessagesToParentSystem, which passes any messages to the system callback of the parent window. In most
.wndfiles I’ve looked at so far, eventually at the top level, the
.wnddefines a system callback that actually does something. The design seems heavily inspired by win32 window messages, but it’s not the same.
Just a short update this week. Until next time!