src/text.c

changeset 59
764fbb013252
parent 58
26ebb2f1e6e6
child 64
f18dc427f86f
equal deleted inserted replaced
58:26ebb2f1e6e6 59:764fbb013252
87 87
88 // Free the surface 88 // Free the surface
89 SDL_FreeSurface(surface); 89 SDL_FreeSurface(surface);
90 } 90 }
91 91
92 AscSceneNode *asc_text(int x, int y, char const *text) { 92 AscSceneNode *asc_text_create(struct asc_text_create_args args) {
93 // TODO: implement fancy struct "named param" initialization
94 AscText *node = calloc(1, sizeof(AscText)); 93 AscText *node = calloc(1, sizeof(AscText));
95 94
96 node->base.render_group = ASC_RENDER_GROUP_SPRITE_BLEND; 95 node->base.render_group = ASC_RENDER_GROUP_SPRITE_BLEND;
97 node->base.free_func = (asc_scene_free_func) asc_text_free; 96 node->base.free_func = (asc_scene_free_func) asc_text_free;
98 node->base.update_func = (asc_scene_update_func) asc_text_update; 97 node->base.update_func = (asc_scene_update_func) asc_text_update;
99 node->base.draw_func = (asc_scene_draw_func) asc_text_draw; 98 node->base.draw_func = (asc_scene_draw_func) asc_text_draw;
100 99
101 node->base.position.x = (float) x; 100 node->base.flags = args.alignment;
102 node->base.position.y = (float) y; 101 node->base.position.x = (float) args.x;
102 node->base.position.y = (float) args.y;
103 node->max_width = args.max_width;
103 node->font = asc_context.active_font; 104 node->font = asc_context.active_font;
104 node->color = asc_context.ink; 105 node->color = asc_context.ink;
105 if (text == NULL) { 106 if (args.text == NULL) {
106 node->text = cx_mutstr(strdup(" ")); 107 node->text = cx_mutstr(strdup(" "));
107 } else { 108 } else {
108 node->text = cx_mutstr(strdup(text)); 109 node->text = cx_mutstr(strdup(args.text));
109 } 110 }
110 111
111 // initialize 112 // initialize
112 asc_text_update(node); 113 asc_text_update(node);
113 114

mercurial