1.1 --- a/src/text.c Fri Apr 12 22:03:15 2024 +0200 1.2 +++ b/src/text.c Fri Apr 12 22:22:07 2024 +0200 1.3 @@ -89,8 +89,7 @@ 1.4 SDL_FreeSurface(surface); 1.5 } 1.6 1.7 -AscSceneNode *asc_text(int x, int y, char const *text) { 1.8 - // TODO: implement fancy struct "named param" initialization 1.9 +AscSceneNode *asc_text_create(struct asc_text_create_args args) { 1.10 AscText *node = calloc(1, sizeof(AscText)); 1.11 1.12 node->base.render_group = ASC_RENDER_GROUP_SPRITE_BLEND; 1.13 @@ -98,14 +97,16 @@ 1.14 node->base.update_func = (asc_scene_update_func) asc_text_update; 1.15 node->base.draw_func = (asc_scene_draw_func) asc_text_draw; 1.16 1.17 - node->base.position.x = (float) x; 1.18 - node->base.position.y = (float) y; 1.19 + node->base.flags = args.alignment; 1.20 + node->base.position.x = (float) args.x; 1.21 + node->base.position.y = (float) args.y; 1.22 + node->max_width = args.max_width; 1.23 node->font = asc_context.active_font; 1.24 node->color = asc_context.ink; 1.25 - if (text == NULL) { 1.26 + if (args.text == NULL) { 1.27 node->text = cx_mutstr(strdup(" ")); 1.28 } else { 1.29 - node->text = cx_mutstr(strdup(text)); 1.30 + node->text = cx_mutstr(strdup(args.text)); 1.31 } 1.32 1.33 // initialize