From 086b157152d37eb4a63263b6a5284a2c70720c98 Mon Sep 17 00:00:00 2001 From: Dav999-v Date: Tue, 21 Feb 2023 03:26:16 +0100 Subject: [PATCH] Allow multiple lines and wordwrapping in activity zone prompts Activity zone prompts have always been limited to a single line, because the text box had a hardcoded size. A translator requested for the possibility to add a subtitle under music names for the jukebox, and the easiest solution is to make it possible to translate a prompt with multiple lines. This is possible now, and the textbox even wordwraps automatically. (I wouldn't really like to see translations using multiple lines for stuff like "Press ENTER to talk to Vitellary", especially if it wraps with one name and not with another, but if a string is too long, wordwrapping will look better than text running out of the box.) --- desktop_version/src/Render.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index a50883de..ca3d73b7 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -2223,6 +2223,7 @@ void gamerender(void) ); uint8_t text_r, text_g, text_b; + uint32_t text_flags = game.activity_print_flags | PR_BRIGHTNESS(act_alpha*255) | PR_CJK_LOW | PR_CEN; if (game.activity_r == 0 && game.activity_g == 0 && game.activity_b == 0) { @@ -2232,11 +2233,14 @@ void gamerender(void) } else { + short lines; + font::string_wordwrap(text_flags, final_string, 37*8, &lines); + graphics.drawpixeltextbox( 4, game.activity_y + 4, 39*8, - 16 + font::height(game.activity_print_flags), + 16 + font::height(text_flags)*lines, game.activity_r*act_alpha, game.activity_g*act_alpha, game.activity_b*act_alpha @@ -2247,14 +2251,16 @@ void gamerender(void) text_b = game.activity_b; } - font::print( - game.activity_print_flags | PR_BRIGHTNESS(act_alpha*255) | PR_CJK_LOW | PR_CEN, + font::print_wrap( + text_flags, -1, game.activity_y + 12, final_string, text_r, text_g, - text_b + text_b, + 8, + 37*8 ); }