File diff r2106:c87c9f2f4751 → r2107:9afd88815f5d
gfx.c
Show inline comments
 
@@ -252,27 +252,27 @@ enum {
 
	ASCII_TINYFONT = 8,
 
	ASCII_BIGFONT = 9,
 
	ASCII_NL = 10,
 

	
 
	ASCII_COLORSTART = 15,
 
};
 

	
 
/** Truncate a given string to a maximum width if neccessary.
 
 * If the string is truncated, add three dots ('...') to show this.
 
 * @param *dest string that is checked and possibly truncated
 
 * @param maxw maximum width in pixels of the string
 
 * @return new width of (truncated) string */
 
static int TruncateString(char *str, uint maxw)
 
static uint TruncateString(char *str, uint maxw)
 
{
 
	int w = 0;
 
	uint w = 0;
 
	int base = _stringwidth_base;
 
	int ddd, ddd_w;
 

	
 
	byte c;
 
	char *ddd_pos;
 

	
 
	base = _stringwidth_base;
 
	ddd_w = ddd = GetCharacterWidth(base + '.') * 3;
 

	
 
	for (c = *str, ddd_pos = str; *str != '\0'; c = (*++str)) {
 
		if (c >= ASCII_LETTERSTART) {
 
			w += GetCharacterWidth(base + c);
 
@@ -296,25 +296,25 @@ static int TruncateString(char *str, uin
 
		}
 

	
 
		// Remember the last position where three dots fit.
 
		if (w + ddd < maxw) {
 
			ddd_w = w + ddd;
 
			ddd_pos = str + 1;
 
		}
 
	}
 

	
 
	return w;
 
}
 

	
 
static inline int TruncateStringID(StringID src, char *dest, uint maxw)
 
static inline uint TruncateStringID(StringID src, char *dest, uint maxw)
 
{
 
	GetString(dest, src);
 
	return TruncateString(dest, maxw);
 
}
 

	
 
/* returns right coordinate */
 
int DrawString(int x, int y, StringID str, uint16 color)
 
{
 
	char buffer[512];
 

	
 
	GetString(buffer, str);
 
	return DoDrawString(buffer, x, y, color);
 
@@ -352,25 +352,25 @@ int DrawStringCentered(int x, int y, Str
 

	
 
	GetString(buffer, str);
 

	
 
	w = GetStringWidth(buffer);
 
	DoDrawString(buffer, x - w / 2, y, color);
 

	
 
	return w;
 
}
 

	
 
int DrawStringCenteredTruncated(int x, int y, StringID str, uint16 color, uint maxw)
 
{
 
	char buffer[512];
 
	int w = TruncateStringID(str, buffer, maxw);
 
	uint w = TruncateStringID(str, buffer, maxw);
 
	return DoDrawString(buffer, x - (w / 2), y, color);
 
}
 

	
 
void DrawStringCenterUnderline(int x, int y, StringID str, uint16 color)
 
{
 
	int w = DrawStringCentered(x, y, str, color);
 
	GfxFillRect(x - (w >> 1), y + 10, x - (w >> 1) + w, y + 10, _string_colorremap[1]);
 
}
 

	
 
void DrawStringCenterUnderlineTruncated(int x, int y, StringID str, uint16 color, uint maxw)
 
{
 
	int w = DrawStringCenteredTruncated(x, y, str, color, maxw);