Add graphics wrapping functions

This will wrap text on-the-fly, since I will be introducing text that
needs to be wrapped whose length we can't know in advance. (Or we can,
but, that'd be stupid.)

I took the algorithm from Dav999's localization branch, but it's not
like it's a complicated algorithm in the first place. Plus I think it
actually handles words that get too long to fit on a single line better
than his localization branch. The only difference is that I removed all
the STL, and made it more memory efficient (unlike his localization
branch, it does not copy the entire string to make a version with
newline separator characters).
This commit is contained in:
Misa
2021-08-06 20:55:09 -07:00
committed by Ethan Lee
parent ee02aa0499
commit ed9cb4ca6d
2 changed files with 119 additions and 0 deletions

View File

@@ -136,6 +136,12 @@ public:
void PrintAlpha(int _x, int _y, std::string _s, int r, int g, int b, int a, bool cen = false);
bool next_wrap(size_t* start, size_t* len, const char* str, int maxwidth);
bool next_wrap_s(char buffer[], size_t buffer_size, size_t* start, const char* str, int maxwidth);
void PrintWrap(int x, int y, const char* str, int r, int g, int b, bool cen, int linespacing, int maxwidth);
void PrintOffAlpha(int _x, int _y, std::string _s, int r, int g, int b, int a, bool cen = false);
void bprint(int x, int y, std::string t, int r, int g, int b, bool cen = false);