Changeset 210 for branches/highdpi/LocalPlayer/Help.pas
- Timestamp:
- May 9, 2020, 4:02:07 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/LocalPlayer/Help.pas
r193 r210 5 5 6 6 uses 7 Protocol, ScreenTools, BaseWin, StringTables, Math, UDpiControls,8 LCLIntf, LCLType, LMessages, Messages, SysUtils, Classes, Graphics, Controls, Forms,9 ExtCtrls, ButtonB, PVSB, Types;7 UDpiControls, Protocol, ScreenTools, BaseWin, StringTables, Math, LCLIntf, LCLType, 8 Messages, SysUtils, Classes, Graphics, Controls, Forms, ExtCtrls, 9 ButtonB, PVSB, Types, fgl; 10 10 11 11 const … … 41 41 THyperText = class(TStringList) 42 42 public 43 procedure AddLine(s: String = ''; Format: integer = 0; Picpix: integer = 0;43 procedure AddLine(s: String = ''; Format: integer = 0; Picpix: Integer = 0; 44 44 LinkCategory: integer = 0; LinkIndex: integer = 0); 45 procedure LF; 45 procedure LineFeed; 46 procedure AppendList(Source: THyperText); 46 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; 47 64 end; 48 65 … … 72 89 procedure OffscreenPaint; override; 73 90 private 74 Kind, no, Sel, nHist, CaptionColor: integer; 75 hADVHELP, hIMPHELP, hFEATUREHELP, hGOVHELP, hSPECIALMODEL, 76 hJOBHELP: integer; 77 SearchContent, NewSearchContent: string; 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; 78 98 CaptionFont: TDpiFont; 79 MainText, SearchResult: THyperText; 99 MainText: THyperText; 100 SearchResult: THyperText; 80 101 HelpText: TStringTable; 81 102 ExtPic, TerrIcon: TDpiBitmap; 82 sb: TPVScrollbar; 83 x0: array [-2 .. 180] of integer; 84 HistKind: array [0 .. MaxHist - 1] of integer; 85 HistNo: array [0 .. MaxHist - 1] of integer; 86 HistPos: array [0 .. MaxHist - 1] of integer; 87 HistSearchContent: array [0 .. MaxHist - 1] of shortstring; 103 ScrollBar: TPVScrollbar; 104 x0: array [-2..180] of Integer; 105 procedure PaintTerrIcon(x, y, xSrc, ySrc: Integer); 88 106 procedure ScrollBarUpdate(Sender: TObject); 89 procedure line(ca: TDpiCanvas; i: integer; lit: boolean); 90 procedure Prepare(sbPos: integer = 0); 91 procedure WaterSign(x0, y0, iix: integer); 107 procedure Line(ca: TDpiCanvas; i: Integer; lit: Boolean); 108 procedure Prepare(sbPos: Integer = 0); 109 procedure ShowNewContentProcExecute(NewMode: Integer; HelpContext: string); 110 procedure WaterSign(x0, y0, iix: Integer); 92 111 procedure Search(SearchString: string); 93 112 procedure OnScroll(var m: TMessage); message WM_VSCROLL; 94 113 procedure OnMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE; 95 114 public 96 Difficulty: integer;97 procedure ShowNewContent(NewMode, Category, Index: integer);115 HistItems: THistItems; 116 Difficulty: Integer; 98 117 procedure ClearHistory; 99 function TextIndex(Item: string): integer; 118 procedure ShowNewContent(NewMode, Category, Index: Integer); 119 function TextIndex(Item: string): Integer; 100 120 end; 101 121 … … 103 123 HelpDlg: THelpDlg; 104 124 125 105 126 implementation 106 127 107 128 uses 108 Directories, ClientTools, Term, Tribes, Inp, Messg ;129 Directories, ClientTools, Term, Tribes, Inp, Messg, UPixelPointer, Global; 109 130 110 131 {$R *.lfm} 111 132 112 133 type 134 135 { THelpLineInfo } 136 113 137 THelpLineInfo = class 114 Format, Picpix: Byte; 138 Format: Byte; 139 Picpix: Byte; 115 140 Link: Word; 116 end; 141 procedure Assign(Source: THelpLineInfo); 142 end; 143 144 { THelpLineInfo } 145 146 procedure THelpLineInfo.Assign(Source: THelpLineInfo); 147 begin 148 Format := Source.Format; 149 PicPix := Source.PicPix; 150 Link := Source.Link; 151 end; 152 153 { THistItem } 154 155 procedure THistItem.Assign(Source: THistItem); 156 begin 157 Kind := Source.Kind; 158 No := Source.No; 159 Pos := Source.Pos; 160 SearchContent := Source.SearchContent; 161 end; 162 163 { THistItems } 164 165 function THistItems.AddNew(Kind, No, Pos: Integer; SearchContent: string 166 ): THistItem; 167 begin 168 Result := THistItem.Create; 169 Result.Kind := Kind; 170 Result.No := No; 171 Result.Pos := Pos; 172 Result.SearchContent := SearchContent; 173 Add(Result); 174 end; 117 175 118 176 procedure THyperText.AddLine(s: String; Format: integer; Picpix: integer; … … 130 188 end; 131 189 132 procedure THyperText.L F;190 procedure THyperText.LineFeed; 133 191 begin 134 192 AddLine; 193 end; 194 195 procedure THyperText.AppendList(Source: THyperText); 196 var 197 I: Integer; 198 HelpLineInfo: THelpLineInfo; 199 begin 200 for I := 0 to Source.Count - 1 do begin 201 HelpLineInfo := THelpLineInfo.Create; 202 HelpLineInfo.Assign(THelpLineInfo(Source.Objects[I])); 203 AddObject(Source.Strings[I], HelpLineInfo); 204 end; 135 205 end; 136 206 … … 198 268 begin 199 269 inherited; 270 HistItems := THistItems.Create; 271 200 272 CaptionLeft := BackBtn.Left + BackBtn.Width; 201 273 CaptionRight := SearchBtn.Left; … … 205 277 SearchResult := THyperText.Create; 206 278 SearchResult.OwnsObjects := True; 207 sb:= TPVScrollbar.Create(Self);208 sb.SetBorderSpacing(36, 9, 11);209 sb.OnUpdate := ScrollBarUpdate;279 ScrollBar := TPVScrollbar.Create(Self); 280 ScrollBar.SetBorderSpacing(36, 9, 11); 281 ScrollBar.OnUpdate := ScrollBarUpdate; 210 282 211 283 HelpText := TStringTable.Create; … … 218 290 hJOBHELP := HelpText.Gethandle('JOBHELP'); 219 291 220 CaptionFont := TDpiFont.Create;292 CaptionFont := Font.Create; 221 293 CaptionFont.Assign(UniFont[ftNormal]); 222 294 CaptionFont.Style := CaptionFont.Style + [fsItalic, fsBold]; … … 233 305 TerrIcon.Canvas.FillRect(0, 0, TerrIcon.Width, TerrIcon.Height); 234 306 SearchContent := ''; 235 nHist := -1; 236 end; 237 238 procedure THelpDlg.ClearHistory; 239 begin 240 nHist := -1; 307 ShowNewContentProc := ShowNewContentProcExecute; 308 end; 309 310 procedure THelpDlg.ShowNewContentProcExecute(NewMode: Integer; 311 HelpContext: string); 312 begin 313 HelpDlg.ShowNewContent(NewMode, hkText, 314 HelpDlg.TextIndex(HelpContext)) 241 315 end; 242 316 243 317 procedure THelpDlg.FormDestroy(Sender: TObject); 244 318 begin 245 FreeAndNil(sb); 319 ShowNewContentProc := nil; 320 FreeAndNil(ScrollBar); 246 321 FreeAndNil(MainText); 247 322 FreeAndNil(SearchResult); … … 250 325 FreeAndNil(HelpText); 251 326 // FreeAndNil(CaptionFont); 327 FreeAndNil(HistItems); 252 328 end; 253 329 … … 255 331 WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); 256 332 begin 257 if sb.ProcessMouseWheel(WheelDelta) then begin333 if ScrollBar.ProcessMouseWheel(WheelDelta) then begin 258 334 PaintBox1MouseMove(nil, [], MousePos.X - Left, 259 335 MousePos.Y - Top); … … 269 345 begin 270 346 { TODO: Handled by MouseWheel event 271 if sb.Process(m) then begin347 if ScrollBar.Process(m) then begin 272 348 Sel := -1; 273 349 SmartUpdateContent(true) … … 279 355 begin 280 356 if Sel <> -1 then begin 281 line(Canvas, Sel, false);357 Line(Canvas, Sel, false); 282 358 Sel := -1 283 359 end 284 360 end; 285 361 362 procedure THelpDlg.ClearHistory; 363 begin 364 HistItems.Clear; 365 end; 366 286 367 procedure THelpDlg.FormPaint(Sender: TObject); 287 368 begin … … 290 371 end; 291 372 292 procedure THelpDlg. line(ca: TDpiCanvas; i: integer; lit: boolean);373 procedure THelpDlg.Line(ca: TDpiCanvas; i: Integer; lit: Boolean); 293 374 var 294 TextColor, x, y: integer;375 TextColor, x, y: Integer; 295 376 TextSize: TSize; 296 377 s: string; 297 378 begin 298 s := MainText[ sb.Position + i];379 s := MainText[ScrollBar.Position + i]; 299 380 if s = '' then 300 exit;381 Exit; 301 382 x := x0[i]; 302 383 y := 2 + i * 24; … … 306 387 y := y + WideFrame 307 388 end; 308 if THelpLineInfo(MainText.Objects[ sb.Position + i]).Format389 if THelpLineInfo(MainText.Objects[ScrollBar.Position + i]).Format 309 390 in [pkCaption, pkBigTer, pkRightIcon, pkBigFeature] then 310 391 begin … … 315 396 ca.FrameRect(rect(x+1,i*24+1,x+24-1,i*24+24-1)); 316 397 ca.Brush.Style:=bsClear; } 317 DpiBit Blt(ca.Handle, x, y - 4, 24, 24, GrExt[HGrSystem].Data.Canvas.Handle, 1,318 146 , SRCCOPY);398 DpiBitCanvas(ca, x, y - 4, 24, 24, GrExt[HGrSystem].Data.Canvas, 1, 399 146); 319 400 BiColorTextOut(ca, $FFFFFF, $7F007F, x + 10 - ca.Textwidth(s[1]) div 2, 320 401 y - 3, s[1]); … … 322 403 ca.Font.Assign(UniFont[ftNormal]); 323 404 end 324 else if THelpLineInfo(MainText.Objects[ sb.Position + i]).Format = pkSection405 else if THelpLineInfo(MainText.Objects[ScrollBar.Position + i]).Format = pkSection 325 406 then 326 407 begin … … 341 422 TextSize.cy := WideFrame + InnerHeight - y; 342 423 FillSeamless(ca, x, y, TextSize.cx, TextSize.cy, -SideFrame, 343 sb.Position * 24 - WideFrame, Paper);424 ScrollBar.Position * 24 - WideFrame, Paper); 344 425 end; 345 426 BiColorTextOut(ca, TextColor, $7F007F, x, y, s); … … 347 428 with ca do 348 429 begin 349 assert(ca = Canvas);350 pen.color := TextColor;351 moveto(x + 1, y + TextSize.cy - 2);352 lineto(x + TextSize.cx, y + TextSize.cy - 2);430 Assert(ca = Canvas); 431 Pen.Color := TextColor; 432 MoveTo(x + 1, y + TextSize.cy - 2); 433 LineTo(x + TextSize.cx, y + TextSize.cy - 2); 353 434 end; 354 435 if (Kind = hkMisc) and (no = miscMain) then … … 363 444 var 364 445 x, y, dx, dy, xSrc, ySrc, sum, xx: integer; 365 Heaven: array [0 ..nHeaven] of integer;446 Heaven: array [0..nHeaven] of integer; 366 447 PaintPtr, CoalPtr: TPixelPointer; 367 ImpPtr: array [-1 .. 1] of TPixelPointer; 368 begin 369 { TODO 448 ImpPtr: array [-1..1] of TPixelPointer; 449 begin 370 450 // assume eiffel tower has free common heaven 371 451 for dy := 0 to nHeaven - 1 do … … 377 457 xSrc := iix mod 7 * xSizeBig; 378 458 ySrc := (iix div 7 + 1) * ySizeBig; 379 for y := 0 to ScaleToVcl(ySizeBig * 2)- 1 do459 for y := 0 to ySizeBig * 2 - 1 do 380 460 if ((y0 + y) >= 0) and ((y0 + y) < InnerHeight) then begin 381 PaintPtr .Init(OffScreen, 0, ScaleToVcl(y0 + y));382 CoalPtr .Init(Templates, 0, ScaleToVcl(yCoal + y));461 PaintPtr := PixelPointer(OffScreen, 0, y0 + y); 462 CoalPtr := PixelPointer(Templates, 0, yCoal + y); 383 463 for dy := -1 to 1 do 384 464 if ((Max(y + dy, 0) shr 1) >= 0) and ((Max(y + dy, 0) shr 1) < ySizeBig) then 385 ImpPtr[dy] .Init(BigImp, 0, ScaleToVcl(ySrc + (Max(y + dy, 0) shr 1)));386 for x := 0 to ScaleToVcl(xSizeBig * 2)- 1 do begin465 ImpPtr[dy] := PixelPointer(BigImp, 0, ySrc + (Max(y + dy, 0) shr 1)); 466 for x := 0 to xSizeBig * 2 - 1 do begin 387 467 sum := 0; 388 468 for dx := -1 to 1 do begin … … 413 493 Offscreen.EndUpdate; 414 494 BigImp.EndUpdate; 415 } 495 end; 496 497 procedure THelpDlg.PaintTerrIcon(x, y, xSrc, ySrc: integer); 498 begin 499 Frame(OffScreen.Canvas, x - 1, y - 1, x + xSizeBig, y + ySizeBig, 500 $000000, $000000); 501 if 2 * yyt < 40 then begin 502 Sprite(OffScreen, HGrTerrain, x, y, 56, 2 * yyt, xSrc, ySrc); 503 Sprite(OffScreen, HGrTerrain, x, y + 2 * yyt, 56, 40 - 2 * yyt, 504 xSrc, ySrc); 505 end else 506 Sprite(OffScreen, HGrTerrain, x, y, 56, 40, xSrc, ySrc); 507 Sprite(OffScreen, HGrTerrain, x, y, xxt, yyt, xSrc + xxt, ySrc + yyt); 508 Sprite(OffScreen, HGrTerrain, x, y + yyt, xxt, 40 - yyt, xSrc + xxt, ySrc); 509 Sprite(OffScreen, HGrTerrain, x + xxt, y, 56 - xxt, yyt, xSrc, ySrc + yyt); 510 Sprite(OffScreen, HGrTerrain, x + xxt, y + yyt, 56 - xxt, 40 - yyt, 511 xSrc, ySrc); 416 512 end; 417 513 418 514 procedure THelpDlg.OffscreenPaint; 419 420 procedure PaintTerrIcon(x, y, xSrc, ySrc: integer);421 begin422 Frame(OffScreen.Canvas, x - 1, y - 1, x + xSizeBig, y + ySizeBig,423 $000000, $000000);424 if 2 * yyt < 40 then425 begin426 Sprite(OffScreen, HGrTerrain, x, y, 56, 2 * yyt, xSrc, ySrc);427 Sprite(OffScreen, HGrTerrain, x, y + 2 * yyt, 56, 40 - 2 * yyt,428 xSrc, ySrc);429 end430 else431 Sprite(OffScreen, HGrTerrain, x, y, 56, 40, xSrc, ySrc);432 Sprite(OffScreen, HGrTerrain, x, y, xxt, yyt, xSrc + xxt, ySrc + yyt);433 Sprite(OffScreen, HGrTerrain, x, y + yyt, xxt, 40 - yyt, xSrc + xxt, ySrc);434 Sprite(OffScreen, HGrTerrain, x + xxt, y, 56 - xxt, yyt, xSrc, ySrc + yyt);435 Sprite(OffScreen, HGrTerrain, x + xxt, y + yyt, 56 - xxt, 40 - yyt,436 xSrc, ySrc);437 end;438 439 515 var 440 i, j, yl, srcno, ofs, cnt, y: integer;516 i, j, yl, srcno, ofs, cnt, y: Integer; 441 517 s: string; 442 518 HelpLineInfo: THelpLineInfo; … … 445 521 CaptionColor := Colors.Canvas.Pixels[clkMisc, cliPaperCaption]; 446 522 FillSeamless(OffScreen.Canvas, 0, 0, InnerWidth, InnerHeight, 0, 447 sb.Position * 24, Paper);523 ScrollBar.Position * 24, Paper); 448 524 with OffScreen.Canvas do 449 525 begin 450 526 Font.Assign(UniFont[ftNormal]); 451 for i := - sb.Position to InnerHeight div 24 do452 if sb.Position + i < MainText.Count then527 for i := -ScrollBar.Position to InnerHeight div 24 do 528 if ScrollBar.Position + i < MainText.Count then 453 529 begin 454 HelpLineInfo := THelpLineInfo(MainText.Objects[ sb.Position + i]);530 HelpLineInfo := THelpLineInfo(MainText.Objects[ScrollBar.Position + i]); 455 531 if HelpLineInfo.Format = pkExternal then 456 532 begin … … 458 534 if 4 + i * 24 + yl > InnerHeight then 459 535 yl := InnerHeight - (4 + i * 24); 460 DpiBit Blt(Handle, 8, 4 + i * 24, ExtPic.Width, yl, ExtPic.Canvas.Handle,461 0, 0 , SRCCOPY);536 DpiBitCanvas(OffScreen.Canvas, 8, 4 + i * 24, ExtPic.Width, yl, ExtPic.Canvas, 537 0, 0); 462 538 end; 463 539 end; 464 540 for i := -2 to InnerHeight div 24 do 465 if ( sb.Position + i >= 0) and (sb.Position + i < MainText.Count) then541 if (ScrollBar.Position + i >= 0) and (ScrollBar.Position + i < MainText.Count) then 466 542 begin 467 HelpLineInfo := THelpLineInfo(MainText.Objects[ sb.Position + i]);543 HelpLineInfo := THelpLineInfo(MainText.Objects[ScrollBar.Position + i]); 468 544 if HelpLineInfo.Link <> 0 then 469 545 begin … … 499 575 8 + xSizeSmall + x0[i], 2 + 20 + i * 24, $000000, $000000); 500 576 if HelpLineInfo.Picpix = imPalace then 501 DpiBit Blt(OffScreen.Canvas.Handle, 8 + x0[i], 2 + i * 24,502 xSizeSmall, ySizeSmall, SmallImp.Canvas .Handle,503 0 * xSizeSmall, 1 * ySizeSmall , SRCCOPY)577 DpiBitCanvas(OffScreen.Canvas, 8 + x0[i], 2 + i * 24, 578 xSizeSmall, ySizeSmall, SmallImp.Canvas, 579 0 * xSizeSmall, 1 * ySizeSmall) 504 580 else 505 DpiBit Blt(OffScreen.Canvas.Handle, 8 + x0[i], 2 + i * 24,506 xSizeSmall, ySizeSmall, SmallImp.Canvas .Handle,581 DpiBitCanvas(OffScreen.Canvas, 8 + x0[i], 2 + i * 24, 582 xSizeSmall, ySizeSmall, SmallImp.Canvas, 507 583 HelpLineInfo.Picpix mod 7 * xSizeSmall, 508 584 (HelpLineInfo.Picpix + SystemIconLines * 7) div 7 * 509 ySizeSmall , SRCCOPY);585 ySizeSmall); 510 586 x0[i] := x0[i] + (8 + 8 + 36); 511 587 end; … … 566 642 $000000, $000000); 567 643 if AdvIcon[HelpLineInfo.Picpix] < 84 then 568 DpiBit Blt(OffScreen.Canvas.Handle, 8 + x0[i], 2 + i * 24,569 xSizeSmall, ySizeSmall, SmallImp.Canvas .Handle,644 DpiBitCanvas(OffScreen.Canvas, 8 + x0[i], 2 + i * 24, 645 xSizeSmall, ySizeSmall, SmallImp.Canvas, 570 646 (AdvIcon[HelpLineInfo.Picpix] + SystemIconLines * 7) mod 7 * 571 647 xSizeSmall, (AdvIcon[HelpLineInfo.Picpix] + SystemIconLines * 572 7) div 7 * ySizeSmall , SRCCOPY)648 7) div 7 * ySizeSmall) 573 649 else 574 650 Dump(OffScreen, HGrSystem, 8 + x0[i], 2 + i * 24, 36, 20, … … 576 652 295 + (AdvIcon[HelpLineInfo.Picpix] - 84) div 8 * 21); 577 653 j := AdvValue[HelpLineInfo.Picpix] div 1000; 578 DpiBit Blt(Handle, x0[i] + 4, 4 + i * 24, 14, 14,579 GrExt[HGrSystem].Mask.Canvas .Handle, 127 + j * 15, 85, SRCAND);654 DpiBitCanvas(OffScreen.Canvas, x0[i] + 4, 4 + i * 24, 14, 14, 655 GrExt[HGrSystem].Mask.Canvas, 127 + j * 15, 85, SRCAND); 580 656 Sprite(OffScreen, HGrSystem, x0[i] + 3, 3 + i * 24, 14, 14, 581 657 127 + j * 15, 85); … … 753 829 ScreenTools.Frame(OffScreen.Canvas, 8 - 1 + x0[i], 2 - 1 + i * 24, 754 830 8 + xSizeSmall + x0[i], 2 + 20 + i * 24, $000000, $000000); 755 DpiBit Blt(OffScreen.Canvas.Handle, 8 + x0[i], 2 + i * 24, xSizeSmall,756 ySizeSmall, SmallImp.Canvas .Handle, (HelpLineInfo.Picpix - 1) *757 xSizeSmall, ySizeSmall , SRCCOPY);831 DpiBitCanvas(OffScreen.Canvas, 8 + x0[i], 2 + i * 24, xSizeSmall, 832 ySizeSmall, SmallImp.Canvas, (HelpLineInfo.Picpix - 1) * 833 xSizeSmall, ySizeSmall); 758 834 x0[i] := x0[i] + (8 + 8 + 36); 759 835 end; … … 769 845 x0[i] := 64 + 8 + 8; 770 846 else 771 x0[i] := x0[i] + 8 847 x0[i] := x0[i] + 8; 772 848 end; 773 Self. line(OffScreen.Canvas, i, false)849 Self.Line(OffScreen.Canvas, i, False) 774 850 end; 775 851 end; 776 852 MarkUsedOffscreen(InnerWidth, InnerHeight + 13 + 48); 777 end; { OffscreenPaint }853 end; 778 854 779 855 procedure THelpDlg.ScrollBarUpdate(Sender: TObject); … … 785 861 procedure THelpDlg.Prepare(sbPos: integer = 0); 786 862 var 787 i, j, special, Domain, Headline, TerrType, TerrSubType: integer;863 i, j, Special, Domain, Headline, TerrType, TerrSubType: integer; 788 864 s: string; 789 865 ps: pchar; 790 866 List: THyperText; 791 CheckSeeAlso: boolean;792 793 procedure AddAdv (i: integer);867 CheckSeeAlso: Boolean; 868 869 procedure AddAdvance(i: integer); 794 870 begin 795 871 MainText.AddLine(Phrases.Lookup('ADVANCES', i), pkAdvIcon, i, … … 803 879 end; 804 880 805 procedure AddImp (i: integer);881 procedure AddImprovement(i: integer); 806 882 begin 807 883 MainText.AddLine(Phrases.Lookup('IMPROVEMENTS', i), pkSmallIcon, i, … … 815 891 end; 816 892 817 procedure AddTer (i: integer);893 procedure AddTerrain(i: integer); 818 894 begin 819 895 if MainText.Count > 1 then 820 896 begin 821 MainText.L F;897 MainText.LineFeed; 822 898 end; 823 899 MainText.AddLine(Phrases.Lookup('TERRAIN', i), pkTer, i, hkTer, i); … … 836 912 begin 837 913 if MainText.Count > 1 then 838 MainText.L F;914 MainText.LineFeed; 839 915 FindStdModelPicture(SpecialModelPictureCode[i], pix, Name); 840 916 MainText.AddLine(Name, pkModel, pix, hkModel + hkCrossLink, i) … … 850 926 begin 851 927 AddLine('', pkLogo); 852 L F;928 LineFeed; 853 929 end 854 930 else if Item = 'TECHFORMULA' then … … 866 942 for i := 1 to 3 do 867 943 begin 868 L F;944 LineFeed; 869 945 AddLine(Phrases.Lookup('TERRAIN', 3 * 12 + i), pkTer, 3 * 12 + i); 870 946 end … … 877 953 end; 878 954 879 procedure DecodeItem(s: string; var Category, Index: integer);955 procedure DecodeItem(s: string; var Category, Index: Integer); 880 956 var 881 i: integer; 882 begin 883 if (length(s) > 0) and (s[1] = ':') then 884 begin 957 i: Integer; 958 begin 959 if (Length(s) > 0) and (s[1] = ':') then begin 885 960 Category := hkMisc; 886 961 Index := 0; 887 962 for i := 3 to length(s) do 888 Index := Index * 10 + ord(s[i]) - 48;963 Index := Index * 10 + Ord(s[i]) - 48; 889 964 case s[2] of 890 'A': 891 Category := hkAdv; 892 'B': 893 Category := hkImp; 894 'T': 895 Category := hkTer; 896 'F': 897 Category := hkFeature; 898 'E': 899 Category := hkInternet; 900 'S': 901 Category := hkModel; 902 'C': 903 Index := miscCredits; 904 'J': 905 Index := miscJobList; 906 'G': 907 Index := miscGovList; 965 'A': Category := hkAdv; 966 'B': Category := hkImp; 967 'T': Category := hkTer; 968 'F': Category := hkFeature; 969 'E': Category := hkInternet; 970 'S': Category := hkModel; 971 'C': Index := miscCredits; 972 'J': Index := miscJobList; 973 'G': Index := miscGovList; 908 974 end; 909 975 if (Category <> hkMisc) and (Index = 0) then 910 976 Index := 200; 911 end 912 else 913 begin 977 end else begin 914 978 Category := hkText; 915 Index := HelpText.Gethandle( copy(s, 1, 255));979 Index := HelpText.Gethandle(Copy(s, 1, 255)); 916 980 end; 917 981 end; … … 935 999 repeat 936 1000 inc(p) 937 until (p > length(s)) or (s[p] = '\');938 Caption := copy(s, 2, p - 2);1001 until (p > Length(s)) or (s[p] = '\'); 1002 Caption := Copy(s, 2, p - 2); 939 1003 Delete(s, 1, p); 940 1004 end … … 944 1008 repeat 945 1009 inc(p) 946 until (p > length(s)) or (s[p] = '\');947 AddStandardBlock( copy(s, 2, p - 2));1010 until (p > Length(s)) or (s[p] = '\'); 1011 AddStandardBlock(Copy(s, 2, p - 2)); 948 1012 Delete(s, 1, p); 949 1013 end 950 1014 else if s[1] = '@' then 951 1015 begin // image 952 if ( length(s) >= 2) and (s[2] = '@') then1016 if (Length(s) >= 2) and (s[2] = '@') then 953 1017 begin // generate from icon 954 1018 Picpix := 0; 955 1019 p := 3; 956 while (p <= length(s)) and (s[p] <> '\') do1020 while (p <= Length(s)) and (s[p] <> '\') do 957 1021 begin 958 Picpix := Picpix * 10 + ord(s[p]) - 48;1022 Picpix := Picpix * 10 + Ord(s[p]) - 48; 959 1023 inc(p) 960 1024 end; … … 962 1026 Picpix := 0; 963 1027 MainText.AddLine('', pkIllu, Picpix); 964 MainText.L F;965 MainText.L F;1028 MainText.LineFeed; 1029 MainText.LineFeed; 966 1030 end 967 1031 else … … 969 1033 p := 1; 970 1034 repeat 971 inc(p)972 until (p > length(s)) or (s[p] = '\');1035 Inc(p) 1036 until (p > Length(s)) or (s[p] = '\'); 973 1037 if LoadGraphicFile(ExtPic, LocalizedFilePath('Help' + 974 DirectorySeparator + copy(s, 2, p - 2)) + '.png') then1038 DirectorySeparator + Copy(s, 2, p - 2)) + '.png') then 975 1039 begin 976 1040 MainText.AddLine('', pkExternal); 977 1041 for i := 0 to (ExtPic.Height - 12) div 24 do 978 MainText.L F;1042 MainText.LineFeed; 979 1043 end; 980 1044 end; … … 989 1053 repeat 990 1054 inc(p) 991 until (p > length(s)) or (s[p] = '\') or (s[p] = ' ');992 DecodeItem( copy(s, 2, p - 2), LinkCategory, LinkIndex);1055 until (p > Length(s)) or (s[p] = '\') or (s[p] = ' '); 1056 DecodeItem(Copy(s, 2, p - 2), LinkCategory, LinkIndex); 993 1057 CurrentFormat := 0; 994 1058 if (LinkCategory <> hkText) and (LinkIndex < 200) then … … 1008 1072 begin 1009 1073 CurrentFormat := pkTer; 1010 Picpix := LinkIndex 1074 Picpix := LinkIndex; 1011 1075 end; 1012 1076 hkFeature: … … 1024 1088 if s[1] = ':' then 1025 1089 LinkCategory := LinkCategory + hkCrossLink; 1026 if (p > length(s)) or (s[p] = ' ') then1090 if (p > Length(s)) or (s[p] = ' ') then 1027 1091 Delete(s, 1, p) 1028 1092 else … … 1030 1094 end; 1031 1095 '!': // highlited 1032 if ( length(s) >= 2) and (s[2] = '!') then1096 if (Length(s) >= 2) and (s[2] = '!') then 1033 1097 begin 1034 1098 if MainText.Count > 1 then 1035 MainText.L F;1099 MainText.LineFeed; 1036 1100 FollowFormat := pkCaption; 1037 1101 CurrentFormat := pkCaption; … … 1060 1124 repeat 1061 1125 repeat 1062 inc(p)1063 until (p > length(s)) or (s[p] = ' ') or (s[p] = '\');1064 if (BiColorTextWidth(OffScreen.Canvas, copy(s, 1, p - 1)) <=1126 Inc(p) 1127 until (p > Length(s)) or (s[p] = ' ') or (s[p] = '\'); 1128 if (BiColorTextWidth(OffScreen.Canvas, Copy(s, 1, p - 1)) <= 1065 1129 RightMargin - ofs) then 1066 1130 l := p - 1 1067 1131 else 1068 1132 Break; 1069 until (p >= length(s)) or (s[l + 1] = '\');1070 MainText.AddLine( copy(s, 1, l), CurrentFormat, Picpix, LinkCategory,1133 until (p >= Length(s)) or (s[l + 1] = '\'); 1134 MainText.AddLine(Copy(s, 1, l), CurrentFormat, Picpix, LinkCategory, 1071 1135 LinkIndex); 1072 if (l < length(s)) and (s[l + 1] = '\') then1136 if (l < Length(s)) and (s[l + 1] = '\') then 1073 1137 FollowFormat := pkNormal; 1074 1138 Delete(s, 1, l + 1); … … 1082 1146 end; 1083 1147 1084 procedure AddModelText(i: integer);1148 procedure AddModelText(i: Integer); 1085 1149 var 1086 pix: integer;1150 pix: Integer; 1087 1151 s: string; 1088 1152 begin 1089 with MainText do 1090 begin 1091 if Count > 1 then 1092 begin 1093 LF; 1094 LF; 1153 with MainText do begin 1154 if Count > 1 then begin 1155 LineFeed; 1156 LineFeed; 1095 1157 end; 1096 1158 FindStdModelPicture(SpecialModelPictureCode[i], pix, s); … … 1126 1188 procedure AddJobList; 1127 1189 var 1128 i, JobCost: integer; 1129 begin 1130 with MainText do 1131 begin 1132 for i := 0 to nJobHelp - 1 do 1133 begin 1134 if i > 0 then 1135 begin 1136 LF; 1137 LF 1190 i, JobCost: Integer; 1191 begin 1192 with MainText do begin 1193 for i := 0 to nJobHelp - 1 do begin 1194 if i > 0 then begin 1195 LineFeed; 1196 LineFeed; 1138 1197 end; 1139 1198 AddLine(Phrases.Lookup('JOBRESULT', JobHelp[i]), pkSection); … … 1144 1203 JobCost := -1; 1145 1204 case JobHelp[i] of 1146 jCanal: 1147 JobCost := CanalWork; 1148 jFort: 1149 JobCost := FortWork; 1150 jBase: 1151 JobCost := BaseWork; 1205 jCanal: JobCost := CanalWork; 1206 jFort: JobCost := FortWork; 1207 jBase: JobCost := BaseWork; 1152 1208 end; 1153 1209 if JobCost >= 0 then … … 1156 1212 else 1157 1213 AddTextual(HelpText.Lookup('JOBCOSTVAR')); 1158 if JobPreq[JobHelp[i]] <> preNone then 1159 begin 1214 if JobPreq[JobHelp[i]] <> preNone then begin 1160 1215 AddPreqAdv(JobPreq[JobHelp[i]]); 1161 1216 MainText[Count - 1] := Format(HelpText.Lookup('REQUIRED'), … … 1168 1223 procedure AddGraphicCredits; 1169 1224 var 1170 i: integer;1225 i: Integer; 1171 1226 s: string; 1172 1227 sr: TSearchRec; 1173 List, plus: TStringList;1228 List, Plus: TStringList; 1174 1229 begin 1175 1230 List := TStringList.Create; 1176 plus := TStringList.Create;1177 if FindFirst( HomeDir + 'Graphics'+ DirectorySeparator + '*.credits.txt', $27, sr) = 0 then1231 Plus := TStringList.Create; 1232 if FindFirst(GetGraphicsDir + DirectorySeparator + '*.credits.txt', $27, sr) = 0 then 1178 1233 repeat 1179 plus.LoadFromFile(HomeDir + 'Graphics'+ DirectorySeparator + sr.Name);1180 List.AddStrings( plus);1234 Plus.LoadFromFile(GetGraphicsDir + DirectorySeparator + sr.Name); 1235 List.AddStrings(Plus); 1181 1236 until FindNext(sr) <> 0; 1182 1237 FindClose(sr); 1183 plus.Free;1238 Plus.Free; 1184 1239 1185 1240 List.Sort; … … 1189 1244 List.Delete(i) 1190 1245 else 1191 inc(i); 1192 1193 for i := 0 to List.Count - 1 do 1194 begin 1246 Inc(i); 1247 1248 for i := 0 to List.Count - 1 do begin 1195 1249 s := List[i]; 1196 1250 while BiColorTextWidth(OffScreen.Canvas, s) > InnerWidth - 16 - … … 1204 1258 procedure AddSoundCredits; 1205 1259 var 1206 i: integer;1260 i: Integer; 1207 1261 s: string; 1208 1262 List: TStringList; 1209 1263 begin 1210 1264 List := TStringList.Create; 1211 List.LoadFromFile(HomeDir + 'Sounds' + DirectorySeparator + 'sound.credits.txt'); 1212 for i := 0 to List.Count - 1 do 1213 begin 1265 List.LoadFromFile(GetSoundsDir + DirectorySeparator + 'sound.credits.txt'); 1266 for i := 0 to List.Count - 1 do begin 1214 1267 s := List[i]; 1215 1268 while BiColorTextWidth(OffScreen.Canvas, s) > InnerWidth - 16 - … … 1227 1280 MainText.Delete(Headline) 1228 1281 else 1229 MainText.L F;1282 MainText.LineFeed; 1230 1283 MainText.AddLine(HelpText.Lookup(Item), pkSection); 1231 1284 Headline := MainText.Count - 1; … … 1233 1286 1234 1287 begin { Prepare } 1235 with MainText do 1236 begin 1288 with MainText do begin 1237 1289 OffScreen.Canvas.Font.Assign(UniFont[ftNormal]); 1238 CheckSeeAlso := false;1290 CheckSeeAlso := False; 1239 1291 Clear; 1240 1292 Headline := -1; 1241 1293 if (no >= 200) or not(Kind in [hkAdv, hkImp, hkTer, hkFeature]) then 1242 L F;1294 LineFeed; 1243 1295 case Kind of 1244 1296 hkText: … … 1252 1304 AddLine(HelpText.Lookup('HELPTITLE_QUICKSTART'), pkSpecialIcon, 1253 1305 0, { pkBigIcon,22, } hkText, HelpText.Gethandle('QUICK')); 1254 L F;1306 LineFeed; 1255 1307 AddLine(HelpText.Lookup('HELPTITLE_CONCEPTS'), pkBigIcon, 6, 1256 1308 hkText, HelpText.Gethandle('CONCEPTS')); 1257 L F;1309 LineFeed; 1258 1310 AddLine(HelpText.Lookup('HELPTITLE_TERLIST'), pkSpecialIcon, 1, 1259 1311 hkTer, 200); 1260 L F;1312 LineFeed; 1261 1313 AddLine(HelpText.Lookup('HELPTITLE_JOBLIST'), pkSpecialIcon, 2, 1262 1314 hkMisc, miscJobList); 1263 L F;1315 LineFeed; 1264 1316 AddLine(HelpText.Lookup('HELPTITLE_TECHLIST'), pkBigIcon, 39, 1265 1317 hkAdv, 200); 1266 L F;1318 LineFeed; 1267 1319 FindStdModelPicture(SpecialModelPictureCode[6], i, s); 1268 1320 AddLine(HelpText.Lookup('HELPTITLE_MODELLIST'), pkModel, i, 1269 1321 hkModel, 0); 1270 L F;1322 LineFeed; 1271 1323 AddLine(HelpText.Lookup('HELPTITLE_FEATURELIST'), pkBigIcon, 28, 1272 1324 hkFeature, 200); 1273 L F;1325 LineFeed; 1274 1326 AddLine(HelpText.Lookup('HELPTITLE_IMPLIST'), pkBigIcon, 1275 1327 7 * SystemIconLines + imCourt, hkImp, 200); 1276 L F;1328 LineFeed; 1277 1329 AddLine(HelpText.Lookup('HELPTITLE_UNIQUELIST'), pkBigIcon, 1278 1330 7 * SystemIconLines + imStockEx, hkImp, 201); 1279 L F;1331 LineFeed; 1280 1332 AddLine(HelpText.Lookup('HELPTITLE_WONDERLIST'), pkBigIcon, 1281 1333 7 * SystemIconLines, hkImp, 202); 1282 L F;1334 LineFeed; 1283 1335 AddLine(HelpText.Lookup('HELPTITLE_GOVLIST'), pkBigIcon, 1284 1336 gDemocracy + 6, hkMisc, miscGovList); 1285 L F;1337 LineFeed; 1286 1338 AddLine(HelpText.Lookup('HELPTITLE_KEYS'), pkBigIcon, 2, hkText, 1287 1339 HelpText.Gethandle('HOTKEYS')); 1288 L F;1340 LineFeed; 1289 1341 AddLine(HelpText.Lookup('HELPTITLE_ABOUT'), pkBigIcon, 1, 1290 1342 hkText, HelpText.Gethandle('ABOUT')); 1291 L F;1343 LineFeed; 1292 1344 AddLine(HelpText.Lookup('HELPTITLE_CREDITS'), pkBigIcon, 22, 1293 1345 hkMisc, miscCredits); … … 1296 1348 begin 1297 1349 AddItem('CREDITS'); 1298 L F;1350 LineFeed; 1299 1351 AddGraphicCredits; 1300 1352 NextSection('CRED_CAPSOUND'); … … 1310 1362 Caption := HelpText.Lookup('HELPTITLE_JOBLIST'); 1311 1363 AddJobList; 1312 L F;1364 LineFeed; 1313 1365 AddItem('TERIMPEXCLUDE'); 1314 L F;1366 LineFeed; 1315 1367 AddItem('TERIMPCITY'); 1316 1368 end; … … 1321 1373 begin 1322 1374 AddLine(Phrases.Lookup('GOVERNMENT', i mod nGov), pkSection); 1323 L F;1375 LineFeed; 1324 1376 if i = nGov then 1325 1377 AddLine('', pkBigIcon, 7 * SystemIconLines + imPalace) 1326 1378 else 1327 1379 AddLine('', pkBigIcon, i + 6); 1328 L F;1380 LineFeed; 1329 1381 AddTextual(HelpText.LookupByHandle(hGOVHELP, i mod nGov)); 1330 1382 if i mod nGov >= 2 then … … 1336 1388 if i < nGov then 1337 1389 begin 1338 L F;1339 L F;1390 LineFeed; 1391 LineFeed; 1340 1392 end 1341 1393 end … … 1345 1397 Caption := HelpText.Lookup('HELPTITLE_SEARCHRESULTS'); 1346 1398 AddTextual(Format(HelpText.Lookup('MATCHES'), [SearchContent])); 1347 MainText.A ddStrings(SearchResult);1348 end 1399 MainText.AppendList(SearchResult); 1400 end; 1349 1401 end; // case no 1350 1402 end; … … 1355 1407 Caption := HelpText.Lookup('HELPTITLE_TECHLIST'); 1356 1408 List := THyperText.Create; 1409 List.OwnsObjects := True; 1357 1410 for j := 0 to 3 do 1358 1411 begin 1359 1412 if j > 0 then 1360 1413 begin 1361 L F;1362 L F;1414 LineFeed; 1415 LineFeed; 1363 1416 end; 1364 1417 AddLine(HelpText.Lookup('TECHAGE', j), pkSection); … … 1378 1431 hkAdv, i); 1379 1432 List.Sort; 1380 A ddStrings(List);1433 AppendList(List); 1381 1434 end; 1382 List.Free 1435 List.Free; 1383 1436 end 1384 1437 else // single advance 1385 1438 begin 1386 1439 Caption := Phrases.Lookup('ADVANCES', no); 1387 L F;1440 LineFeed; 1388 1441 AddLine(Phrases.Lookup('ADVANCES', no), pkCaption); 1389 1442 if no in FutureTech then 1390 1443 begin 1391 1444 AddLine(HelpText.Lookup('HELPSPEC_FUTURE')); 1392 L F;1445 LineFeed; 1393 1446 if no = futResearchTechnology then 1394 1447 AddItem('FUTURETECHHELP100') … … 1413 1466 for i := 0 to 27 do 1414 1467 if Imp[i].Preq = no then 1415 AddImp (i);1468 AddImprovement(i); 1416 1469 for i := 28 to nImp - 1 do 1417 1470 if (Imp[i].Preq = no) and (Imp[i].Kind <> ikCommon) then 1418 AddImp (i);1471 AddImprovement(i); 1419 1472 for i := 28 to nImp - 1 do 1420 1473 if (Imp[i].Preq = no) and (Imp[i].Kind = ikCommon) then 1421 AddImp (i);1474 AddImprovement(i); 1422 1475 NextSection('MODELALLOW'); 1423 1476 for i := 0 to nSpecialModel - 1 do … … 1432 1485 if (AdvPreq[i, 0] = no) or (AdvPreq[i, 1] = no) or 1433 1486 (AdvPreq[i, 2] = no) then 1434 AddAdv (i);1487 AddAdvance(i); 1435 1488 NextSection('UPGRADEALLOW'); 1436 1489 for Domain := 0 to nDomains - 1 do … … 1456 1509 for i := 0 to 27 do 1457 1510 if (Imp[i].Preq <> preNA) and (Imp[i].Expiration = no) then 1458 AddImp (i);1511 AddImprovement(i); 1459 1512 NextSection('ADVEFFECT'); 1460 1513 s := HelpText.LookupByHandle(hADVHELP, no); … … 1471 1524 // AddLine(HelpText.Lookup('HELPTITLE_IMPLIST'),pkSection); 1472 1525 List := THyperText.Create; 1526 List.OwnsObjects := True; 1473 1527 for i := 28 to nImp - 1 do 1474 1528 if (i <> imTrGoods) and (Imp[i].Preq <> preNA) and … … 1477 1531 i, hkImp, i); 1478 1532 List.Sort; 1479 A ddStrings(List);1480 List.Free 1533 AppendList(List); 1534 List.Free; 1481 1535 end 1482 1536 else if no = 201 then … … 1489 1543 AddLine(Phrases.Lookup('IMPROVEMENTS', i), pkSmallIcon, i, 1490 1544 hkImp, i); 1491 { L F;1492 L F;1545 { LineFeed; 1546 LineFeed; 1493 1547 AddLine(HelpText.Lookup('HELPTITLE_SHIPPARTLIST'),pkSection); 1494 1548 for i:=28 to nImp-1 do … … 1508 1562 begin // single building 1509 1563 Caption := Phrases.Lookup('IMPROVEMENTS', no); 1510 L F;1564 LineFeed; 1511 1565 AddLine(Phrases.Lookup('IMPROVEMENTS', no), pkRightIcon, no); 1512 1566 case Imp[no].Kind of 1513 ikWonder: 1514 AddLine(HelpText.Lookup('HELPSPEC_WONDER')); 1515 ikCommon: 1516 AddLine(HelpText.Lookup('HELPSPEC_IMP')); 1517 ikShipPart: 1518 AddLine(HelpText.Lookup('HELPSPEC_SHIPPART')); 1567 ikWonder: AddLine(HelpText.Lookup('HELPSPEC_WONDER')); 1568 ikCommon: AddLine(HelpText.Lookup('HELPSPEC_IMP')); 1569 ikShipPart: AddLine(HelpText.Lookup('HELPSPEC_SHIPPART')); 1519 1570 else 1520 1571 AddLine(HelpText.Lookup('HELPSPEC_NAT')) 1521 1572 end; 1522 if Imp[no].Kind <> ikShipPart then 1523 begin 1573 if Imp[no].Kind <> ikShipPart then begin 1524 1574 NextSection('EFFECT'); 1525 1575 AddTextual(HelpText.LookupByHandle(hIMPHELP, no)); 1526 1576 end; 1527 if no = woSun then 1528 begin 1577 if no = woSun then begin 1529 1578 AddFeature(mcFirst); 1530 1579 AddFeature(mcWill); … … 1533 1582 if (no < 28) and not Phrases2FallenBackToEnglish then 1534 1583 begin 1535 L F;1584 LineFeed; 1536 1585 if Imp[no].Expiration >= 0 then 1537 1586 AddTextual(Phrases2.Lookup('HELP_WONDERMORALE1')) … … 1563 1612 j := 1 1564 1613 end; 1565 AddImp (ImpReplacement[i].OldImp);1614 AddImprovement(ImpReplacement[i].OldImp); 1566 1615 end; 1567 1616 if Imp[no].Kind = ikShipPart then 1568 1617 begin 1569 L F;1618 LineFeed; 1570 1619 if no = imShipComp then 1571 1620 i := 1 … … 1588 1637 NextSection('SEEALSO'); 1589 1638 if (no < 28) and (Imp[no].Expiration >= 0) then 1590 AddImp (woEiffel);1639 AddImprovement(woEiffel); 1591 1640 for i := 0 to nImpReplacement - 1 do 1592 1641 if ImpReplacement[i].OldImp = no then 1593 AddImp (ImpReplacement[i].NewImp);1642 AddImprovement(ImpReplacement[i].NewImp); 1594 1643 if no = imSupermarket then 1595 1644 AddLine(HelpText.Lookup('HELPTITLE_JOBLIST'), pkNormal, 0, … … 1604 1653 // AddLine(HelpText.Lookup('HELPTITLE_TERLIST'),pkSection); 1605 1654 for i := 0 to nTerrainHelp - 1 do 1606 AddTer (TerrainHelp[i]);1655 AddTerrain(TerrainHelp[i]); 1607 1656 end 1608 1657 else … … 1620 1669 begin 1621 1670 Caption := Phrases.Lookup('TERRAIN', no); 1622 L F;1671 LineFeed; 1623 1672 AddLine(Phrases.Lookup('TERRAIN', no), pkBigTer, no); 1624 1673 AddLine(HelpText.Lookup('HELPSPEC_TER')); 1625 L F;1674 LineFeed; 1626 1675 if (ProdRes[TerrSubType] > 0) or (MineEff > 0) then 1627 1676 AddLine(Format(HelpText.Lookup('RESPROD'), … … 1649 1698 if no = 3 * 12 then 1650 1699 begin 1651 L F;1700 LineFeed; 1652 1701 AddTextual(HelpText.Lookup('DEADLANDS')); 1653 1702 end; 1654 1703 if (TerrType = fDesert) and (no <> fDesert + 12) then 1655 1704 begin 1656 L F;1705 LineFeed; 1657 1706 AddTextual(Format(HelpText.Lookup('HOSTILE'), [DesertThurst])); 1658 1707 end; 1659 1708 if TerrType = fArctic then 1660 1709 begin 1661 L F;1710 LineFeed; 1662 1711 AddTextual(Format(HelpText.Lookup('HOSTILE'), [ArcticThurst])); 1663 1712 end; 1664 1713 if (no < 3 * 12) and (TransTerrain >= 0) then 1665 1714 begin 1666 L F;1715 LineFeed; 1667 1716 i := TransTerrain; 1668 1717 if (TerrType <> fGrass) and (i <> fGrass) then 1669 1718 i := i + TerrSubType * 12; 1670 // trafo to same special resource group1719 // trafo to same Special resource group 1671 1720 AddLine(Format(HelpText.Lookup('TRAFO'), 1672 1721 [Phrases.Lookup('TERRAIN', i)]), pkTer, i, … … 1674 1723 if no = fSwamp + 12 then 1675 1724 begin 1676 L F;1725 LineFeed; 1677 1726 AddLine(Format(HelpText.Lookup('TRAFO'), 1678 1727 [Phrases.Lookup('TERRAIN', TransTerrain + 24)]), pkTer, … … 1681 1730 else if i = fGrass then 1682 1731 begin 1683 L F;1732 LineFeed; 1684 1733 AddLine(Format(HelpText.Lookup('TRAFO'), 1685 1734 [Phrases.Lookup('TERRAIN', fGrass + 12)]), pkTer, fGrass + 12, … … 1690 1739 if no = 3 * 12 then 1691 1740 begin 1692 L F;1693 for special := 1 to 3 do1741 LineFeed; 1742 for Special := 1 to 3 do 1694 1743 begin 1695 if special > 1 then1696 L F;1697 AddLine(Phrases.Lookup('TERRAIN', 3 * 12 + special), pkTer,1698 3 * 12 + special);1744 if Special > 1 then 1745 LineFeed; 1746 AddLine(Phrases.Lookup('TERRAIN', 3 * 12 + Special), pkTer, 1747 3 * 12 + Special); 1699 1748 end 1700 1749 end 1701 1750 else if (no < 12) and (no <> fGrass) and (no <> fOcean) then 1702 1751 begin 1703 L F;1704 for special := 1 to 2 do1705 if (no <> fArctic) and (no <> fSwamp) or ( special < 2) then1752 LineFeed; 1753 for Special := 1 to 2 do 1754 if (no <> fArctic) and (no <> fSwamp) or (Special < 2) then 1706 1755 begin 1707 if special > 1 then1708 L F;1709 AddLine(Phrases.Lookup('TERRAIN', no + special * 12), pkTer,1710 no + special * 12);1711 i := FoodRes[ special] - FoodRes[0];1756 if Special > 1 then 1757 LineFeed; 1758 AddLine(Phrases.Lookup('TERRAIN', no + Special * 12), pkTer, 1759 no + Special * 12); 1760 i := FoodRes[Special] - FoodRes[0]; 1712 1761 if i <> 0 then 1713 1762 MainText[Count - 1] := MainText[Count - 1] + 1714 1763 Format(HelpText.Lookup('SPECIALFOOD'), [i]); 1715 i := ProdRes[ special] - ProdRes[0];1764 i := ProdRes[Special] - ProdRes[0]; 1716 1765 if i <> 0 then 1717 1766 MainText[Count - 1] := MainText[Count - 1] + 1718 1767 Format(HelpText.Lookup('SPECIALPROD'), [i]); 1719 i := TradeRes[ special] - TradeRes[0];1768 i := TradeRes[Special] - TradeRes[0]; 1720 1769 if i <> 0 then 1721 1770 MainText[Count - 1] := MainText[Count - 1] + … … 1725 1774 if no = 3 * 12 then 1726 1775 begin 1727 L F;1776 LineFeed; 1728 1777 AddTextual(HelpText.Lookup('RARE')); 1729 1778 end; … … 1731 1780 begin 1732 1781 NextSection('SEEALSO'); 1733 AddImp (woGardens);1782 AddImprovement(woGardens); 1734 1783 CheckSeeAlso := true 1735 1784 end … … 1742 1791 Caption := HelpText.Lookup('HELPTITLE_FEATURELIST'); 1743 1792 List := THyperText.Create; 1744 for special := 0 to 2 do 1793 List.OwnsObjects := True; 1794 for Special := 0 to 2 do 1745 1795 begin 1746 if special > 0 then 1747 begin 1748 LF; 1749 LF 1750 end; 1751 case special of 1752 0: 1753 AddLine(HelpText.Lookup('HELPTITLE_FEATURE1LIST'), pkSection); 1754 1: 1755 AddLine(HelpText.Lookup('HELPTITLE_FEATURE2LIST'), pkSection); 1756 2: 1757 AddLine(HelpText.Lookup('HELPTITLE_FEATURE3LIST'), pkSection); 1796 if Special > 0 then 1797 begin 1798 LineFeed; 1799 LineFeed; 1800 end; 1801 case Special of 1802 0: AddLine(HelpText.Lookup('HELPTITLE_FEATURE1LIST'), pkSection); 1803 1: AddLine(HelpText.Lookup('HELPTITLE_FEATURE2LIST'), pkSection); 1804 2: AddLine(HelpText.Lookup('HELPTITLE_FEATURE3LIST'), pkSection); 1758 1805 end; 1759 1806 List.Clear; … … 1767 1814 else 1768 1815 j := 1; 1769 if j = special then1816 if j = Special then 1770 1817 List.AddLine(Phrases.Lookup('FEATURES', i), pkFeature, i, 1771 1818 hkFeature, i); 1772 1819 end; 1773 1820 List.Sort; 1774 A ddStrings(List);1821 AppendList(List); 1775 1822 end; 1776 List.Free 1823 List.Free; 1777 1824 end 1778 1825 else 1779 1826 begin // single feature 1780 1827 Caption := Phrases.Lookup('FEATURES', no); 1781 L F;1828 LineFeed; 1782 1829 AddLine(Phrases.Lookup('FEATURES', no), pkBigFeature, no); 1783 1830 if no < mcFirstNonCap then … … 1807 1854 if Feature[no].Preq <> preNone then 1808 1855 begin 1809 L F;1856 LineFeed; 1810 1857 if Feature[no].Preq = preSun then 1811 1858 AddPreqImp(woSun) // sun tsu feature … … 1816 1863 end; 1817 1864 NextSection('SEEALSO'); 1818 CheckSeeAlso := true1865 CheckSeeAlso := True; 1819 1866 end; 1820 1867 … … 1825 1872 if i <> 2 then 1826 1873 AddModelText(i); 1827 L F;1874 LineFeed; 1828 1875 AddItem('MODELNOTE'); 1829 1876 end; … … 1834 1881 if (SeeAlso[i].Kind = Kind) and (SeeAlso[i].no = no) then 1835 1882 case SeeAlso[i].SeeKind of 1836 hkImp: 1837 AddImp(SeeAlso[i].SeeNo); 1838 hkAdv: 1839 AddAdv(SeeAlso[i].SeeNo); 1840 hkFeature: 1841 AddFeature(SeeAlso[i].SeeNo); 1883 hkImp: AddImprovement(SeeAlso[i].SeeNo); 1884 hkAdv: AddAdvance(SeeAlso[i].SeeNo); 1885 hkFeature: AddFeature(SeeAlso[i].SeeNo); 1842 1886 end; 1843 1887 if (Headline >= 0) and (Count = Headline + 1) then 1844 1888 Delete(Headline) 1845 1889 else 1846 L F;1890 LineFeed; 1847 1891 1848 1892 //Self.Show; 1849 sb.Init(Count - 1, InnerHeight div 24);1850 sb.SetPos(sbPos);1851 BackBtn.Visible := nHist > 0;1852 TopBtn.Visible := ( nHist > 0) or (Kind <> hkMisc) or (no <> miscMain);1893 ScrollBar.Init(Count - 1, InnerHeight div 24); 1894 ScrollBar.SetPos(sbPos); 1895 BackBtn.Visible := HistItems.Count > 1; 1896 TopBtn.Visible := (HistItems.Count > 1) or (Kind <> hkMisc) or (no <> miscMain); 1853 1897 Sel := -1; 1854 1898 end; // with MainText 1855 end; { Prepare }1856 1857 procedure THelpDlg.ShowNewContent(NewMode, Category, Index: integer);1899 end; 1900 1901 procedure THelpDlg.ShowNewContent(NewMode, Category, Index: Integer); 1858 1902 begin 1859 1903 if (Category <> Kind) or (Index <> no) or (Category = hkMisc) and 1860 (Index = miscSearchResult) then 1861 begin 1862 if nHist = MaxHist then 1863 begin 1864 move(HistKind[2], HistKind[1], 4 * (nHist - 2)); 1865 move(HistNo[2], HistNo[1], 4 * (nHist - 2)); 1866 move(HistPos[2], HistPos[1], 4 * (nHist - 2)); 1867 move(HistSearchContent[2], HistSearchContent[1], 1868 sizeof(shortstring) * (nHist - 2)); 1869 end 1870 else 1871 inc(nHist); 1872 if nHist > 0 then 1873 begin 1874 HistKind[nHist - 1] := Kind; 1875 HistNo[nHist - 1] := no; 1876 HistPos[nHist - 1] := sb.Position; 1877 HistSearchContent[nHist - 1] := SearchContent 1878 end 1904 (Index = miscSearchResult) then begin 1905 if HistItems.Count = MaxHist then HistItems.Delete(0); 1906 if HistItems.Count = 0 then 1907 HistItems.AddNew(Category, Index, ScrollBar.Position, NewSearchContent) 1908 else HistItems.AddNew(Kind, No, ScrollBar.Position, SearchContent); 1879 1909 end; 1880 1910 Kind := Category; … … 1889 1919 x, y: integer); 1890 1920 var 1891 i0, Sel0: integer;1921 i0, Sel0: Integer; 1892 1922 begin 1893 1923 y := y - WideFrame; 1894 i0 := sb.Position;1924 i0 := ScrollBar.Position; 1895 1925 Sel0 := Sel; 1896 1926 if (x >= SideFrame) and (x < SideFrame + InnerWidth) and (y >= 0) and … … 1905 1935 begin 1906 1936 if Sel0 <> -1 then 1907 line(Canvas, Sel0, false);1937 Line(Canvas, Sel0, False); 1908 1938 if Sel <> -1 then 1909 line(Canvas, Sel, true)1939 Line(Canvas, Sel, True) 1910 1940 end 1911 1941 end; … … 1915 1945 begin 1916 1946 if Sel >= 0 then 1917 with THelpLineInfo(MainText.Objects[Sel + sb.Position]) do1947 with THelpLineInfo(MainText.Objects[Sel + ScrollBar.Position]) do 1918 1948 if Link shr 8 and $3F = hkInternet then 1919 1949 case Link and $FF of 1920 1: OpenDocument( pchar(HomeDir + 'AI Template' + DirectorySeparator + 'AI development manual.html'));1921 2: OpenURL( 'http://c-evo.org');1922 3: OpenURL( 'http://c-evo.org/_sg/contact');1950 1: OpenDocument(HomeDir + AITemplateFileName); 1951 2: OpenURL(CevoHomepage); 1952 3: OpenURL(CevoContact); 1923 1953 end 1924 1954 else … … 1934 1964 1935 1965 procedure THelpDlg.BackBtnClick(Sender: TObject); 1936 begin 1937 if nHist > 0 then 1938 begin 1939 dec(nHist); 1940 if (HistKind[nHist] = hkMisc) and (HistNo[nHist] = miscSearchResult) and 1941 (HistSearchContent[nHist] <> SearchContent) then 1966 var 1967 HistItem: THistItem; 1968 begin 1969 if HistItems.Count > 1 then begin 1970 HistItem := THistItem.Create; 1971 HistItem.Assign(HistItems.Last); 1972 HistItems.Delete(HistItems.Count - 1); 1973 if (HistItem.Kind = hkMisc) and (HistItem.No = miscSearchResult) and 1974 (HistItem.SearchContent <> SearchContent) then 1942 1975 begin 1943 SearchContent := Hist SearchContent[nHist];1976 SearchContent := HistItem.SearchContent; 1944 1977 Search(SearchContent); 1945 1978 end; 1946 Kind := Hist Kind[nHist];1947 no := Hist No[nHist];1948 Prepare(Hist Pos[nHist]);1979 Kind := HistItem.Kind; 1980 no := HistItem.No; 1981 Prepare(HistItem.Pos); 1949 1982 OffscreenPaint; 1950 1983 Invalidate; 1951 end 1984 HistItem.Free; 1985 end; 1952 1986 end; 1953 1987 1954 1988 procedure THelpDlg.TopBtnClick(Sender: TObject); 1955 1989 begin 1956 nHist := 0;1990 while HistItems.Count > 1 do HistItems.Delete(HistItems.Count - 1); 1957 1991 Kind := hkMisc; 1958 1992 no := miscMain; … … 1968 2002 end; 1969 2003 1970 function THelpDlg.TextIndex(Item: string): integer;1971 begin 1972 result := HelpText.Gethandle(Item)2004 function THelpDlg.TextIndex(Item: string): Integer; 2005 begin 2006 Result := HelpText.Gethandle(Item) 1973 2007 end; 1974 2008 … … 1987 2021 InputDlg.CenterToRect(BoundsRect); 1988 2022 InputDlg.ShowModal; 1989 if (InputDlg.ModalResult = mrOK) and ( length(InputDlg.EInput.Text) >= 2) then2023 if (InputDlg.ModalResult = mrOK) and (Length(InputDlg.EInput.Text) >= 2) then 1990 2024 begin 1991 2025 Search(InputDlg.EInput.Text); … … 2004 2038 NewSearchContent := InputDlg.EInput.Text; 2005 2039 ShowNewContent(FWindowMode, hkMisc, miscSearchResult); 2006 end 2007 end 2008 end 2040 end; 2041 end; 2042 end; 2009 2043 end; 2010 2044 2011 2045 procedure THelpDlg.Search(SearchString: string); 2012 2046 var 2013 h, i, PrevHandle, PrevIndex, p, RightMargin: integer;2047 h, i, PrevHandle, PrevIndex, p, RightMargin: Integer; 2014 2048 s: string; 2015 2049 mADVHELP, mIMPHELP, mFEATUREHELP: set of 0 .. 255; 2016 bGOVHELP, bSPECIALMODEL, bJOBHELP: boolean;2050 bGOVHELP, bSPECIALMODEL, bJOBHELP: Boolean; 2017 2051 begin 2018 2052 SearchResult.Clear; … … 2020 2054 mIMPHELP := []; 2021 2055 mFEATUREHELP := []; 2022 bGOVHELP := false;2023 bSPECIALMODEL := false;2024 bJOBHELP := false;2056 bGOVHELP := False; 2057 bSPECIALMODEL := False; 2058 bJOBHELP := False; 2025 2059 2026 2060 // search in generic reference 2027 2061 SearchString := UpperCase(SearchString); 2028 for i := 0 to 35 + 4 do 2029 begin 2062 for i := 0 to 35 + 4 do begin 2030 2063 s := Phrases.Lookup('TERRAIN', i); 2031 2064 if pos(SearchString, UpperCase(s)) > 0 then … … 2042 2075 imShipComp + i - 37) + ' ' + HelpText.Lookup('HELPSPEC_SHIPPART'), 2043 2076 pkNormal, 0, hkImp + hkCrossLink, imShipComp + i - 37); 2044 Break 2045 end 2077 Break; 2078 end; 2046 2079 end; 2047 2080 for i := 0 to nJobHelp - 1 do … … 2051 2084 SearchResult.AddLine(HelpText.Lookup('HELPTITLE_JOBLIST'), pkNormal, 0, 2052 2085 hkMisc + hkCrossLink, miscJobList); 2053 bJOBHELP := true;2054 Break 2086 bJOBHELP := True; 2087 Break; 2055 2088 end; 2056 2089 for i := 0 to nAdv - 1 do … … 2065 2098 SearchResult.AddLine(s, pkNormal, 0, hkAdv + hkCrossLink, i); 2066 2099 include(mADVHELP, i); 2067 end 2100 end; 2068 2101 end; 2069 2102 for i := 0 to nSpecialModel - 1 do … … 2074 2107 SearchResult.AddLine(HelpText.Lookup('HELPTITLE_MODELLIST'), pkNormal, 0, 2075 2108 hkModel + hkCrossLink, 0); 2076 bSPECIALMODEL := true;2077 Break 2109 bSPECIALMODEL := True; 2110 Break; 2078 2111 end; 2079 2112 end; … … 2081 2114 begin 2082 2115 s := Phrases.Lookup('FEATURES', i); 2083 if pos(SearchString, UpperCase(s)) > 0 then2116 if Pos(SearchString, UpperCase(s)) > 0 then 2084 2117 begin 2085 2118 if i < mcFirstNonCap then … … 2090 2123 s := s + ' ' + HelpText.Lookup('HELPSPEC_FEATURE'); 2091 2124 SearchResult.AddLine(s, pkNormal, 0, hkFeature + hkCrossLink, i); 2092 include(mFEATUREHELP, i);2093 end 2125 Include(mFEATUREHELP, i); 2126 end; 2094 2127 end; 2095 2128 for i := 0 to nImp - 1 do 2096 2129 begin 2097 2130 s := Phrases.Lookup('IMPROVEMENTS', i); 2098 if pos(SearchString, UpperCase(s)) > 0 then2131 if Pos(SearchString, UpperCase(s)) > 0 then 2099 2132 begin 2100 2133 case Imp[i].Kind of … … 2109 2142 end; 2110 2143 SearchResult.AddLine(s, pkNormal, 0, hkImp + hkCrossLink, i); 2111 include(mIMPHELP, i);2144 Include(mIMPHELP, i); 2112 2145 end 2113 2146 end; 2114 2147 for i := 0 to nGov - 1 do 2115 if pos(SearchString, UpperCase(Phrases.Lookup('GOVERNMENT', i))) > 0 then2148 if Pos(SearchString, UpperCase(Phrases.Lookup('GOVERNMENT', i))) > 0 then 2116 2149 begin 2117 2150 SearchResult.AddLine(HelpText.Lookup('HELPTITLE_GOVLIST'), pkNormal, 0, 2118 2151 hkMisc + hkCrossLink, miscGovList); 2119 bGOVHELP := true;2120 Break 2152 bGOVHELP := True; 2153 Break; 2121 2154 end; 2122 2155 … … 2139 2172 s := s + ' ' + HelpText.Lookup('HELPSPEC_ADV'); 2140 2173 SearchResult.AddLine(s, pkNormal, 0, hkAdv + hkCrossLink, i) 2141 end 2174 end; 2142 2175 end 2143 2176 else if h = hIMPHELP then … … 2158 2191 end; 2159 2192 SearchResult.AddLine(s, pkNormal, 0, hkImp + hkCrossLink, i) 2160 end 2193 end; 2161 2194 end 2162 2195 else if h = hFEATUREHELP then … … 2173 2206 s := s + ' ' + HelpText.Lookup('HELPSPEC_FEATURE'); 2174 2207 SearchResult.AddLine(s, pkNormal, 0, hkFeature + hkCrossLink, i); 2175 end 2208 end; 2176 2209 end 2177 2210 else if h = hGOVHELP then … … 2196 2229 begin 2197 2230 s := HelpText.LookupByHandle(h); 2198 p := pos('$', s);2231 p := Pos('$', s); 2199 2232 if p > 0 then 2200 2233 begin 2201 s := copy(s, p + 1, maxint);2202 p := pos('\', s);2234 s := Copy(s, p + 1, maxint); 2235 p := Pos('\', s); 2203 2236 if p > 0 then 2204 s := copy(s, 1, p - 1);2237 s := Copy(s, 1, p - 1); 2205 2238 SearchResult.AddLine(s, pkNormal, 0, hkText + hkCrossLink, h); 2206 end 2207 end 2208 until false;2239 end; 2240 end; 2241 until False; 2209 2242 2210 2243 // cut lines to fit to window
Note:
See TracChangeset
for help on using the changeset viewer.