hedgewars/uRenderUtils.pas
changeset 10494 0eb97cf4c78e
parent 10142 adb804cb2638
child 10687 2e921409b5b1
equal deleted inserted replaced
10493:bcbf029e6b08 10494:0eb97cf4c78e
    75 begin
    75 begin
    76     WriteInRoundRect:= WriteInRoundRect(Surface, X, Y, Color, Font, s, 0);
    76     WriteInRoundRect:= WriteInRoundRect(Surface, X, Y, Color, Font, s, 0);
    77 end;*)
    77 end;*)
    78 
    78 
    79 function WriteInRoundRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: ansistring; maxLength: LongWord): TSDL_Rect;
    79 function WriteInRoundRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: ansistring; maxLength: LongWord): TSDL_Rect;
    80 var w, h: LongInt;
    80 var w, h: Longword;
    81     tmpsurf: PSDL_Surface;
    81     tmpsurf: PSDL_Surface;
    82     clr: TSDL_Color;
    82     clr: TSDL_Color;
    83     finalRect, textRect: TSDL_Rect;
    83     finalRect, textRect: TSDL_Rect;
    84 begin
    84 begin
    85     TTF_SizeUTF8(Fontz[Font].Handle, PChar(s), @w, @h);
    85     TTF_SizeUTF8(Fontz[Font].Handle, PChar(s), @w, @h);
    86     if (maxLength <> 0) and (w > maxLength) then w := maxLength;
    86     if (maxLength > 0) and (w > maxLength) then w := maxLength;
    87     finalRect.x:= X;
    87     finalRect.x:= X;
    88     finalRect.y:= Y;
    88     finalRect.y:= Y;
    89     finalRect.w:= w + cFontBorder * 2 + 4;
    89     finalRect.w:= w + cFontBorder * 2 + 4;
    90     finalRect.h:= h + cFontBorder * 2;
    90     finalRect.h:= h + cFontBorder * 2;
    91     textRect.x:= X;
    91     textRect.x:= X;
   272 begin
   272 begin
   273     RenderStringTex:= RenderStringTexLim(s, Color, font, 0);
   273     RenderStringTex:= RenderStringTexLim(s, Color, font, 0);
   274 end;
   274 end;
   275 
   275 
   276 function RenderStringTexLim(s: ansistring; Color: Longword; font: THWFont; maxLength: LongWord): PTexture;
   276 function RenderStringTexLim(s: ansistring; Color: Longword; font: THWFont; maxLength: LongWord): PTexture;
   277 var w, h: LongInt;
   277 var w, h: Longword;
   278     finalSurface: PSDL_Surface;
   278     finalSurface: PSDL_Surface;
   279 begin
   279 begin
   280     if cOnlyStats then
   280     if cOnlyStats then
   281         begin
   281         begin
   282         RenderStringTexLim:= nil;
   282         RenderStringTexLim:= nil;
   285         begin
   285         begin
   286         if length(s) = 0 then s:= _S' ';
   286         if length(s) = 0 then s:= _S' ';
   287         font:= CheckCJKFont(s, font);
   287         font:= CheckCJKFont(s, font);
   288         w:= 0; h:= 0; // avoid compiler hints
   288         w:= 0; h:= 0; // avoid compiler hints
   289         TTF_SizeUTF8(Fontz[font].Handle, PChar(s), @w, @h);
   289         TTF_SizeUTF8(Fontz[font].Handle, PChar(s), @w, @h);
   290         if (maxLength <> 0) and (w > maxLength) then w := maxLength;
   290         if (maxLength > 0) and (w > maxLength) then w := maxLength;
   291 
   291 
   292         finalSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, w + cFontBorder * 2 + 4, h + cFontBorder * 2,
   292         finalSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, w + cFontBorder * 2 + 4, h + cFontBorder * 2,
   293                 32, RMask, GMask, BMask, AMask);
   293                 32, RMask, GMask, BMask, AMask);
   294 
   294 
   295         TryDo(finalSurface <> nil, 'RenderString: fail to create surface', true);
   295         TryDo(finalSurface <> nil, 'RenderString: fail to create surface', true);