Game Maker

GMS: Chrome Menu Updates

Tonight I spent a few hours working further on my menu UI framework. I managed to tidy up the style slightly, whilst making it aware of its position and boundaries. The menu behaves similar to its original behaviour in Chrome by anchoring itself within the window boundary.

I added support for sub menus which are showing/hiding when necessary at the side of their parent menus. Finally the elements are customisable and I added settings in for a darker theme, oh and I almost forgot to mention I added dividers.



The way I’m designing this is to be simple to work with, whilst avoiding rooting it deep into a project. A menu is created by merely creating an object that extends the super menu object, then defining what items the menu has within its create event.

Currently a new menu has code similar to this in its create event:

//Inherit menu

//Create Items
ds_list_add(items, "Add Node");
ds_list_add(items, "Something Else");
ds_list_add(items, "@-"); //Add a divider
ds_list_add(items, "Something...");

ds_list_add(items, ["Edit", objContextMenu2]); //Add a sub menu
ds_list_add(items, "Print...");
ds_list_add(items, "Cast...");

The data structure is still up in the air. I’m thinking of how I’ll implement icons next or even how I’ll add further meta data to each row. I’m looking at swapping the string/array values for a map, but instead I just keep wishing for structs or object literals.