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

Macros

#define ITEMS_PER_PAGE   5
 
#define ITEM_MARGIN   1
 
#define Y_SECTION_MARGIN   13
 
#define Y_ITEM_START   55
 
#define MAX_ITEM_TEXT_WIDTH   191
 
#define ARROW_PERIOD_US   1000000
 
#define DEFAULT_BODY_HEIGHT   66
 

Functions

menuMegaRenderer_tinitMenuMegaRenderer (font_t *titleFont, font_t *titleFontOutline, font_t *menuFont)
 Initialize a and return a menu renderer.
 
void deinitMenuMegaRenderer (menuMegaRenderer_t *renderer)
 Deinitialize a menu renderer and free associated memory. This will not free the font passed into initMenuMegaRenderer()
 
void setDrawBody (menuMegaRenderer_t *renderer, bool drawBody)
 Set whether or not to draw the sci-fi rectangle background body.
 
void setBodyHeight (menuMegaRenderer_t *renderer, int16_t height)
 Set the height of the body between top and bottom decorated parts If the given height is negative, it will be set to the default height.
 
void recolorMenuMegaRenderer (menuMegaRenderer_t *renderer, paletteColor_t textFill, paletteColor_t textOutline, paletteColor_t c1, paletteColor_t c2, paletteColor_t c3, paletteColor_t c4, paletteColor_t c5, paletteColor_t c6, paletteColor_t c7, paletteColor_t c8, const paletteColor_t *bgColors, int32_t numBgColors)
 Recolor the Mega menu renderer. Arguments c1 through c8 should get progressively lighter.
 
void drawMenuBody (uint16_t topLeftX, uint16_t topLeftY, uint8_t expansionHeight, bool flipLR, menuMegaRenderer_t *renderer)
 Draw the menu body background.
 
void drawMenuMega (menu_t *menu, menuMegaRenderer_t *renderer, int64_t elapsedUs)
 Draw a themed menu to the display and control the LEDs.
 
void setMegaLedsOn (menuMegaRenderer_t *renderer, bool ledsOn)
 Set the renderer's LEDs to be on or off.
 

Macro Definition Documentation

◆ ITEMS_PER_PAGE

#define ITEMS_PER_PAGE   5

◆ ITEM_MARGIN

#define ITEM_MARGIN   1

◆ Y_SECTION_MARGIN

#define Y_SECTION_MARGIN   13

◆ Y_ITEM_START

#define Y_ITEM_START   55

◆ MAX_ITEM_TEXT_WIDTH

#define MAX_ITEM_TEXT_WIDTH   191

◆ ARROW_PERIOD_US

#define ARROW_PERIOD_US   1000000

◆ DEFAULT_BODY_HEIGHT

#define DEFAULT_BODY_HEIGHT   66

Function Documentation

◆ initMenuMegaRenderer()

menuMegaRenderer_t * initMenuMegaRenderer ( font_t * titleFont,
font_t * titleFontOutline,
font_t * menuFont )

Initialize a and return a menu renderer.

Parameters
titleFontThe font used to draw the title, preferably RIGHTEOUS_150_FONT. If this is NULL it will be allocated by the renderer in SPIRAM.
titleFontOutlineThe outline font used to draw the title. If this is NULL it will be allocated by the renderer in SPIRAM.
menuFontThe font used to draw this menu, preferably RODIN_EB_FONT. If this is NULL it will be allocated by the renderer in SPIRAM.
Returns
A pointer to the menu renderer. This memory is allocated and must be freed with deinitMenuMegaRenderer() when done

◆ deinitMenuMegaRenderer()

void deinitMenuMegaRenderer ( menuMegaRenderer_t * renderer)

Deinitialize a menu renderer and free associated memory. This will not free the font passed into initMenuMegaRenderer()

Parameters
rendererThe renderer to deinitialize. It must not be used after deinitialization.

◆ setDrawBody()

void setDrawBody ( menuMegaRenderer_t * renderer,
bool drawBody )

Set whether or not to draw the sci-fi rectangle background body.

Parameters
rendererThe renderer.
drawBodytrue to draw the body background, false to skip it

◆ setBodyHeight()

void setBodyHeight ( menuMegaRenderer_t * renderer,
int16_t height )

Set the height of the body between top and bottom decorated parts If the given height is negative, it will be set to the default height.

Parameters
rendererThe renderer to adjust the body height for
heightThe new height. If the given value is negative, the default height will be set.

◆ recolorMenuMegaRenderer()

void recolorMenuMegaRenderer ( menuMegaRenderer_t * renderer,
paletteColor_t textFill,
paletteColor_t textOutline,
paletteColor_t c1,
paletteColor_t c2,
paletteColor_t c3,
paletteColor_t c4,
paletteColor_t c5,
paletteColor_t c6,
paletteColor_t c7,
paletteColor_t c8,
const paletteColor_t * bgColors,
int32_t numBgColors )

Recolor the Mega menu renderer. Arguments c1 through c8 should get progressively lighter.

Parameters
rendererThe renderer to recolor
textFillThe color of the text fill, originally white
textOutlineThe color of the text outline, originally black
c1Replacement for Darkest blue
c2Replacement for Very dark blue
c3Replacement for Dark blue
c4Replacement for Dark moderate blue
c5Replacement for Dark strong blue
c6Replacement for Light strong blue
c7Replacement for Pure cyan
c8Replacement for Very pale cyan
bgColorsA list of colors to cycle through in the hexagonal background. May be NULL for no change.
numBgColorsThe length of bgColors

◆ drawMenuBody()

void drawMenuBody ( uint16_t topLeftX,
uint16_t topLeftY,
uint8_t expansionHeight,
bool flipLR,
menuMegaRenderer_t * renderer )

Draw the menu body background.

Parameters
topLeftXThe X coordinate of the top left corner of the body
topLeftYThe Y coordinate of the top left corner of the body
expansionHeightThe y distance of filler rectangle between the top and bottom parts of the body
flipLRtrue to flip the body horizontally
rendererThe renderer to draw a body with

◆ drawMenuMega()

void drawMenuMega ( menu_t * menu,
menuMegaRenderer_t * renderer,
int64_t elapsedUs )

Draw a themed menu to the display and control the LEDs.

Parameters
menuThe menu to draw
rendererThe renderer to draw with
elapsedUsThe time elapsed since this function was last called, for LED animation

◆ setMegaLedsOn()

void setMegaLedsOn ( menuMegaRenderer_t * renderer,
bool ledsOn )

Set the renderer's LEDs to be on or off.

Parameters
rendererThe renderer to set
ledsOntrue to animate the LEDs, false to keep them off