When I say menus, I don’t mean restaurant menus. I mean the thing you see after the company’s logo when you play a video game. The first project I’m working on for CANINE is a menu system, and I’ve been trying to make time to develop it. Sadly, there are always other things that have to be done. Actually, I got a working basis for the system the day after I made my original post about it, but it’s only now that I can write a progress report.
I abandoned the FLTK-style array-based menu definition for something a bit more flexible. I instead based it off the Syslinux bootloader’s way of doing it, which is declaring the menus like a series of function calls. My implementation is quite a bit different, of course, but it still fits the bill. I chose this design over the previous system because I thought it would make it much easier to bind to other programming languages, or to allow people to load their menu definitions from scripts and data files.
Declaring a menu looks something like this:
JEWEL_MENU *menu = jewel_create_menu(my_awesome_font); jewel_add_inform(menu, "Are you sure you would like to quit? All progress will be lost!"); jewel_add_button(menu, "Yes", &quit_yes_clicked); jewel_add_button(menu, "No", &quit_no_clicked);
That displays a black-and-white menu with a question and two options. You can navigate the options using the arrow keys and select one pressing either enter or space. It’s looking pretty good!
The next thing I want to do is add a toggle button and slider. Afterwards, sub-menus will be top priority. One of the primary reasons I wanted to write a library was to handle this.
Lastly will be themes. Currently, you can set the font for text and it will adjust dimensions appropriately, but I want to implement configurations for back/foreground color, margins, and padding. Even more, I want to have controls able to specify classes like in CSS so you can style them differently (e.g. to make the aforementioned “Yes” button more impending).
Code cleanup is also on the list. I’m considering obliterating all of the asserts in the library and having any and all errors just return error codes. I’d rather programmers be able to display error dialogs then to have sudden crashes and weird 0x0000F82A-type messages.
For now I’m uploading the source code as Alpha-1. I hereby place it under the GNU General Public License version 3 or later. Feel free to play around with it! (Note: only tested on the 64-bit Arch Linux GNU/Linux distribution. Requires Allegro 5.x, tested with 5.0.8.)