equal
deleted
inserted
replaced
|
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 |
|
13 uses uTextures, uRenderUtils, uVariables, uRender, uConsts; |
|
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 |
|
42 {$IFDEF IPHONEOS} |
|
43 offset:= 40; |
|
44 {$ELSE} |
|
45 if ((TrainingFlags and tfTimeTrial) <> 0) and (TimeTrialStartTime > 0) then |
|
46 offset:= 48 |
|
47 else |
|
48 offset:= 8; |
|
49 {$ENDIF} |
|
50 |
|
51 for grp:= Low(TCapGroup) to High(TCapGroup) do |
|
52 with Captions[grp] do |
|
53 if Tex <> nil then |
|
54 begin |
|
55 DrawCentered(0, offset, Tex); |
|
56 inc(offset, Tex^.h + 2); |
|
57 if EndTime <= RealTicks then |
|
58 begin |
|
59 FreeTexture(Tex); |
|
60 Tex:= nil; |
|
61 EndTime:= 0 |
|
62 end; |
|
63 end; |
|
64 end; |
|
65 |
|
66 procedure initModule; |
|
67 begin |
|
68 FillChar(Captions, sizeof(Captions), 0) |
|
69 end; |
|
70 |
|
71 procedure freeModule; |
|
72 begin |
|
73 end; |
|
74 |
|
75 end. |