X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=src%2Fdraw_wins.c;h=b15e1742d75aab610c6e29e97c34159c28a0f4ba;hb=951248dddace9f7cadcf30700a3c3e6ad7ae2888;hp=7747757b82d957de7ae54d2ab26126636210f3bf;hpb=435c55c675cad9355a4e82c4d4379267f0c9a9b0;p=plomrogue diff --git a/src/draw_wins.c b/src/draw_wins.c index 7747757..b15e174 100644 --- a/src/draw_wins.c +++ b/src/draw_wins.c @@ -12,6 +12,7 @@ #include "map.h" /* for Map struct */ #include "main.h" /* for World struct */ #include "rexit.h" /* for err_exit() */ +#include "command_db.h" /* for get_command_longdesc() */ @@ -207,11 +208,18 @@ extern void draw_map_win(struct Win * win) extern void draw_info_win(struct Win * win) { struct World * world = (struct World *) win->data; - char text[100]; - snprintf(text, 100, - "Turn: %d\nHitpoints: %d\nScore: %d", - world->turn, world->player->hitpoints, world->score); + char * dsc_turn = "Turn: "; + char * dsc_hitpoints = "\nHitpoints: "; + char * dsc_score = "\nScore: "; + uint16_t maxl = strlen(dsc_turn) + strlen(dsc_hitpoints) + strlen(dsc_score) + + 10 + 5 + 10; /* max strlens of numbers to be used */ + char * text = malloc(maxl + 1); + sprintf(text, "%s%d%s%d%s%d", + dsc_turn, world->turn, + dsc_hitpoints, world->player->hitpoints, + dsc_score, world->score); draw_with_linebreaks(win, text, 0); + free(text); } @@ -226,6 +234,7 @@ extern void draw_keys_win(struct Win * win) char * keydesc = malloc(keydescwidth), * keyname; char * err_hint = "Trouble with draw_scroll_hint() in draw_keys_win()."; attr_t attri; + char * cmd_dsc; for (y = 0; y <= world->keyswindata->max && y < win->frame.size.y; y++) { if (0 == y && offset > 0) @@ -256,19 +265,19 @@ extern void draw_keys_win(struct Win * win) keyname = get_keyname(world->keybindings[y + offset].key); snprintf(keydesc, keydescwidth, "%-9s", keyname); free(keyname); + cmd_dsc = get_command_longdsc(world, + world->keybindings[y + offset].name); for (x = 0; x < win->frame.size.x; x++) { if (x < strlen(keydesc)) { mvwaddch(win->frame.curses_win, y, x, keydesc[x] | attri); } - else if (strlen(keydesc) < x - && x < strlen(world->keybindings[y + offset].name) - + strlen(keydesc) + 1) + else if ( strlen(keydesc) < x + && x < strlen(cmd_dsc) + strlen(keydesc) + 1) { mvwaddch(win->frame.curses_win, y, x, - world->keybindings[y + offset] - .name[x - strlen(keydesc) - 1] | attri); + cmd_dsc[x - strlen(keydesc) - 1] | attri); } else {