mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-31 02:14:09 +03:00
Add initial version of font::print_wrap
graphics.PrintWrap is now also deprecated. An advantage of the new version (with flags) is that it'll be possible to do things like put a border around wrapped text, wrap text at larger scales, etc, but these things don't work perfectly yet. This commit also has some other fixes, like the default advance of 6 pixels for characters 0x00-0x1F in 8x8 fonts.
This commit is contained in:
committed by
Misa Elizabeth Kai
parent
0475539075
commit
1d8494db8d
@@ -443,7 +443,7 @@ bool Graphics::next_wrap_s(
|
||||
int Graphics::PrintWrap(
|
||||
const int x,
|
||||
int y,
|
||||
std::string s,
|
||||
const std::string& text,
|
||||
const int r,
|
||||
const int g,
|
||||
const int b,
|
||||
@@ -451,50 +451,11 @@ int Graphics::PrintWrap(
|
||||
int linespacing /*= -1*/,
|
||||
int maxwidth /*= -1*/
|
||||
) {
|
||||
if (linespacing == -1)
|
||||
{
|
||||
linespacing = 10;
|
||||
}
|
||||
linespacing = SDL_max(linespacing, loc::get_langmeta()->font_h);
|
||||
|
||||
if (maxwidth == -1)
|
||||
{
|
||||
maxwidth = 304;
|
||||
}
|
||||
|
||||
const char* str = s.c_str();
|
||||
/* Screen width is 320 pixels. The shortest a char can be is 6 pixels wide.
|
||||
* 320 / 6 is 54, rounded up. 4 bytes per char. */
|
||||
char buffer[54*4 + 1];
|
||||
size_t start = 0;
|
||||
|
||||
if (flipmode)
|
||||
{
|
||||
/* Correct for the height of the resulting print. */
|
||||
size_t len = 0;
|
||||
while (next_wrap(&start, &len, &str[start], maxwidth))
|
||||
{
|
||||
y += linespacing;
|
||||
}
|
||||
y -= linespacing;
|
||||
start = 0;
|
||||
}
|
||||
|
||||
while (next_wrap_s(buffer, sizeof(buffer), &start, str, maxwidth))
|
||||
{
|
||||
Print(x, y, buffer, r, g, b, cen);
|
||||
|
||||
if (flipmode)
|
||||
{
|
||||
y -= linespacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
y += linespacing;
|
||||
}
|
||||
}
|
||||
|
||||
return y + linespacing;
|
||||
// DEPRECATED
|
||||
if (cen)
|
||||
return font::print_wrap(PR_CEN, -1, y, text, r, g, b, linespacing /*= -1 */, maxwidth /*= -1 */);
|
||||
else
|
||||
return font::print_wrap(0, x, y, text, r, g, b, linespacing /*= -1 */, maxwidth /*= -1 */);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user