|
Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
|
A menu renderer takes the data in the menu_t data structure and renders it to the display. The menu data structure is separated from the rendering logic so that it is possible to draw menus with differing themes.
First a menu_t data structure must be created. For that usage, see menu.h.
The menu renderer is initialized with initMenuSimpleRenderer() and deinitialized with deinitMenuSimpleRenderer(). Menu renderers must be deinitialized or they will leak memory. When initializing the menu, fonts may be passed in as an argument, or the arguments may be NULL. If the Swadge mode is loading fonts for itself, you can save RAM by using the same font in the menu renderer. If the Swadge mode isn't using the same fonts, it's easier to have the menu renderer manage it's own fonts. Either way, you should avoid loading the same font multiple times.
The menu is drawn with drawMenuSimple(). This will both draw over the entire display and light LEDs. The menu may be drawn on top of later.
See menu.h for examples on how to use menuSimpleRenderer
Go to the source code of this file.
Data Structures | |
| struct | menuSimpleRenderer_t |
| A struct containing all the state data to render a simple menu. More... | |
Functions | |
| menuSimpleRenderer_t * | initMenuSimpleRenderer (font_t *font, paletteColor_t border, paletteColor_t bg, paletteColor_t text, int32_t rows) |
| Initialize a and return a menu renderer. | |
| void | deinitMenuSimpleRenderer (menuSimpleRenderer_t *renderer) |
| Deinitialize a menu renderer and free associated memory. This will not free the font passed into initMenuSimpleRenderer() | |
| void | drawMenuSimple (menu_t *menu, menuSimpleRenderer_t *renderer) |
| Draw a themed menu to the display and control the LEDs. | |
| struct menuSimpleRenderer_t |
| Data Fields | ||
|---|---|---|
| font_t * | font | The font to render the title with. |
| int32_t | numRows | |
| paletteColor_t | borderColor | The color of the background border. |
| paletteColor_t | bgColor | The color of the screen background. |
| paletteColor_t | rowTextColor | The color of the row text. |
| menuSimpleRenderer_t * initMenuSimpleRenderer | ( | font_t * | font, |
| paletteColor_t | border, | ||
| paletteColor_t | bg, | ||
| paletteColor_t | text, | ||
| int32_t | rows ) |
Initialize a and return a menu renderer.
| font | The font used to draw this menu |
| border | The color for the background border |
| bg | The color for the background |
| text | The color for the text |
| rows | The number of rows to display |
| void deinitMenuSimpleRenderer | ( | menuSimpleRenderer_t * | renderer | ) |
Deinitialize a menu renderer and free associated memory. This will not free the font passed into initMenuSimpleRenderer()
| renderer | The renderer to deinitialize. It must not be used after deinitialization. |
| void drawMenuSimple | ( | menu_t * | menu, |
| menuSimpleRenderer_t * | renderer ) |
Draw a themed menu to the display and control the LEDs.
| menu | The menu to draw |
| renderer | The renderer to draw with |