1 | {$INCLUDE switches}
|
---|
2 | unit MessgEx;
|
---|
3 |
|
---|
4 | interface
|
---|
5 |
|
---|
6 | uses
|
---|
7 | Messg, Protocol, ScreenTools,
|
---|
8 |
|
---|
9 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, ButtonA,
|
---|
10 | ButtonB, ButtonBase, StdCtrls;
|
---|
11 |
|
---|
12 | type
|
---|
13 | TMessgExDlg = class(TBaseMessgDlg)
|
---|
14 | Button1: TButtonA;
|
---|
15 | Button2: TButtonA;
|
---|
16 | Button3: TButtonA;
|
---|
17 | RemoveBtn: TButtonB;
|
---|
18 | EInput: TEdit;
|
---|
19 | procedure FormCreate(Sender: TObject);
|
---|
20 | procedure FormPaint(Sender: TObject);
|
---|
21 | procedure FormShow(Sender: TObject);
|
---|
22 | procedure Button1Click(Sender: TObject);
|
---|
23 | procedure Button2Click(Sender: TObject);
|
---|
24 | procedure Button3Click(Sender: TObject);
|
---|
25 | procedure FormKeyPress(Sender: TObject; var Key: char);
|
---|
26 | procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
27 | procedure RemoveBtnClick(Sender: TObject);
|
---|
28 | public
|
---|
29 | Kind, IconKind, IconIndex, HelpKind, HelpNo, CenterTo: integer;
|
---|
30 | OpenSound: string;
|
---|
31 | function ShowModal: integer; override;
|
---|
32 | procedure CancelMovie;
|
---|
33 | private
|
---|
34 | MovieCancelled: boolean;
|
---|
35 | procedure PaintBook(ca: TCanvas; x, y, clPage, clCover: integer);
|
---|
36 | procedure PaintMyArmy;
|
---|
37 | procedure PaintEnemyArmy;
|
---|
38 | procedure OnPlaySound(var Msg: TMessage); message WM_PLAYSOUND;
|
---|
39 | end;
|
---|
40 |
|
---|
41 | const
|
---|
42 | // extra message kinds
|
---|
43 | mkYesNoCancel = 4;
|
---|
44 | mkOkCancelRemove = 5;
|
---|
45 | mkOkHelp = 6;
|
---|
46 | mkModel = 7;
|
---|
47 |
|
---|
48 | // message icon kinds
|
---|
49 | mikNone = -1;
|
---|
50 | mikImp = 0;
|
---|
51 | mikModel = 1;
|
---|
52 | mikTribe = 2;
|
---|
53 | mikBook = 3;
|
---|
54 | mikAge = 4;
|
---|
55 | mikPureIcon = 5;
|
---|
56 | mikMyArmy = 6;
|
---|
57 | mikEnemyArmy = 7;
|
---|
58 | mikFullControl = 8;
|
---|
59 | mikShip = 9;
|
---|
60 | mikBigIcon = 10;
|
---|
61 | mikEnemyShipComplete = 11;
|
---|
62 |
|
---|
63 | var
|
---|
64 | MessgExDlg: TMessgExDlg;
|
---|
65 |
|
---|
66 | procedure SoundMessageEx(SimpleText, SoundItem: string);
|
---|
67 | procedure TribeMessage(p: integer; SimpleText, SoundItem: string);
|
---|
68 | function SimpleQuery(QueryKind: integer; SimpleText, SoundItem: string)
|
---|
69 | : integer;
|
---|
70 | procedure ContextMessage(SimpleText, SoundItem: string;
|
---|
71 | ContextKind, ContextNo: integer);
|
---|
72 |
|
---|
73 | implementation
|
---|
74 |
|
---|
75 | uses
|
---|
76 | ClientTools, BaseWin, Term, Help, Select, Diplomacy, Inp, UnitStat, Tribes,
|
---|
77 | IsoEngine, Diagram;
|
---|
78 |
|
---|
79 | {$R *.DFM}
|
---|
80 |
|
---|
81 | const
|
---|
82 | LostUnitsPerLine = 6;
|
---|
83 |
|
---|
84 | var
|
---|
85 | PerfFreq: int64;
|
---|
86 |
|
---|
87 | procedure TMessgExDlg.FormCreate(Sender: TObject);
|
---|
88 | begin
|
---|
89 | inherited;
|
---|
90 | IconKind := mikNone;
|
---|
91 | CenterTo := 0;
|
---|
92 | OpenSound := '';
|
---|
93 | end;
|
---|
94 |
|
---|
95 | procedure TMessgExDlg.FormShow(Sender: TObject);
|
---|
96 | var
|
---|
97 | i: integer;
|
---|
98 | begin
|
---|
99 | if IconKind = mikEnemyArmy then
|
---|
100 | InitAllEnemyModels;
|
---|
101 |
|
---|
102 | Button1.Visible := GameMode <> cMovie;
|
---|
103 | Button2.Visible := (GameMode <> cMovie) and (Kind <> mkOk);
|
---|
104 | Button3.Visible := (GameMode <> cMovie) and (Kind = mkYesNoCancel);
|
---|
105 | RemoveBtn.Visible := (GameMode <> cMovie) and (Kind = mkOkCancelRemove);
|
---|
106 | EInput.Visible := (GameMode <> cMovie) and (Kind = mkModel);
|
---|
107 | if Button3.Visible then
|
---|
108 | begin
|
---|
109 | Button1.Left := 43;
|
---|
110 | Button2.Left := 159;
|
---|
111 | end
|
---|
112 | else if Button2.Visible then
|
---|
113 | begin
|
---|
114 | Button1.Left := 101;
|
---|
115 | Button2.Left := 217;
|
---|
116 | end
|
---|
117 | else
|
---|
118 | Button1.Left := 159;
|
---|
119 | RemoveBtn.Left := ClientWidth - 38;
|
---|
120 | case Kind of
|
---|
121 | mkYesNo, mkYesNoCancel:
|
---|
122 | begin
|
---|
123 | Button1.Caption := Phrases.Lookup('BTN_YES');
|
---|
124 | Button2.Caption := Phrases.Lookup('BTN_NO')
|
---|
125 | end;
|
---|
126 | mkOKCancel, mkOkCancelRemove:
|
---|
127 | begin
|
---|
128 | Button1.Caption := Phrases.Lookup('BTN_OK');
|
---|
129 | Button2.Caption := Phrases.Lookup('BTN_CANCEL');
|
---|
130 | end;
|
---|
131 | else
|
---|
132 | begin
|
---|
133 | Button1.Caption := Phrases.Lookup('BTN_OK');
|
---|
134 | Button2.Caption := Phrases.Lookup('BTN_INFO');
|
---|
135 | end;
|
---|
136 | end;
|
---|
137 | Button3.Caption := Phrases.Lookup('BTN_CANCEL');
|
---|
138 | RemoveBtn.Hint := Phrases.Lookup('BTN_DELGAME');
|
---|
139 |
|
---|
140 | case IconKind of
|
---|
141 | mikImp, mikModel, mikAge, mikPureIcon:
|
---|
142 | TopSpace := 56;
|
---|
143 | mikBigIcon:
|
---|
144 | TopSpace := 152;
|
---|
145 | mikEnemyShipComplete:
|
---|
146 | TopSpace := 136;
|
---|
147 | mikBook:
|
---|
148 | if IconIndex >= 0 then
|
---|
149 | TopSpace := 84
|
---|
150 | else
|
---|
151 | TopSpace := 47;
|
---|
152 | mikTribe:
|
---|
153 | begin
|
---|
154 | Tribe[IconIndex].InitAge(GetAge(IconIndex));
|
---|
155 | if Tribe[IconIndex].faceHGr >= 0 then
|
---|
156 | TopSpace := 64
|
---|
157 | end;
|
---|
158 | mikFullControl:
|
---|
159 | TopSpace := 80;
|
---|
160 | mikShip:
|
---|
161 | TopSpace := 240;
|
---|
162 | else
|
---|
163 | TopSpace := 0;
|
---|
164 | end;
|
---|
165 |
|
---|
166 | SplitText(true);
|
---|
167 | ClientHeight := 72 + Border + TopSpace + Lines * MessageLineSpacing;
|
---|
168 | if GameMode = cMovie then
|
---|
169 | ClientHeight := ClientHeight - 32;
|
---|
170 | if Kind = mkModel then
|
---|
171 | ClientHeight := ClientHeight + 36;
|
---|
172 | if IconKind in [mikMyArmy, mikEnemyArmy] then
|
---|
173 | begin
|
---|
174 | if nLostArmy > LostUnitsPerLine * 6 then
|
---|
175 | ClientHeight := ClientHeight + 6 * 48
|
---|
176 | else
|
---|
177 | ClientHeight := ClientHeight + ((nLostArmy - 1) div LostUnitsPerLine
|
---|
178 | + 1) * 48;
|
---|
179 | end;
|
---|
180 | case CenterTo of
|
---|
181 | 0:
|
---|
182 | begin
|
---|
183 | Left := (Screen.Width - ClientWidth) div 2;
|
---|
184 | Top := (Screen.Height - ClientHeight) div 2 - MapCenterUp;
|
---|
185 | end;
|
---|
186 | 1:
|
---|
187 | begin
|
---|
188 | Left := (Screen.Width - ClientWidth) div 4;
|
---|
189 | Top := (Screen.Height - ClientHeight) * 2 div 3 - MapCenterUp;
|
---|
190 | end;
|
---|
191 | -1:
|
---|
192 | begin
|
---|
193 | Left := (Screen.Width - ClientWidth) div 4;
|
---|
194 | Top := (Screen.Height - ClientHeight) div 3 - MapCenterUp;
|
---|
195 | end;
|
---|
196 | end;
|
---|
197 | for i := 0 to ControlCount - 1 do
|
---|
198 | Controls[i].Top := ClientHeight - (34 + Border);
|
---|
199 | if Kind = mkModel then
|
---|
200 | EInput.Top := ClientHeight - (76 + Border);
|
---|
201 | end;
|
---|
202 |
|
---|
203 | function TMessgExDlg.ShowModal: integer;
|
---|
204 | var
|
---|
205 | Ticks0, Ticks: int64;
|
---|
206 | begin
|
---|
207 | if GameMode = cMovie then
|
---|
208 | begin
|
---|
209 | if not((GameMode = cMovie) and (MovieSpeed = 4)) then
|
---|
210 | begin
|
---|
211 | MovieCancelled := false;
|
---|
212 | Show;
|
---|
213 | QueryPerformanceCounter(Ticks0);
|
---|
214 | repeat
|
---|
215 | Application.ProcessMessages;
|
---|
216 | Sleep(1);
|
---|
217 | QueryPerformanceCounter(Ticks);
|
---|
218 | until MovieCancelled or ((Ticks - Ticks0) * 1000 >= 1500 * PerfFreq);
|
---|
219 | Hide;
|
---|
220 | end;
|
---|
221 | result := mrOk;
|
---|
222 | end
|
---|
223 | else
|
---|
224 | result := inherited ShowModal;
|
---|
225 | end;
|
---|
226 |
|
---|
227 | procedure TMessgExDlg.CancelMovie;
|
---|
228 | begin
|
---|
229 | MovieCancelled := true;
|
---|
230 | end;
|
---|
231 |
|
---|
232 | procedure TMessgExDlg.PaintBook(ca: TCanvas; x, y, clPage, clCover: integer);
|
---|
233 | const
|
---|
234 | xScrewed = 77;
|
---|
235 | yScrewed = 10;
|
---|
236 | wScrewed = 43;
|
---|
237 | hScrewed = 27;
|
---|
238 | type
|
---|
239 | TLine = array [0 .. 9999, 0 .. 2] of Byte;
|
---|
240 | var
|
---|
241 | ix, iy, xDst, yDst, dx, dy, xIcon, yIcon, xb, yb, wb, hb: integer;
|
---|
242 | x1, xR, yR, share: single;
|
---|
243 | Screwed: array [0 .. wScrewed - 1, 0 .. hScrewed - 1, 0 .. 3] of single;
|
---|
244 | SrcLine: ^TLine;
|
---|
245 |
|
---|
246 | begin
|
---|
247 | if IconIndex >= 0 then
|
---|
248 | begin
|
---|
249 | xIcon := IconIndex mod 7 * xSizeBig;
|
---|
250 | yIcon := (IconIndex + SystemIconLines * 7) div 7 * ySizeBig;
|
---|
251 | // prepare screwed icon
|
---|
252 | fillchar(Screwed, sizeof(Screwed), 0);
|
---|
253 | for iy := 0 to 39 do
|
---|
254 | begin
|
---|
255 | SrcLine := BigImp.ScanLine[iy + yIcon];
|
---|
256 | for ix := 0 to 55 do
|
---|
257 | begin
|
---|
258 | xR := ix * (37 + iy * 5 / 40) / 56;
|
---|
259 | xDst := Trunc(xR);
|
---|
260 | xR := Frac(xR);
|
---|
261 | x1 := (120 - ix) * (120 - ix) - 10000;
|
---|
262 | yR := iy * 18 / 40 + x1 * x1 / 4000000;
|
---|
263 | yDst := Trunc(yR);
|
---|
264 | yR := Frac(yR);
|
---|
265 | for dx := 0 to 1 do
|
---|
266 | for dy := 0 to 1 do
|
---|
267 | begin
|
---|
268 | if dx = 0 then
|
---|
269 | share := 1 - xR
|
---|
270 | else
|
---|
271 | share := xR;
|
---|
272 | if dy = 0 then
|
---|
273 | share := share * (1 - yR)
|
---|
274 | else
|
---|
275 | share := share * yR;
|
---|
276 | Screwed[xDst + dx, yDst + dy, 0] := Screwed[xDst + dx, yDst + dy, 0]
|
---|
277 | + share * SrcLine[ix + xIcon, 0];
|
---|
278 | Screwed[xDst + dx, yDst + dy, 1] := Screwed[xDst + dx, yDst + dy, 1]
|
---|
279 | + share * SrcLine[ix + xIcon, 1];
|
---|
280 | Screwed[xDst + dx, yDst + dy, 2] := Screwed[xDst + dx, yDst + dy, 2]
|
---|
281 | + share * SrcLine[ix + xIcon, 2];
|
---|
282 | Screwed[xDst + dx, yDst + dy, 3] := Screwed[xDst + dx, yDst + dy,
|
---|
283 | 3] + share;
|
---|
284 | end
|
---|
285 | end;
|
---|
286 | end;
|
---|
287 | xb := xBBook;
|
---|
288 | yb := yBBook;
|
---|
289 | wb := wBBook;
|
---|
290 | hb := hBBook;
|
---|
291 | end
|
---|
292 | else
|
---|
293 | begin
|
---|
294 | xb := xSBook;
|
---|
295 | yb := ySBook;
|
---|
296 | wb := wSBook;
|
---|
297 | hb := hSBook;
|
---|
298 | end;
|
---|
299 | x := x - wb div 2;
|
---|
300 |
|
---|
301 | // paint
|
---|
302 | BitBlt(LogoBuffer.Canvas.Handle, 0, 0, wb, hb, ca.Handle, x, y, SRCCOPY);
|
---|
303 |
|
---|
304 | if IconIndex >= 0 then
|
---|
305 | for iy := 0 to hScrewed - 1 do
|
---|
306 | for ix := 0 to wScrewed - 1 do
|
---|
307 | if Screwed[ix, iy, 3] > 0.01 then
|
---|
308 | LogoBuffer.Canvas.Pixels[xScrewed + ix, yScrewed + iy] :=
|
---|
309 | Trunc(Screwed[ix, iy, 2] / Screwed[ix, iy, 3]) +
|
---|
310 | Trunc(Screwed[ix, iy, 1] / Screwed[ix, iy, 3]) shl 8 +
|
---|
311 | Trunc(Screwed[ix, iy, 0] / Screwed[ix, iy, 3]) shl 16;
|
---|
312 |
|
---|
313 | ImageOp_BCC(LogoBuffer, Templates, 0, 0, xb, yb, wb, hb, clCover, clPage);
|
---|
314 |
|
---|
315 | BitBlt(ca.Handle, x, y, wb, hb, LogoBuffer.Canvas.Handle, 0, 0, SRCCOPY);
|
---|
316 | end;
|
---|
317 |
|
---|
318 | procedure TMessgExDlg.PaintMyArmy;
|
---|
319 | begin
|
---|
320 | end;
|
---|
321 |
|
---|
322 | procedure TMessgExDlg.PaintEnemyArmy;
|
---|
323 | var
|
---|
324 | emix, ix, iy, x, y, count, UnitsInLine: integer;
|
---|
325 | begin
|
---|
326 | ix := 0;
|
---|
327 | iy := 0;
|
---|
328 | if nLostArmy > LostUnitsPerLine then
|
---|
329 | UnitsInLine := LostUnitsPerLine
|
---|
330 | else
|
---|
331 | UnitsInLine := nLostArmy;
|
---|
332 | for emix := 0 to MyRO.nEnemyModel - 1 do
|
---|
333 | for count := 0 to LostArmy[emix] - 1 do
|
---|
334 | begin
|
---|
335 | x := ClientWidth div 2 + ix * 64 - UnitsInLine * 32;
|
---|
336 | y := 26 + Border + TopSpace + Lines * MessageLineSpacing + iy * 48;
|
---|
337 | with MyRO.EnemyModel[emix], Tribe[Owner].ModelPicture[mix] do
|
---|
338 | begin
|
---|
339 | BitBlt(Canvas.Handle, x, y, 64, 48, GrExt[HGr].Mask.Canvas.Handle,
|
---|
340 | pix mod 10 * 65 + 1, pix div 10 * 49 + 1, SRCAND);
|
---|
341 | BitBlt(Canvas.Handle, x, y, 64, 48, GrExt[HGr].Data.Canvas.Handle,
|
---|
342 | pix mod 10 * 65 + 1, pix div 10 * 49 + 1, SRCPAINT);
|
---|
343 | end;
|
---|
344 |
|
---|
345 | // next position
|
---|
346 | inc(ix);
|
---|
347 | if ix = LostUnitsPerLine then
|
---|
348 | begin // next line
|
---|
349 | ix := 0;
|
---|
350 | inc(iy);
|
---|
351 | if iy = 6 then
|
---|
352 | exit;
|
---|
353 | UnitsInLine := nLostArmy - LostUnitsPerLine * iy;
|
---|
354 | if UnitsInLine > LostUnitsPerLine then
|
---|
355 | UnitsInLine := LostUnitsPerLine;
|
---|
356 | end
|
---|
357 | end;
|
---|
358 | end;
|
---|
359 |
|
---|
360 | procedure TMessgExDlg.FormPaint(Sender: TObject);
|
---|
361 | var
|
---|
362 | p1, clSaveTextLight, clSaveTextShade: integer;
|
---|
363 | begin
|
---|
364 | if (IconKind = mikImp) and (IconIndex = 27) then
|
---|
365 | begin // "YOU WIN" message
|
---|
366 | clSaveTextLight := MainTexture.clTextLight;
|
---|
367 | clSaveTextShade := MainTexture.clTextShade;
|
---|
368 | MainTexture.clTextLight := $000000; // gold
|
---|
369 | MainTexture.clTextShade := $0FDBFF;
|
---|
370 | inherited;
|
---|
371 | MainTexture.clTextLight := clSaveTextLight;
|
---|
372 | MainTexture.clTextShade := clSaveTextShade;
|
---|
373 | end
|
---|
374 | else
|
---|
375 | inherited;
|
---|
376 |
|
---|
377 | case IconKind of
|
---|
378 | mikImp:
|
---|
379 | if Imp[IconIndex].Kind = ikWonder then
|
---|
380 | begin
|
---|
381 | p1 := MyRO.Wonder[IconIndex].EffectiveOwner;
|
---|
382 | BitBlt(Buffer.Canvas.Handle, 0, 0, xSizeBig + 2 * GlowRange,
|
---|
383 | ySizeBig + 2 * GlowRange, Canvas.Handle,
|
---|
384 | ClientWidth div 2 - (28 + GlowRange), 24 - GlowRange, SRCCOPY);
|
---|
385 | BitBlt(Buffer.Canvas.Handle, GlowRange, GlowRange, xSizeBig, ySizeBig,
|
---|
386 | BigImp.Canvas.Handle, IconIndex mod 7 * xSizeBig,
|
---|
387 | (IconIndex + SystemIconLines * 7) div 7 * ySizeBig, SRCCOPY);
|
---|
388 | if p1 < 0 then
|
---|
389 | GlowFrame(Buffer, GlowRange, GlowRange, xSizeBig, ySizeBig, $000000)
|
---|
390 | else
|
---|
391 | GlowFrame(Buffer, GlowRange, GlowRange, xSizeBig, ySizeBig,
|
---|
392 | Tribe[p1].Color);
|
---|
393 | BitBlt(Canvas.Handle, ClientWidth div 2 - (28 + GlowRange),
|
---|
394 | 24 - GlowRange, xSizeBig + 2 * GlowRange, ySizeBig + 2 * GlowRange,
|
---|
395 | Buffer.Canvas.Handle, 0, 0, SRCCOPY);
|
---|
396 | end
|
---|
397 | else
|
---|
398 | ImpImage(Canvas, ClientWidth div 2 - 28, 24, IconIndex);
|
---|
399 | mikAge:
|
---|
400 | begin
|
---|
401 | if IconIndex = 0 then
|
---|
402 | ImpImage(Canvas, ClientWidth div 2 - 28, 24, -7)
|
---|
403 | else
|
---|
404 | ImpImage(Canvas, ClientWidth div 2 - 28, 24, 24 + IconIndex)
|
---|
405 | end;
|
---|
406 | mikModel:
|
---|
407 | with Tribe[me].ModelPicture[IconIndex] do
|
---|
408 | begin
|
---|
409 | FrameImage(Canvas, BigImp, ClientWidth div 2 - 28, 24, xSizeBig,
|
---|
410 | ySizeBig, 0, 0);
|
---|
411 | BitBlt(Canvas.Handle, ClientWidth div 2 - 32, 20, 64, 44,
|
---|
412 | GrExt[HGr].Mask.Canvas.Handle, pix mod 10 * 65 + 1,
|
---|
413 | pix div 10 * 49 + 1, SRCAND);
|
---|
414 | BitBlt(Canvas.Handle, ClientWidth div 2 - 32, 20, 64, 44,
|
---|
415 | GrExt[HGr].Data.Canvas.Handle, pix mod 10 * 65 + 1,
|
---|
416 | pix div 10 * 49 + 1, SRCPAINT);
|
---|
417 | end;
|
---|
418 | mikBook:
|
---|
419 | PaintBook(Canvas, ClientWidth div 2, 24, MainTexture.clPage,
|
---|
420 | MainTexture.clCover);
|
---|
421 | mikTribe:
|
---|
422 | if Tribe[IconIndex].faceHGr >= 0 then
|
---|
423 | begin
|
---|
424 | Frame(Canvas, ClientWidth div 2 - 32 - 1, 24 - 1,
|
---|
425 | ClientWidth div 2 + 32, 24 + 48, $000000, $000000);
|
---|
426 | BitBlt(Canvas.Handle, ClientWidth div 2 - 32, 24, 64, 48,
|
---|
427 | GrExt[Tribe[IconIndex].faceHGr].Data.Canvas.Handle,
|
---|
428 | 1 + Tribe[IconIndex].facepix mod 10 * 65,
|
---|
429 | 1 + Tribe[IconIndex].facepix div 10 * 49, SRCCOPY)
|
---|
430 | end;
|
---|
431 | mikPureIcon:
|
---|
432 | FrameImage(Canvas, BigImp, ClientWidth div 2 - 28, 24, xSizeBig, ySizeBig,
|
---|
433 | IconIndex mod 7 * xSizeBig, IconIndex div 7 * ySizeBig);
|
---|
434 | mikBigIcon:
|
---|
435 | FrameImage(Canvas, BigImp, ClientWidth div 2 - 3 * 28, 32, xSizeBig * 3,
|
---|
436 | ySizeBig * 3, IconIndex mod 2 * 3 * xSizeBig,
|
---|
437 | IconIndex div 2 * 3 * ySizeBig);
|
---|
438 | mikEnemyShipComplete:
|
---|
439 | begin
|
---|
440 | BitBlt(Buffer.Canvas.Handle, 0, 0, 140, 120, Canvas.Handle,
|
---|
441 | (ClientWidth - 140) div 2, 24, SRCCOPY);
|
---|
442 | ImageOp_BCC(Buffer, Templates, 0, 0, 1, 279, 140, 120, 0, $FFFFFF);
|
---|
443 | BitBlt(Canvas.Handle, (ClientWidth - 140) div 2, 24, 140, 120,
|
---|
444 | Buffer.Canvas.Handle, 0, 0, SRCCOPY);
|
---|
445 | end;
|
---|
446 | mikMyArmy:
|
---|
447 | PaintMyArmy;
|
---|
448 | mikEnemyArmy:
|
---|
449 | PaintEnemyArmy;
|
---|
450 | mikFullControl:
|
---|
451 | Sprite(Canvas, HGrSystem2, ClientWidth div 2 - 31, 24, 63, 63, 1, 281);
|
---|
452 | mikShip:
|
---|
453 | PaintColonyShip(Canvas, IconIndex, 17, ClientWidth - 34, 38);
|
---|
454 | end;
|
---|
455 |
|
---|
456 | if EInput.Visible then
|
---|
457 | EditFrame(Canvas, EInput.BoundsRect, MainTexture);
|
---|
458 |
|
---|
459 | if OpenSound <> '' then
|
---|
460 | PostMessage(Handle, WM_PLAYSOUND, 0, 0);
|
---|
461 | end; { FormPaint }
|
---|
462 |
|
---|
463 | procedure TMessgExDlg.Button1Click(Sender: TObject);
|
---|
464 | begin
|
---|
465 | ModalResult := mrOk;
|
---|
466 | end;
|
---|
467 |
|
---|
468 | procedure TMessgExDlg.Button2Click(Sender: TObject);
|
---|
469 | begin
|
---|
470 | if Kind = mkOkHelp then
|
---|
471 | HelpDlg.ShowNewContent(wmSubmodal, HelpKind, HelpNo)
|
---|
472 | else if Kind = mkModel then
|
---|
473 | UnitStatDlg.ShowNewContent_OwnModel(wmSubmodal, IconIndex)
|
---|
474 | else
|
---|
475 | ModalResult := mrIgnore;
|
---|
476 | end;
|
---|
477 |
|
---|
478 | procedure TMessgExDlg.Button3Click(Sender: TObject);
|
---|
479 | begin
|
---|
480 | ModalResult := mrCancel
|
---|
481 | end;
|
---|
482 |
|
---|
483 | procedure TMessgExDlg.RemoveBtnClick(Sender: TObject);
|
---|
484 | begin
|
---|
485 | ModalResult := mrNo
|
---|
486 | end;
|
---|
487 |
|
---|
488 | procedure TMessgExDlg.FormKeyPress(Sender: TObject; var Key: char);
|
---|
489 | begin
|
---|
490 | if Key = #13 then
|
---|
491 | ModalResult := mrOk
|
---|
492 | else if (Key = #27) then
|
---|
493 | if Button3.Visible then
|
---|
494 | ModalResult := mrCancel
|
---|
495 | else if Button2.Visible then
|
---|
496 | ModalResult := mrIgnore
|
---|
497 | end;
|
---|
498 |
|
---|
499 | procedure SoundMessageEx(SimpleText, SoundItem: string);
|
---|
500 | // because Messg.SoundMessage not capable of movie mode
|
---|
501 | begin
|
---|
502 | with MessgExDlg do
|
---|
503 | begin
|
---|
504 | MessgText := SimpleText;
|
---|
505 | OpenSound := SoundItem;
|
---|
506 | Kind := mkOk;
|
---|
507 | ShowModal;
|
---|
508 | end
|
---|
509 | end;
|
---|
510 |
|
---|
511 | procedure TribeMessage(p: integer; SimpleText, SoundItem: string);
|
---|
512 | begin
|
---|
513 | with MessgExDlg do
|
---|
514 | begin
|
---|
515 | OpenSound := SoundItem;
|
---|
516 | MessgText := SimpleText;
|
---|
517 | Kind := mkOk;
|
---|
518 | IconKind := mikTribe;
|
---|
519 | IconIndex := p;
|
---|
520 | ShowModal;
|
---|
521 | end;
|
---|
522 | end;
|
---|
523 |
|
---|
524 | function SimpleQuery(QueryKind: integer; SimpleText, SoundItem: string)
|
---|
525 | : integer;
|
---|
526 | begin
|
---|
527 | with MessgExDlg do
|
---|
528 | begin
|
---|
529 | MessgText := SimpleText;
|
---|
530 | OpenSound := SoundItem;
|
---|
531 | Kind := QueryKind;
|
---|
532 | ShowModal;
|
---|
533 | result := ModalResult
|
---|
534 | end
|
---|
535 | end;
|
---|
536 |
|
---|
537 | procedure ContextMessage(SimpleText, SoundItem: string;
|
---|
538 | ContextKind, ContextNo: integer);
|
---|
539 | begin
|
---|
540 | with MessgExDlg do
|
---|
541 | begin
|
---|
542 | MessgText := SimpleText;
|
---|
543 | OpenSound := SoundItem;
|
---|
544 | Kind := mkOkHelp;
|
---|
545 | HelpKind := ContextKind;
|
---|
546 | HelpNo := ContextNo;
|
---|
547 | ShowModal;
|
---|
548 | end
|
---|
549 | end;
|
---|
550 |
|
---|
551 | procedure TMessgExDlg.FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
552 | begin
|
---|
553 | IconKind := mikNone;
|
---|
554 | CenterTo := 0;
|
---|
555 | end;
|
---|
556 |
|
---|
557 | procedure TMessgExDlg.OnPlaySound(var Msg: TMessage);
|
---|
558 | begin
|
---|
559 | Play(OpenSound);
|
---|
560 | OpenSound := '';
|
---|
561 | end;
|
---|
562 |
|
---|
563 | initialization
|
---|
564 |
|
---|
565 | QueryPerformanceFrequency(PerfFreq);
|
---|
566 |
|
---|
567 | end.
|
---|