hedgewars/uCaptions.pas
branch0.9.17
changeset 6371 c6f73d8e87e2
parent 5303 e06bf3954a83
child 6374 b024e279587c
equal deleted inserted replaced
6370:fb9aeddcb046 6371:c6f73d8e87e2
    33 uses uTextures, uRenderUtils, uVariables, uRender;
    33 uses uTextures, uRenderUtils, uVariables, uRender;
    34 
    34 
    35 type TCaptionStr = record
    35 type TCaptionStr = record
    36                    Tex: PTexture;
    36                    Tex: PTexture;
    37                    EndTime: LongWord;
    37                    EndTime: LongWord;
       
    38                    Text: shortstring;
    38                    end;
    39                    end;
    39 var
    40 var
    40     Captions: array[TCapGroup] of TCaptionStr;
    41     Captions: array[TCapGroup] of TCaptionStr;
    41 
    42 
    42 procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup);
    43 procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup);
    43 begin
    44 begin
    44     if Captions[Group].Tex <> nil then
    45     if (Captions[Group].Tex <> nil) and (Captions[Group].Text <> s) then
       
    46         begin
    45         FreeTexture(Captions[Group].Tex);
    47         FreeTexture(Captions[Group].Tex);
    46     Captions[Group].Tex:= nil;
    48         Captions[Group].Tex:= nil
    47 
    49         end;
    48     Captions[Group].Tex:= RenderStringTex(s, Color, fntBig);
    50     
       
    51     if Captions[Group].Text <> s then
       
    52         begin
       
    53         Captions[Group].Text:= s;
       
    54         Captions[Group].Tex:= RenderStringTex(s, Color, fntBig)
       
    55         end;
    49 
    56 
    50     case Group of
    57     case Group of
    51         capgrpGameState: Captions[Group].EndTime:= RealTicks + 2200
    58         capgrpGameState: Captions[Group].EndTime:= RealTicks + 2200
    52     else
    59     else
    53         Captions[Group].EndTime:= RealTicks + 1400 + LongWord(Captions[Group].Tex^.w) * 3;
    60         Captions[Group].EndTime:= RealTicks + 1400 + LongWord(Captions[Group].Tex^.w) * 3;