From 7bcb05f7f09ee73c4d327191868816648ba5664b Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Tue, 13 Jan 2015 12:55:56 +0000 Subject: [PATCH] Fix aligned screentext with newlines. git-svn-id: https://svn.eduke32.com/eduke32@4913 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/game.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index ea7d0e7db..3ad741d81 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -548,6 +548,8 @@ vec2_t G_ScreenTextSize(const int32_t font, break; case '\n': // near-CODEDUP "if (wrap)" + extent.x = 0; + // save the position if (!(f & TEXT_XOFFSETZERO)) // we want the entire offset to count as the character width pos.x -= offset.x; @@ -798,7 +800,7 @@ vec2_t G_ScreenText(const int32_t font, { char *line = G_GetSubString(text, end, iter, length); - linewidth = G_ScreenTextSize(font, x, y, z, blockangle, line, o | ROTATESPRITE_FULL16, xspace, yline, 0, 0, f & ~(TEXT_XJUSTIFY|TEXT_YJUSTIFY|TEXT_BACKWARDS), x1, y1, x2, y2).x; + linewidth = G_ScreenTextSize(font, x, y, z, blockangle, line, o | ROTATESPRITE_FULL16, xspace, yline, (f & TEXT_XJUSTIFY) ? 0 : xbetween, (f & TEXT_YJUSTIFY) ? 0 : ybetween, f & ~(TEXT_XJUSTIFY|TEXT_YJUSTIFY|TEXT_BACKWARDS), x1, y1, x2, y2).x; Bfree(line); } @@ -951,6 +953,8 @@ vec2_t G_ScreenText(const int32_t font, break; case '\n': // near-CODEDUP "if (wrap)" + extent.x = 0; + // reset the position pos.x = 0; @@ -984,11 +988,11 @@ vec2_t G_ScreenText(const int32_t font, // near-CODEDUP "alignments" if ((f & TEXT_XJUSTIFY) || (f & TEXT_XRIGHT) || (f & TEXT_XCENTER)) { - const int32_t length = G_GetStringLineLength(text, end, iter); + const int32_t length = G_GetStringLineLength(text+1, end, iter); - char *line = G_GetSubString(text, end, iter, length); + char *line = G_GetSubString(text+1, end, iter, length); - int32_t linewidth = G_ScreenTextSize(font, x, y, z, blockangle, line, o | ROTATESPRITE_FULL16, xspace, yline, 0, 0, f & ~(TEXT_XJUSTIFY|TEXT_YJUSTIFY|TEXT_BACKWARDS), x1, y1, x2, y2).x; + int32_t linewidth = G_ScreenTextSize(font, x, y, z, blockangle, line, o | ROTATESPRITE_FULL16, xspace, yline, (f & TEXT_XJUSTIFY) ? 0 : xbetween, (f & TEXT_YJUSTIFY) ? 0 : ybetween, f & ~(TEXT_XJUSTIFY|TEXT_YJUSTIFY|TEXT_BACKWARDS), x1, y1, x2, y2).x; Bfree(line);