From b7efccc27b3730d33060d4710f9f71089b3421e9 Mon Sep 17 00:00:00 2001 From: Lorenzo Carletti Date: Mon, 17 Jan 2022 20:55:28 +0100 Subject: [PATCH] Adds one missing pixel to the width overflow check Also better handles the case of "X and its cohorts attacked!" by breaking it into "X and its cohorts attacked!" if possible. --- src/c/custom_codes.c | 2 +- src/c/vwf.c | 14 ++++++++++---- src/c/vwf.h | 1 + working/m12-strings-english.txt | 4 +++- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/c/custom_codes.c b/src/c/custom_codes.c index 8bb75a0..49b9c2a 100644 --- a/src/c/custom_codes.c +++ b/src/c/custom_codes.c @@ -214,7 +214,7 @@ int custom_codes_parse_generic(int code, char* parserAddress, WINDOW* window, by window->inside_width_calc = true; while(window->inside_width_calc) m2_printnextch(window); - if(window->text_x >= window->window_width) { + if(text_overflows_window(window)) { w.text_x = 0; w.pixel_x = 0; w.text_y += 2; diff --git a/src/c/vwf.c b/src/c/vwf.c index d01e902..55c23a9 100644 --- a/src/c/vwf.c +++ b/src/c/vwf.c @@ -803,6 +803,12 @@ void clear_window_arrows(WINDOW *window) (*tilemap_pointer)[x + 1 + (y * 32)] = tile; } +// Confirms the text breaks the boundaries +bool text_overflows_window(WINDOW* window) +{ + return (window->text_x > window->window_width) || ((window->text_x == window->window_width) && (window->pixel_x > 0)); +} + void weld_entry(WINDOW *window, byte *str) { weld_entry_custom(window, str, 0, 0xF); @@ -832,8 +838,8 @@ void weld_entry_custom(WINDOW *window, byte *str, int font, int foreground) window->pixel_x = x & 7; window->text_x = (x >> 3) - window->window_x; - if(window->inside_width_calc && window->text_x >= window->window_width) - window->text_x = window->window_width; + if(window->inside_width_calc && text_overflows_window(window)) + window->text_x = window->window_width + 1; } // Returns: ____XXXX = number of characters printed @@ -1532,8 +1538,8 @@ void weld_entry_custom_buffer(WINDOW *window, byte *str, int font, int foregroun window->pixel_x = x & 7; window->text_x = (x >> 3) - window->window_x; - if(window->inside_width_calc && window->text_x >= window->window_width) - window->text_x = window->window_width; + if(window->inside_width_calc && text_overflows_window(window)) + window->text_x = window->window_width + 1; } diff --git a/src/c/vwf.h b/src/c/vwf.h index dbbcbac..b8c9e23 100644 --- a/src/c/vwf.h +++ b/src/c/vwf.h @@ -66,6 +66,7 @@ void copy_name_header(WINDOW *window, int character_index); void clear_name_header(WINDOW* window); void draw_window_arrows(WINDOW *window, bool big); void clear_window_arrows(WINDOW *window); +bool text_overflows_window(WINDOW* window); void weld_entry(WINDOW *window, byte *str); int weld_entry_saturn(WINDOW *window, byte *str); void weld_entry_custom(WINDOW *window, byte *str, int font, int foreground); diff --git a/working/m12-strings-english.txt b/working/m12-strings-english.txt index 7649aef..a606e45 100644 --- a/working/m12-strings-english.txt +++ b/working/m12-strings-english.txt @@ -1946,11 +1946,13 @@ ^L1951^[83 FF C5 00][82 FF _L2197_][08 FF 0C 02][A2 FF _L5617_][FC FF 05 00][1C FF 80 01 _L2197_][9D FF 01 1F _L5625_][00 FF] ^L1952^[1C FF 49 00 _L2197_][9D FF 01 0E _L5614_][00 FF] ^L10000^[5E FF 01][95 FF 03 _L10001_ _L10002_ _L10003_][00 FF] -^L10000SP^[5E FF 01][95 FF 03 _L10001SP_ _L10002_ _L10003_][00 FF] +^L10000SP^[5E FF 01][95 FF 03 _L10001SP_ _L10002SP_ _L10003SP_][00 FF] ^L10001^[86 FF _useruppertheignore_][57 FF 00][86 FF _twospacesifnewline_][9F FF][00 FF] ^L10001SP^[86 FF _useruppertheignore_][57 FF 00][86 FF _twospacesifnewline_][9F FF][57 FF 01][57 FF 00][86 FF _onespaceifnewline_][00 FF] ^L10002^[86 FF _useruppertheignore_][57 FF 00][86 FF _twospacesifnewline_][9F FF][57 FF 01][57 FF 00][86 FF _onespaceifnewline_] and its cohort[00 FF] +^L10002SP^[86 FF _useruppertheignore_][57 FF 00][86 FF _twospacesifnewline_][9F FF][57 FF 01][57 FF 00][86 FF _onespaceifnewline_] and[57 FF 01][57 FF 00][86 FF _onespaceifnewline_] its cohort[00 FF] ^L10003^[86 FF _useruppertheignore_][57 FF 00][86 FF _twospacesifnewline_][9F FF][57 FF 01][57 FF 00][86 FF _onespaceifnewline_] and its cohorts[00 FF] +^L10003SP^[86 FF _useruppertheignore_][57 FF 00][86 FF _twospacesifnewline_][9F FF][57 FF 01][57 FF 00][86 FF _onespaceifnewline_] and[57 FF 01][57 FF 00][86 FF _onespaceifnewline_] its cohorts[00 FF] ^L10004^[5E FF 01][95 FF 03 _L10005_ _L10006_ _L10007_][00 FF] ^L10005^[86 FF _userlowertheignore_][57 FF 00][86 FF _twospacesifnewline_][9F FF][00 FF] ^L10006^[86 FF _userlowertheignore_][57 FF 00][86 FF _twospacesifnewline_][9F FF][57 FF 01][57 FF 00][86 FF _onespaceifnewline_] and its cohort[00 FF]