hedgewars/uCaptions.pas
branch0.9.17
changeset 6371 c6f73d8e87e2
parent 5303 e06bf3954a83
child 6374 b024e279587c
--- a/hedgewars/uCaptions.pas	Mon Nov 14 13:28:16 2011 +0400
+++ b/hedgewars/uCaptions.pas	Mon Nov 14 13:13:38 2011 -0500
@@ -35,17 +35,24 @@
 type TCaptionStr = record
                    Tex: PTexture;
                    EndTime: LongWord;
+                   Text: shortstring;
                    end;
 var
     Captions: array[TCapGroup] of TCaptionStr;
 
 procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup);
 begin
-    if Captions[Group].Tex <> nil then
+    if (Captions[Group].Tex <> nil) and (Captions[Group].Text <> s) then
+        begin
         FreeTexture(Captions[Group].Tex);
-    Captions[Group].Tex:= nil;
-
-    Captions[Group].Tex:= RenderStringTex(s, Color, fntBig);
+        Captions[Group].Tex:= nil
+        end;
+    
+    if Captions[Group].Text <> s then
+        begin
+        Captions[Group].Text:= s;
+        Captions[Group].Tex:= RenderStringTex(s, Color, fntBig)
+        end;
 
     case Group of
         capgrpGameState: Captions[Group].EndTime:= RealTicks + 2200