Make wordwrapping functions take font arguments

They need to know how wide the text is going to be in a particular
font, so font::string_wordwrap and font::string_wordwrap_balanced now
take a flags argument like all the printing and dimensions-getting
functions. next_wrap and next_wrap_s take a Font* now, they're internal
to Font.cpp so they can take a Font and avoid double flag-parsing. But
if any non-Font.cpp code needs next_wrap/next_wrap_s in the future, I'd
just make a public wrapper that takes a uint32_t flags and passes the
Font* to the internal functions.
This commit is contained in:
Dav999-v
2023-01-21 02:31:44 +01:00
committed by Misa Elizabeth Kai
parent 0eaceed0a2
commit 25feb9dbb5
7 changed files with 119 additions and 109 deletions

View File

@@ -1161,7 +1161,7 @@ void editorrender(void)
}
short lines;
message = font::string_wordwrap(message, 312, &lines);
message = font::string_wordwrap(0, message, 312, &lines);
short textheight = font::height(0)*lines;
graphics.fill_rect(0,238-textheight,320,240, graphics.getRGB(32,32,32));
@@ -1264,7 +1264,7 @@ void editorrender(void)
else if (ed.textmod)
{
short lines;
std::string wrapped = font::string_wordwrap(ed.textdesc, 312, &lines);
std::string wrapped = font::string_wordwrap(0, ed.textdesc, 312, &lines);
short textheight = font::height(0)*lines+font::height(PR_FONT_LEVEL);
graphics.fill_rect(0, 238-textheight, 320, 240, graphics.getRGB(32, 32, 32));
@@ -1604,7 +1604,7 @@ void editorrender(void)
if(ed.notedelay>0 || ed.oldnotedelay>0)
{
short lines;
std::string wrapped = font::string_wordwrap(ed.note, 304, &lines);
std::string wrapped = font::string_wordwrap(0, ed.note, 304, &lines);
short textheight = 8+(lines-1)*SDL_max(10, font::height(0));
short banner_y = 120 - textheight/2 - 5;