|
@@ -524,13 +524,13 @@ static int DrawString(int left, int righ
|
|
|
* remove it and undo the incrementing of the pointer! */
|
|
|
*p-- = '\0';
|
|
|
loc += len + (c == SCC_SETXY ? 2 : 1);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
if ((align & SA_MASK) != SA_LEFT) {
|
|
|
if ((align & SA_HOR_MASK) != SA_LEFT) {
|
|
|
DEBUG(grf, 1, "Using SETX and/or SETXY when not aligned to the left. Fixing alignment...");
|
|
|
|
|
|
/* For left alignment and change the left so it will roughly be in the
|
|
|
* middle. This will never cause the string to be completely centered,
|
|
|
* but once SETX is used you cannot be sure the actual content of the
|
|
|
* string is centered, so it doesn't really matter. */
|
|
@@ -551,13 +551,13 @@ static int DrawString(int left, int righ
|
|
|
*p++ = *loc++;
|
|
|
/* ... and finally copy the y coordinate if it exists */
|
|
|
if (c == SCC_SETXY) *p++ = *loc++;
|
|
|
}
|
|
|
|
|
|
/* In case we have a RTL language we swap the alignment. */
|
|
|
if (!(align & SA_FORCE) && _dynlang.text_dir == TD_RTL && align != SA_CENTER) align ^= SA_RIGHT;
|
|
|
if (!(align & SA_FORCE) && _dynlang.text_dir == TD_RTL && !(align & SA_STRIP) && (align & SA_HOR_MASK) != SA_HOR_CENTER) align ^= SA_RIGHT;
|
|
|
|
|
|
for (UChar **iter = setx_offsets.Begin(); iter != setx_offsets.End(); iter++) {
|
|
|
UChar *to_draw = *iter;
|
|
|
int offset = 0;
|
|
|
|
|
|
/* Skip the SETX(Y) and set the appropriate offsets. */
|
|
@@ -572,20 +572,20 @@ static int DrawString(int left, int righ
|
|
|
|
|
|
/* right is the right most position to draw on. In this case we want to do
|
|
|
* calculations with the width of the string. In comparison right can be
|
|
|
* seen as lastof(todraw) and width as lengthof(todraw). They differ by 1.
|
|
|
* So most +1/-1 additions are to move from lengthof to 'indices'.
|
|
|
*/
|
|
|
switch (align & SA_MASK) {
|
|
|
switch (align & SA_HOR_MASK) {
|
|
|
case SA_LEFT:
|
|
|
/* right + 1 = left + w */
|
|
|
left = initial_left + offset;
|
|
|
right = left + w - 1;
|
|
|
break;
|
|
|
|
|
|
case SA_CENTER:
|
|
|
case SA_HOR_CENTER:
|
|
|
left = RoundDivSU(initial_right + 1 + initial_left - w, 2);
|
|
|
/* right + 1 = left + w */
|
|
|
right = left + w - 1;
|
|
|
break;
|
|
|
|
|
|
case SA_RIGHT:
|
|
@@ -602,13 +602,13 @@ static int DrawString(int left, int righ
|
|
|
ReallyDoDrawString(to_draw, left, top, params, !truncate);
|
|
|
if (underline) {
|
|
|
GfxFillRect(left, top + FONT_HEIGHT_NORMAL, right, top + FONT_HEIGHT_NORMAL, _string_colourremap[1]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return align == SA_RIGHT ? min_left : max_right;
|
|
|
return (align & SA_HOR_MASK) == SA_RIGHT ? min_left : max_right;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Draw string, possibly truncated to make it fit in its allocated space
|
|
|
*
|
|
|
* @param left The left most position to draw on.
|
|
@@ -821,15 +821,13 @@ Dimension GetStringMultiLineBoundingBox(
|
|
|
* @param left The left most position to draw on.
|
|
|
* @param right The right most position to draw on.
|
|
|
* @param top The top most position to draw on.
|
|
|
* @param bottom The bottom most position to draw on.
|
|
|
* @param str String to draw.
|
|
|
* @param colour Colour used for drawing the string, see DoDrawString() for details
|
|
|
* @param align The alignment of the string when drawing left-to-right. In the
|
|
|
* case a right-to-left language is chosen this is inverted so it
|
|
|
* will be drawn in the right direction.
|
|
|
* @param align The horizontal and vertical alignment of the string.
|
|
|
* @param underline Whether to underline all strings
|
|
|
*
|
|
|
* @return The bottom to where we have written.
|
|
|
*/
|
|
|
int DrawStringMultiLine(int left, int right, int top, int bottom, StringID str, TextColour colour, StringAlignment align, bool underline)
|
|
|
{
|
|
@@ -854,13 +852,13 @@ int DrawStringMultiLine(int left, int ri
|
|
|
if (maxh < mt) return top;
|
|
|
|
|
|
num = maxh / mt - 1;
|
|
|
total_height = (num + 1) * mt;
|
|
|
}
|
|
|
|
|
|
int y = (align == SA_CENTER) ? RoundDivSU(bottom + top - total_height, 2) : top;
|
|
|
int y = ((align & SA_VERT_MASK) == SA_VERT_CENTER) ? RoundDivSU(bottom + top - total_height, 2) : top;
|
|
|
const char *src = buffer;
|
|
|
|
|
|
DrawStringParams params(colour);
|
|
|
|
|
|
for (;;) {
|
|
|
char buf2[DRAW_STRING_BUFFER];
|