gfx.c
changeset 2107 607a900aefa3
parent 2104 74b151cc3004
child 2113 f228b399da01
equal deleted inserted replaced
2106:e0cbbec2e6e9 2107:607a900aefa3
   259 /** Truncate a given string to a maximum width if neccessary.
   259 /** Truncate a given string to a maximum width if neccessary.
   260  * If the string is truncated, add three dots ('...') to show this.
   260  * If the string is truncated, add three dots ('...') to show this.
   261  * @param *dest string that is checked and possibly truncated
   261  * @param *dest string that is checked and possibly truncated
   262  * @param maxw maximum width in pixels of the string
   262  * @param maxw maximum width in pixels of the string
   263  * @return new width of (truncated) string */
   263  * @return new width of (truncated) string */
   264 static int TruncateString(char *str, uint maxw)
   264 static uint TruncateString(char *str, uint maxw)
   265 {
   265 {
   266 	int w = 0;
   266 	uint w = 0;
   267 	int base = _stringwidth_base;
   267 	int base = _stringwidth_base;
   268 	int ddd, ddd_w;
   268 	int ddd, ddd_w;
   269 
   269 
   270 	byte c;
   270 	byte c;
   271 	char *ddd_pos;
   271 	char *ddd_pos;
   303 	}
   303 	}
   304 
   304 
   305 	return w;
   305 	return w;
   306 }
   306 }
   307 
   307 
   308 static inline int TruncateStringID(StringID src, char *dest, uint maxw)
   308 static inline uint TruncateStringID(StringID src, char *dest, uint maxw)
   309 {
   309 {
   310 	GetString(dest, src);
   310 	GetString(dest, src);
   311 	return TruncateString(dest, maxw);
   311 	return TruncateString(dest, maxw);
   312 }
   312 }
   313 
   313 
   359 }
   359 }
   360 
   360 
   361 int DrawStringCenteredTruncated(int x, int y, StringID str, uint16 color, uint maxw)
   361 int DrawStringCenteredTruncated(int x, int y, StringID str, uint16 color, uint maxw)
   362 {
   362 {
   363 	char buffer[512];
   363 	char buffer[512];
   364 	int w = TruncateStringID(str, buffer, maxw);
   364 	uint w = TruncateStringID(str, buffer, maxw);
   365 	return DoDrawString(buffer, x - (w / 2), y, color);
   365 	return DoDrawString(buffer, x - (w / 2), y, color);
   366 }
   366 }
   367 
   367 
   368 void DrawStringCenterUnderline(int x, int y, StringID str, uint16 color)
   368 void DrawStringCenterUnderline(int x, int y, StringID str, uint16 color)
   369 {
   369 {