Text
Writing text, fonts, anchors.
For the full list see "UI development". Each call below comes with a one-line usage note and an example; signatures come from
Lib/c/vml_ui.h(the authoritative source).
ui_text_set_font(int size, int style, int color, int anchor)
Sets the font once, and every later ui_2d_text_cur uses it (so you do not have to pass the same four arguments again and again).
ui_text_set_font(18, VML_FONT_BOLD, 0xFFFFFFFF, VML_ANCHOR_CENTER);
ui_2d_text_cur(180, 40, "Press a direction key to exit");
ui_text_set_valign(int valign)
Sets the default vertical alignment (it applies to every text drawn afterwards).
ui_text_set_valign(VML_VALIGN_MIDDLE);
ui_2d_text(int x, int y, char* s, int color, int size, int anchor)
Writes one line of text at (x,y). size is the font size; anchor decides which side of the text (x,y) refers to (VML_ANCHOR_LEFT / CENTER / RIGHT).
ui_2d_text(180, 40, "Score: 120", 0xFFFFFFFF, 20, VML_ANCHOR_CENTER);
ui_2d_text_cur(int x, int y, char* s)
Draws text with the font set by ui_text_set_font.
ui_2d_text_cur(180, 300, "Game over");
ui_2d_text_styled(int x, int y, char* s, int color, int size, int anchor, int style)
The same, plus a style (bold / italic / underline).
ui_2d_text_styled(10, 10, "Title", 0xFFFFFFFF, 22, VML_ANCHOR_LEFT, VML_FONT_BOLD);
ui_2d_text_v(int x, int y, char* s, int color, int size, int anchor, int valign, int style)
Text with vertical alignment (VML_VALIGN_*) - for ui_2d_text the y is the baseline, while this one can align to top / middle / bottom.
ui_2d_text_v(200, 100, "Centered", 0xFFFFFFFF, 20, VML_ANCHOR_CENTER, VML_VALIGN_MIDDLE, 0);