equal
deleted
inserted
replaced
23 interface |
23 interface |
24 uses uTypes; |
24 uses uTypes; |
25 |
25 |
26 procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup); |
26 procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup); |
27 procedure DrawCaptions; |
27 procedure DrawCaptions; |
|
28 procedure ReloadCaptions; |
28 |
29 |
29 procedure initModule; |
30 procedure initModule; |
30 procedure freeModule; |
31 procedure freeModule; |
31 |
32 |
32 implementation |
33 implementation |
34 |
35 |
35 type TCaptionStr = record |
36 type TCaptionStr = record |
36 Tex: PTexture; |
37 Tex: PTexture; |
37 EndTime: LongWord; |
38 EndTime: LongWord; |
38 Text: shortstring; |
39 Text: shortstring; |
|
40 Color: Longword |
39 end; |
41 end; |
40 var |
42 var |
41 Captions: array[TCapGroup] of TCaptionStr; |
43 Captions: array[TCapGroup] of TCaptionStr; |
42 |
44 |
43 procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup); |
45 procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup); |
48 Captions[Group].Tex:= nil |
50 Captions[Group].Tex:= nil |
49 end; |
51 end; |
50 |
52 |
51 if Captions[Group].Tex = nil then |
53 if Captions[Group].Tex = nil then |
52 begin |
54 begin |
|
55 Captions[Group].Color:= Color; |
53 Captions[Group].Text:= s; |
56 Captions[Group].Text:= s; |
54 Captions[Group].Tex:= RenderStringTex(s, Color, fntBig) |
57 Captions[Group].Tex:= RenderStringTex(s, Color, fntBig) |
55 end; |
58 end; |
56 |
59 |
57 case Group of |
60 case Group of |
58 capgrpGameState: Captions[Group].EndTime:= RealTicks + 2200 |
61 capgrpGameState: Captions[Group].EndTime:= RealTicks + 2200 |
59 else |
62 else |
60 Captions[Group].EndTime:= RealTicks + 1400 + LongWord(Captions[Group].Tex^.w) * 3; |
63 Captions[Group].EndTime:= RealTicks + 1400 + LongWord(Captions[Group].Tex^.w) * 3; |
61 end; |
64 end; |
|
65 end; |
|
66 // For uStore texture recreation |
|
67 procedure ReloadCaptions; |
|
68 var Group: TCapGroup; |
|
69 begin |
|
70 for Group:= Low(TCapGroup) to High(TCapGroup) do |
|
71 begin |
|
72 if Captions[Group].Tex <> nil then FreeTexture(Captions[Group].Tex); |
|
73 Captions[Group].Tex:= RenderStringTex(Captions[Group].Text, Captions[Group].Color, fntBig) |
|
74 end |
62 end; |
75 end; |
63 |
76 |
64 procedure DrawCaptions; |
77 procedure DrawCaptions; |
65 var |
78 var |
66 grp: TCapGroup; |
79 grp: TCapGroup; |
73 {$ENDIF} |
86 {$ENDIF} |
74 |
87 |
75 for grp:= Low(TCapGroup) to High(TCapGroup) do |
88 for grp:= Low(TCapGroup) to High(TCapGroup) do |
76 with Captions[grp] do |
89 with Captions[grp] do |
77 if Tex <> nil then |
90 if Tex <> nil then |
78 begin |
91 begin |
79 DrawCentered(0, offset, Tex); |
92 DrawCentered(0, offset, Tex); |
80 inc(offset, Tex^.h + 2); |
93 inc(offset, Tex^.h + 2); |
81 if EndTime <= RealTicks then |
94 if EndTime <= RealTicks then |
82 begin |
95 begin |
83 FreeTexture(Tex); |
96 FreeTexture(Tex); |
84 Tex:= nil; |
97 Tex:= nil; |
|
98 Text:= ''; |
85 EndTime:= 0 |
99 EndTime:= 0 |
|
100 end; |
86 end; |
101 end; |
87 end; |
|
88 end; |
102 end; |
89 |
103 |
90 procedure initModule; |
104 procedure initModule; |
91 begin |
105 begin |
92 FillChar(Captions, sizeof(Captions), 0) |
106 FillChar(Captions, sizeof(Captions), 0) |
95 procedure freeModule; |
109 procedure freeModule; |
96 var |
110 var |
97 group: TCapGroup; |
111 group: TCapGroup; |
98 begin |
112 begin |
99 for group:= Low(TCapGroup) to High(TCapGroup) do |
113 for group:= Low(TCapGroup) to High(TCapGroup) do |
100 begin |
114 begin |
101 FreeTexture(Captions[group].Tex); |
115 FreeTexture(Captions[group].Tex); |
102 end; |
116 Captions[group].Tex:= nil |
|
117 end |
103 end; |
118 end; |
104 |
119 |
105 end. |
120 end. |