Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
|
TextEntry serves as a method to create strings for a multitude of cases. It should be easy to see, easy to customize and as intuitive to use as possible. Several customization options are available.
Text entry in initialize with textEntryInit(), where the font used, max string length, and string pointer are provided. By default, a blank, black background is used with white text and no emphasis color.
Once initalized, additional commands can be run to customize the text entry screen:
The text entry is re-drawn from scratch every cycle. The above commands can be run between cycles if desired, though it is strongly discouraged to keep the text entry easy for the end user to navigate and utilize.
textEntryInit() can be called once during initialization or just before the text entry is required, but cannot be inside the loop or it will not function.
After all of the initialization is done, use textEntryDraw() to draw the current text entry box and textEntryInput() to send inputs to the tent entry. textEntryInput() returns true until enter/okay is selected.
The controls are as follows: Directions: navigate the keyboard A button: Select currently highlighted symbol B button: Backspace Start button: Move cursor to the enter key
Go to the source code of this file.
Macros | |
#define | KB_LINES 5 |
#define | ENTER_X 12 |
#define | ENTER_Y 2 |
#define | CORNER_MARGIN 20 |
#define | SHADOWBOX_MARGIN 4 |
#define | RETURN_WIDTH 16 |
#define | KEY_SPACING 5 |
#define | MAX_WIDTH_CHAR 32 |
#define | BLINK_RATE 500000 |
Enumerations | |
enum | keyModifier_t { NO_SHIFT , SHIFT , CAPS_LOCK , PROPER_NOUN , SPECIAL_DONE } |
enum | controlChar_t { KEY_SHIFT = 0x01 , KEY_CAPS_LOCK = 0x02 , KEY_BACKSPACE = 0x03 , KEY_SPACE = 0x20 , KEY_EOL = 0x05 , KEY_TAB = 0x09 , KEY_ENTER = 0x0A } |
enum | bgMode_t { WSG_BG , COLOR_BG , CLEAR_BG } |
Functions | |
void | textEntryInit (font_t *useFont, int max_len, char *buffer) |
Initialize the text entry with prettier graphics. | |
bool | textEntryDraw (int64_t elapsedUs) |
Draw the text entry UI. | |
bool | textEntryInput (uint8_t down, uint8_t button) |
Handle button input for text entry. | |
void | textEntrySetFont (font_t *newFont) |
A new font to load into the text entry screen. | |
void | textEntrySetBgWsg (wsg_t *BG) |
Sets a background image and sets the BG Mode to use the WSG. | |
void | textEntrySetBGColor (uint8_t color) |
Sets the background to use a solid color. | |
void | textEntrySetBGTransparent (void) |
Sets the background to be transparent. | |
void | textEntrySetTextColor (uint8_t color, bool emphasis) |
Set the main text color for the keyboard and entry text. | |
void | textEntrySetEmphasisColor (uint8_t color) |
Set the emphasis color for the text. | |
void | textEntrySetShadowboxColor (bool active, uint8_t color) |
Sets the color of the shadowbox. | |
void | textEntrySetNewEnterStyle (bool newStyle) |
Sets the style of the Enter key. | |
void | textEntrySetNewCapsStyle (bool newStyle) |
Sets the style of the caps lock key. | |
void | textEntrySetMultiline (bool multiline) |
Sets the text entry mode from single line to multi-line. | |
void | textEntrySoftReset (void) |
Allow the text box to continue without a full reset. | |
void | textEntrySetPrompt (char *prompt) |
Sets the prompt text to be displayed. Use an empty string ("") to disable. | |
void | textEntrySetCapMode (void) |
Sets the starting mode to capslock. | |
void | textEntrySetNoShiftMode (void) |
Sets the starting mode to lowercase text. | |
void | textEntrySetShiftMode (void) |
Sets the starting mode to Shift, does one capital letter. | |
void | textEntrySetNounMode (void) |
Sets the starting mode to Porper Nouns (Auto capitalizes first letter after a space) | |
#define KB_LINES 5 |
#define ENTER_X 12 |
#define ENTER_Y 2 |
#define CORNER_MARGIN 20 |
#define SHADOWBOX_MARGIN 4 |
#define RETURN_WIDTH 16 |
#define KEY_SPACING 5 |
#define MAX_WIDTH_CHAR 32 |
#define BLINK_RATE 500000 |
enum keyModifier_t |
enum controlChar_t |
enum bgMode_t |
void textEntryInit | ( | font_t * | useFont, |
int | max_len, | ||
char * | buffer ) |
Initialize the text entry with prettier graphics.
useFont | The font to use |
max_len | The length of buffer |
buffer | A char* to store the entered text in |
bool textEntryDraw | ( | int64_t | elapsedUs | ) |
Draw the text entry UI.
bool textEntryInput | ( | uint8_t | down, |
uint8_t | button ) |
Handle button input for text entry.
down | true if the button was pressed, false if it was released |
button | The button that was pressed |
void textEntrySetFont | ( | font_t * | newFont | ) |
A new font to load into the text entry screen.
newFont | pointer to a font file |
void textEntrySetBgWsg | ( | wsg_t * | BG | ) |
Sets a background image and sets the BG Mode to use the WSG.
BG | Pointer to Background image to set |
void textEntrySetBGColor | ( | uint8_t | color | ) |
Sets the background to use a solid color.
color | Color to set the background |
void textEntrySetBGTransparent | ( | void | ) |
Sets the background to be transparent.
void textEntrySetTextColor | ( | uint8_t | color, |
bool | emphasis ) |
Set the main text color for the keyboard and entry text.
color | Color to set the text to. |
emphasis | Whether emphasis color should also be set to the same color |
void textEntrySetEmphasisColor | ( | uint8_t | color | ) |
Set the emphasis color for the text.
color | Color for the emphasis text |
void textEntrySetShadowboxColor | ( | bool | active, |
uint8_t | color ) |
Sets the color of the shadowbox.
active | Whether these boxes should be drawn |
color | Color for the shadowboxes |
void textEntrySetNewEnterStyle | ( | bool | newStyle | ) |
Sets the style of the Enter key.
newStyle | if true, use the new style |
void textEntrySetNewCapsStyle | ( | bool | newStyle | ) |
Sets the style of the caps lock key.
newStyle | if true, use the new style |
void textEntrySetMultiline | ( | bool | multiline | ) |
Sets the text entry mode from single line to multi-line.
multiline | True if using multi-line, false if not |
void textEntrySoftReset | ( | void | ) |
Allow the text box to continue without a full reset.
void textEntrySetPrompt | ( | char * | prompt | ) |
Sets the prompt text to be displayed. Use an empty string ("") to disable.
prompt | Text string to use |
void textEntrySetCapMode | ( | void | ) |
Sets the starting mode to capslock.
void textEntrySetNoShiftMode | ( | void | ) |
Sets the starting mode to lowercase text.
void textEntrySetShiftMode | ( | void | ) |
Sets the starting mode to Shift, does one capital letter.
void textEntrySetNounMode | ( | void | ) |
Sets the starting mode to Porper Nouns (Auto capitalizes first letter after a space)