![]() |
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) |
| void | lg_info_win_s (const char *text, LG_Win_Style *style) |
| int | lg_question_win (const char *text) |
| int | lg_question_win_s (const char *text, LG_Win_Style *style) |
| 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) |
| void | lg_win_show_annoying_errors () |
| void | lg_win_no_annoying_errors () |
| 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 | is_lg_win (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, int max_width) |
| 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) |
| zboolean | lg_font_load_array (LG_Font_Des fonts[], int n_fonts) |
| void | lg_font_list_array (LG_Font_Des fonts[], int n_fonts) |
=== GUI windows implementation === You may use helper macros: - WITH_FRAME / FRAMELESS - BLOCK / NO_BLOCK - SWAP_FB / NO_SWAP
| 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 |
| void lg_info_win_s | ( | const char * | text, |
| LG_Win_Style * | style | ||
| ) |
Window is centered
Use LG_Win_Style
=== WARNING: Also swap framebuffer ===
=== WARNING2: This one uses WAIT_FOR_PRESS_OR_CLICK_OR_TOUCH === Also don't output "Press any key ..."
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 | |
| style |
| 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 |
| int lg_question_win_s | ( | const char * | text, |
| LG_Win_Style * | style | ||
| ) |
Window is centered
Use LG_Win_Style
On Android: left tap = no / right tap = yes
=== WARNING: Also swap framebuffer ===
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 | |
| style |
| 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 | ||
| ) |
Text entry win
(-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) or UNUSED_LG_COLOR_U 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 |
| void lg_win_show_annoying_errors | ( | ) |
Enable output of annoying, not-critical errors (default)
| void lg_win_no_annoying_errors | ( | ) |
Disable output of annoying, not-critical errors
| 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 is_lg_win | ( | 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, | ||
| int | max_width | ||
| ) |
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 and viewport width
Returned string must be freed afterwards
TODO: keep improving the algo
| txt | |
| font | |
| max_width | In pixels |
| 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
To check out game engine preloaded fonts, see: lg_load_engine_fonts()
=== TODO: using a simple list, should use a doubly-linked one to remove some stupid limitations ===
| 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, not relative if symlink |
| 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
You should probably not use this func because:
WARNING1: Removing a TTF font will likely remove all registered sizes
WARNING2: Doesn't enable to add extra fonts, only free all font resources (because the fonts list is not a doubly-linked one)
| name | Font user-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
| zboolean lg_font_load_array | ( | LG_Font_Des | fonts[], |
| int | n_fonts | ||
| ) |
Load an array of LG_Font_Des and add them to the global fonts list
| fonts | An array of LG_Font_Des |
| n_fonts | Num of fonts |
| void lg_font_list_array | ( | LG_Font_Des | fonts[], |
| int | n_fonts | ||
| ) |
Print out nicely an array of LG_Font_Des
| fonts | An array of LG_Font_Des |
| n_fonts | Num of fonts |