Skip to content

Commit

Permalink
fix display of menu strings containing '%'
Browse files Browse the repository at this point in the history
  • Loading branch information
irixxxx committed Mar 26, 2021
1 parent 8ba41c7 commit d57c999
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,10 @@ static void smalltext_out16(int x, int y, const char *texto, int color)

if (maxw < 0)
return;

strncpy(buffer, texto, sizeof(buffer));
if (maxw > sizeof(buffer) - 1)
maxw = sizeof(buffer) - 1;

strncpy(buffer, texto, maxw);
buffer[maxw] = 0;

smalltext_out16_(x, y, buffer, color);
Expand Down Expand Up @@ -601,15 +601,15 @@ static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void))
name = ent->generate_name(ent->id, &offs);
}
if (name != NULL) {
text_out16(x, y, name);
text_out16(x, y, "%s", name);
leftname_end = x + (strlen(name) + 1) * me_mfont_w;
}

switch (ent->beh) {
case MB_NONE:
break;
case MB_OPT_ONOFF:
text_out16(x + col2_offs, y, me_read_onoff(ent) ? "ON" : "OFF");
text_out16(x + col2_offs, y, "%s", me_read_onoff(ent) ? "ON" : "OFF");
break;
case MB_OPT_RANGE:
text_out16(x + col2_offs, y, "%i", *(int *)ent->var);
Expand Down Expand Up @@ -650,7 +650,7 @@ static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void))
h = (g_menuscreen_h - h) / 2; // bottom area height
if (menu_error_msg[0] != 0) {
if (h >= me_mfont_h + 4)
text_out16(5, g_menuscreen_h - me_mfont_h - 4, menu_error_msg);
text_out16(5, g_menuscreen_h - me_mfont_h - 4, "%s", menu_error_msg);
else
lprintf("menu msg doesn't fit!\n");

Expand Down Expand Up @@ -813,7 +813,7 @@ static void draw_menu_message(const char *msg, void (*draw_more)(void))
menu_draw_begin(1, 0);

for (p = msg; *p != 0 && y <= g_menuscreen_h - me_mfont_h; y += me_mfont_h) {
text_out16(x, y, p);
text_out16(x, y, "%s", p);

for (; *p != 0 && *p != '\n'; p++)
;
Expand Down Expand Up @@ -855,7 +855,7 @@ static void do_delete(const char *fpath, const char *fname)
snprintf(tmp + len, sizeof(tmp) - len, "%s - cancel)", nm);
len = strlen(tmp);

text_out16(mid - me_mfont_w * len / 2, 12 * me_mfont_h, tmp);
text_out16(mid - me_mfont_w * len / 2, 12 * me_mfont_h, "%s", tmp);
menu_draw_end();

while (in_menu_wait_any(NULL, 50) & (PBTN_MENU|PBTN_MA2));
Expand Down Expand Up @@ -1425,13 +1425,13 @@ static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_
snprintf(buff2, sizeof(buff2), "%s", in_get_key_name(-1, -PBTN_MOK));
snprintf(buff, sizeof(buff), "%s - bind, %s - clear", buff2,
in_get_key_name(-1, -PBTN_MA2));
text_out16(x, g_menuscreen_h - 4 * me_mfont_h, buff);
text_out16(x, g_menuscreen_h - 4 * me_mfont_h, "%s", buff);
}
else
text_out16(x, g_menuscreen_h - 4 * me_mfont_h, "Press a button to bind/unbind");

if (dev_count > 1) {
text_out16(x, g_menuscreen_h - 3 * me_mfont_h, dev_name);
text_out16(x, g_menuscreen_h - 3 * me_mfont_h, "%s", dev_name);
text_out16(x, g_menuscreen_h - 2 * me_mfont_h, "Press left/right for other devs");
}

Expand Down

0 comments on commit d57c999

Please sign in to comment.