![]() |
LibGame
v0.4.0
The LG Game Engine - Copyright (C) 2024-2025 ETMSoftware
|
Functions | |
void | lg_info_win_no_block (const char *text, zboolean with_frame, zboolean swap_fb) |
void | lg_info_win (const char *text, zboolean with_frame, zboolean swap_fb) |
int | lg_question_win (const char *text) |
void | lg_warning_win (const char *text) |
void | lg_error_win (const char *text) |
char * | lg_entry_win (const char *label, int x, int y) |
int | lg_win_open_centered (LG_Window *win) |
LG_Window | lg_win (const char *text, LG_Color_u text_color, zboolean with_frame, LG_Color_u bg_color, LG_Color_u border_color, TTF_Font *font) |
int | lg_win_open (LG_Window *win, int x, int y) |
int | lg_win_close (LG_Window *win) |
void | lg_win_free_tex (LG_Window *win) |
zboolean | lg_win_check (LG_Window *win) |
int | lg_get_win_w (LG_Window *win) |
int | lg_get_win_h (LG_Window *win) |
LG_WinColors * | lg_get_win_colors () |
void | lg_set_default_win_colors () |
char * | lg_wrap_lines (const char *txt, TTF_Font *font) |
void | lg_fonts_list_init () |
zboolean | lg_fonts_list_is_initialized () |
zboolean | lg_font_add_to_list (const char *name, const char *relative_path, int size) |
LG_Font * | lg_font_get (const char *name) |
TTF_Font * | lg_font_get_ttf (const char *name) |
void | lg_font_free (const char *name) |
void | lg_font_free_all () |
void | lg_font_list_all () |
void | lg_font_info (LG_Font *font) |
=== GUI windows implementation ===
void lg_info_win_no_block | ( | const char * | text, |
zboolean | with_frame, | ||
zboolean | swap_fb | ||
) |
Window at screen bottom, horiz. centered - Free but don't close win
text | |
with_frame | |
swap_fb |
void lg_info_win | ( | const char * | text, |
zboolean | with_frame, | ||
zboolean | swap_fb | ||
) |
Window is centered
TODO: Which font size on Android ? TODO #2: Should warn if win text is over 12 lines
text | |
with_frame | |
swap_fb |
int lg_question_win | ( | const char * | text | ) |
Window is centered
On Android: left tap = no / right tap = yes
=== WARNING: Also swap framebuffer ===
TODO: Which font size on Android ?
You should always clear or render to bg just before calling this func (with lg_clear_bg() or lg_read_and_render_screen_back() or ...)
text |
void lg_warning_win | ( | const char * | text | ) |
=== WARNING: Also swap framebuffer ===
You should always clear or render to bg just before calling this func
TODO: Which font size on Android ?
text |
void lg_error_win | ( | const char * | text | ) |
=== WARNING: Also swap framebuffer ===
You should always clear or render to bg just before calling this func
TODO: Which font size on Android ?
text |
char* lg_entry_win | ( | const char * | label, |
int | x, | ||
int | y | ||
) |
TODO: check/test/update
(-1, -1) for centered win, same colors as lg_question_win()
If not NULL (<esc> pressed), returned str must be freed
=== WARNING: Also swap framebuffer ===
You should always clear or render to bg just before calling this func
label | |
x | |
y |
LG_Window lg_win | ( | const char * | text, |
LG_Color_u | text_color, | ||
zboolean | with_frame, | ||
LG_Color_u | bg_color, | ||
LG_Color_u | border_color, | ||
TTF_Font * | font | ||
) |
Create a new LG_Window
WARNING: for frameless wins, the background/border colors are still used, so you MUST set them (ie, DO use either a fully/partially transparent color or an opaque color)
For instance, use lg_color_u(0, 0, 0, 0) for a fully transparent bg
Max lines num inside window is LG_WIN_N_LINES_MAX, defined in lg_win.h
H_PADDING, V_PADDING, and BORDER_WIDTH are also defined in lg_win.h
TODO: add text overflow check
Params are self-explanatory
text | |
text_color | |
with_frame | |
bg_color | |
border_color | |
font |
int lg_win_open | ( | LG_Window * | win, |
int | x, | ||
int | y | ||
) |
Open a LG_Window instance
Set: x = -1, y = -1 for a centered window
win | |
x | |
y |
int lg_win_close | ( | LG_Window * | win | ) |
Close a LG_Window instance
=== This func is DEPRECATED and now a NO-OP ===
win |
void lg_win_free_tex | ( | LG_Window * | win | ) |
Free resources (texture atlas actually) of a LG_Window instance
win |
zboolean lg_win_check | ( | LG_Window * | win | ) |
Check win is valid
win |
int lg_get_win_w | ( | LG_Window * | win | ) |
win |
int lg_get_win_h | ( | LG_Window * | win | ) |
win |
LG_WinColors* lg_get_win_colors | ( | ) |
Get win colors
void lg_set_default_win_colors | ( | ) |
Set default win colors
char* lg_wrap_lines | ( | const char * | txt, |
TTF_Font * | font | ||
) |
Line and word wrapping: Insert newline(s) if one string (ie between 2 newlines) is too long (ie > max_line_len)
max_line_len is set (very roughly) depending on font size
Returned string must be freed afterwards
TODO: improve the algo, need sth better
txt | |
font |
void lg_fonts_list_init | ( | ) |
Initialize the global fonts list
We use a simple list at the moment
TODO: should use a doubly-linked one
zboolean lg_fonts_list_is_initialized | ( | ) |
Check if the global fonts list has been initialized
zboolean lg_font_add_to_list | ( | const char * | name, |
const char * | relative_path, | ||
int | size | ||
) |
Add a font to the global fonts list
Load a font once from file and register it with a user-defined name, so that it's easy later on to use it just by name
Max number of fonts is N_FONTS_MAX, defined in lg_wins.h
name | A user-defined font name - whatever you want but you should pick sth short but descriptive and not confusing |
relative_path | Path inside the fonts folder |
size | Font size |
LG_Font* lg_font_get | ( | const char * | name | ) |
TTF_Font* lg_font_get_ttf | ( | const char * | name | ) |
Retrieve a TTF_Font from the global fonts list - search by name
name | A user-defined font name |
void lg_font_free | ( | const char * | name | ) |
Find font by name and free all associated resources
Doesn't enable to add extra fonts, only free all font resources
name | Font used-defined name |
void lg_font_free_all | ( | ) |
Free all fonts and associated resources from the list
To use the list again, you should first initialize it
WARNING:
void lg_font_list_all | ( | ) |
List all loaded fonts