Wed, 09 Jul 2025 22:30:52 +0200
improves signature of asc_text_printf() and adds documentation
src/ascension/ui/text.h | file | annotate | diff | comparison | revisions | |
src/text.c | file | annotate | diff | comparison | revisions | |
test/snake/snake.c | file | annotate | diff | comparison | revisions |
--- a/src/ascension/ui/text.h Tue Jul 08 19:55:55 2025 +0200 +++ b/src/ascension/ui/text.h Wed Jul 09 22:30:52 2025 +0200 @@ -149,13 +149,14 @@ } /** - * TODO: docstring - * @param node - * @param format - * @param ... + * Updates the content of a text node with formatted text. + * + * @param text_node the node + * @param format the format string + * @param ... the format arguments */ void asc_text_printf( - AscSceneNode *node, + AscText *text_node, const char *format, ... );
--- a/src/text.c Tue Jul 08 19:55:55 2025 +0200 +++ b/src/text.c Wed Jul 09 22:30:52 2025 +0200 @@ -126,13 +126,11 @@ return node; } -// TODO: maybe we should prefer a clean signature and molest the caller with the cast void asc_text_printf( - AscSceneNode *node, + AscText *text_node, const char *format, ... ) { - AscText *text_node = (AscText*) node; va_list ap; va_start(ap, format); cx_vsprintf( @@ -142,6 +140,6 @@ ap ); va_end(ap); - asc_node_update(node); + asc_node_update((AscSceneNode*)text_node); }
--- a/test/snake/snake.c Tue Jul 08 19:55:55 2025 +0200 +++ b/test/snake/snake.c Wed Jul 09 22:30:52 2025 +0200 @@ -56,7 +56,7 @@ } static void update_fps_counter(AscBehavior *behavior) { - AscSceneNode *node = behavior->node; + asc_ptr_cast(AscText, node, behavior->node); static float last_fps = 0.f; if (fabsf(asc_context.frame_rate - last_fps) > 1) { last_fps = asc_context.frame_rate;