4393
+ − 1
unit uCaptions;
+ − 2
+ − 3
interface
+ − 4
uses uTypes;
+ − 5
+ − 6
procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup);
+ − 7
procedure DrawCaptions;
+ − 8
+ − 9
procedure initModule;
+ − 10
procedure freeModule;
+ − 11
+ − 12
implementation
4850
+ − 13
uses uTextures, uRenderUtils, uVariables, uRender;
4393
+ − 14
+ − 15
type TCaptionStr = record
+ − 16
Tex: PTexture;
+ − 17
EndTime: LongWord;
+ − 18
end;
+ − 19
var
+ − 20
Captions: array[TCapGroup] of TCaptionStr;
+ − 21
+ − 22
procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup);
+ − 23
begin
+ − 24
if Captions[Group].Tex <> nil then
+ − 25
FreeTexture(Captions[Group].Tex);
+ − 26
Captions[Group].Tex:= nil;
+ − 27
+ − 28
Captions[Group].Tex:= RenderStringTex(s, Color, fntBig);
+ − 29
+ − 30
case Group of
+ − 31
capgrpGameState: Captions[Group].EndTime:= RealTicks + 2200
+ − 32
else
+ − 33
Captions[Group].EndTime:= RealTicks + 1400 + LongWord(Captions[Group].Tex^.w) * 3;
+ − 34
end;
+ − 35
end;
+ − 36
+ − 37
procedure DrawCaptions;
+ − 38
var
+ − 39
grp: TCapGroup;
+ − 40
offset: LongInt;
+ − 41
begin
4808
+ − 42
{$IFDEF IPHONEOS}
4393
+ − 43
offset:= 40;
4808
+ − 44
{$ELSE}
+ − 45
offset:= 8;
+ − 46
{$ENDIF}
4393
+ − 47
+ − 48
for grp:= Low(TCapGroup) to High(TCapGroup) do
+ − 49
with Captions[grp] do
+ − 50
if Tex <> nil then
+ − 51
begin
+ − 52
DrawCentered(0, offset, Tex);
+ − 53
inc(offset, Tex^.h + 2);
+ − 54
if EndTime <= RealTicks then
+ − 55
begin
+ − 56
FreeTexture(Tex);
+ − 57
Tex:= nil;
+ − 58
EndTime:= 0
+ − 59
end;
+ − 60
end;
+ − 61
end;
+ − 62
+ − 63
procedure initModule;
+ − 64
begin
+ − 65
FillChar(Captions, sizeof(Captions), 0)
+ − 66
end;
+ − 67
+ − 68
procedure freeModule;
4901
+ − 69
var
+ − 70
group: TCapGroup;
4393
+ − 71
begin
4901
+ − 72
for group:= Low(TCapGroup) to High(TCapGroup) do
+ − 73
begin
+ − 74
FreeTexture(Captions[group].Tex);
+ − 75
end;
4393
+ − 76
end;
+ − 77
+ − 78
end.