hedgewars/uRenderUtils.pas
changeset 10139 9046f69dae4c
parent 10127 7f29a65aa1e4
child 10142 adb804cb2638
--- a/hedgewars/uRenderUtils.pas	Thu Feb 13 23:53:47 2014 +0400
+++ b/hedgewars/uRenderUtils.pas	Fri Feb 14 13:48:14 2014 +0400
@@ -277,24 +277,31 @@
 var w, h: LongInt;
     finalSurface: PSDL_Surface;
 begin
-    if length(s) = 0 then s:= _S' ';
-    font:= CheckCJKFont(s, font);
-    w:= 0; h:= 0; // avoid compiler hints
-    TTF_SizeUTF8(Fontz[font].Handle, PChar(s), @w, @h);
-    if (maxLength <> 0) and (w > maxLength) then w := maxLength;
-
-    finalSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, w + cFontBorder * 2 + 4, h + cFontBorder * 2,
-            32, RMask, GMask, BMask, AMask);
+    if cOnlyStats then
+        begin
+        RenderStringTexLim:= nil;
+        end
+    else
+        begin
+        if length(s) = 0 then s:= _S' ';
+        font:= CheckCJKFont(s, font);
+        w:= 0; h:= 0; // avoid compiler hints
+        TTF_SizeUTF8(Fontz[font].Handle, PChar(s), @w, @h);
+        if (maxLength <> 0) and (w > maxLength) then w := maxLength;
 
-    TryDo(finalSurface <> nil, 'RenderString: fail to create surface', true);
+        finalSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, w + cFontBorder * 2 + 4, h + cFontBorder * 2,
+                32, RMask, GMask, BMask, AMask);
 
-    WriteInRoundRect(finalSurface, 0, 0, Color, font, s, maxLength);
+        TryDo(finalSurface <> nil, 'RenderString: fail to create surface', true);
+
+        WriteInRoundRect(finalSurface, 0, 0, Color, font, s, maxLength);
 
-    TryDo(SDL_SetColorKey(finalSurface, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
+        TryDo(SDL_SetColorKey(finalSurface, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
 
-    RenderStringTexLim:= Surface2Tex(finalSurface, false);
+        RenderStringTexLim:= Surface2Tex(finalSurface, false);
 
-    SDL_FreeSurface(finalSurface);
+        SDL_FreeSurface(finalSurface);
+        end;
 end;
 
 
@@ -308,22 +315,24 @@
     substr: shortstring;
     edge, corner, tail: TSPrite;
 begin
-      case SpeechType of
+    if cOnlyStats then exit(nil);
+
+    case SpeechType of
         1: begin;
-        edge:= sprSpeechEdge;
-        corner:= sprSpeechCorner;
-        tail:= sprSpeechTail;
-        end;
+            edge:= sprSpeechEdge;
+            corner:= sprSpeechCorner;
+            tail:= sprSpeechTail;
+            end;
         2: begin;
-        edge:= sprThoughtEdge;
-        corner:= sprThoughtCorner;
-        tail:= sprThoughtTail;
-        end;
+            edge:= sprThoughtEdge;
+            corner:= sprThoughtCorner;
+            tail:= sprThoughtTail;
+            end;
         3: begin;
-        edge:= sprShoutEdge;
-        corner:= sprShoutCorner;
-        tail:= sprShoutTail;
-        end;
+            edge:= sprShoutEdge;
+            corner:= sprShoutCorner;
+            tail:= sprShoutTail;
+            end;
         end;
     edgeHeight:= SpritesData[edge].Height;
     edgeWidth:= SpritesData[edge].Width;