Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
menu_utils.h File Reference

Detailed Description

This file contains common utility functions to assist in manipulating menus and making menu renderers.

Go to the source code of this file.

Functions

const char * getMenuItemLabelText (char *buffer, int buflen, const menuItem_t *item)
 Write and return the proper text label to use for the given menu item.
 
bool menuItemIsSetting (const menuItem_t *item)
 Returns whether a menu item is a settings item.
 
bool menuItemHasOptions (const menuItem_t *item)
 Returns whether this menu item has options.
 
bool menuItemHasPrev (const menuItem_t *item)
 Returns true if this item has any previous option.
 
bool menuItemHasNext (const menuItem_t *item)
 Returns true if this item has any next option.
 
bool menuItemIsBack (const menuItem_t *item)
 Returns true if this item is the "Back" button on a sub-menu.
 
bool menuItemHasSubMenu (const menuItem_t *item)
 Returns true if this item will enter a sub-menu when selected.
 
void menuSavePosition (const char **out, int len, const menu_t *menu)
 Stores the current menu position in a buffer.
 
menu_tmenuRestorePosition (const char **in, int len, menu_t *menu)
 Restores the menu position from the given buffer.
 

Function Documentation

◆ getMenuItemLabelText()

const char * getMenuItemLabelText ( char * buffer,
int buflen,
const menuItem_t * item )

Write and return the proper text label to use for the given menu item.

If the menu item's label is a simple string, it will be returned directly. If the menu item's label must be constructed from multiple strings, it will be written to buffer, and a pointer to buffer will be returned.

Parameters
bufferA buffer to use for constructing the label, if needed
buflenThe size of the buffer
itemThe menu item whose label to return
Returns
A pointer to the item's label text

◆ menuItemIsSetting()

bool menuItemIsSetting ( const menuItem_t * item)

Returns whether a menu item is a settings item.

This will return true for items that were added with either addSettingsItemToMenu() or addSettingsOptionsItemToMenu()

Parameters
itemA pointer to the menu item to check
Returns
true if the item is associated with a setting
false if the item does not have a setting

◆ menuItemHasOptions()

bool menuItemHasOptions ( const menuItem_t * item)

Returns whether this menu item has options.

This will return true for items that were added with either addMultiItemToMenu() or addSettingsOptionsItemToMenu()

Parameters
itemA pointer to the menu item to check
Returns
true if the item has multiple options
false if the item has a single label

◆ menuItemHasPrev()

bool menuItemHasPrev ( const menuItem_t * item)

Returns true if this item has any previous option.

Parameters
itemA pointer to the menu item to check
Returns
true if the item has an option before the current one
false if the item has the first option selected

◆ menuItemHasNext()

bool menuItemHasNext ( const menuItem_t * item)

Returns true if this item has any next option.

Parameters
itemA pointer to the menu item to check
Returns
true if the item has an option after the current one
false if the item has the last option selected

◆ menuItemIsBack()

bool menuItemIsBack ( const menuItem_t * item)

Returns true if this item is the "Back" button on a sub-menu.

Parameters
itemA pointer to the menu item to check
Returns
true if the item is the "Back" item
false if the item is any other menu item

◆ menuItemHasSubMenu()

bool menuItemHasSubMenu ( const menuItem_t * item)

Returns true if this item will enter a sub-menu when selected.

Parameters
itemA pointer to the menu item to check
Returns
true if the item has a sub-menu
false if the item does not have a sub-menu

◆ menuSavePosition()

void menuSavePosition ( const char ** out,
int len,
const menu_t * menu )

Stores the current menu position in a buffer.

The output array should contain at least as many items as the maximum nesting depth of the menu

Parameters
outA pointer to an array of char-pointers that will receive the state
lenThe maximum number of items to write into the out buffer.
menuThe menu whose state to save

◆ menuRestorePosition()

menu_t * menuRestorePosition ( const char ** in,
int len,
menu_t * menu )

Restores the menu position from the given buffer.

Parameters
inThe char-pointer array that was set by menuSavePosition()
lenThe length of the char-poniter array
menuThe menu
Returns
A pointer to the currently-selected menu