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.
This commit is contained in:
Lorenzo Carletti 2022-01-17 20:55:28 +01:00
parent 1e261f5e7d
commit b7efccc27b
4 changed files with 15 additions and 6 deletions

View File

@ -214,7 +214,7 @@ int custom_codes_parse_generic(int code, char* parserAddress, WINDOW* window, by
window->inside_width_calc = true; window->inside_width_calc = true;
while(window->inside_width_calc) while(window->inside_width_calc)
m2_printnextch(window); m2_printnextch(window);
if(window->text_x >= window->window_width) { if(text_overflows_window(window)) {
w.text_x = 0; w.text_x = 0;
w.pixel_x = 0; w.pixel_x = 0;
w.text_y += 2; w.text_y += 2;

View File

@ -803,6 +803,12 @@ void clear_window_arrows(WINDOW *window)
(*tilemap_pointer)[x + 1 + (y * 32)] = tile; (*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) void weld_entry(WINDOW *window, byte *str)
{ {
weld_entry_custom(window, str, 0, 0xF); 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->pixel_x = x & 7;
window->text_x = (x >> 3) - window->window_x; window->text_x = (x >> 3) - window->window_x;
if(window->inside_width_calc && window->text_x >= window->window_width) if(window->inside_width_calc && text_overflows_window(window))
window->text_x = window->window_width; window->text_x = window->window_width + 1;
} }
// Returns: ____XXXX = number of characters printed // 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->pixel_x = x & 7;
window->text_x = (x >> 3) - window->window_x; window->text_x = (x >> 3) - window->window_x;
if(window->inside_width_calc && window->text_x >= window->window_width) if(window->inside_width_calc && text_overflows_window(window))
window->text_x = window->window_width; window->text_x = window->window_width + 1;
} }

View File

@ -66,6 +66,7 @@ void copy_name_header(WINDOW *window, int character_index);
void clear_name_header(WINDOW* window); void clear_name_header(WINDOW* window);
void draw_window_arrows(WINDOW *window, bool big); void draw_window_arrows(WINDOW *window, bool big);
void clear_window_arrows(WINDOW *window); void clear_window_arrows(WINDOW *window);
bool text_overflows_window(WINDOW* window);
void weld_entry(WINDOW *window, byte *str); void weld_entry(WINDOW *window, byte *str);
int weld_entry_saturn(WINDOW *window, byte *str); int weld_entry_saturn(WINDOW *window, byte *str);
void weld_entry_custom(WINDOW *window, byte *str, int font, int foreground); void weld_entry_custom(WINDOW *window, byte *str, int font, int foreground);

View File

@ -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] ^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] ^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] ^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] ^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] ^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] ^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] ^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] ^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] ^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] ^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]