hedgewars/uCaptions.pas
changeset 6377 3ce19204b14b
parent 6374 b024e279587c
child 6379 ef4288298e57
--- a/hedgewars/uCaptions.pas	Mon Nov 14 15:51:02 2011 -0500
+++ b/hedgewars/uCaptions.pas	Mon Nov 14 16:17:58 2011 -0500
@@ -25,6 +25,7 @@
 
 procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup);
 procedure DrawCaptions;
+procedure ReloadCaptions;
 
 procedure initModule;
 procedure freeModule;
@@ -36,6 +37,7 @@
                    Tex: PTexture;
                    EndTime: LongWord;
                    Text: shortstring;
+                   Color: Longword
                    end;
 var
     Captions: array[TCapGroup] of TCaptionStr;
@@ -50,6 +52,7 @@
     
     if Captions[Group].Tex = nil then
         begin
+        Captions[Group].Color:= Color;
         Captions[Group].Text:= s;
         Captions[Group].Tex:= RenderStringTex(s, Color, fntBig)
         end;
@@ -60,6 +63,16 @@
         Captions[Group].EndTime:= RealTicks + 1400 + LongWord(Captions[Group].Tex^.w) * 3;
     end;
 end;
+// For uStore texture recreation
+procedure ReloadCaptions;
+var Group: TCapGroup;
+begin
+for Group:= Low(TCapGroup) to High(TCapGroup) do
+    begin
+    if Captions[Group].Tex <> nil then FreeTexture(Captions[Group].Tex);
+    Captions[Group].Tex:= RenderStringTex(Captions[Group].Text, Captions[Group].Color, fntBig)
+    end
+end;
 
 procedure DrawCaptions;
 var
@@ -75,16 +88,17 @@
     for grp:= Low(TCapGroup) to High(TCapGroup) do
         with Captions[grp] do
             if Tex <> nil then
-            begin
+                begin
                 DrawCentered(0, offset, Tex);
                 inc(offset, Tex^.h + 2);
                 if EndTime <= RealTicks then
-                begin
+                    begin
                     FreeTexture(Tex);
                     Tex:= nil;
+                    Text:= '';
                     EndTime:= 0
+                    end;
                 end;
-            end;
 end;
 
 procedure initModule;
@@ -97,9 +111,10 @@
     group: TCapGroup;
 begin
     for group:= Low(TCapGroup) to High(TCapGroup) do
-    begin
+        begin
         FreeTexture(Captions[group].Tex);
-    end;
+        Captions[group].Tex:= nil
+        end
 end;
 
 end.