hedgewars/uCaptions.pas
changeset 10634 35d059bd0932
parent 10124 aabd1b75d5a3
child 11046 47a8c19ecb60
equal deleted inserted replaced
10633:2f062fac5791 10634:35d059bd0932
    46 begin
    46 begin
    47     if cOnlyStats then exit;
    47     if cOnlyStats then exit;
    48     if Length(s) = 0 then
    48     if Length(s) = 0 then
    49         exit;
    49         exit;
    50     if Captions[Group].Text <> s then
    50     if Captions[Group].Text <> s then
    51         begin
    51         FreeAndNilTexture(Captions[Group].Tex);
    52         FreeTexture(Captions[Group].Tex);
       
    53         Captions[Group].Tex:= nil
       
    54         end;
       
    55 
    52 
    56     if Captions[Group].Tex = nil then
    53     if Captions[Group].Tex = nil then
    57         begin
    54         begin
    58         Captions[Group].Color:= Color;
    55         Captions[Group].Color:= Color;
    59         Captions[Group].Text:= s;
    56         Captions[Group].Text:= s;
    71 procedure ReloadCaptions(unload: boolean);
    68 procedure ReloadCaptions(unload: boolean);
    72 var Group: TCapGroup;
    69 var Group: TCapGroup;
    73 begin
    70 begin
    74 for Group:= Low(TCapGroup) to High(TCapGroup) do
    71 for Group:= Low(TCapGroup) to High(TCapGroup) do
    75     if unload then
    72     if unload then
    76         FreeTexture(Captions[Group].Tex)
    73         FreeAndNilTexture(Captions[Group].Tex)
    77     else if length(Captions[Group].Text) > 0 then
    74     else if length(Captions[Group].Text) > 0 then
    78         Captions[Group].Tex:= RenderStringTex(Captions[Group].Text, Captions[Group].Color, fntBig)
    75         Captions[Group].Tex:= RenderStringTex(Captions[Group].Text, Captions[Group].Color, fntBig)
    79 end;
    76 end;
    80 
    77 
    81 procedure DrawCaptions;
    78 procedure DrawCaptions;
    95                 begin
    92                 begin
    96                 DrawTextureCentered(0, offset, Tex);
    93                 DrawTextureCentered(0, offset, Tex);
    97                 inc(offset, Tex^.h + 2);
    94                 inc(offset, Tex^.h + 2);
    98                 if EndTime <= RealTicks then
    95                 if EndTime <= RealTicks then
    99                     begin
    96                     begin
   100                     FreeTexture(Tex);
    97                     FreeAndNilTexture(Tex);
   101                     Tex:= nil;
       
   102                     Text:= ansistring('');
    98                     Text:= ansistring('');
   103                     EndTime:= 0
    99                     EndTime:= 0
   104                     end;
   100                     end;
   105                 end;
   101                 end;
   106 end;
   102 end;
   112 
   108 
   113 procedure freeModule;
   109 procedure freeModule;
   114 var group: TCapGroup;
   110 var group: TCapGroup;
   115 begin
   111 begin
   116     for group:= Low(TCapGroup) to High(TCapGroup) do
   112     for group:= Low(TCapGroup) to High(TCapGroup) do
   117         begin
   113         FreeAndNilTexture(Captions[group].Tex);
   118         FreeTexture(Captions[group].Tex);
       
   119         Captions[group].Tex:= nil
       
   120         end
       
   121 end;
   114 end;
   122 
   115 
   123 end.
   116 end.