[SILL]
So as I mentioned last post, I’m currently working on a small game at the same time I’m working on the Sill / Manual as a way to maintain motivation on the project. One of the first things I needed to do for my game project was make a simple menu for the user to interact with…and just like that I was back working on Sill, changing things to accommodate this ‘feature’.
As you may be aware, Sill has a built-in menu API for making selection menus. The first iteration of this API was an overly complex mess that tried to support every menu type imaginable (circle, dynamic, etc). That version of the API was eventually scrapped and rebuilt in order to limit the bloat (only supported context style menus and limited display options) and to fix some bugs (which, in the end, didn’t require a rewrite after all).
Well, now I scrapped that version and have made a new menu API that is not only way simpler to use and understand, but also streamlined internally for performance and user control (also, currently fully stable with no bugs ^^).
SILL_API sill_menu_create(SILL_RESOURCE *menu);
SILL_API sill_menu_error_exists(SILL_RESOURCE menu);
SILL_API sill_menu_destroy(SILL_RESOURCE menu);
SILL_API sill_menu_destroy_all();
SILL_API sill_menu_input_add(SILL_RESOURCE menu, SILL_UINT key, SILL_MENU_OPERATION_TYPE operation, SILL_UINT op_ext, SILL_UINT item_id);
SILL_API sill_menu_input_remove(SILL_RESOURCE menu, SILL_UINT key);
SILL_API sill_menu_input_mouse(SILL_RESOURCE menu, SILL_UINT enable);
SILL_API sill_menu_item_add(SILL_RESOURCE menu, SILL_UINT item_id, SILL_REAL x, SILL_REAL y, SILL_UINT width, SILL_UINT height);
SILL_API sill_menu_item_set_position(SILL_RESOURCE menu, SILL_UINT item_id, SILL_REAL x, SILL_REAL y);
SILL_API sill_menu_item_get_position(SILL_REAL *x, SILL_REAL *y, SILL_RESOURCE menu, SILL_UINT item_id);
SILL_API sill_menu_item_set_size(SILL_RESOURCE menu, SILL_UINT item_id, SILL_UINT width, SILL_UINT height);
SILL_API sill_menu_item_get_size(SILL_UINT *width, SILL_UINT *height, SILL_RESOURCE menu, SILL_UINT item_id);
SILL_API sill_menu_item_remove(SILL_RESOURCE menu, SILL_UINT item_id);
SILL_API sill_menu_set_texture(SILL_RESOURCE menu, SILL_RESOURCE texture);
SILL_API sill_menu_get_texture(SILL_RESOURCE *texture, SILL_RESOURCE menu);
SILL_API sill_menu_remove_texture(SILL_RESOURCE menu);
SILL_API sill_menu_set_parent(SILL_RESOURCE menu, SILL_RESOURCE parent_menu);
SILL_API sill_menu_get_parent(SILL_RESOURCE *parent_menu, SILL_RESOURCE menu);
SILL_API sill_menu_remove_parent(SILL_RESOURCE menu);
SILL_API sill_menu_start(SILL_RESOURCE menu, SILL_REAL x, SILL_REAL y);
SILL_API sill_menu_simulate(SILL_RESOURCE menu, SILL_MENU_OPERATION_TYPE operation, SILL_UINT op_ext, SILL_UINT item_id);
SILL_API sill_menu_status(SILL_MENU_OPERATION_TYPE *operation, SILL_UINT *op_ext, SILL_UINT *item_id, SILL_RESOURCE menu);
SILL_API sill_menu_stop(SILL_RESOURCE menu);
SILL_API sill_menu_stop_children(SILL_RESOURCE parent_menu);
SILL_API sill_menu_set_position(SILL_RESOURCE menu, SILL_REAL x, SILL_REAL y);
SILL_API sill_menu_get_position(SILL_REAL *x, SILL_REAL *y, SILL_RESOURCE menu);
SILL_API sill_menu_is_running(SILL_UINT *running, SILL_RESOURCE menu);
SILL_API sill_menu_debug(SILL_RESOURCE menu, SILL_UINT enable, SILL_UINT color);
SILL_API sill_menu_lock(SILL_RESOURCE menu);
SILL_API sill_menu_unlock(SILL_RESOURCE menu);
SILL_API sill_menu_is_locked(SILL_UINT *locked, SILL_RESOURCE menu);
^Still WIP API^
The biggest change from the previous versions of the menu API is that the new one doesn’t keep track of any internal Z-ordering or drawing procedures. These two abilities are now the responsibility of the programmer using the API (which makes sense, since both of these are highly dependent on the type of application being made). This allows for the menu API to be streamlined to a bare-bones input handling system while opening up a lot of control options for developers to customize and expand on the existing foundation. In a nut shell, menus can now be way more dynamic (circle, angled, scatter, animated, etc) while still being simple to build.
Some of the new features:
- Internal support for mouse and keyboard input.
(customizable input and can be disabled independently) - Programmer controlled parenting and current state lock/unlock options.
(For Z-order development and/or disabling menu interaction) - Simulate input or set a menu state.
(For making custom input methods or forcing a menu state) - Dynamic item adding/removing, positioning and sizing on the fly.
(Possibility for reactive or animated menus) - Texture assignment for displaying on a dedicated menu layer.
(Above view layer and below the draw overlay layer)
(Keep in mind that the texture can be part of a draw buffer) - Simple polling style status results
- Debug interface, for testing internal input handling
I plan to document the menu API here shortly (next few days) just so it’s covered in the manual, then I’ll be shifting focus back to the game…which will hopefully make some decent progress before I’m fixing / updating Sill again…
~Brandon
