source: trunk/LocalPlayer/Help.pas@ 318

Last change on this file since 318 was 318, checked in by chronos, 9 months ago
  • Modified: Defined and used more Templates graphic set items.
  • Fixed: Incorrect evaluation of nil graphic set references.
File size: 78.8 KB
Line 
1{$INCLUDE Switches.inc}
2unit Help;
3
4interface
5
6uses
7 Protocol, ScreenTools, BaseWin, StringTables, Math, LCLIntf, LCLType,
8 Messages, SysUtils, Classes, Graphics, Controls, Forms, ExtCtrls,
9 ButtonB, PVSB, Types, fgl;
10
11const
12 MaxHist = 16;
13
14 { link categories }
15 hkNoLink = 0;
16 hkAdv = 1;
17 hkImp = 2;
18 hkTer = 3;
19 hkFeature = 4;
20 hkInternet = 5;
21 hkModel = 6;
22 hkMisc = 7;
23 hkCrossLink = $40;
24 hkText = $80;
25
26 liInvalid = $3FFF; // link index indicates invalid link
27
28 { link indices for category hkMisc }
29 miscMain = 0;
30 miscCredits = 1;
31 miscGovList = 2;
32 miscJobList = 3;
33 miscSearchResult = 7;
34
35 fJungle = 8; // pseudo terrain
36
37type
38
39 { THyperText }
40
41 THyperText = class(TStringList)
42 public
43 procedure AddLine(s: String = ''; Format: integer = 0; Picpix: Integer = 0;
44 LinkCategory: integer = 0; LinkIndex: integer = 0);
45 procedure LineFeed;
46 procedure AppendList(Source: THyperText);
47 destructor Destroy; override;
48 end;
49
50 { THistItem }
51
52 THistItem = class
53 Kind: Integer;
54 No: Integer;
55 Pos: Integer;
56 SearchContent: string;
57 procedure Assign(Source: THistItem);
58 end;
59
60 { THistItems }
61
62 THistItems = class(TFPGObjectList<THistItem>)
63 function AddNew(Kind, No, Pos: Integer; SearchContent: string): THistItem;
64 end;
65
66 { THelpDlg }
67
68 THelpDlg = class(TFramedDlg)
69 CloseBtn: TButtonB;
70 BackBtn: TButtonB;
71 TopBtn: TButtonB;
72 SearchBtn: TButtonB;
73 procedure FormCreate(Sender: TObject);
74 procedure FormDestroy(Sender: TObject);
75 procedure FormMouseWheel(Sender: TObject; Shift: TShiftState;
76 WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
77 procedure FormPaint(Sender: TObject);
78 procedure CloseBtnClick(Sender: TObject);
79 procedure PaintBox1MouseMove(Sender: TObject; Shift: TShiftState;
80 x, y: integer);
81 procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
82 Shift: TShiftState; x, y: integer);
83 procedure BackBtnClick(Sender: TObject);
84 procedure TopBtnClick(Sender: TObject);
85 procedure FormClose(Sender: TObject; var Action: TCloseAction);
86 procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
87 procedure SearchBtnClick(Sender: TObject);
88 protected
89 procedure OffscreenPaint; override;
90 private
91 Kind: Integer;
92 no: Integer;
93 Sel: Integer;
94 CaptionColor: Integer;
95 hADVHELP, hIMPHELP, hFEATUREHELP, hGOVHELP, hSPECIALMODEL, hJOBHELP: Integer;
96 SearchContent: string;
97 NewSearchContent: string;
98 CaptionFont: TFont;
99 MainText: THyperText;
100 SearchResult: THyperText;
101 HelpText: TStringTable;
102 ExtPic, TerrIcon: TBitmap;
103 ScrollBar: TPVScrollbar;
104 x0: array [-2..180] of Integer;
105 procedure PaintTerrIcon(x, y, xSrc, ySrc: Integer);
106 procedure ScrollBarUpdate(Sender: TObject);
107 procedure Line(ca: TCanvas; i: Integer; lit: Boolean);
108 procedure Prepare(sbPos: Integer = 0);
109 procedure ShowNewContentProcExecute(NewMode: Integer; HelpContext: string);
110 procedure WaterSign(x0, y0, iix: Integer);
111 procedure Search(SearchString: string);
112 procedure OnScroll(var m: TMessage); message WM_VSCROLL;
113 procedure OnMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE;
114 public
115 HistItems: THistItems;
116 Difficulty: Integer;
117 procedure ClearHistory;
118 procedure ShowNewContent(NewMode, Category, Index: Integer);
119 function TextIndex(Item: string): Integer;
120 end;
121
122var
123 HelpDlg: THelpDlg;
124
125
126implementation
127
128uses
129 Directories, ClientTools, Term, Tribes, Inp, Messg, UPixelPointer, Global,
130 UKeyBindings;
131
132{$R *.lfm}
133
134type
135
136 { THelpLineInfo }
137
138 THelpLineInfo = class
139 Format: Byte;
140 Picpix: Byte;
141 Link: Word;
142 procedure Assign(Source: THelpLineInfo);
143 end;
144
145{ THelpLineInfo }
146
147procedure THelpLineInfo.Assign(Source: THelpLineInfo);
148begin
149 Format := Source.Format;
150 PicPix := Source.PicPix;
151 Link := Source.Link;
152end;
153
154{ THistItem }
155
156procedure THistItem.Assign(Source: THistItem);
157begin
158 Kind := Source.Kind;
159 No := Source.No;
160 Pos := Source.Pos;
161 SearchContent := Source.SearchContent;
162end;
163
164{ THistItems }
165
166function THistItems.AddNew(Kind, No, Pos: Integer; SearchContent: string
167 ): THistItem;
168begin
169 Result := THistItem.Create;
170 Result.Kind := Kind;
171 Result.No := No;
172 Result.Pos := Pos;
173 Result.SearchContent := SearchContent;
174 Add(Result);
175end;
176
177procedure THyperText.AddLine(s: String; Format: integer; Picpix: integer;
178 LinkCategory: integer; LinkIndex: integer);
179var
180 HelpLineInfo: THelpLineInfo;
181begin
182 HelpLineInfo := THelpLineInfo.Create;
183 if LinkIndex < 0 then
184 LinkIndex := liInvalid;
185 HelpLineInfo.Format := Format;
186 HelpLineInfo.Picpix := Picpix;
187 HelpLineInfo.Link := LinkCategory shl 8 + LinkIndex;
188 AddObject(s, TObject(HelpLineInfo));
189end;
190
191procedure THyperText.LineFeed;
192begin
193 AddLine;
194end;
195
196procedure THyperText.AppendList(Source: THyperText);
197var
198 I: Integer;
199 HelpLineInfo: THelpLineInfo;
200begin
201 for I := 0 to Source.Count - 1 do begin
202 HelpLineInfo := THelpLineInfo.Create;
203 HelpLineInfo.Assign(THelpLineInfo(Source.Objects[I]));
204 AddObject(Source.Strings[I], HelpLineInfo);
205 end;
206end;
207
208destructor THyperText.Destroy;
209begin
210 inherited;
211end;
212
213const
214 { text formats }
215 pkNormal = 0;
216 pkCaption = 1;
217 pkSmallIcon = 2;
218 pkBigIcon = 3;
219 pkAdvIcon = 4;
220 pkTer = 5;
221 pkBigTer = 6;
222 pkFeature = 7;
223 pkDot = 8;
224 pkNormal_Dot = 9;
225 pkDomain = 10;
226 pkSection = 11;
227 pkBigFeature = 12;
228 pkExp = 13;
229 pkAITStat = 14;
230 pkExternal = 15;
231 pkModel = 16;
232 pkNormal_64 = 17;
233 pkIllu = 18;
234 pkLogo = 19;
235 pkTerImp = 20;
236 pkRightIcon = 21;
237 pkAdvIcon_AsPreq = 22;
238 pkSmallIcon_AsPreq = 23;
239 pkSpecialIcon = 24;
240 pkGov = 25;
241
242 nSeeAlso = 14;
243 SeeAlso: array [0 .. nSeeAlso - 1] of record
244 Kind: Integer;
245 no: Integer;
246 SeeKind: Integer;
247 SeeNo: Integer;
248 end = ((Kind: hkImp; no: imWalls; SeeKind: hkFeature;
249 SeeNo: mcArtillery), (Kind: hkImp; no: imHydro; SeeKind: hkImp;
250 SeeNo: woHoover), (Kind: hkImp; no: imWalls; SeeKind: hkImp;
251 SeeNo: imGrWall), (Kind: hkImp; no: imHighways; SeeKind: hkAdv;
252 SeeNo: adWheel), (Kind: hkImp; no: imCathedral; SeeKind: hkImp;
253 SeeNo: woBach), (Kind: hkImp; no: imBank; SeeKind: hkImp; SeeNo: imStockEx),
254 (Kind: hkImp; no: imShipComp; SeeKind: hkImp; SeeNo: imSpacePort),
255 (Kind: hkImp; no: imShipPow; SeeKind: hkImp; SeeNo: imSpacePort),
256 (Kind: hkImp; no: imShipHab; SeeKind: hkImp; SeeNo: imSpacePort),
257 (Kind: hkFeature; no: mcSub; SeeKind: hkFeature; SeeNo: mcRadar),
258 (Kind: hkFeature; no: mcDefense; SeeKind: hkAdv; SeeNo: adSteel),
259 (Kind: hkFeature; no: mcSE; SeeKind: hkFeature; SeeNo: mcNP), (Kind: hkAdv;
260 no: adWheel; SeeKind: hkImp; SeeNo: imHighways), (Kind: hkAdv; no: adSteel;
261 SeeKind: hkFeature; SeeNo: mcDefense));
262
263 nTerrainHelp = 14;
264 TerrainHelp: array [0 .. nTerrainHelp - 1] of integer = (fGrass, fGrass + 12,
265 fPrairie, fForest, fJungle, fHills, fMountains, fSwamp, fTundra, fArctic,
266 fDesert, 3 * 12 { DeadLands } , fShore, fOcean);
267
268 nJobHelp = 8;
269 JobHelp: array [0 .. nJobHelp - 1] of integer = (jRoad, jRR, jCanal, jIrr,
270 jFarm, jMine, jFort, jBase);
271
272procedure THelpDlg.FormCreate(Sender: TObject);
273begin
274 inherited;
275 HistItems := THistItems.Create;
276
277 CaptionLeft := BackBtn.Left + BackBtn.Width;
278 CaptionRight := SearchBtn.Left;
279 inc(ModalFrameIndent, 29);
280 MainText := THyperText.Create;
281 MainText.OwnsObjects := True;
282 SearchResult := THyperText.Create;
283 SearchResult.OwnsObjects := True;
284 ScrollBar := TPVScrollbar.Create(Self);
285 ScrollBar.SetBorderSpacing(36, 9, 11);
286 ScrollBar.OnUpdate := ScrollBarUpdate;
287
288 HelpText := TStringTable.Create;
289 HelpText.LoadFromFile(LocalizedFilePath('Help' + DirectorySeparator + 'help.txt'));
290 hADVHELP := HelpText.Gethandle('ADVHELP');
291 hIMPHELP := HelpText.Gethandle('IMPHELP');
292 hFEATUREHELP := HelpText.Gethandle('FEATUREHELP');
293 hGOVHELP := HelpText.Gethandle('GOVHELP');
294 hSPECIALMODEL := HelpText.Gethandle('SPECIALMODEL');
295 hJOBHELP := HelpText.Gethandle('JOBHELP');
296
297 CaptionFont := Font.Create;
298 CaptionFont.Assign(UniFont[ftNormal]);
299 CaptionFont.Style := CaptionFont.Style + [fsItalic, fsBold];
300 InitButtons();
301
302 TopBtn.Hint := Phrases.Lookup('BTN_CONTENTS');
303 BackBtn.Hint := Phrases.Lookup('BTN_BACK');
304 SearchBtn.Hint := Phrases.Lookup('BTN_SEARCH');
305
306 ExtPic := TBitmap.Create;
307 TerrIcon := TBitmap.Create;
308 TerrIcon.PixelFormat := pf24bit;
309 TerrIcon.SetSize(xSizeBig, ySizeBig);
310 TerrIcon.Canvas.FillRect(0, 0, TerrIcon.Width, TerrIcon.Height);
311 SearchContent := '';
312 ShowNewContentProc := ShowNewContentProcExecute;
313end;
314
315procedure THelpDlg.ShowNewContentProcExecute(NewMode: Integer;
316 HelpContext: string);
317begin
318 HelpDlg.ShowNewContent(NewMode, hkText,
319 HelpDlg.TextIndex(HelpContext))
320end;
321
322procedure THelpDlg.FormDestroy(Sender: TObject);
323begin
324 ShowNewContentProc := nil;
325 FreeAndNil(ScrollBar);
326 FreeAndNil(MainText);
327 FreeAndNil(SearchResult);
328 FreeAndNil(ExtPic);
329 FreeAndNil(TerrIcon);
330 FreeAndNil(HelpText);
331 // FreeAndNil(CaptionFont);
332 FreeAndNil(HistItems);
333end;
334
335procedure THelpDlg.FormMouseWheel(Sender: TObject; Shift: TShiftState;
336 WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
337begin
338 if ScrollBar.ProcessMouseWheel(WheelDelta) then begin
339 PaintBox1MouseMove(nil, [], MousePos.X - Left,
340 MousePos.Y - Top);
341 end;
342end;
343
344procedure THelpDlg.CloseBtnClick(Sender: TObject);
345begin
346 Close;
347end;
348
349procedure THelpDlg.OnScroll(var m: TMessage);
350begin
351 { TODO: Handled by MouseWheel event
352 if ScrollBar.Process(m) then begin
353 Sel := -1;
354 SmartUpdateContent(true)
355 end;
356 }
357end;
358
359procedure THelpDlg.OnMouseLeave(var Msg: TMessage);
360begin
361 if Sel <> -1 then begin
362 Line(Canvas, Sel, false);
363 Sel := -1
364 end;
365end;
366
367procedure THelpDlg.ClearHistory;
368begin
369 HistItems.Clear;
370end;
371
372procedure THelpDlg.FormPaint(Sender: TObject);
373begin
374 inherited;
375 Canvas.Font.Assign(UniFont[ftNormal]);
376end;
377
378procedure THelpDlg.Line(ca: TCanvas; i: Integer; lit: Boolean);
379var
380 TextColor, x, y: Integer;
381 TextSize: TSize;
382 s: string;
383begin
384 s := MainText[ScrollBar.Position + i];
385 if s = '' then
386 Exit;
387 x := x0[i];
388 y := 2 + i * 24;
389 if ca = Canvas then
390 begin
391 x := x + SideFrame;
392 y := y + WideFrame
393 end;
394 if THelpLineInfo(MainText.Objects[ScrollBar.Position + i]).Format
395 in [pkCaption, pkBigTer, pkRightIcon, pkBigFeature] then
396 begin
397 ca.Font.Assign(CaptionFont);
398 { ca.brush.color:=CaptionColor;
399 ca.FillRect(rect(x,i*24,x+24,i*24+24));
400 ca.brush.color:=$FFFFFF;
401 ca.FrameRect(rect(x+1,i*24+1,x+24-1,i*24+24-1));
402 ca.Brush.Style:=bsClear; }
403 BitBltCanvas(ca, x, y - 4, 24, 24, HGrSystem.Data.Canvas, 1,
404 146);
405 BiColorTextOut(ca, $FFFFFF, $7F007F, x + 10 - ca.Textwidth(s[1]) div 2,
406 y - 3, s[1]);
407 BiColorTextOut(ca, CaptionColor, $7F007F, x + 24, y - 3, copy(s, 2, 255));
408 ca.Font.Assign(UniFont[ftNormal]);
409 end
410 else if THelpLineInfo(MainText.Objects[ScrollBar.Position + i]).Format = pkSection
411 then
412 begin
413 ca.Font.Assign(CaptionFont);
414 BiColorTextOut(ca, CaptionColor, $7F007F, x, y - 3, s);
415 ca.Font.Assign(UniFont[ftNormal]);
416 end
417 else
418 begin
419 if (Kind = hkMisc) and (no = miscMain) then
420 ca.Font.Assign(CaptionFont);
421 TextColor := Colors.Canvas.Pixels[clkMisc, cliPaperText];
422 if ca = Canvas then
423 begin
424 TextSize.cx := BiColorTextWidth(ca, s);
425 TextSize.cy := ca.TextHeight(s);
426 if y + TextSize.cy >= WideFrame + InnerHeight then
427 TextSize.cy := WideFrame + InnerHeight - y;
428 FillSeamless(ca, x, y, TextSize.cx, TextSize.cy, -SideFrame,
429 ScrollBar.Position * 24 - WideFrame, Paper);
430 end;
431 BiColorTextOut(ca, TextColor, $7F007F, x, y, s);
432 if lit then
433 with ca do
434 begin
435 Assert(ca = Canvas);
436 Pen.Color := TextColor;
437 MoveTo(x + 1, y + TextSize.cy - 2);
438 LineTo(x + TextSize.cx, y + TextSize.cy - 2);
439 end;
440 if (Kind = hkMisc) and (no = miscMain) then
441 ca.Font.Assign(UniFont[ftNormal]);
442 end;
443end;
444
445procedure THelpDlg.WaterSign(x0, y0, iix: integer);
446const
447 nHeaven = 28;
448 MaxSum = 9 * 9 * 255 * 75 div 100;
449var
450 x, y, dx, dy, xSrc, ySrc, sum, xx: integer;
451 Heaven: array [0..nHeaven] of integer;
452 PaintPtr, CoalPtr: TPixelPointer;
453 ImpPtr: array [-1..1] of TPixelPointer;
454begin
455 // assume eiffel tower has free common heaven
456 for dy := 0 to nHeaven - 1 do
457 Heaven[dy] := BigImp.Canvas.Pixels[woEiffel mod 7 * xSizeBig,
458 (SystemIconLines + woEiffel div 7) * ySizeBig + dy];
459
460 BigImp.BeginUpdate;
461 Offscreen.BeginUpdate;
462 xSrc := iix mod 7 * xSizeBig;
463 ySrc := (iix div 7 + 1) * ySizeBig;
464 for y := 0 to ScaleToNative(ySizeBig) * 2 - 1 do
465 if ((ScaleToNative(y0) + y) >= 0) and ((ScaleToNative(y0) + y) < ScaleToNative(InnerHeight)) then begin
466 PaintPtr := PixelPointer(OffScreen, 0, ScaleToNative(y0) + y);
467 CoalPtr := PixelPointer(Templates.Data, 0, ScaleToNative(yCoal) + y);
468 for dy := -1 to 1 do
469 if ((Max(y + ScaleToNative(dy), 0) shr 1) >= 0) and ((Max(y + ScaleToNative(dy), 0) shr 1) < ScaleToNative(ySizeBig)) then
470 ImpPtr[dy] := PixelPointer(BigImp, 0, ScaleToNative(ySrc) + (Max(y + ScaleToNative(dy), 0) shr 1));
471 for x := 0 to ScaleToNative(xSizeBig) * 2 - 1 do begin
472 sum := 0;
473 for dx := -1 to 1 do begin
474 xx := ScaleToNative(xSrc) + Max((x + ScaleToNative(dx)), 0) shr 1;
475 for dy := -1 to 1 do begin
476 ImpPtr[dy].SetX(xx);
477 if ((y + ScaleToNative(dy)) shr 1 < 0) or ((y + ScaleToNative(dy)) shr 1 >= ScaleToNative(ySizeBig)) or
478 ((x + ScaleToNative(dx)) shr 1 < 0) or ((x + ScaleToNative(dx)) shr 1 >= ScaleToNative(xSizeBig)) or
479 ((y + ScaleToNative(dy)) shr 1 < ScaleToNative(nHeaven)) and
480 (ImpPtr[dy].Pixel^.B shl 16 + ImpPtr[dy].Pixel^.G shl 8 +
481 ImpPtr[dy].Pixel^.R = Heaven[(ScaleFromNative(y) + dy) shr 1]) then
482 sum := sum + 9 * 255
483 else
484 sum := sum + ImpPtr[dy].Pixel^.B + 5 * ImpPtr[dy].Pixel^.G + 3 *
485 ImpPtr[dy].Pixel^.R;
486 end;
487 end;
488 if sum < MaxSum then begin // no saturation
489 CoalPtr.SetX(ScaleToNative(xCoal) + x);
490 sum := 1 shl 22 - (MaxSum - sum) * (256 - CoalPtr.Pixel^.B * 2);
491 PaintPtr.SetX(x0 + x);
492 PaintPtr.Pixel^.B := PaintPtr.Pixel^.B * sum shr 22;
493 PaintPtr.Pixel^.G := PaintPtr.Pixel^.G * sum shr 22;
494 PaintPtr.Pixel^.R := PaintPtr.Pixel^.R * sum shr 22;
495 end;
496 end;
497 end;
498 Offscreen.EndUpdate;
499 BigImp.EndUpdate;
500end;
501
502procedure THelpDlg.PaintTerrIcon(x, y, xSrc, ySrc: integer);
503begin
504 Frame(OffScreen.Canvas, x - 1, y - 1, x + xSizeBig, y + ySizeBig,
505 $000000, $000000);
506 if 2 * yyt < 40 then begin
507 Sprite(OffScreen, HGrTerrain, x, y, 56, 2 * yyt, xSrc, ySrc);
508 Sprite(OffScreen, HGrTerrain, x, y + 2 * yyt, 56, 40 - 2 * yyt,
509 xSrc, ySrc);
510 end else
511 Sprite(OffScreen, HGrTerrain, x, y, 56, 40, xSrc, ySrc);
512 Sprite(OffScreen, HGrTerrain, x, y, xxt, yyt, xSrc + xxt, ySrc + yyt);
513 Sprite(OffScreen, HGrTerrain, x, y + yyt, xxt, 40 - yyt, xSrc + xxt, ySrc);
514 Sprite(OffScreen, HGrTerrain, x + xxt, y, 56 - xxt, yyt, xSrc, ySrc + yyt);
515 Sprite(OffScreen, HGrTerrain, x + xxt, y + yyt, 56 - xxt, 40 - yyt,
516 xSrc, ySrc);
517end;
518
519procedure THelpDlg.OffscreenPaint;
520var
521 i, j, yl, srcno, ofs, cnt, y: Integer;
522 s: string;
523 HelpLineInfo: THelpLineInfo;
524begin
525 inherited;
526 CaptionColor := Colors.Canvas.Pixels[clkMisc, cliPaperCaption];
527 FillSeamless(OffScreen.Canvas, 0, 0, InnerWidth, InnerHeight, 0,
528 ScrollBar.Position * 24, Paper);
529 with OffScreen.Canvas do
530 begin
531 Font.Assign(UniFont[ftNormal]);
532 for i := -ScrollBar.Position to InnerHeight div 24 do
533 if ScrollBar.Position + i < MainText.Count then
534 begin
535 HelpLineInfo := THelpLineInfo(MainText.Objects[ScrollBar.Position + i]);
536 if HelpLineInfo.Format = pkExternal then
537 begin
538 yl := ExtPic.Height;
539 if 4 + i * 24 + yl > InnerHeight then
540 yl := InnerHeight - (4 + i * 24);
541 BitBltCanvas(OffScreen.Canvas, 8, 4 + i * 24, ExtPic.Width, yl, ExtPic.Canvas,
542 0, 0);
543 end;
544 end;
545 for i := -2 to InnerHeight div 24 do
546 if (ScrollBar.Position + i >= 0) and (ScrollBar.Position + i < MainText.Count) then
547 begin
548 HelpLineInfo := THelpLineInfo(MainText.Objects[ScrollBar.Position + i]);
549 if HelpLineInfo.Link <> 0 then
550 begin
551 if (Kind = hkMisc) and (no = miscSearchResult) then
552 Sprite(OffScreen, HGrSystem, 18, 9 + i * 24, 8, 8, 90, 16)
553 else if HelpLineInfo.Format in [pkSmallIcon_AsPreq, pkAdvIcon_AsPreq]
554 then
555 Sprite(OffScreen, HGrSystem, 12, i * 24 + 5, 14, 14, 65, 20)
556 else if HelpLineInfo.Link and (hkCrossLink shl 8) <> 0 then
557 Sprite(OffScreen, HGrSystem, 12, i * 24 + 5, 14, 14, 80, 1)
558 else if not((Kind = hkMisc) and (no = miscMain)) then
559 Sprite(OffScreen, HGrSystem, 10, i * 24 + 6, 14, 14, 65, 1);
560 x0[i] := 24;
561 end
562 else
563 x0[i] := 0;
564 case HelpLineInfo.Format of
565 pkLogo:
566 begin
567 Server(sGetVersion, 0, 0, j);
568 s := Format('%d.%d.%d', [j shr 16 and $FF, j shr 8 and $FF,
569 j and $FF]);
570 PaintLogo(OffScreen.Canvas, (InnerWidth - 122) div 2, i * 24 + 1,
571 HGrSystem.Data.Canvas.Pixels[95, 1], $000000);
572 Font.Assign(UniFont[ftSmall]);
573 BiColorTextOut(OffScreen.Canvas, $000000, $7F007F,
574 (InnerWidth - Textwidth(s)) div 2, i * 24 + 26, s);
575 Font.Assign(UniFont[ftNormal]);
576 end;
577 pkSmallIcon, pkSmallIcon_AsPreq:
578 begin
579 ScreenTools.Frame(OffScreen.Canvas, 8 - 1 + x0[i], 2 - 1 + i * 24,
580 8 + xSizeSmall + x0[i], 2 + 20 + i * 24, $000000, $000000);
581 if HelpLineInfo.Picpix = imPalace then
582 BitBltCanvas(OffScreen.Canvas, 8 + x0[i], 2 + i * 24,
583 xSizeSmall, ySizeSmall, SmallImp.Canvas,
584 0 * xSizeSmall, 1 * ySizeSmall)
585 else
586 BitBltCanvas(OffScreen.Canvas, 8 + x0[i], 2 + i * 24,
587 xSizeSmall, ySizeSmall, SmallImp.Canvas,
588 HelpLineInfo.Picpix mod 7 * xSizeSmall,
589 (HelpLineInfo.Picpix + SystemIconLines * 7) div 7 *
590 ySizeSmall);
591 x0[i] := x0[i] + (8 + 8 + 36);
592 end;
593 pkBigIcon:
594 begin
595 FrameImage(OffScreen.Canvas, BigImp, x0[i] + 12, i * 24 - 7, 56,
596 40, HelpLineInfo.Picpix mod 7 * xSizeBig,
597 HelpLineInfo.Picpix div 7 * ySizeBig);
598 x0[i] := 64 + 8 + 8 + x0[i];
599 end;
600 pkSpecialIcon:
601 begin
602 case HelpLineInfo.Picpix of
603 0:
604 FrameImage(OffScreen.Canvas, HGrSystem2.Data,
605 12 + x0[i], -7 + i * 24, 56, 40, 137, 127);
606 1:
607 begin
608 PaintTerrIcon(12 + x0[i], -7 + i * 24,
609 1 + 3 * (xxt * 2 + 1), 1 + yyt);
610 if 2 * yyt < 40 then
611 Sprite(OffScreen, HGrTerrain, 12 + x0[i], -7 + 4 + i * 24,
612 56, 2 * yyt, 1 + 3 * (xxt * 2 + 1) + xxt - 28,
613 1 + yyt + 1 * (yyt * 3 + 1))
614 else
615 Sprite(OffScreen, HGrTerrain, 12 + x0[i],
616 -7 + 4 + i * 24 - 4, 56, 40, 1 + 3 * (xxt * 2 + 1) + xxt
617 - 28, 1 + yyt + 1 * (yyt * 3 + 1) + yyt - 20);
618 end;
619 2:
620 begin
621 PaintTerrIcon(12 + x0[i], -7 + i * 24,
622 1 + 7 * (xxt * 2 + 1), 1 + yyt + 4 * (yyt * 3 + 1));
623 if 2 * yyt < 40 then
624 Sprite(OffScreen, HGrTerrain, 12 + x0[i], -7 + 4 + i * 24,
625 56, 32, 1 + 4 * (xxt * 2 + 1) + xxt - 28,
626 1 + yyt + 12 * (yyt * 3 + 1) + yyt - 16)
627 else
628 Sprite(OffScreen, HGrTerrain, 12 + x0[i], -7 + 4 + i * 24,
629 56, 32, 1 + 4 * (xxt * 2 + 1) + xxt - 28,
630 1 + yyt + 12 * (yyt * 3 + 1) + yyt - 16)
631 end;
632 end;
633 x0[i] := 64 + 8 + 8 + x0[i];
634 end;
635 pkDomain:
636 begin
637 ScreenTools.Frame(OffScreen.Canvas, 8 - 1 + x0[i], 2 - 1 + i * 24,
638 8 + 36 + x0[i], 2 + 20 + i * 24, $000000, $000000);
639 Dump(OffScreen, HGrSystem, 8 + x0[i], 2 + i * 24, 36, 20,
640 75 + HelpLineInfo.Picpix * 37, 295);
641 x0[i] := x0[i] + (8 + 8 + 36);
642 end;
643 pkAdvIcon, pkAdvIcon_AsPreq:
644 begin
645 ScreenTools.Frame(OffScreen.Canvas, 8 - 1 + x0[i], 2 - 1 + i * 24,
646 8 + xSizeSmall + x0[i], 2 + ySizeSmall + i * 24,
647 $000000, $000000);
648 if AdvIcon[HelpLineInfo.Picpix] < 84 then
649 BitBltCanvas(OffScreen.Canvas, 8 + x0[i], 2 + i * 24,
650 xSizeSmall, ySizeSmall, SmallImp.Canvas,
651 (AdvIcon[HelpLineInfo.Picpix] + SystemIconLines * 7) mod 7 *
652 xSizeSmall, (AdvIcon[HelpLineInfo.Picpix] + SystemIconLines *
653 7) div 7 * ySizeSmall)
654 else
655 Dump(OffScreen, HGrSystem, 8 + x0[i], 2 + i * 24, 36, 20,
656 1 + (AdvIcon[HelpLineInfo.Picpix] - 84) mod 8 * 37,
657 295 + (AdvIcon[HelpLineInfo.Picpix] - 84) div 8 * 21);
658 j := AdvValue[HelpLineInfo.Picpix] div 1000;
659 BitBltCanvas(OffScreen.Canvas, x0[i] + 4, 4 + i * 24, 14, 14,
660 HGrSystem.Mask.Canvas, 127 + j * 15, 85, SRCAND);
661 Sprite(OffScreen, HGrSystem, x0[i] + 3, 3 + i * 24, 14, 14,
662 127 + j * 15, 85);
663 x0[i] := x0[i] + (8 + 8 + 36);
664 end;
665 pkRightIcon:
666 begin
667 if Imp[HelpLineInfo.Picpix].Kind <> ikWonder then
668 ImpImage(OffScreen.Canvas, InnerWidth - (40 + xSizeBig), i * 24,
669 HelpLineInfo.Picpix, gDespotism)
670 else
671 WaterSign(InnerWidth - (40 + 2 * xSizeBig), i * 24 - 8,
672 HelpLineInfo.Picpix + 7);
673 x0[i] := x0[i] + 8;
674 end;
675 pkIllu:
676 WaterSign(8, i * 24 - 8, HelpLineInfo.Picpix);
677 pkBigFeature:
678 begin
679 cnt := 0;
680 for j := nDomains - 1 downto 0 do
681 if 1 shl j and Feature[HelpLineInfo.Picpix].Domains <> 0 then
682 begin
683 inc(cnt);
684 Dump(OffScreen, HGrSystem, InnerWidth - 38 - 38 * cnt,
685 i * 24 + 1, 36, 20, 75 + j * 37, 295);
686 ScreenTools.Frame(OffScreen.Canvas, InnerWidth - 39 - 38 * cnt, i * 24,
687 InnerWidth - 2 - 38 * cnt, i * 24 + 21, $000000, $000000);
688 end;
689 DarkGradient(OffScreen.Canvas, InnerWidth - 38 - 38 * cnt,
690 i * 24 + 23, cnt * 38 - 2, 1);
691 ofs := InnerWidth - (39 + 7) - 19 * cnt;
692 with OffScreen.Canvas do
693 begin
694 Brush.color := $C0C0C0;
695 FrameRect(Rect(ofs, 1 + 23 + i * 24, ofs + 14,
696 15 + 23 + i * 24));
697 Brush.Style := bsClear;
698 Sprite(OffScreen, HGrSystem, ofs + 2, 3 + 23 + i * 24, 10, 10,
699 66 + HelpLineInfo.Picpix mod 11 * 11,
700 137 + HelpLineInfo.Picpix div 11 * 11);
701 end;
702 x0[i] := x0[i] + 8;
703 end;
704 pkTer, pkBigTer:
705 begin
706 if HelpLineInfo.Format = pkBigTer then
707 y := i * 24 - 3 + yyt
708 else
709 y := i * 24 + 13;
710 if HelpLineInfo.Picpix >= 3 * 12 then
711 srcno := 2 * 9 + 6
712 else if HelpLineInfo.Picpix mod 12 = fJungle then
713 srcno := 18 * 9
714 else if HelpLineInfo.Picpix mod 12 < fJungle then
715 srcno := HelpLineInfo.Picpix mod 12
716 else
717 srcno := 27 + (HelpLineInfo.Picpix mod 12 - 9) * 18;
718 if HelpLineInfo.Format = pkTer then
719 begin
720 ofs := x0[i] + 8;
721 x0[i] := 2 * xxt + 8 + ofs;
722 end
723 else
724 begin
725 ofs := InnerWidth - (2 * xxt + 38);
726 x0[i] := x0[i] + 8;
727 end;
728 if srcno >= fJungle then
729 begin
730 Sprite(OffScreen, HGrTerrain, ofs + 4, y - yyt + 2, xxt * 2 - 8,
731 yyt * 2 - 4, 5 + 2 * (xxt * 2 + 1),
732 3 + yyt + 2 * (yyt * 3 + 1));
733 Sprite(OffScreen, HGrTerrain, ofs, y - 2 * yyt, xxt * 2,
734 yyt * 3 - 2, 1 + srcno mod 9 * (xxt * 2 + 1),
735 1 + srcno div 9 * (yyt * 3 + 1));
736 end
737 else
738 Sprite(OffScreen, HGrTerrain, ofs + 4, y - yyt + 2, xxt * 2 - 8,
739 yyt * 2 - 4, 5 + srcno mod 9 * (xxt * 2 + 1),
740 3 + yyt + srcno div 9 * (yyt * 3 + 1));
741 if HelpLineInfo.Picpix >= 3 * 12 then { rare resource }
742 Sprite(OffScreen, HGrTerrain, ofs, y - 2 * yyt, xxt * 2,
743 yyt * 3, 1 + 8 * (xxt * 2 + 1),
744 1 + (HelpLineInfo.Picpix - 2 * 12) * (yyt * 3 + 1))
745 else if HelpLineInfo.Picpix >= 12 then { special tile }
746 begin
747 if HelpLineInfo.Picpix mod 12 = fJungle then
748 srcno := 17 * 9 + 8
749 else if HelpLineInfo.Picpix mod 12 < fJungle then
750 srcno := HelpLineInfo.Picpix mod 12
751 else
752 srcno := 18 + 8 + (HelpLineInfo.Picpix mod 12 - 9) * 18;
753 srcno := srcno + HelpLineInfo.Picpix div 12 * 9;
754 Sprite(OffScreen, HGrTerrain, ofs, y - 2 * yyt, xxt * 2,
755 yyt * 3, 1 + srcno mod 9 * (xxt * 2 + 1),
756 1 + srcno div 9 * (yyt * 3 + 1));
757 end;
758 end;
759 pkTerImp:
760 begin
761 ofs := 8;
762 if HelpLineInfo.Picpix = 5 then
763 begin // display mine on hills
764 Sprite(OffScreen, HGrTerrain, ofs + 4, i * 24 + 13 - yyt,
765 xxt * 2 - 8, yyt * 2 - 4, 5 + 2 * (xxt * 2 + 1),
766 3 + yyt + 2 * (yyt * 3 + 1));
767 srcno := 45
768 end
769 else
770 srcno := fPrairie; // display on prairie
771 Sprite(OffScreen, HGrTerrain, ofs + 4, i * 24 + 13 - yyt,
772 xxt * 2 - 8, yyt * 2 - 4, 5 + srcno mod 9 * (xxt * 2 + 1),
773 3 + yyt + srcno div 9 * (yyt * 3 + 1));
774 if HelpLineInfo.Picpix = 12 then { river }
775 Sprite(OffScreen, HGrTerrain, ofs, i * 24 + 11 - yyt, xxt * 2,
776 yyt * 2, 1 + 5 * (xxt * 2 + 1), 1 + yyt + 13 * (yyt * 3 + 1))
777 else if HelpLineInfo.Picpix >= 3 then { improvement 2 }
778 begin
779 if HelpLineInfo.Picpix = 6 then
780 Sprite(OffScreen, HGrTerrain, ofs, i * 24 + 11 - 2 * yyt,
781 xxt * 2, yyt * 3, 1 + 7 * (xxt * 2 + 1),
782 1 + 12 * (yyt * 3 + 1));
783 Sprite(OffScreen, HGrTerrain, ofs, i * 24 + 11 - 2 * yyt,
784 xxt * 2, yyt * 3, 1 + (HelpLineInfo.Picpix - 3) *
785 (xxt * 2 + 1), 1 + 12 * (yyt * 3 + 1))
786 end
787 else { improvement 1 }
788 begin
789 Sprite(OffScreen, HGrTerrain, ofs, i * 24 + 11 - 2 * yyt,
790 xxt * 2, yyt * 3, 1 + 2 * (xxt * 2 + 1),
791 1 + (9 + HelpLineInfo.Picpix) * (yyt * 3 + 1));
792 Sprite(OffScreen, HGrTerrain, ofs, i * 24 + 11 - 2 * yyt,
793 xxt * 2, yyt * 3, 1 + 5 * (xxt * 2 + 1),
794 1 + (9 + HelpLineInfo.Picpix) * (yyt * 3 + 1))
795 end;
796 x0[i] := x0[i] + 8;
797 end;
798 pkModel:
799 begin
800 FrameImage(OffScreen.Canvas, BigImp, x0[i] + 12, i * 24 - 7,
801 56, 40, 0, 0);
802 Sprite(OffScreen, HGrStdUnits, x0[i] + 8, i * 24 - 11, 64, 44,
803 1 + HelpLineInfo.Picpix mod 10 * 65,
804 1 + HelpLineInfo.Picpix div 10 * 49);
805 x0[i] := 64 + 8 + 8 + x0[i];
806 end;
807 pkFeature:
808 begin
809 DarkGradient(OffScreen.Canvas, x0[i] + 8 - 1,
810 7 + i * 24 - 3, 16, 1);
811 ScreenTools.Frame(OffScreen.Canvas, x0[i] + 8, 7 + i * 24 - 2, x0[i] + 8 + 13,
812 7 + i * 24 - 2 + 13, $C0C0C0, $C0C0C0);
813 Sprite(OffScreen, HGrSystem, x0[i] + 8 + 2, 7 + i * 24, 10, 10,
814 66 + HelpLineInfo.Picpix mod 11 * 11,
815 137 + HelpLineInfo.Picpix div 11 * 11);
816 x0[i] := x0[i] + 8 + 8 + 2 + 13;
817 end;
818 pkExp:
819 begin
820 ScreenTools.Frame(OffScreen.Canvas, 20 - 1, 8 - 4 + i * 24, 20 + 12,
821 8 + 11 + i * 24, $000000, $000000);
822 Dump(OffScreen, HGrSystem, 20, 8 - 3 + i * 24, 12, 14,
823 121 + HelpLineInfo.Picpix * 13, 28);
824 x0[i] := 20 + 8 + 11;
825 end;
826 pkAITStat:
827 begin
828 Sprite(OffScreen, HGrSystem, 20, 6 + i * 24, 14, 14,
829 1 + HelpLineInfo.Picpix * 15, 316);
830 x0[i] := 20 + 8 + 11;
831 end;
832 pkGov:
833 begin
834 ScreenTools.Frame(OffScreen.Canvas, 8 - 1 + x0[i], 2 - 1 + i * 24,
835 8 + xSizeSmall + x0[i], 2 + 20 + i * 24, $000000, $000000);
836 BitBltCanvas(OffScreen.Canvas, 8 + x0[i], 2 + i * 24, xSizeSmall,
837 ySizeSmall, SmallImp.Canvas, (HelpLineInfo.Picpix - 1) *
838 xSizeSmall, ySizeSmall);
839 x0[i] := x0[i] + (8 + 8 + 36);
840 end;
841 pkDot:
842 begin
843 Sprite(OffScreen, HGrSystem, x0[i] + 18, 9 + i * 24, 8,
844 8, 81, 16);
845 x0[i] := 20 + 8 + 4;
846 end;
847 pkNormal_Dot:
848 x0[i] := 20 + 8 + 4;
849 pkNormal_64:
850 x0[i] := 64 + 8 + 8;
851 else
852 x0[i] := x0[i] + 8;
853 end;
854 Self.Line(OffScreen.Canvas, i, False)
855 end;
856 end;
857 MarkUsedOffscreen(InnerWidth, InnerHeight + 13 + 48);
858end;
859
860procedure THelpDlg.ScrollBarUpdate(Sender: TObject);
861begin
862 Sel := -1;
863 SmartUpdateContent(true)
864end;
865
866procedure THelpDlg.Prepare(sbPos: integer = 0);
867var
868 i, j, Special, Domain, Headline, TerrType, TerrSubType: integer;
869 s: string;
870 ps: pchar;
871 List: THyperText;
872 CheckSeeAlso: Boolean;
873
874 procedure AddAdvance(i: integer);
875 begin
876 MainText.AddLine(Phrases.Lookup('ADVANCES', i), pkAdvIcon, i,
877 hkAdv + hkCrossLink, i);
878 end;
879
880 procedure AddPreqAdv(i: integer);
881 begin
882 MainText.AddLine(Phrases.Lookup('ADVANCES', i), pkAdvIcon_AsPreq, i,
883 hkAdv + hkCrossLink, i);
884 end;
885
886 procedure AddImprovement(i: integer);
887 begin
888 MainText.AddLine(Phrases.Lookup('IMPROVEMENTS', i), pkSmallIcon, i,
889 hkImp + hkCrossLink, i);
890 end;
891
892 procedure AddPreqImp(i: integer);
893 begin
894 MainText.AddLine(Phrases.Lookup('IMPROVEMENTS', i), pkSmallIcon_AsPreq, i,
895 hkImp + hkCrossLink, i);
896 end;
897
898 procedure AddTerrain(i: integer);
899 begin
900 if MainText.Count > 1 then
901 begin
902 MainText.LineFeed;
903 end;
904 MainText.AddLine(Phrases.Lookup('TERRAIN', i), pkTer, i, hkTer, i);
905 end;
906
907 procedure AddFeature(i: integer);
908 begin
909 MainText.AddLine(Phrases.Lookup('FEATURES', i), pkFeature, i,
910 hkFeature + hkCrossLink, i);
911 end;
912
913 procedure AddModel(i: integer);
914 var
915 pix: integer;
916 Name: string;
917 begin
918 if MainText.Count > 1 then
919 MainText.LineFeed;
920 FindStdModelPicture(SpecialModelPictureCode[i], pix, Name);
921 MainText.AddLine(Name, pkModel, pix, hkModel + hkCrossLink, i)
922 end;
923
924 procedure AddStandardBlock(Item: string);
925 var
926 i: integer;
927 begin
928 with MainText do
929 begin
930 if Item = 'LOGO' then
931 begin
932 AddLine('', pkLogo);
933 LineFeed;
934 end
935 else if Item = 'TECHFORMULA' then
936 begin
937 i := Difficulty;
938 if i = 0 then
939 i := 2;
940 AddLine(Format(HelpText.Lookup('TECHFORMULA'), [TechFormula_M[i],
941 TechFormula_D[i]]))
942 end
943 else if Item = 'EXPERIENCE' then
944 for i := 0 to nExp - 1 do
945 AddLine(Phrases.Lookup('EXPERIENCE', i), pkExp, i)
946 else if Item = 'MODERN' then
947 for i := 1 to 3 do
948 begin
949 LineFeed;
950 AddLine(Phrases.Lookup('TERRAIN', 3 * 12 + i), pkTer, 3 * 12 + i);
951 end
952 else if Item = 'SAVED' then
953 AddLine(DataDir + 'Saved', pkNormal)
954 else if Item = 'AITSTAT' then
955 for i := 0 to 3 do
956 AddLine(Phrases2.Lookup('AITSTAT', i), pkAITStat, i)
957 end
958 end;
959
960 procedure DecodeItem(s: string; var Category, Index: Integer);
961 var
962 i: Integer;
963 begin
964 if (Length(s) > 0) and (s[1] = ':') then begin
965 Category := hkMisc;
966 Index := 0;
967 for i := 3 to length(s) do
968 Index := Index * 10 + Ord(s[i]) - 48;
969 case s[2] of
970 'A': Category := hkAdv;
971 'B': Category := hkImp;
972 'T': Category := hkTer;
973 'F': Category := hkFeature;
974 'E': Category := hkInternet;
975 'S': Category := hkModel;
976 'C': Index := miscCredits;
977 'J': Index := miscJobList;
978 'G': Index := miscGovList;
979 end;
980 if (Category <> hkMisc) and (Index = 0) then
981 Index := 200;
982 end else begin
983 Category := hkText;
984 Index := HelpText.Gethandle(Copy(s, 1, 255));
985 end;
986 end;
987
988 procedure AddTextual(s: string);
989 var
990 i: Integer;
991 p: Integer;
992 l: Integer;
993 ofs: Integer;
994 CurrentFormat: Integer;
995 FollowFormat: Integer;
996 Picpix: Integer;
997 LinkCategory: Integer;
998 LinkIndex: Integer;
999 RightMargin: Integer;
1000 Name: string;
1001 Text: string;
1002 begin
1003 RightMargin := InnerWidth - 16 - GetSystemMetrics(SM_CXVSCROLL);
1004 FollowFormat := pkNormal;
1005 while s <> '' do
1006 begin
1007 Picpix := 0;
1008 LinkCategory := 0;
1009 LinkIndex := 0;
1010 if s[1] = '$' then
1011 begin // window caption
1012 p := 1;
1013 repeat
1014 inc(p)
1015 until (p > Length(s)) or (s[p] = '\');
1016 Caption := Copy(s, 2, p - 2);
1017 Delete(s, 1, p);
1018 end
1019 else if s[1] = '&' then
1020 begin // standard block
1021 p := 1;
1022 repeat
1023 inc(p)
1024 until (p > Length(s)) or (s[p] = '\');
1025 AddStandardBlock(Copy(s, 2, p - 2));
1026 Delete(s, 1, p);
1027 end
1028 else if s[1] = '@' then
1029 begin // image
1030 if (Length(s) >= 2) and (s[2] = '@') then
1031 begin // generate from icon
1032 Picpix := 0;
1033 p := 3;
1034 while (p <= Length(s)) and (s[p] <> '\') do
1035 begin
1036 Picpix := Picpix * 10 + Ord(s[p]) - 48;
1037 inc(p)
1038 end;
1039 if (Picpix < 0) or (Picpix >= nImp) then
1040 Picpix := 0;
1041 MainText.AddLine('', pkIllu, Picpix);
1042 MainText.LineFeed;
1043 MainText.LineFeed;
1044 end
1045 else
1046 begin // external image
1047 p := 1;
1048 repeat
1049 Inc(p)
1050 until (p > Length(s)) or (s[p] = '\');
1051 if LoadGraphicFile(ExtPic, LocalizedFilePath('Help' +
1052 DirectorySeparator + Copy(s, 2, p - 2)) + '.png') then
1053 begin
1054 MainText.AddLine('', pkExternal);
1055 for i := 0 to (ExtPic.Height - 12) div 24 do
1056 MainText.LineFeed;
1057 end;
1058 end;
1059 Delete(s, 1, p);
1060 end
1061 else
1062 begin
1063 case s[1] of
1064 ':', ';':
1065 begin // link
1066 p := 1;
1067 repeat
1068 inc(p)
1069 until (p > Length(s)) or (s[p] = '\') or (s[p] = ' ');
1070 DecodeItem(Copy(s, 2, p - 2), LinkCategory, LinkIndex);
1071 CurrentFormat := 0;
1072 if (LinkCategory <> hkText) and (LinkIndex < 200) then
1073 // show icon
1074 case LinkCategory of
1075 hkAdv:
1076 begin
1077 CurrentFormat := pkAdvIcon;
1078 Picpix := LinkIndex
1079 end;
1080 hkImp:
1081 begin
1082 CurrentFormat := pkSmallIcon;
1083 Picpix := LinkIndex
1084 end;
1085 hkTer:
1086 begin
1087 CurrentFormat := pkTer;
1088 Picpix := LinkIndex;
1089 end;
1090 hkFeature:
1091 begin
1092 CurrentFormat := pkFeature;
1093 Picpix := LinkIndex
1094 end;
1095 hkModel:
1096 begin
1097 CurrentFormat := pkModel;
1098 FindStdModelPicture(SpecialModelPictureCode[LinkIndex],
1099 Picpix, Name);
1100 end;
1101 end;
1102 if s[1] = ':' then
1103 LinkCategory := LinkCategory + hkCrossLink;
1104 if (p > Length(s)) or (s[p] = ' ') then
1105 Delete(s, 1, p)
1106 else
1107 Delete(s, 1, p - 1)
1108 end;
1109 '!': // highlited
1110 if (Length(s) >= 2) and (s[2] = '!') then
1111 begin
1112 if MainText.Count > 1 then
1113 MainText.LineFeed;
1114 FollowFormat := pkCaption;
1115 CurrentFormat := pkCaption;
1116 Delete(s, 1, 2);
1117 end
1118 else
1119 begin
1120 FollowFormat := pkSection;
1121 CurrentFormat := pkSection;
1122 Delete(s, 1, 1);
1123 end;
1124 '-':
1125 begin // list
1126 FollowFormat := pkNormal_Dot;
1127 CurrentFormat := pkDot;
1128 Delete(s, 1, 1);
1129 end;
1130 else
1131 CurrentFormat := FollowFormat;
1132 end;
1133 if FollowFormat = pkNormal_Dot then
1134 ofs := 20 + 4 + 8
1135 else
1136 ofs := 8;
1137 p := 0;
1138 repeat
1139 repeat
1140 Inc(p)
1141 until (p > Length(s)) or (s[p] = ' ') or (s[p] = '\');
1142 if (BiColorTextWidth(OffScreen.Canvas, Copy(s, 1, p - 1)) <=
1143 RightMargin - ofs) then
1144 l := p - 1
1145 else
1146 Break;
1147 until (p >= Length(s)) or (s[l + 1] = '\');
1148 Text := Copy(s, 1, l);
1149 if LinkCategory and $3f = hkInternet then begin
1150 if LinkIndex = 1 then Text := AITemplateManual
1151 else if LinkIndex = 2 then Text := CevoHomepageShort
1152 else if LinkIndex = 3 then Text := CevoContactShort;
1153 end;
1154 MainText.AddLine(Text, CurrentFormat, Picpix, LinkCategory,
1155 LinkIndex);
1156 if (l < Length(s)) and (s[l + 1] = '\') then
1157 FollowFormat := pkNormal;
1158 Delete(s, 1, l + 1);
1159 end
1160 end
1161 end;
1162
1163 procedure AddItem(Item: string);
1164 begin
1165 AddTextual(HelpText.Lookup(Item));
1166 end;
1167
1168 procedure AddModelText(i: Integer);
1169 var
1170 pix: Integer;
1171 s: string;
1172 begin
1173 with MainText do begin
1174 if Count > 1 then begin
1175 LineFeed;
1176 LineFeed;
1177 end;
1178 FindStdModelPicture(SpecialModelPictureCode[i], pix, s);
1179 AddLine(s, pkSection);
1180 AddLine(Format(HelpText.Lookup('STRENGTH'), [SpecialModel[i].Attack,
1181 SpecialModel[i].Defense]), pkNormal_64);
1182 AddLine(Format(HelpText.Lookup('SPEED'),
1183 [MovementToString(SpecialModel[i].Speed)]), pkModel, pix);
1184 if Difficulty = 0 then
1185 AddLine(Format(HelpText.Lookup('BUILDCOST'), [SpecialModel[i].Cost]),
1186 pkNormal_64)
1187 else
1188 AddLine(Format(HelpText.Lookup('BUILDCOST'),
1189 [SpecialModel[i].Cost * BuildCostMod[Difficulty] div 12]),
1190 pkNormal_64);
1191 s := HelpText.LookupByHandle(hSPECIALMODEL, i);
1192 if (s <> '') and (s <> '*') then
1193 AddTextual(s);
1194 if SpecialModelPreq[i] >= 0 then
1195 AddPreqAdv(SpecialModelPreq[i])
1196 else if SpecialModelPreq[i] = preLighthouse then
1197 AddPreqImp(woLighthouse)
1198 else if SpecialModelPreq[i] = preBuilder then
1199 AddPreqImp(woPyramids)
1200 else if SpecialModelPreq[i] = preLeo then
1201 AddPreqImp(woLeo);
1202 if SpecialModelPreq[i] <> preNone then
1203 MainText[Count - 1] := Format(HelpText.Lookup('REQUIRED'),
1204 [MainText[Count - 1]]);
1205 end
1206 end;
1207
1208 procedure AddJobList;
1209 var
1210 i, JobCost: Integer;
1211 begin
1212 with MainText do begin
1213 for i := 0 to nJobHelp - 1 do begin
1214 if i > 0 then begin
1215 LineFeed;
1216 LineFeed;
1217 end;
1218 AddLine(Phrases.Lookup('JOBRESULT', JobHelp[i]), pkSection);
1219 AddLine;
1220 AddLine('', pkTerImp, i);
1221 AddLine;
1222 AddTextual(HelpText.LookupByHandle(hJOBHELP, i));
1223 JobCost := -1;
1224 case JobHelp[i] of
1225 jCanal: JobCost := CanalWork;
1226 jFort: JobCost := FortWork;
1227 jBase: JobCost := BaseWork;
1228 end;
1229 if JobCost >= 0 then
1230 AddTextual(Format(HelpText.Lookup('JOBCOST'),
1231 [MovementToString(JobCost)]))
1232 else
1233 AddTextual(HelpText.Lookup('JOBCOSTVAR'));
1234 if JobPreq[JobHelp[i]] <> preNone then begin
1235 AddPreqAdv(JobPreq[JobHelp[i]]);
1236 MainText[Count - 1] := Format(HelpText.Lookup('REQUIRED'),
1237 [MainText[Count - 1]]);
1238 end
1239 end;
1240 end
1241 end;
1242
1243 procedure AddGraphicCredits;
1244 var
1245 i: Integer;
1246 s: string;
1247 sr: TSearchRec;
1248 List, Plus: TStringList;
1249 begin
1250 List := TStringList.Create;
1251 Plus := TStringList.Create;
1252 if FindFirst(GetGraphicsDir + DirectorySeparator + '*.credits.txt', $27, sr) = 0 then
1253 repeat
1254 Plus.LoadFromFile(GetGraphicsDir + DirectorySeparator + sr.Name);
1255 List.AddStrings(Plus);
1256 until FindNext(sr) <> 0;
1257 FindClose(sr);
1258 FreeAndNil(Plus);
1259
1260 List.Sort;
1261 i := 1;
1262 while i < List.Count do
1263 if List[i] = List[i - 1] then
1264 List.Delete(i)
1265 else
1266 Inc(i);
1267
1268 for i := 0 to List.Count - 1 do begin
1269 s := List[i];
1270 while BiColorTextWidth(OffScreen.Canvas, s) > InnerWidth - 16 -
1271 GetSystemMetrics(SM_CXVSCROLL) do
1272 Delete(s, length(s), 1);
1273 MainText.AddLine(s);
1274 end;
1275 FreeAndNil(List);
1276 end;
1277
1278 procedure AddSoundCredits;
1279 var
1280 i: Integer;
1281 s: string;
1282 List: TStringList;
1283 begin
1284 List := TStringList.Create;
1285 List.LoadFromFile(GetSoundsDir + DirectorySeparator + 'sound.credits.txt');
1286 for i := 0 to List.Count - 1 do begin
1287 s := List[i];
1288 while BiColorTextWidth(OffScreen.Canvas, s) > InnerWidth - 16 -
1289 GetSystemMetrics(SM_CXVSCROLL) do
1290 Delete(s, length(s), 1);
1291 MainText.AddLine(s);
1292 end;
1293 FreeAndNil(List);
1294 end;
1295
1296 procedure NextSection(Item: string);
1297 begin
1298 if MainText.Count > 1 then
1299 if MainText.Count = Headline + 1 then
1300 MainText.Delete(Headline)
1301 else
1302 MainText.LineFeed;
1303 MainText.AddLine(HelpText.Lookup(Item), pkSection);
1304 Headline := MainText.Count - 1;
1305 end;
1306
1307begin { Prepare }
1308 with MainText do begin
1309 OffScreen.Canvas.Font.Assign(UniFont[ftNormal]);
1310 CheckSeeAlso := False;
1311 Clear;
1312 Headline := -1;
1313 if (no >= 200) or not(Kind in [hkAdv, hkImp, hkTer, hkFeature]) then
1314 LineFeed;
1315 case Kind of
1316 hkText:
1317 AddTextual(HelpText.LookupByHandle(no));
1318 hkMisc:
1319 begin
1320 case no of
1321 miscMain:
1322 begin
1323 Caption := HelpText.Lookup('HELPTITLE_MAIN');
1324 AddLine(HelpText.Lookup('HELPTITLE_QUICKSTART'), pkSpecialIcon,
1325 0, { pkBigIcon,22, } hkText, HelpText.Gethandle('QUICK'));
1326 LineFeed;
1327 AddLine(HelpText.Lookup('HELPTITLE_CONCEPTS'), pkBigIcon, 6,
1328 hkText, HelpText.Gethandle('CONCEPTS'));
1329 LineFeed;
1330 AddLine(HelpText.Lookup('HELPTITLE_TERLIST'), pkSpecialIcon, 1,
1331 hkTer, 200);
1332 LineFeed;
1333 AddLine(HelpText.Lookup('HELPTITLE_JOBLIST'), pkSpecialIcon, 2,
1334 hkMisc, miscJobList);
1335 LineFeed;
1336 AddLine(HelpText.Lookup('HELPTITLE_TECHLIST'), pkBigIcon, 39,
1337 hkAdv, 200);
1338 LineFeed;
1339 FindStdModelPicture(SpecialModelPictureCode[6], i, s);
1340 AddLine(HelpText.Lookup('HELPTITLE_MODELLIST'), pkModel, i,
1341 hkModel, 0);
1342 LineFeed;
1343 AddLine(HelpText.Lookup('HELPTITLE_FEATURELIST'), pkBigIcon, 28,
1344 hkFeature, 200);
1345 LineFeed;
1346 AddLine(HelpText.Lookup('HELPTITLE_IMPLIST'), pkBigIcon,
1347 7 * SystemIconLines + imCourt, hkImp, 200);
1348 LineFeed;
1349 AddLine(HelpText.Lookup('HELPTITLE_UNIQUELIST'), pkBigIcon,
1350 7 * SystemIconLines + imStockEx, hkImp, 201);
1351 LineFeed;
1352 AddLine(HelpText.Lookup('HELPTITLE_WONDERLIST'), pkBigIcon,
1353 7 * SystemIconLines, hkImp, 202);
1354 LineFeed;
1355 AddLine(HelpText.Lookup('HELPTITLE_GOVLIST'), pkBigIcon,
1356 gDemocracy + 6, hkMisc, miscGovList);
1357 LineFeed;
1358 AddLine(HelpText.Lookup('HELPTITLE_KEYS'), pkBigIcon, 2, hkText,
1359 HelpText.Gethandle('HOTKEYS'));
1360 LineFeed;
1361 AddLine(HelpText.Lookup('HELPTITLE_ABOUT'), pkBigIcon, 1,
1362 hkText, HelpText.Gethandle('ABOUT'));
1363 LineFeed;
1364 AddLine(HelpText.Lookup('HELPTITLE_CREDITS'), pkBigIcon, 22,
1365 hkMisc, miscCredits);
1366 end;
1367 miscCredits:
1368 begin
1369 AddItem('CREDITS');
1370 LineFeed;
1371 AddGraphicCredits;
1372 NextSection('CRED_CAPSOUND');
1373 AddSoundCredits;
1374 NextSection('CRED_CAPAI');
1375 Server(sGetAICredits, 0, 0, ps);
1376 AddTextual(ps);
1377 NextSection('CRED_CAPLANG');
1378 AddItem('AUTHOR');
1379 end;
1380 miscJobList:
1381 begin
1382 Caption := HelpText.Lookup('HELPTITLE_JOBLIST');
1383 AddJobList;
1384 LineFeed;
1385 AddItem('TERIMPEXCLUDE');
1386 LineFeed;
1387 AddItem('TERIMPCITY');
1388 end;
1389 miscGovList:
1390 begin
1391 Caption := HelpText.Lookup('HELPTITLE_GOVLIST');
1392 for i := 1 to nGov do
1393 begin
1394 AddLine(Phrases.Lookup('GOVERNMENT', i mod nGov), pkSection);
1395 LineFeed;
1396 if i = nGov then
1397 AddLine('', pkBigIcon, 7 * SystemIconLines + imPalace)
1398 else
1399 AddLine('', pkBigIcon, i + 6);
1400 LineFeed;
1401 AddTextual(HelpText.LookupByHandle(hGOVHELP, i mod nGov));
1402 if i mod nGov >= 2 then
1403 begin
1404 AddPreqAdv(GovPreq[i mod nGov]);
1405 MainText[Count - 1] := Format(HelpText.Lookup('REQUIRED'),
1406 [MainText[Count - 1]]);
1407 end;
1408 if i < nGov then
1409 begin
1410 LineFeed;
1411 LineFeed;
1412 end
1413 end
1414 end;
1415 miscSearchResult:
1416 begin
1417 Caption := HelpText.Lookup('HELPTITLE_SEARCHRESULTS');
1418 AddTextual(Format(HelpText.Lookup('MATCHES'), [SearchContent]));
1419 MainText.AppendList(SearchResult);
1420 end;
1421 end; // case no
1422 end;
1423
1424 hkAdv:
1425 if no = 200 then
1426 begin // complete advance list
1427 Caption := HelpText.Lookup('HELPTITLE_TECHLIST');
1428 List := THyperText.Create;
1429 List.OwnsObjects := True;
1430 for j := 0 to 3 do
1431 begin
1432 if j > 0 then
1433 begin
1434 LineFeed;
1435 LineFeed;
1436 end;
1437 AddLine(HelpText.Lookup('TECHAGE', j), pkSection);
1438 if j = 1 then
1439 AddLine(Phrases.Lookup('ADVANCES', adScience) + ' ' +
1440 HelpText.Lookup('BASETECH'), pkAdvIcon, adScience, hkAdv,
1441 adScience);
1442 if j = 2 then
1443 AddLine(Phrases.Lookup('ADVANCES', adMassProduction) + ' ' +
1444 HelpText.Lookup('BASETECH'), pkAdvIcon, adMassProduction, hkAdv,
1445 adMassProduction);
1446 List.Clear;
1447 for i := 0 to nAdv - 1 do
1448 if (i <> adScience) and (i <> adMassProduction) and
1449 (AdvValue[i] div 1000 = j) then
1450 List.AddLine(Phrases.Lookup('ADVANCES', i), pkAdvIcon, i,
1451 hkAdv, i);
1452 List.Sort;
1453 AppendList(List);
1454 end;
1455 FreeAndNil(List);
1456 end
1457 else // single advance
1458 begin
1459 Caption := Phrases.Lookup('ADVANCES', no);
1460 LineFeed;
1461 AddLine(Phrases.Lookup('ADVANCES', no), pkCaption);
1462 if no in FutureTech then
1463 begin
1464 AddLine(HelpText.Lookup('HELPSPEC_FUTURE'));
1465 LineFeed;
1466 if no = futResearchTechnology then
1467 AddItem('FUTURETECHHELP100')
1468 else
1469 AddItem('FUTURETECHHELP25');
1470 end
1471 else
1472 AddLine(HelpText.Lookup('HELPSPEC_ADV'));
1473 if AdvPreq[no, 2] <> preNone then
1474 NextSection('PREREQALT')
1475 else
1476 NextSection('PREREQ');
1477 for i := 0 to 2 do
1478 if AdvPreq[no, i] <> preNone then
1479 AddPreqAdv(AdvPreq[no, i]);
1480 NextSection('GOVALLOW');
1481 for i := 2 to nGov - 1 do
1482 if GovPreq[i] = no then
1483 AddLine(Phrases.Lookup('GOVERNMENT', i), pkGov, i,
1484 hkMisc + hkCrossLink, miscGovList);
1485 NextSection('BUILDALLOW');
1486 for i := 0 to 27 do
1487 if Imp[i].Preq = no then
1488 AddImprovement(i);
1489 for i := 28 to nImp - 1 do
1490 if (Imp[i].Preq = no) and (Imp[i].Kind <> ikCommon) then
1491 AddImprovement(i);
1492 for i := 28 to nImp - 1 do
1493 if (Imp[i].Preq = no) and (Imp[i].Kind = ikCommon) then
1494 AddImprovement(i);
1495 NextSection('MODELALLOW');
1496 for i := 0 to nSpecialModel - 1 do
1497 if SpecialModelPreq[i] = no then
1498 AddModel(i);
1499 NextSection('FEATALLOW');
1500 for i := 0 to nFeature - 1 do
1501 if Feature[i].Preq = no then
1502 AddFeature(i);
1503 NextSection('FOLLOWADV');
1504 for i := 0 to nAdv - 1 do
1505 if (AdvPreq[i, 0] = no) or (AdvPreq[i, 1] = no) or
1506 (AdvPreq[i, 2] = no) then
1507 AddAdvance(i);
1508 NextSection('UPGRADEALLOW');
1509 for Domain := 0 to nDomains - 1 do
1510 for i := 1 to nUpgrade - 1 do
1511 if upgrade[Domain, i].Preq = no then
1512 begin
1513 if upgrade[Domain, i].Strength > 0 then
1514 AddLine(Format(HelpText.Lookup('STRENGTHUP'),
1515 [Phrases.Lookup('DOMAIN', Domain), upgrade[Domain,
1516 i].Strength]), pkDomain, Domain);
1517 if upgrade[Domain, i].Trans > 0 then
1518 AddLine(Format(HelpText.Lookup('TRANSUP'),
1519 [Phrases.Lookup('DOMAIN', Domain), upgrade[Domain, i].Trans]
1520 ), pkDomain, Domain);
1521 if no in FutureTech then
1522 AddLine(Format(HelpText.Lookup('COSTUP'),
1523 [upgrade[Domain, i].Cost]), pkNormal_Dot)
1524 else
1525 AddLine(Format(HelpText.Lookup('COSTMIN'),
1526 [upgrade[Domain, i].Cost]), pkNormal_Dot)
1527 end;
1528 NextSection('EXPIRATION');
1529 for i := 0 to 27 do
1530 if (Imp[i].Preq <> preNA) and (Imp[i].Expiration = no) then
1531 AddImprovement(i);
1532 NextSection('ADVEFFECT');
1533 s := HelpText.LookupByHandle(hADVHELP, no);
1534 if s <> '*' then
1535 AddTextual(s);
1536 NextSection('SEEALSO');
1537 CheckSeeAlso := true
1538 end;
1539
1540 hkImp:
1541 if no = 200 then
1542 begin // complete city improvement list
1543 Caption := HelpText.Lookup('HELPTITLE_IMPLIST');
1544 // AddLine(HelpText.Lookup('HELPTITLE_IMPLIST'),pkSection);
1545 List := THyperText.Create;
1546 List.OwnsObjects := True;
1547 for i := 28 to nImp - 1 do
1548 if (i <> imTrGoods) and (Imp[i].Preq <> preNA) and
1549 (Imp[i].Kind = ikCommon) then
1550 List.AddLine(Phrases.Lookup('IMPROVEMENTS', i), pkSmallIcon,
1551 i, hkImp, i);
1552 List.Sort;
1553 AppendList(List);
1554 FreeAndNil(List);
1555 end
1556 else if no = 201 then
1557 begin // complete nat. project list
1558 Caption := HelpText.Lookup('HELPTITLE_UNIQUELIST');
1559 // AddLine(HelpText.Lookup('HELPTITLE_UNIQUELIST'),pkSection);
1560 for i := 28 to nImp - 1 do
1561 if (Imp[i].Preq <> preNA) and
1562 ((Imp[i].Kind = ikNatLocal) or (Imp[i].Kind = ikNatGlobal)) then
1563 AddLine(Phrases.Lookup('IMPROVEMENTS', i), pkSmallIcon, i,
1564 hkImp, i);
1565 { LineFeed;
1566 LineFeed;
1567 AddLine(HelpText.Lookup('HELPTITLE_SHIPPARTLIST'),pkSection);
1568 for i:=28 to nImp-1 do
1569 if (Imp[i].Preq<>preNA) and (Imp[i].Kind=ikShipPart) then
1570 AddLine(Phrases.Lookup('IMPROVEMENTS',i),pkSmallIcon,i,hkImp,i); }
1571 end
1572 else if no = 202 then
1573 begin // complete wonder list
1574 Caption := HelpText.Lookup('HELPTITLE_WONDERLIST');
1575 // AddLine(HelpText.Lookup('HELPTITLE_WONDERLIST'),pkSection);
1576 for i := 0 to 27 do
1577 if Imp[i].Preq <> preNA then
1578 AddLine(Phrases.Lookup('IMPROVEMENTS', i), pkSmallIcon, i,
1579 hkImp, i);
1580 end
1581 else
1582 begin // single building
1583 Caption := Phrases.Lookup('IMPROVEMENTS', no);
1584 LineFeed;
1585 AddLine(Phrases.Lookup('IMPROVEMENTS', no), pkRightIcon, no);
1586 case Imp[no].Kind of
1587 ikWonder: AddLine(HelpText.Lookup('HELPSPEC_WONDER'));
1588 ikCommon: AddLine(HelpText.Lookup('HELPSPEC_IMP'));
1589 ikShipPart: AddLine(HelpText.Lookup('HELPSPEC_SHIPPART'));
1590 else
1591 AddLine(HelpText.Lookup('HELPSPEC_NAT'))
1592 end;
1593 if Imp[no].Kind <> ikShipPart then begin
1594 NextSection('EFFECT');
1595 AddTextual(HelpText.LookupByHandle(hIMPHELP, no));
1596 end;
1597 if no = woSun then begin
1598 AddFeature(mcFirst);
1599 AddFeature(mcWill);
1600 AddFeature(mcAcademy);
1601 end;
1602 if (no < 28) and not Phrases2FallenBackToEnglish then
1603 begin
1604 LineFeed;
1605 if Imp[no].Expiration >= 0 then
1606 AddTextual(Phrases2.Lookup('HELP_WONDERMORALE1'))
1607 else
1608 AddTextual(Phrases2.Lookup('HELP_WONDERMORALE2'));
1609 end;
1610 if Imp[no].Preq <> preNone then
1611 begin
1612 NextSection('PREREQ');
1613 AddPreqAdv(Imp[no].Preq);
1614 end;
1615 NextSection('COSTS');
1616 if Difficulty = 0 then
1617 s := Format(HelpText.Lookup('BUILDCOST'), [Imp[no].Cost])
1618 else
1619 s := Format(HelpText.Lookup('BUILDCOST'),
1620 [Imp[no].Cost * BuildCostMod[Difficulty] div 12]);
1621 AddLine(s);
1622 if Imp[no].Maint > 0 then
1623 AddLine(Format(HelpText.Lookup('MAINTCOST'), [Imp[no].Maint]));
1624 j := 0;
1625 for i := 0 to nImpReplacement - 1 do
1626 if ImpReplacement[i].NewImp = no then
1627 begin
1628 if j = 0 then
1629 begin
1630 NextSection('REPLACE');
1631 AddItem('REPLACETEXT');
1632 j := 1
1633 end;
1634 AddImprovement(ImpReplacement[i].OldImp);
1635 end;
1636 if Imp[no].Kind = ikShipPart then
1637 begin
1638 LineFeed;
1639 if no = imShipComp then
1640 i := 1
1641 else if no = imShipPow then
1642 i := 2
1643 else { if no=imShipHab then }
1644 i := 3;
1645 AddLine(Format(HelpText.Lookup('RAREREQUIRED'),
1646 [Phrases.Lookup('TERRAIN', 3 * 12 + i)]), pkTer, 3 * 12 + i);
1647 end;
1648 if (no < 28) and (Imp[no].Expiration >= 0) then
1649 begin
1650 NextSection('EXPIRATION');
1651 s := Format(HelpText.Lookup('EXPWITH'),
1652 [Phrases.Lookup('ADVANCES', Imp[no].Expiration)]);
1653 if no = woPyramids then
1654 s := s + ' ' + HelpText.Lookup('EXPSLAVE');
1655 AddTextual(s);
1656 end;
1657 NextSection('SEEALSO');
1658 if (no < 28) and (Imp[no].Expiration >= 0) then
1659 AddImprovement(woEiffel);
1660 for i := 0 to nImpReplacement - 1 do
1661 if ImpReplacement[i].OldImp = no then
1662 AddImprovement(ImpReplacement[i].NewImp);
1663 if no = imSupermarket then
1664 AddLine(HelpText.Lookup('HELPTITLE_JOBLIST'), pkNormal, 0,
1665 hkMisc + hkCrossLink, miscJobList);
1666 CheckSeeAlso := true
1667 end;
1668
1669 hkTer:
1670 if no = 200 then
1671 begin // complete terrain type list
1672 Caption := HelpText.Lookup('HELPTITLE_TERLIST');
1673 // AddLine(HelpText.Lookup('HELPTITLE_TERLIST'),pkSection);
1674 for i := 0 to nTerrainHelp - 1 do
1675 AddTerrain(TerrainHelp[i]);
1676 end
1677 else
1678 begin // sigle terrain type
1679 TerrType := no mod 12;
1680 if TerrType = fJungle then
1681 TerrType := fForest;
1682 TerrSubType := no div 12;
1683 if no = 3 * 12 then
1684 begin
1685 TerrType := fDesert;
1686 TerrSubType := 0
1687 end;
1688 with Terrain[TerrType] do
1689 begin
1690 Caption := Phrases.Lookup('TERRAIN', no);
1691 LineFeed;
1692 AddLine(Phrases.Lookup('TERRAIN', no), pkBigTer, no);
1693 AddLine(HelpText.Lookup('HELPSPEC_TER'));
1694 LineFeed;
1695 if (ProdRes[TerrSubType] > 0) or (MineEff > 0) then
1696 AddLine(Format(HelpText.Lookup('RESPROD'),
1697 [ProdRes[TerrSubType]]));
1698 if (no < 3 * 12) and (MineEff > 0) then
1699 MainText[Count - 1] := MainText[Count - 1] + ' ' +
1700 Format(HelpText.Lookup('MOREMINE'), [MineEff]);
1701 if (FoodRes[TerrSubType] > 0) or (IrrEff > 0) then
1702 AddLine(Format(HelpText.Lookup('RESFOOD'),
1703 [FoodRes[TerrSubType]]));
1704 if (no < 3 * 12) and (IrrEff > 0) then
1705 MainText[Count - 1] := MainText[Count - 1] + ' ' +
1706 Format(HelpText.Lookup('MOREIRR'), [IrrEff]);
1707 if TradeRes[TerrSubType] > 0 then
1708 AddLine(Format(HelpText.Lookup('RESTRADE'),
1709 [TradeRes[TerrSubType]]));
1710 if Defense > 4 then
1711 AddLine(Format(HelpText.Lookup('DEFBONUS'),
1712 [(Defense - 4) * 25]));
1713 if (TerrType >= fGrass) and (TerrType <> fMountains) then
1714 if MoveCost = 2 then
1715 AddLine(HelpText.Lookup('MOVEHEAVY'))
1716 else
1717 AddLine(HelpText.Lookup('MOVEPLAIN'));
1718 if no = 3 * 12 then
1719 begin
1720 LineFeed;
1721 AddTextual(HelpText.Lookup('DEADLANDS'));
1722 end;
1723 if (TerrType = fDesert) and (no <> fDesert + 12) then
1724 begin
1725 LineFeed;
1726 AddTextual(Format(HelpText.Lookup('HOSTILE'), [DesertThurst]));
1727 end;
1728 if TerrType = fArctic then
1729 begin
1730 LineFeed;
1731 AddTextual(Format(HelpText.Lookup('HOSTILE'), [ArcticThurst]));
1732 end;
1733 if (no < 3 * 12) and (TransTerrain >= 0) then
1734 begin
1735 LineFeed;
1736 i := TransTerrain;
1737 if (TerrType <> fGrass) and (i <> fGrass) then
1738 i := i + TerrSubType * 12;
1739 // trafo to same Special resource group
1740 AddLine(Format(HelpText.Lookup('TRAFO'),
1741 [Phrases.Lookup('TERRAIN', i)]), pkTer, i,
1742 hkTer + hkCrossLink, i);
1743 if no = fSwamp + 12 then
1744 begin
1745 LineFeed;
1746 AddLine(Format(HelpText.Lookup('TRAFO'),
1747 [Phrases.Lookup('TERRAIN', TransTerrain + 24)]), pkTer,
1748 TransTerrain + 24, hkTer + hkCrossLink, TransTerrain + 24);
1749 end
1750 else if i = fGrass then
1751 begin
1752 LineFeed;
1753 AddLine(Format(HelpText.Lookup('TRAFO'),
1754 [Phrases.Lookup('TERRAIN', fGrass + 12)]), pkTer, fGrass + 12,
1755 hkTer + hkCrossLink, fGrass + 12);
1756 end
1757 end;
1758 NextSection('SPECIAL');
1759 if no = 3 * 12 then
1760 begin
1761 LineFeed;
1762 for Special := 1 to 3 do
1763 begin
1764 if Special > 1 then
1765 LineFeed;
1766 AddLine(Phrases.Lookup('TERRAIN', 3 * 12 + Special), pkTer,
1767 3 * 12 + Special);
1768 end
1769 end
1770 else if (no < 12) and (no <> fGrass) and (no <> fOcean) then
1771 begin
1772 LineFeed;
1773 for Special := 1 to 2 do
1774 if (no <> fArctic) and (no <> fSwamp) or (Special < 2) then
1775 begin
1776 if Special > 1 then
1777 LineFeed;
1778 AddLine(Phrases.Lookup('TERRAIN', no + Special * 12), pkTer,
1779 no + Special * 12);
1780 i := FoodRes[Special] - FoodRes[0];
1781 if i <> 0 then
1782 MainText[Count - 1] := MainText[Count - 1] +
1783 Format(HelpText.Lookup('SPECIALFOOD'), [i]);
1784 i := ProdRes[Special] - ProdRes[0];
1785 if i <> 0 then
1786 MainText[Count - 1] := MainText[Count - 1] +
1787 Format(HelpText.Lookup('SPECIALPROD'), [i]);
1788 i := TradeRes[Special] - TradeRes[0];
1789 if i <> 0 then
1790 MainText[Count - 1] := MainText[Count - 1] +
1791 Format(HelpText.Lookup('SPECIALTRADE'), [i]);
1792 end;
1793 end;
1794 if no = 3 * 12 then
1795 begin
1796 LineFeed;
1797 AddTextual(HelpText.Lookup('RARE'));
1798 end;
1799 if (no < 3 * 12) and (TerrType in [fDesert, fArctic]) then
1800 begin
1801 NextSection('SEEALSO');
1802 AddImprovement(woGardens);
1803 CheckSeeAlso := true
1804 end
1805 end
1806 end;
1807
1808 hkFeature:
1809 if no = 200 then
1810 begin // complete feature list
1811 Caption := HelpText.Lookup('HELPTITLE_FEATURELIST');
1812 List := THyperText.Create;
1813 List.OwnsObjects := True;
1814 for Special := 0 to 2 do
1815 begin
1816 if Special > 0 then
1817 begin
1818 LineFeed;
1819 LineFeed;
1820 end;
1821 case Special of
1822 0: AddLine(HelpText.Lookup('HELPTITLE_FEATURE1LIST'), pkSection);
1823 1: AddLine(HelpText.Lookup('HELPTITLE_FEATURE2LIST'), pkSection);
1824 2: AddLine(HelpText.Lookup('HELPTITLE_FEATURE3LIST'), pkSection);
1825 end;
1826 List.Clear;
1827 for i := 0 to nFeature - 1 do
1828 if Feature[i].Preq <> preNA then
1829 begin
1830 if i < mcFirstNonCap then
1831 j := 0
1832 else if i in AutoFeature then
1833 j := 2
1834 else
1835 j := 1;
1836 if j = Special then
1837 List.AddLine(Phrases.Lookup('FEATURES', i), pkFeature, i,
1838 hkFeature, i);
1839 end;
1840 List.Sort;
1841 AppendList(List);
1842 end;
1843 FreeAndNil(List);
1844 end
1845 else
1846 begin // single feature
1847 Caption := Phrases.Lookup('FEATURES', no);
1848 LineFeed;
1849 AddLine(Phrases.Lookup('FEATURES', no), pkBigFeature, no);
1850 if no < mcFirstNonCap then
1851 AddLine(HelpText.Lookup('HELPSPEC_CAP'))
1852 else if no in AutoFeature then
1853 AddLine(HelpText.Lookup('HELPSPEC_STANDARD'))
1854 else
1855 AddLine(HelpText.Lookup('HELPSPEC_FEATURE'));
1856 NextSection('EFFECT');
1857 AddTextual(HelpText.LookupByHandle(hFEATUREHELP, no));
1858 if (Feature[no].Weight <> 0) or (Feature[no].Cost <> 0) then
1859 begin
1860 NextSection('COSTS');
1861 s := IntToStr(Feature[no].Cost);
1862 if Feature[no].Cost >= 0 then
1863 s := '+' + s;
1864 AddLine(Format(HelpText.Lookup('COSTBASE'), [s]));
1865 if Feature[no].Weight > 0 then
1866 begin
1867 AddLine(Format(HelpText.Lookup('WEIGHT'),
1868 ['+' + IntToStr(Feature[no].Weight)]));
1869 if no = mcDefense then
1870 AddLine(Format(HelpText.Lookup('WEIGHT'), ['+2']),
1871 pkDomain, dGround);
1872 end
1873 end;
1874 if Feature[no].Preq <> preNone then
1875 begin
1876 LineFeed;
1877 if Feature[no].Preq = preSun then
1878 AddPreqImp(woSun) // sun tsu feature
1879 else
1880 AddPreqAdv(Feature[no].Preq);
1881 MainText[Count - 1] := Format(HelpText.Lookup('REQUIRED'),
1882 [MainText[Count - 1]]);
1883 end;
1884 NextSection('SEEALSO');
1885 CheckSeeAlso := True;
1886 end;
1887
1888 hkModel:
1889 begin
1890 Caption := HelpText.Lookup('HELPTITLE_MODELLIST');
1891 for i := 0 to nSpecialModel - 1 do
1892 if i <> 2 then
1893 AddModelText(i);
1894 LineFeed;
1895 AddItem('MODELNOTE');
1896 end;
1897
1898 end;
1899 if CheckSeeAlso then
1900 for i := 0 to nSeeAlso - 1 do
1901 if (SeeAlso[i].Kind = Kind) and (SeeAlso[i].no = no) then
1902 case SeeAlso[i].SeeKind of
1903 hkImp: AddImprovement(SeeAlso[i].SeeNo);
1904 hkAdv: AddAdvance(SeeAlso[i].SeeNo);
1905 hkFeature: AddFeature(SeeAlso[i].SeeNo);
1906 end;
1907 if (Headline >= 0) and (Count = Headline + 1) then
1908 Delete(Headline)
1909 else
1910 LineFeed;
1911
1912 //Self.Show;
1913 ScrollBar.Init(Count - 1, InnerHeight div 24);
1914 ScrollBar.SetPos(sbPos);
1915 BackBtn.Visible := HistItems.Count > 1;
1916 TopBtn.Visible := (HistItems.Count > 1) or (Kind <> hkMisc) or (no <> miscMain);
1917 Sel := -1;
1918 end; // with MainText
1919end;
1920
1921procedure THelpDlg.ShowNewContent(NewMode, Category, Index: Integer);
1922begin
1923 if (Category <> Kind) or (Index <> no) or (Category = hkMisc) and
1924 (Index = miscSearchResult) then begin
1925 if HistItems.Count = MaxHist then HistItems.Delete(0);
1926 if HistItems.Count = 0 then
1927 HistItems.AddNew(Category, Index, ScrollBar.Position, NewSearchContent)
1928 else HistItems.AddNew(Kind, No, ScrollBar.Position, SearchContent);
1929 end;
1930 Kind := Category;
1931 no := Index;
1932 SearchContent := NewSearchContent;
1933 Prepare;
1934 OffscreenPaint;
1935 inherited ShowNewContent(NewMode);
1936end;
1937
1938procedure THelpDlg.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState;
1939 x, y: integer);
1940var
1941 i0, Sel0: Integer;
1942begin
1943 y := y - WideFrame;
1944 i0 := ScrollBar.Position;
1945 Sel0 := Sel;
1946 if (x >= SideFrame) and (x < SideFrame + InnerWidth) and (y >= 0) and
1947 (y < InnerHeight) and (y mod 24 >= 8) then
1948 Sel := y div 24
1949 else
1950 Sel := -1;
1951 if (Sel + i0 >= MainText.Count) or (Sel >= 0) and
1952 (THelpLineInfo(MainText.Objects[Sel + i0]).Link = 0) then
1953 Sel := -1;
1954 if Sel <> Sel0 then
1955 begin
1956 if Sel0 <> -1 then
1957 Line(Canvas, Sel0, False);
1958 if Sel <> -1 then
1959 Line(Canvas, Sel, True)
1960 end
1961end;
1962
1963procedure THelpDlg.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
1964 Shift: TShiftState; x, y: integer);
1965begin
1966 if Sel >= 0 then
1967 with THelpLineInfo(MainText.Objects[Sel + ScrollBar.Position]) do
1968 if Link shr 8 and $3F = hkInternet then
1969 case Link and $FF of
1970 1: OpenDocument(HomeDir + AITemplateFileName);
1971 2: OpenURL(CevoHomepage);
1972 3: OpenURL(CevoContact);
1973 end
1974 else
1975 begin
1976 if (Link >= $8000) and (Link and $3FFF = liInvalid) then
1977 exit; // invalid link;
1978 if Link >= $8000 then
1979 ShowNewContent(FWindowMode, hkText, Link and $3FFF)
1980 else
1981 ShowNewContent(FWindowMode, Link shr 8 and $3F, Link and $FF);
1982 end
1983end;
1984
1985procedure THelpDlg.BackBtnClick(Sender: TObject);
1986var
1987 HistItem: THistItem;
1988begin
1989 if HistItems.Count > 1 then begin
1990 HistItem := THistItem.Create;
1991 HistItem.Assign(HistItems.Last);
1992 HistItems.Delete(HistItems.Count - 1);
1993 if (HistItem.Kind = hkMisc) and (HistItem.No = miscSearchResult) and
1994 (HistItem.SearchContent <> SearchContent) then
1995 begin
1996 SearchContent := HistItem.SearchContent;
1997 Search(SearchContent);
1998 end;
1999 Kind := HistItem.Kind;
2000 no := HistItem.No;
2001 Prepare(HistItem.Pos);
2002 OffscreenPaint;
2003 Invalidate;
2004 FreeAndNil(HistItem);
2005 end;
2006end;
2007
2008procedure THelpDlg.TopBtnClick(Sender: TObject);
2009begin
2010 while HistItems.Count > 1 do HistItems.Delete(HistItems.Count - 1);
2011 Kind := hkMisc;
2012 no := miscMain;
2013 Prepare;
2014 OffscreenPaint;
2015 Invalidate;
2016end;
2017
2018procedure THelpDlg.FormClose(Sender: TObject; var Action: TCloseAction);
2019begin
2020 ExtPic.Height := 0;
2021 inherited;
2022end;
2023
2024function THelpDlg.TextIndex(Item: string): Integer;
2025begin
2026 Result := HelpText.Gethandle(Item)
2027end;
2028
2029procedure THelpDlg.FormKeyDown(Sender: TObject; var Key: Word;
2030 Shift: TShiftState);
2031begin
2032 if KeyToShortCut(Key, Shift) = BHelp.ShortCut then // my key
2033 else
2034 inherited;
2035end;
2036
2037procedure THelpDlg.SearchBtnClick(Sender: TObject);
2038begin
2039 InputDlg.Caption := Phrases.Lookup('SEARCH');
2040 InputDlg.EInput.Text := SearchContent;
2041 InputDlg.CenterToRect(BoundsRect);
2042 InputDlg.ShowModal;
2043 if (InputDlg.ModalResult = mrOK) and (Length(InputDlg.EInput.Text) >= 2) then
2044 begin
2045 Search(InputDlg.EInput.Text);
2046 case SearchResult.Count of
2047 0:
2048 SimpleMessage(Format(HelpText.Lookup('NOMATCHES'),
2049 [InputDlg.EInput.Text]));
2050 1:
2051 with THelpLineInfo(SearchResult.Objects[0]) do
2052 if Link >= $8000 then
2053 ShowNewContent(FWindowMode, hkText, Link and $3FFF)
2054 else
2055 ShowNewContent(FWindowMode, Link shr 8 and $3F, Link and $FF);
2056 else
2057 begin
2058 NewSearchContent := InputDlg.EInput.Text;
2059 ShowNewContent(FWindowMode, hkMisc, miscSearchResult);
2060 end;
2061 end;
2062 end;
2063end;
2064
2065procedure THelpDlg.Search(SearchString: string);
2066var
2067 h, i, PrevHandle, PrevIndex, p, RightMargin: Integer;
2068 s: string;
2069 mADVHELP, mIMPHELP, mFEATUREHELP: set of 0 .. 255;
2070 bGOVHELP, bSPECIALMODEL, bJOBHELP: Boolean;
2071begin
2072 SearchResult.Clear;
2073 mADVHELP := [];
2074 mIMPHELP := [];
2075 mFEATUREHELP := [];
2076 bGOVHELP := False;
2077 bSPECIALMODEL := False;
2078 bJOBHELP := False;
2079
2080 // search in generic reference
2081 SearchString := UpperCase(SearchString);
2082 for i := 0 to 35 + 4 do begin
2083 s := Phrases.Lookup('TERRAIN', i);
2084 if pos(SearchString, UpperCase(s)) > 0 then
2085 if i < 36 then
2086 SearchResult.AddLine(s + ' ' + HelpText.Lookup('HELPSPEC_TER'),
2087 pkNormal, 0, hkTer + hkCrossLink, i)
2088 else
2089 begin
2090 SearchResult.AddLine(Phrases.Lookup('TERRAIN', 36) + ' ' +
2091 HelpText.Lookup('HELPSPEC_TER'), pkNormal, 0,
2092 hkTer + hkCrossLink, 36);
2093 if i > 36 then
2094 SearchResult.AddLine(Phrases.Lookup('IMPROVEMENTS',
2095 imShipComp + i - 37) + ' ' + HelpText.Lookup('HELPSPEC_SHIPPART'),
2096 pkNormal, 0, hkImp + hkCrossLink, imShipComp + i - 37);
2097 Break;
2098 end;
2099 end;
2100 for i := 0 to nJobHelp - 1 do
2101 if pos(SearchString, UpperCase(Phrases.Lookup('JOBRESULT', JobHelp[i]))) > 0
2102 then
2103 begin
2104 SearchResult.AddLine(HelpText.Lookup('HELPTITLE_JOBLIST'), pkNormal, 0,
2105 hkMisc + hkCrossLink, miscJobList);
2106 bJOBHELP := True;
2107 Break;
2108 end;
2109 for i := 0 to nAdv - 1 do
2110 begin
2111 s := Phrases.Lookup('ADVANCES', i);
2112 if pos(SearchString, UpperCase(s)) > 0 then
2113 begin
2114 if i in FutureTech then
2115 s := s + ' ' + HelpText.Lookup('HELPSPEC_FUTURE')
2116 else
2117 s := s + ' ' + HelpText.Lookup('HELPSPEC_ADV');
2118 SearchResult.AddLine(s, pkNormal, 0, hkAdv + hkCrossLink, i);
2119 include(mADVHELP, i);
2120 end;
2121 end;
2122 for i := 0 to nSpecialModel - 1 do
2123 begin
2124 FindStdModelPicture(SpecialModelPictureCode[i], h, s);
2125 if pos(SearchString, UpperCase(s)) > 0 then
2126 begin
2127 SearchResult.AddLine(HelpText.Lookup('HELPTITLE_MODELLIST'), pkNormal, 0,
2128 hkModel + hkCrossLink, 0);
2129 bSPECIALMODEL := True;
2130 Break;
2131 end;
2132 end;
2133 for i := 0 to nFeature - 1 do
2134 begin
2135 s := Phrases.Lookup('FEATURES', i);
2136 if Pos(SearchString, UpperCase(s)) > 0 then
2137 begin
2138 if i < mcFirstNonCap then
2139 s := s + ' ' + HelpText.Lookup('HELPSPEC_CAP')
2140 else if i in AutoFeature then
2141 s := s + ' ' + HelpText.Lookup('HELPSPEC_STANDARD')
2142 else
2143 s := s + ' ' + HelpText.Lookup('HELPSPEC_FEATURE');
2144 SearchResult.AddLine(s, pkNormal, 0, hkFeature + hkCrossLink, i);
2145 Include(mFEATUREHELP, i);
2146 end;
2147 end;
2148 for i := 0 to nImp - 1 do
2149 begin
2150 s := Phrases.Lookup('IMPROVEMENTS', i);
2151 if Pos(SearchString, UpperCase(s)) > 0 then
2152 begin
2153 case Imp[i].Kind of
2154 ikWonder:
2155 s := s + ' ' + HelpText.Lookup('HELPSPEC_WONDER');
2156 ikCommon:
2157 s := s + ' ' + HelpText.Lookup('HELPSPEC_IMP');
2158 ikShipPart:
2159 s := s + ' ' + HelpText.Lookup('HELPSPEC_SHIPPART');
2160 else
2161 s := s + ' ' + HelpText.Lookup('HELPSPEC_NAT')
2162 end;
2163 SearchResult.AddLine(s, pkNormal, 0, hkImp + hkCrossLink, i);
2164 Include(mIMPHELP, i);
2165 end
2166 end;
2167 for i := 0 to nGov - 1 do
2168 if Pos(SearchString, UpperCase(Phrases.Lookup('GOVERNMENT', i))) > 0 then
2169 begin
2170 SearchResult.AddLine(HelpText.Lookup('HELPTITLE_GOVLIST'), pkNormal, 0,
2171 hkMisc + hkCrossLink, miscGovList);
2172 bGOVHELP := True;
2173 Break;
2174 end;
2175
2176 // full text search
2177 h := -1;
2178 repeat
2179 PrevHandle := h;
2180 PrevIndex := i;
2181 if not HelpText.Search(SearchString, h, i) then
2182 Break;
2183 if h = hADVHELP then
2184 begin
2185 if (i >= 0) and ((i <> PrevIndex) or (h <> PrevHandle)) and
2186 not(i in mADVHELP) then
2187 begin
2188 s := Phrases.Lookup('ADVANCES', i);
2189 if i in FutureTech then
2190 s := s + ' ' + HelpText.Lookup('HELPSPEC_FUTURE')
2191 else
2192 s := s + ' ' + HelpText.Lookup('HELPSPEC_ADV');
2193 SearchResult.AddLine(s, pkNormal, 0, hkAdv + hkCrossLink, i)
2194 end;
2195 end
2196 else if h = hIMPHELP then
2197 begin
2198 if (i >= 0) and ((i <> PrevIndex) or (h <> PrevHandle)) and
2199 not(i in mIMPHELP) then
2200 begin
2201 s := Phrases.Lookup('IMPROVEMENTS', i);
2202 case Imp[i].Kind of
2203 ikWonder:
2204 s := s + ' ' + HelpText.Lookup('HELPSPEC_WONDER');
2205 ikCommon:
2206 s := s + ' ' + HelpText.Lookup('HELPSPEC_IMP');
2207 ikShipPart:
2208 s := s + ' ' + HelpText.Lookup('HELPSPEC_SHIPPART');
2209 else
2210 s := s + ' ' + HelpText.Lookup('HELPSPEC_NAT')
2211 end;
2212 SearchResult.AddLine(s, pkNormal, 0, hkImp + hkCrossLink, i)
2213 end;
2214 end
2215 else if h = hFEATUREHELP then
2216 begin
2217 if (i >= 0) and ((i <> PrevIndex) or (h <> PrevHandle)) and
2218 not(i in mFEATUREHELP) then
2219 begin
2220 s := Phrases.Lookup('FEATURES', i);
2221 if i < mcFirstNonCap then
2222 s := s + ' ' + HelpText.Lookup('HELPSPEC_CAP')
2223 else if i in AutoFeature then
2224 s := s + ' ' + HelpText.Lookup('HELPSPEC_STANDARD')
2225 else
2226 s := s + ' ' + HelpText.Lookup('HELPSPEC_FEATURE');
2227 SearchResult.AddLine(s, pkNormal, 0, hkFeature + hkCrossLink, i);
2228 end;
2229 end
2230 else if h = hGOVHELP then
2231 begin
2232 if (i >= 0) and (h <> PrevHandle) and not bGOVHELP then
2233 SearchResult.AddLine(HelpText.Lookup('HELPTITLE_GOVLIST'), pkNormal, 0,
2234 hkMisc + hkCrossLink, miscGovList)
2235 end
2236 else if h = hSPECIALMODEL then
2237 begin
2238 if (i >= 0) and (h <> PrevHandle) and not bSPECIALMODEL then
2239 SearchResult.AddLine(HelpText.Lookup('HELPTITLE_MODELLIST'), pkNormal,
2240 0, hkModel + hkCrossLink, 0)
2241 end
2242 else if h = hJOBHELP then
2243 begin
2244 if (i >= 0) and (h <> PrevHandle) and not bJOBHELP then
2245 SearchResult.AddLine(HelpText.Lookup('HELPTITLE_JOBLIST'), pkNormal, 0,
2246 hkMisc + hkCrossLink, miscJobList)
2247 end
2248 else if { (h<>hMAIN) and } (h <> PrevHandle) then
2249 begin
2250 s := HelpText.LookupByHandle(h);
2251 p := Pos('$', s);
2252 if p > 0 then
2253 begin
2254 s := Copy(s, p + 1, maxint);
2255 p := Pos('\', s);
2256 if p > 0 then
2257 s := Copy(s, 1, p - 1);
2258 SearchResult.AddLine(s, pkNormal, 0, hkText + hkCrossLink, h);
2259 end;
2260 end;
2261 until False;
2262
2263 // cut lines to fit to window
2264 RightMargin := InnerWidth - 16 - GetSystemMetrics(SM_CXVSCROLL);
2265 OffScreen.Canvas.Font.Assign(UniFont[ftNormal]);
2266 for i := 0 to SearchResult.Count - 1 do
2267 begin
2268 while BiColorTextWidth(OffScreen.Canvas, SearchResult[i]) >
2269 RightMargin - 32 do
2270 SearchResult[i] := copy(SearchResult[i], 1, length(SearchResult[i]) - 1)
2271 end;
2272 end;
2273
2274end.
Note: See TracBrowser for help on using the repository browser.