hedgewars/uRenderUtils.pas
changeset 15092 ba9d54d1c25d
parent 14747 7dfc6ed13337
child 15753 72f735c03fec
equal deleted inserted replaced
15091:5c8c729a16ce 15092:ba9d54d1c25d
   412 function RenderSpeechBubbleTex(s: ansistring; SpeechType: Longword; font: THWFont): PTexture;
   412 function RenderSpeechBubbleTex(s: ansistring; SpeechType: Longword; font: THWFont): PTexture;
   413 var textWidth, textHeight, x, y, w, h, i, j, pos, line, numLines, edgeWidth, edgeHeight, cornerWidth, cornerHeight: LongInt;
   413 var textWidth, textHeight, x, y, w, h, i, j, pos, line, numLines, edgeWidth, edgeHeight, cornerWidth, cornerHeight: LongInt;
   414     finalSurface, tmpsurf, rotatedEdge: PSDL_Surface;
   414     finalSurface, tmpsurf, rotatedEdge: PSDL_Surface;
   415     rect: TSDL_Rect;
   415     rect: TSDL_Rect;
   416     {$IFNDEF PAS2C}
   416     {$IFNDEF PAS2C}
   417     chars: set of char = [#9,' ',';',':','?','!',','];
   417     breakChars: set of char = [#9,' ','-'];
   418     {$ENDIF}
   418     {$ENDIF}
   419     substr: ansistring;
   419     substr: ansistring;
   420     edge, corner, tail: TSPrite;
   420     edge, corner, tail: TSPrite;
   421 begin
   421 begin
   422     if cOnlyStats then exit(nil);
   422     if cOnlyStats then exit(nil);
   462     if (length(s) > 20) then
   462     if (length(s) > 20) then
   463         begin
   463         begin
   464         w:= 0;
   464         w:= 0;
   465         i:= round(Sqrt(length(s)) * 2);
   465         i:= round(Sqrt(length(s)) * 2);
   466         {$IFNDEF PAS2C}
   466         {$IFNDEF PAS2C}
   467         s:= WrapText(s, #1, chars, i);
   467         s:= WrapText(s, #1, breakChars, i);
   468         {$ENDIF}
   468         {$ENDIF}
   469         pos:= 1; line:= 0;
   469         pos:= 1; line:= 0;
   470     // Find the longest line for the purposes of centring the text.  Font dependant.
   470     // Find the longest line for the purposes of centring the text.  Font dependant.
   471         while GetNextSpeechLine(s, #1, pos, substr) do
   471         while GetNextSpeechLine(s, #1, pos, substr) do
   472             begin
   472             begin