src/gfx.cpp
branchgamebalance
changeset 9907 3b068c3a1c74
parent 9906 6f41b8713b65
child 9909 dce9a6923bb7
equal deleted inserted replaced
9906:6f41b8713b65 9907:3b068c3a1c74
   529 		}
   529 		}
   530 	}
   530 	}
   531 }
   531 }
   532 
   532 
   533 
   533 
   534 uint DrawStringMultiLine(int x, int y, StringID str, int maxw)
   534 uint DrawStringMultiLine(int x, int y, StringID str, int maxw, int maxh)
   535 {
   535 {
   536 	char buffer[512];
   536 	char buffer[512];
   537 	uint32 tmp;
   537 	uint32 tmp;
   538 	int num, mt;
   538 	int num, mt;
   539 	uint total_height;
   539 	uint total_height;
   545 	tmp = FormatStringLinebreaks(buffer, maxw);
   545 	tmp = FormatStringLinebreaks(buffer, maxw);
   546 	num = GB(tmp, 0, 16);
   546 	num = GB(tmp, 0, 16);
   547 
   547 
   548 	mt = GetCharacterHeight((FontSize)GB(tmp, 16, 16));
   548 	mt = GetCharacterHeight((FontSize)GB(tmp, 16, 16));
   549 	total_height = (num + 1) * mt;
   549 	total_height = (num + 1) * mt;
       
   550 
       
   551 	if (maxh != -1 && (int)total_height > maxh) {
       
   552 		/* Check there's room enough for at least one line. */
       
   553 		if (maxh < mt) return 0;
       
   554 
       
   555 		num = maxh / mt - 1;
       
   556 		total_height = (num + 1) * mt;
       
   557 	}
   550 
   558 
   551 	src = buffer;
   559 	src = buffer;
   552 
   560 
   553 	for (;;) {
   561 	for (;;) {
   554 		DoDrawString(src, x, y, 0xFE);
   562 		DoDrawString(src, x, y, 0xFE);