Changeset 171 for trunk/LocalPlayer/Help.pas
- Timestamp:
- Jun 15, 2019, 7:20:36 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/Help.pas
r170 r171 7 7 Protocol, ScreenTools, BaseWin, StringTables, Math, 8 8 LCLIntf, LCLType, LMessages, Messages, SysUtils, Classes, Graphics, Controls, Forms, 9 ExtCtrls, ButtonB, PVSB, Types ;9 ExtCtrls, 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: TFont; 79 MainText, SearchResult: THyperText; 99 MainText: THyperText; 100 SearchResult: THyperText; 80 101 HelpText: TStringTable; 81 102 ExtPic, TerrIcon: TBitmap; 82 sb: TPVScrollbar; 83 x0: array [-2 .. 18] 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: TCanvas; i: integer; lit: boolean);90 procedure Prepare(sbPos: integer = 0);107 procedure Line(ca: TCanvas; i: Integer; lit: Boolean); 108 procedure Prepare(sbPos: Integer = 0); 91 109 procedure ShowNewContentProcExecute(NewMode: Integer; HelpContext: string); 92 procedure WaterSign(x0, y0, iix: integer);110 procedure WaterSign(x0, y0, iix: Integer); 93 111 procedure Search(SearchString: string); 94 112 procedure OnScroll(var m: TMessage); message WM_VSCROLL; 95 113 procedure OnMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE; 96 114 public 97 Difficulty: integer;98 procedure ShowNewContent(NewMode, Category, Index: integer);115 HistItems: THistItems; 116 Difficulty: Integer; 99 117 procedure ClearHistory; 100 function TextIndex(Item: string): integer; 118 procedure ShowNewContent(NewMode, Category, Index: Integer); 119 function TextIndex(Item: string): Integer; 101 120 end; 102 121 … … 112 131 113 132 type 133 134 { THelpLineInfo } 135 114 136 THelpLineInfo = class 115 Format, Picpix: Byte; 137 Format: Byte; 138 Picpix: Byte; 116 139 Link: Word; 117 end; 140 procedure Assign(Source: THelpLineInfo); 141 end; 142 143 { THelpLineInfo } 144 145 procedure THelpLineInfo.Assign(Source: THelpLineInfo); 146 begin 147 Format := Source.Format; 148 PicPix := Source.PicPix; 149 Link := Source.Link; 150 end; 151 152 { THistItem } 153 154 procedure THistItem.Assign(Source: THistItem); 155 begin 156 Kind := Source.Kind; 157 No := Source.No; 158 Pos := Source.Pos; 159 SearchContent := Source.SearchContent; 160 end; 161 162 { THistItems } 163 164 function THistItems.AddNew(Kind, No, Pos: Integer; SearchContent: string 165 ): THistItem; 166 begin 167 Result := THistItem.Create; 168 Result.Kind := Kind; 169 Result.No := No; 170 Result.Pos := Pos; 171 Result.SearchContent := SearchContent; 172 Add(Result); 173 end; 118 174 119 175 procedure THyperText.AddLine(s: String; Format: integer; Picpix: integer; … … 131 187 end; 132 188 133 procedure THyperText.L F;189 procedure THyperText.LineFeed; 134 190 begin 135 191 AddLine; 192 end; 193 194 procedure THyperText.AppendList(Source: THyperText); 195 var 196 I: Integer; 197 HelpLineInfo: THelpLineInfo; 198 begin 199 for I := 0 to Source.Count - 1 do begin 200 HelpLineInfo := THelpLineInfo.Create; 201 HelpLineInfo.Assign(THelpLineInfo(Source.Objects[I])); 202 AddObject(Source.Strings[I], HelpLineInfo); 203 end; 136 204 end; 137 205 … … 199 267 begin 200 268 inherited; 269 HistItems := THistItems.Create; 270 201 271 CaptionLeft := BackBtn.Left + BackBtn.Width; 202 272 CaptionRight := SearchBtn.Left; … … 206 276 SearchResult := THyperText.Create; 207 277 SearchResult.OwnsObjects := True; 208 sb:= TPVScrollbar.Create(Self);209 sb.SetBorderSpacing(36, 9, 11);210 sb.OnUpdate := ScrollBarUpdate;278 ScrollBar := TPVScrollbar.Create(Self); 279 ScrollBar.SetBorderSpacing(36, 9, 11); 280 ScrollBar.OnUpdate := ScrollBarUpdate; 211 281 212 282 HelpText := TStringTable.Create; … … 234 304 TerrIcon.Canvas.FillRect(0, 0, TerrIcon.Width, TerrIcon.Height); 235 305 SearchContent := ''; 236 nHist := -1;237 306 ShowNewContentProc := ShowNewContentProcExecute; 238 307 end; … … 245 314 end; 246 315 247 procedure THelpDlg.ClearHistory;248 begin249 nHist := -1;250 end;251 252 316 procedure THelpDlg.FormDestroy(Sender: TObject); 253 317 begin 254 318 ShowNewContentProc := nil; 255 FreeAndNil( sb);319 FreeAndNil(ScrollBar); 256 320 FreeAndNil(MainText); 257 321 FreeAndNil(SearchResult); … … 260 324 FreeAndNil(HelpText); 261 325 // FreeAndNil(CaptionFont); 326 FreeAndNil(HistItems); 262 327 end; 263 328 … … 265 330 WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); 266 331 begin 267 if sb.ProcessMouseWheel(WheelDelta) then begin332 if ScrollBar.ProcessMouseWheel(WheelDelta) then begin 268 333 PaintBox1MouseMove(nil, [], MousePos.X - Left, 269 334 MousePos.Y - Top); … … 279 344 begin 280 345 { TODO: Handled by MouseWheel event 281 if sb.Process(m) then begin346 if ScrollBar.Process(m) then begin 282 347 Sel := -1; 283 348 SmartUpdateContent(true) … … 289 354 begin 290 355 if Sel <> -1 then begin 291 line(Canvas, Sel, false);356 Line(Canvas, Sel, false); 292 357 Sel := -1 293 358 end 294 359 end; 295 360 361 procedure THelpDlg.ClearHistory; 362 begin 363 HistItems.Clear; 364 end; 365 296 366 procedure THelpDlg.FormPaint(Sender: TObject); 297 367 begin … … 300 370 end; 301 371 302 procedure THelpDlg. line(ca: TCanvas; i: integer; lit: boolean);372 procedure THelpDlg.Line(ca: TCanvas; i: Integer; lit: Boolean); 303 373 var 304 TextColor, x, y: integer;374 TextColor, x, y: Integer; 305 375 TextSize: TSize; 306 376 s: string; 307 377 begin 308 s := MainText[ sb.Position + i];378 s := MainText[ScrollBar.Position + i]; 309 379 if s = '' then 310 exit;380 Exit; 311 381 x := x0[i]; 312 382 y := 2 + i * 24; … … 316 386 y := y + WideFrame 317 387 end; 318 if THelpLineInfo(MainText.Objects[ sb.Position + i]).Format388 if THelpLineInfo(MainText.Objects[ScrollBar.Position + i]).Format 319 389 in [pkCaption, pkBigTer, pkRightIcon, pkBigFeature] then 320 390 begin … … 332 402 ca.Font.Assign(UniFont[ftNormal]); 333 403 end 334 else if THelpLineInfo(MainText.Objects[ sb.Position + i]).Format = pkSection404 else if THelpLineInfo(MainText.Objects[ScrollBar.Position + i]).Format = pkSection 335 405 then 336 406 begin … … 351 421 TextSize.cy := WideFrame + InnerHeight - y; 352 422 FillSeamless(ca, x, y, TextSize.cx, TextSize.cy, -SideFrame, 353 sb.Position * 24 - WideFrame, Paper);423 ScrollBar.Position * 24 - WideFrame, Paper); 354 424 end; 355 425 BiColorTextOut(ca, TextColor, $7F007F, x, y, s); … … 357 427 with ca do 358 428 begin 359 assert(ca = Canvas);360 pen.color := TextColor;361 moveto(x + 1, y + TextSize.cy - 2);362 lineto(x + TextSize.cx, y + TextSize.cy - 2);429 Assert(ca = Canvas); 430 Pen.Color := TextColor; 431 MoveTo(x + 1, y + TextSize.cy - 2); 432 LineTo(x + TextSize.cx, y + TextSize.cy - 2); 363 433 end; 364 434 if (Kind = hkMisc) and (no = miscMain) then … … 373 443 var 374 444 x, y, dx, dy, xSrc, ySrc, sum, xx: integer; 375 Heaven: array [0 ..nHeaven] of integer;445 Heaven: array [0..nHeaven] of integer; 376 446 PaintPtr, CoalPtr: TPixelPointer; 377 ImpPtr: array [-1 ..1] of TPixelPointer;447 ImpPtr: array [-1..1] of TPixelPointer; 378 448 begin 379 449 // assume eiffel tower has free common heaven … … 424 494 end; 425 495 496 procedure THelpDlg.PaintTerrIcon(x, y, xSrc, ySrc: integer); 497 begin 498 Frame(OffScreen.Canvas, x - 1, y - 1, x + xSizeBig, y + ySizeBig, 499 $000000, $000000); 500 if 2 * yyt < 40 then begin 501 Sprite(OffScreen, HGrTerrain, x, y, 56, 2 * yyt, xSrc, ySrc); 502 Sprite(OffScreen, HGrTerrain, x, y + 2 * yyt, 56, 40 - 2 * yyt, 503 xSrc, ySrc); 504 end else 505 Sprite(OffScreen, HGrTerrain, x, y, 56, 40, xSrc, ySrc); 506 Sprite(OffScreen, HGrTerrain, x, y, xxt, yyt, xSrc + xxt, ySrc + yyt); 507 Sprite(OffScreen, HGrTerrain, x, y + yyt, xxt, 40 - yyt, xSrc + xxt, ySrc); 508 Sprite(OffScreen, HGrTerrain, x + xxt, y, 56 - xxt, yyt, xSrc, ySrc + yyt); 509 Sprite(OffScreen, HGrTerrain, x + xxt, y + yyt, 56 - xxt, 40 - yyt, 510 xSrc, ySrc); 511 end; 512 426 513 procedure THelpDlg.OffscreenPaint; 427 428 procedure PaintTerrIcon(x, y, xSrc, ySrc: integer);429 begin430 Frame(OffScreen.Canvas, x - 1, y - 1, x + xSizeBig, y + ySizeBig,431 $000000, $000000);432 if 2 * yyt < 40 then433 begin434 Sprite(OffScreen, HGrTerrain, x, y, 56, 2 * yyt, xSrc, ySrc);435 Sprite(OffScreen, HGrTerrain, x, y + 2 * yyt, 56, 40 - 2 * yyt,436 xSrc, ySrc);437 end438 else439 Sprite(OffScreen, HGrTerrain, x, y, 56, 40, xSrc, ySrc);440 Sprite(OffScreen, HGrTerrain, x, y, xxt, yyt, xSrc + xxt, ySrc + yyt);441 Sprite(OffScreen, HGrTerrain, x, y + yyt, xxt, 40 - yyt, xSrc + xxt, ySrc);442 Sprite(OffScreen, HGrTerrain, x + xxt, y, 56 - xxt, yyt, xSrc, ySrc + yyt);443 Sprite(OffScreen, HGrTerrain, x + xxt, y + yyt, 56 - xxt, 40 - yyt,444 xSrc, ySrc);445 end;446 447 514 var 448 i, j, yl, srcno, ofs, cnt, y: integer;515 i, j, yl, srcno, ofs, cnt, y: Integer; 449 516 s: string; 450 517 HelpLineInfo: THelpLineInfo; … … 453 520 CaptionColor := Colors.Canvas.Pixels[clkMisc, cliPaperCaption]; 454 521 FillSeamless(OffScreen.Canvas, 0, 0, InnerWidth, InnerHeight, 0, 455 sb.Position * 24, Paper);522 ScrollBar.Position * 24, Paper); 456 523 with OffScreen.Canvas do 457 524 begin 458 525 Font.Assign(UniFont[ftNormal]); 459 for i := - sb.Position to InnerHeight div 24 do460 if sb.Position + i < MainText.Count then526 for i := -ScrollBar.Position to InnerHeight div 24 do 527 if ScrollBar.Position + i < MainText.Count then 461 528 begin 462 HelpLineInfo := THelpLineInfo(MainText.Objects[ sb.Position + i]);529 HelpLineInfo := THelpLineInfo(MainText.Objects[ScrollBar.Position + i]); 463 530 if HelpLineInfo.Format = pkExternal then 464 531 begin … … 471 538 end; 472 539 for i := -2 to InnerHeight div 24 do 473 if ( sb.Position + i >= 0) and (sb.Position + i < MainText.Count) then540 if (ScrollBar.Position + i >= 0) and (ScrollBar.Position + i < MainText.Count) then 474 541 begin 475 HelpLineInfo := THelpLineInfo(MainText.Objects[ sb.Position + i]);542 HelpLineInfo := THelpLineInfo(MainText.Objects[ScrollBar.Position + i]); 476 543 if HelpLineInfo.Link <> 0 then 477 544 begin … … 777 844 x0[i] := 64 + 8 + 8; 778 845 else 779 x0[i] := x0[i] + 8 846 x0[i] := x0[i] + 8; 780 847 end; 781 Self. line(OffScreen.Canvas, i, false)848 Self.Line(OffScreen.Canvas, i, False) 782 849 end; 783 850 end; 784 851 MarkUsedOffscreen(InnerWidth, InnerHeight + 13 + 48); 785 end; { OffscreenPaint }852 end; 786 853 787 854 procedure THelpDlg.ScrollBarUpdate(Sender: TObject); … … 793 860 procedure THelpDlg.Prepare(sbPos: integer = 0); 794 861 var 795 i, j, special, Domain, Headline, TerrType, TerrSubType: integer;862 i, j, Special, Domain, Headline, TerrType, TerrSubType: integer; 796 863 s: string; 797 864 ps: pchar; 798 865 List: THyperText; 799 CheckSeeAlso: boolean;800 801 procedure AddAdv (i: integer);866 CheckSeeAlso: Boolean; 867 868 procedure AddAdvance(i: integer); 802 869 begin 803 870 MainText.AddLine(Phrases.Lookup('ADVANCES', i), pkAdvIcon, i, … … 811 878 end; 812 879 813 procedure AddImp (i: integer);880 procedure AddImprovement(i: integer); 814 881 begin 815 882 MainText.AddLine(Phrases.Lookup('IMPROVEMENTS', i), pkSmallIcon, i, … … 823 890 end; 824 891 825 procedure AddTer (i: integer);892 procedure AddTerrain(i: integer); 826 893 begin 827 894 if MainText.Count > 1 then 828 895 begin 829 MainText.L F;896 MainText.LineFeed; 830 897 end; 831 898 MainText.AddLine(Phrases.Lookup('TERRAIN', i), pkTer, i, hkTer, i); … … 844 911 begin 845 912 if MainText.Count > 1 then 846 MainText.L F;913 MainText.LineFeed; 847 914 FindStdModelPicture(SpecialModelPictureCode[i], pix, Name); 848 915 MainText.AddLine(Name, pkModel, pix, hkModel + hkCrossLink, i) … … 858 925 begin 859 926 AddLine('', pkLogo); 860 L F;927 LineFeed; 861 928 end 862 929 else if Item = 'TECHFORMULA' then … … 874 941 for i := 1 to 3 do 875 942 begin 876 L F;943 LineFeed; 877 944 AddLine(Phrases.Lookup('TERRAIN', 3 * 12 + i), pkTer, 3 * 12 + i); 878 945 end … … 885 952 end; 886 953 887 procedure DecodeItem(s: string; var Category, Index: integer);954 procedure DecodeItem(s: string; var Category, Index: Integer); 888 955 var 889 i: integer; 890 begin 891 if (length(s) > 0) and (s[1] = ':') then 892 begin 956 i: Integer; 957 begin 958 if (Length(s) > 0) and (s[1] = ':') then begin 893 959 Category := hkMisc; 894 960 Index := 0; 895 961 for i := 3 to length(s) do 896 Index := Index * 10 + ord(s[i]) - 48;962 Index := Index * 10 + Ord(s[i]) - 48; 897 963 case s[2] of 898 'A': 899 Category := hkAdv; 900 'B': 901 Category := hkImp; 902 'T': 903 Category := hkTer; 904 'F': 905 Category := hkFeature; 906 'E': 907 Category := hkInternet; 908 'S': 909 Category := hkModel; 910 'C': 911 Index := miscCredits; 912 'J': 913 Index := miscJobList; 914 'G': 915 Index := miscGovList; 964 'A': Category := hkAdv; 965 'B': Category := hkImp; 966 'T': Category := hkTer; 967 'F': Category := hkFeature; 968 'E': Category := hkInternet; 969 'S': Category := hkModel; 970 'C': Index := miscCredits; 971 'J': Index := miscJobList; 972 'G': Index := miscGovList; 916 973 end; 917 974 if (Category <> hkMisc) and (Index = 0) then 918 975 Index := 200; 919 end 920 else 921 begin 976 end else begin 922 977 Category := hkText; 923 Index := HelpText.Gethandle( copy(s, 1, 255));978 Index := HelpText.Gethandle(Copy(s, 1, 255)); 924 979 end; 925 980 end; … … 943 998 repeat 944 999 inc(p) 945 until (p > length(s)) or (s[p] = '\');946 Caption := copy(s, 2, p - 2);1000 until (p > Length(s)) or (s[p] = '\'); 1001 Caption := Copy(s, 2, p - 2); 947 1002 Delete(s, 1, p); 948 1003 end … … 952 1007 repeat 953 1008 inc(p) 954 until (p > length(s)) or (s[p] = '\');955 AddStandardBlock( copy(s, 2, p - 2));1009 until (p > Length(s)) or (s[p] = '\'); 1010 AddStandardBlock(Copy(s, 2, p - 2)); 956 1011 Delete(s, 1, p); 957 1012 end 958 1013 else if s[1] = '@' then 959 1014 begin // image 960 if ( length(s) >= 2) and (s[2] = '@') then1015 if (Length(s) >= 2) and (s[2] = '@') then 961 1016 begin // generate from icon 962 1017 Picpix := 0; 963 1018 p := 3; 964 while (p <= length(s)) and (s[p] <> '\') do1019 while (p <= Length(s)) and (s[p] <> '\') do 965 1020 begin 966 Picpix := Picpix * 10 + ord(s[p]) - 48;1021 Picpix := Picpix * 10 + Ord(s[p]) - 48; 967 1022 inc(p) 968 1023 end; … … 970 1025 Picpix := 0; 971 1026 MainText.AddLine('', pkIllu, Picpix); 972 MainText.L F;973 MainText.L F;1027 MainText.LineFeed; 1028 MainText.LineFeed; 974 1029 end 975 1030 else … … 977 1032 p := 1; 978 1033 repeat 979 inc(p)980 until (p > length(s)) or (s[p] = '\');1034 Inc(p) 1035 until (p > Length(s)) or (s[p] = '\'); 981 1036 if LoadGraphicFile(ExtPic, LocalizedFilePath('Help' + 982 DirectorySeparator + copy(s, 2, p - 2)) + '.png') then1037 DirectorySeparator + Copy(s, 2, p - 2)) + '.png') then 983 1038 begin 984 1039 MainText.AddLine('', pkExternal); 985 1040 for i := 0 to (ExtPic.Height - 12) div 24 do 986 MainText.L F;1041 MainText.LineFeed; 987 1042 end; 988 1043 end; … … 997 1052 repeat 998 1053 inc(p) 999 until (p > length(s)) or (s[p] = '\') or (s[p] = ' ');1000 DecodeItem( copy(s, 2, p - 2), LinkCategory, LinkIndex);1054 until (p > Length(s)) or (s[p] = '\') or (s[p] = ' '); 1055 DecodeItem(Copy(s, 2, p - 2), LinkCategory, LinkIndex); 1001 1056 CurrentFormat := 0; 1002 1057 if (LinkCategory <> hkText) and (LinkIndex < 200) then … … 1016 1071 begin 1017 1072 CurrentFormat := pkTer; 1018 Picpix := LinkIndex 1073 Picpix := LinkIndex; 1019 1074 end; 1020 1075 hkFeature: … … 1032 1087 if s[1] = ':' then 1033 1088 LinkCategory := LinkCategory + hkCrossLink; 1034 if (p > length(s)) or (s[p] = ' ') then1089 if (p > Length(s)) or (s[p] = ' ') then 1035 1090 Delete(s, 1, p) 1036 1091 else … … 1038 1093 end; 1039 1094 '!': // highlited 1040 if ( length(s) >= 2) and (s[2] = '!') then1095 if (Length(s) >= 2) and (s[2] = '!') then 1041 1096 begin 1042 1097 if MainText.Count > 1 then 1043 MainText.L F;1098 MainText.LineFeed; 1044 1099 FollowFormat := pkCaption; 1045 1100 CurrentFormat := pkCaption; … … 1068 1123 repeat 1069 1124 repeat 1070 inc(p)1071 until (p > length(s)) or (s[p] = ' ') or (s[p] = '\');1072 if (BiColorTextWidth(OffScreen.Canvas, copy(s, 1, p - 1)) <=1125 Inc(p) 1126 until (p > Length(s)) or (s[p] = ' ') or (s[p] = '\'); 1127 if (BiColorTextWidth(OffScreen.Canvas, Copy(s, 1, p - 1)) <= 1073 1128 RightMargin - ofs) then 1074 1129 l := p - 1 1075 1130 else 1076 1131 Break; 1077 until (p >= length(s)) or (s[l + 1] = '\');1078 MainText.AddLine( copy(s, 1, l), CurrentFormat, Picpix, LinkCategory,1132 until (p >= Length(s)) or (s[l + 1] = '\'); 1133 MainText.AddLine(Copy(s, 1, l), CurrentFormat, Picpix, LinkCategory, 1079 1134 LinkIndex); 1080 if (l < length(s)) and (s[l + 1] = '\') then1135 if (l < Length(s)) and (s[l + 1] = '\') then 1081 1136 FollowFormat := pkNormal; 1082 1137 Delete(s, 1, l + 1); … … 1090 1145 end; 1091 1146 1092 procedure AddModelText(i: integer);1147 procedure AddModelText(i: Integer); 1093 1148 var 1094 pix: integer;1149 pix: Integer; 1095 1150 s: string; 1096 1151 begin 1097 with MainText do 1098 begin 1099 if Count > 1 then 1100 begin 1101 LF; 1102 LF; 1152 with MainText do begin 1153 if Count > 1 then begin 1154 LineFeed; 1155 LineFeed; 1103 1156 end; 1104 1157 FindStdModelPicture(SpecialModelPictureCode[i], pix, s); … … 1134 1187 procedure AddJobList; 1135 1188 var 1136 i, JobCost: integer; 1137 begin 1138 with MainText do 1139 begin 1140 for i := 0 to nJobHelp - 1 do 1141 begin 1142 if i > 0 then 1143 begin 1144 LF; 1145 LF 1189 i, JobCost: Integer; 1190 begin 1191 with MainText do begin 1192 for i := 0 to nJobHelp - 1 do begin 1193 if i > 0 then begin 1194 LineFeed; 1195 LineFeed; 1146 1196 end; 1147 1197 AddLine(Phrases.Lookup('JOBRESULT', JobHelp[i]), pkSection); … … 1152 1202 JobCost := -1; 1153 1203 case JobHelp[i] of 1154 jCanal: 1155 JobCost := CanalWork; 1156 jFort: 1157 JobCost := FortWork; 1158 jBase: 1159 JobCost := BaseWork; 1204 jCanal: JobCost := CanalWork; 1205 jFort: JobCost := FortWork; 1206 jBase: JobCost := BaseWork; 1160 1207 end; 1161 1208 if JobCost >= 0 then … … 1164 1211 else 1165 1212 AddTextual(HelpText.Lookup('JOBCOSTVAR')); 1166 if JobPreq[JobHelp[i]] <> preNone then 1167 begin 1213 if JobPreq[JobHelp[i]] <> preNone then begin 1168 1214 AddPreqAdv(JobPreq[JobHelp[i]]); 1169 1215 MainText[Count - 1] := Format(HelpText.Lookup('REQUIRED'), … … 1176 1222 procedure AddGraphicCredits; 1177 1223 var 1178 i: integer;1224 i: Integer; 1179 1225 s: string; 1180 1226 sr: TSearchRec; 1181 List, plus: TStringList;1227 List, Plus: TStringList; 1182 1228 begin 1183 1229 List := TStringList.Create; 1184 plus := TStringList.Create;1230 Plus := TStringList.Create; 1185 1231 if FindFirst(HomeDir + 'Graphics' + DirectorySeparator + '*.credits.txt', $27, sr) = 0 then 1186 1232 repeat 1187 plus.LoadFromFile(HomeDir + 'Graphics' + DirectorySeparator + sr.Name);1188 List.AddStrings( plus);1233 Plus.LoadFromFile(HomeDir + 'Graphics' + DirectorySeparator + sr.Name); 1234 List.AddStrings(Plus); 1189 1235 until FindNext(sr) <> 0; 1190 1236 FindClose(sr); 1191 plus.Free;1237 Plus.Free; 1192 1238 1193 1239 List.Sort; … … 1197 1243 List.Delete(i) 1198 1244 else 1199 inc(i); 1200 1201 for i := 0 to List.Count - 1 do 1202 begin 1245 Inc(i); 1246 1247 for i := 0 to List.Count - 1 do begin 1203 1248 s := List[i]; 1204 1249 while BiColorTextWidth(OffScreen.Canvas, s) > InnerWidth - 16 - … … 1212 1257 procedure AddSoundCredits; 1213 1258 var 1214 i: integer;1259 i: Integer; 1215 1260 s: string; 1216 1261 List: TStringList; … … 1218 1263 List := TStringList.Create; 1219 1264 List.LoadFromFile(HomeDir + 'Sounds' + DirectorySeparator + 'sound.credits.txt'); 1220 for i := 0 to List.Count - 1 do 1221 begin 1265 for i := 0 to List.Count - 1 do begin 1222 1266 s := List[i]; 1223 1267 while BiColorTextWidth(OffScreen.Canvas, s) > InnerWidth - 16 - … … 1235 1279 MainText.Delete(Headline) 1236 1280 else 1237 MainText.L F;1281 MainText.LineFeed; 1238 1282 MainText.AddLine(HelpText.Lookup(Item), pkSection); 1239 1283 Headline := MainText.Count - 1; … … 1241 1285 1242 1286 begin { Prepare } 1243 with MainText do 1244 begin 1287 with MainText do begin 1245 1288 OffScreen.Canvas.Font.Assign(UniFont[ftNormal]); 1246 CheckSeeAlso := false;1289 CheckSeeAlso := False; 1247 1290 Clear; 1248 1291 Headline := -1; 1249 1292 if (no >= 200) or not(Kind in [hkAdv, hkImp, hkTer, hkFeature]) then 1250 L F;1293 LineFeed; 1251 1294 case Kind of 1252 1295 hkText: … … 1260 1303 AddLine(HelpText.Lookup('HELPTITLE_QUICKSTART'), pkSpecialIcon, 1261 1304 0, { pkBigIcon,22, } hkText, HelpText.Gethandle('QUICK')); 1262 L F;1305 LineFeed; 1263 1306 AddLine(HelpText.Lookup('HELPTITLE_CONCEPTS'), pkBigIcon, 6, 1264 1307 hkText, HelpText.Gethandle('CONCEPTS')); 1265 L F;1308 LineFeed; 1266 1309 AddLine(HelpText.Lookup('HELPTITLE_TERLIST'), pkSpecialIcon, 1, 1267 1310 hkTer, 200); 1268 L F;1311 LineFeed; 1269 1312 AddLine(HelpText.Lookup('HELPTITLE_JOBLIST'), pkSpecialIcon, 2, 1270 1313 hkMisc, miscJobList); 1271 L F;1314 LineFeed; 1272 1315 AddLine(HelpText.Lookup('HELPTITLE_TECHLIST'), pkBigIcon, 39, 1273 1316 hkAdv, 200); 1274 L F;1317 LineFeed; 1275 1318 FindStdModelPicture(SpecialModelPictureCode[6], i, s); 1276 1319 AddLine(HelpText.Lookup('HELPTITLE_MODELLIST'), pkModel, i, 1277 1320 hkModel, 0); 1278 L F;1321 LineFeed; 1279 1322 AddLine(HelpText.Lookup('HELPTITLE_FEATURELIST'), pkBigIcon, 28, 1280 1323 hkFeature, 200); 1281 L F;1324 LineFeed; 1282 1325 AddLine(HelpText.Lookup('HELPTITLE_IMPLIST'), pkBigIcon, 1283 1326 7 * SystemIconLines + imCourt, hkImp, 200); 1284 L F;1327 LineFeed; 1285 1328 AddLine(HelpText.Lookup('HELPTITLE_UNIQUELIST'), pkBigIcon, 1286 1329 7 * SystemIconLines + imStockEx, hkImp, 201); 1287 L F;1330 LineFeed; 1288 1331 AddLine(HelpText.Lookup('HELPTITLE_WONDERLIST'), pkBigIcon, 1289 1332 7 * SystemIconLines, hkImp, 202); 1290 L F;1333 LineFeed; 1291 1334 AddLine(HelpText.Lookup('HELPTITLE_GOVLIST'), pkBigIcon, 1292 1335 gDemocracy + 6, hkMisc, miscGovList); 1293 L F;1336 LineFeed; 1294 1337 AddLine(HelpText.Lookup('HELPTITLE_KEYS'), pkBigIcon, 2, hkText, 1295 1338 HelpText.Gethandle('HOTKEYS')); 1296 L F;1339 LineFeed; 1297 1340 AddLine(HelpText.Lookup('HELPTITLE_ABOUT'), pkBigIcon, 1, 1298 1341 hkText, HelpText.Gethandle('ABOUT')); 1299 L F;1342 LineFeed; 1300 1343 AddLine(HelpText.Lookup('HELPTITLE_CREDITS'), pkBigIcon, 22, 1301 1344 hkMisc, miscCredits); … … 1304 1347 begin 1305 1348 AddItem('CREDITS'); 1306 L F;1349 LineFeed; 1307 1350 AddGraphicCredits; 1308 1351 NextSection('CRED_CAPSOUND'); … … 1318 1361 Caption := HelpText.Lookup('HELPTITLE_JOBLIST'); 1319 1362 AddJobList; 1320 L F;1363 LineFeed; 1321 1364 AddItem('TERIMPEXCLUDE'); 1322 L F;1365 LineFeed; 1323 1366 AddItem('TERIMPCITY'); 1324 1367 end; … … 1329 1372 begin 1330 1373 AddLine(Phrases.Lookup('GOVERNMENT', i mod nGov), pkSection); 1331 L F;1374 LineFeed; 1332 1375 if i = nGov then 1333 1376 AddLine('', pkBigIcon, 7 * SystemIconLines + imPalace) 1334 1377 else 1335 1378 AddLine('', pkBigIcon, i + 6); 1336 L F;1379 LineFeed; 1337 1380 AddTextual(HelpText.LookupByHandle(hGOVHELP, i mod nGov)); 1338 1381 if i mod nGov >= 2 then … … 1344 1387 if i < nGov then 1345 1388 begin 1346 L F;1347 L F;1389 LineFeed; 1390 LineFeed; 1348 1391 end 1349 1392 end … … 1353 1396 Caption := HelpText.Lookup('HELPTITLE_SEARCHRESULTS'); 1354 1397 AddTextual(Format(HelpText.Lookup('MATCHES'), [SearchContent])); 1355 MainText.A ddStrings(SearchResult);1356 end 1398 MainText.AppendList(SearchResult); 1399 end; 1357 1400 end; // case no 1358 1401 end; … … 1367 1410 if j > 0 then 1368 1411 begin 1369 L F;1370 L F;1412 LineFeed; 1413 LineFeed; 1371 1414 end; 1372 1415 AddLine(HelpText.Lookup('TECHAGE', j), pkSection); … … 1386 1429 hkAdv, i); 1387 1430 List.Sort; 1388 A ddStrings(List);1431 AppendList(List); 1389 1432 end; 1390 List.Free 1433 List.Free; 1391 1434 end 1392 1435 else // single advance 1393 1436 begin 1394 1437 Caption := Phrases.Lookup('ADVANCES', no); 1395 L F;1438 LineFeed; 1396 1439 AddLine(Phrases.Lookup('ADVANCES', no), pkCaption); 1397 1440 if no in FutureTech then 1398 1441 begin 1399 1442 AddLine(HelpText.Lookup('HELPSPEC_FUTURE')); 1400 L F;1443 LineFeed; 1401 1444 if no = futResearchTechnology then 1402 1445 AddItem('FUTURETECHHELP100') … … 1421 1464 for i := 0 to 27 do 1422 1465 if Imp[i].Preq = no then 1423 AddImp (i);1466 AddImprovement(i); 1424 1467 for i := 28 to nImp - 1 do 1425 1468 if (Imp[i].Preq = no) and (Imp[i].Kind <> ikCommon) then 1426 AddImp (i);1469 AddImprovement(i); 1427 1470 for i := 28 to nImp - 1 do 1428 1471 if (Imp[i].Preq = no) and (Imp[i].Kind = ikCommon) then 1429 AddImp (i);1472 AddImprovement(i); 1430 1473 NextSection('MODELALLOW'); 1431 1474 for i := 0 to nSpecialModel - 1 do … … 1440 1483 if (AdvPreq[i, 0] = no) or (AdvPreq[i, 1] = no) or 1441 1484 (AdvPreq[i, 2] = no) then 1442 AddAdv (i);1485 AddAdvance(i); 1443 1486 NextSection('UPGRADEALLOW'); 1444 1487 for Domain := 0 to nDomains - 1 do … … 1464 1507 for i := 0 to 27 do 1465 1508 if (Imp[i].Preq <> preNA) and (Imp[i].Expiration = no) then 1466 AddImp (i);1509 AddImprovement(i); 1467 1510 NextSection('ADVEFFECT'); 1468 1511 s := HelpText.LookupByHandle(hADVHELP, no); … … 1485 1528 i, hkImp, i); 1486 1529 List.Sort; 1487 A ddStrings(List);1488 List.Free 1530 AppendList(List); 1531 List.Free; 1489 1532 end 1490 1533 else if no = 201 then … … 1497 1540 AddLine(Phrases.Lookup('IMPROVEMENTS', i), pkSmallIcon, i, 1498 1541 hkImp, i); 1499 { L F;1500 L F;1542 { LineFeed; 1543 LineFeed; 1501 1544 AddLine(HelpText.Lookup('HELPTITLE_SHIPPARTLIST'),pkSection); 1502 1545 for i:=28 to nImp-1 do … … 1516 1559 begin // single building 1517 1560 Caption := Phrases.Lookup('IMPROVEMENTS', no); 1518 L F;1561 LineFeed; 1519 1562 AddLine(Phrases.Lookup('IMPROVEMENTS', no), pkRightIcon, no); 1520 1563 case Imp[no].Kind of 1521 ikWonder: 1522 AddLine(HelpText.Lookup('HELPSPEC_WONDER')); 1523 ikCommon: 1524 AddLine(HelpText.Lookup('HELPSPEC_IMP')); 1525 ikShipPart: 1526 AddLine(HelpText.Lookup('HELPSPEC_SHIPPART')); 1564 ikWonder: AddLine(HelpText.Lookup('HELPSPEC_WONDER')); 1565 ikCommon: AddLine(HelpText.Lookup('HELPSPEC_IMP')); 1566 ikShipPart: AddLine(HelpText.Lookup('HELPSPEC_SHIPPART')); 1527 1567 else 1528 1568 AddLine(HelpText.Lookup('HELPSPEC_NAT')) 1529 1569 end; 1530 if Imp[no].Kind <> ikShipPart then 1531 begin 1570 if Imp[no].Kind <> ikShipPart then begin 1532 1571 NextSection('EFFECT'); 1533 1572 AddTextual(HelpText.LookupByHandle(hIMPHELP, no)); 1534 1573 end; 1535 if no = woSun then 1536 begin 1574 if no = woSun then begin 1537 1575 AddFeature(mcFirst); 1538 1576 AddFeature(mcWill); … … 1541 1579 if (no < 28) and not Phrases2FallenBackToEnglish then 1542 1580 begin 1543 L F;1581 LineFeed; 1544 1582 if Imp[no].Expiration >= 0 then 1545 1583 AddTextual(Phrases2.Lookup('HELP_WONDERMORALE1')) … … 1571 1609 j := 1 1572 1610 end; 1573 AddImp (ImpReplacement[i].OldImp);1611 AddImprovement(ImpReplacement[i].OldImp); 1574 1612 end; 1575 1613 if Imp[no].Kind = ikShipPart then 1576 1614 begin 1577 L F;1615 LineFeed; 1578 1616 if no = imShipComp then 1579 1617 i := 1 … … 1596 1634 NextSection('SEEALSO'); 1597 1635 if (no < 28) and (Imp[no].Expiration >= 0) then 1598 AddImp (woEiffel);1636 AddImprovement(woEiffel); 1599 1637 for i := 0 to nImpReplacement - 1 do 1600 1638 if ImpReplacement[i].OldImp = no then 1601 AddImp (ImpReplacement[i].NewImp);1639 AddImprovement(ImpReplacement[i].NewImp); 1602 1640 if no = imSupermarket then 1603 1641 AddLine(HelpText.Lookup('HELPTITLE_JOBLIST'), pkNormal, 0, … … 1612 1650 // AddLine(HelpText.Lookup('HELPTITLE_TERLIST'),pkSection); 1613 1651 for i := 0 to nTerrainHelp - 1 do 1614 AddTer (TerrainHelp[i]);1652 AddTerrain(TerrainHelp[i]); 1615 1653 end 1616 1654 else … … 1628 1666 begin 1629 1667 Caption := Phrases.Lookup('TERRAIN', no); 1630 L F;1668 LineFeed; 1631 1669 AddLine(Phrases.Lookup('TERRAIN', no), pkBigTer, no); 1632 1670 AddLine(HelpText.Lookup('HELPSPEC_TER')); 1633 L F;1671 LineFeed; 1634 1672 if (ProdRes[TerrSubType] > 0) or (MineEff > 0) then 1635 1673 AddLine(Format(HelpText.Lookup('RESPROD'), … … 1657 1695 if no = 3 * 12 then 1658 1696 begin 1659 L F;1697 LineFeed; 1660 1698 AddTextual(HelpText.Lookup('DEADLANDS')); 1661 1699 end; 1662 1700 if (TerrType = fDesert) and (no <> fDesert + 12) then 1663 1701 begin 1664 L F;1702 LineFeed; 1665 1703 AddTextual(Format(HelpText.Lookup('HOSTILE'), [DesertThurst])); 1666 1704 end; 1667 1705 if TerrType = fArctic then 1668 1706 begin 1669 L F;1707 LineFeed; 1670 1708 AddTextual(Format(HelpText.Lookup('HOSTILE'), [ArcticThurst])); 1671 1709 end; 1672 1710 if (no < 3 * 12) and (TransTerrain >= 0) then 1673 1711 begin 1674 L F;1712 LineFeed; 1675 1713 i := TransTerrain; 1676 1714 if (TerrType <> fGrass) and (i <> fGrass) then 1677 1715 i := i + TerrSubType * 12; 1678 // trafo to same special resource group1716 // trafo to same Special resource group 1679 1717 AddLine(Format(HelpText.Lookup('TRAFO'), 1680 1718 [Phrases.Lookup('TERRAIN', i)]), pkTer, i, … … 1682 1720 if no = fSwamp + 12 then 1683 1721 begin 1684 L F;1722 LineFeed; 1685 1723 AddLine(Format(HelpText.Lookup('TRAFO'), 1686 1724 [Phrases.Lookup('TERRAIN', TransTerrain + 24)]), pkTer, … … 1689 1727 else if i = fGrass then 1690 1728 begin 1691 L F;1729 LineFeed; 1692 1730 AddLine(Format(HelpText.Lookup('TRAFO'), 1693 1731 [Phrases.Lookup('TERRAIN', fGrass + 12)]), pkTer, fGrass + 12, … … 1698 1736 if no = 3 * 12 then 1699 1737 begin 1700 L F;1701 for special := 1 to 3 do1738 LineFeed; 1739 for Special := 1 to 3 do 1702 1740 begin 1703 if special > 1 then1704 L F;1705 AddLine(Phrases.Lookup('TERRAIN', 3 * 12 + special), pkTer,1706 3 * 12 + special);1741 if Special > 1 then 1742 LineFeed; 1743 AddLine(Phrases.Lookup('TERRAIN', 3 * 12 + Special), pkTer, 1744 3 * 12 + Special); 1707 1745 end 1708 1746 end 1709 1747 else if (no < 12) and (no <> fGrass) and (no <> fOcean) then 1710 1748 begin 1711 L F;1712 for special := 1 to 2 do1713 if (no <> fArctic) and (no <> fSwamp) or ( special < 2) then1749 LineFeed; 1750 for Special := 1 to 2 do 1751 if (no <> fArctic) and (no <> fSwamp) or (Special < 2) then 1714 1752 begin 1715 if special > 1 then1716 L F;1717 AddLine(Phrases.Lookup('TERRAIN', no + special * 12), pkTer,1718 no + special * 12);1719 i := FoodRes[ special] - FoodRes[0];1753 if Special > 1 then 1754 LineFeed; 1755 AddLine(Phrases.Lookup('TERRAIN', no + Special * 12), pkTer, 1756 no + Special * 12); 1757 i := FoodRes[Special] - FoodRes[0]; 1720 1758 if i <> 0 then 1721 1759 MainText[Count - 1] := MainText[Count - 1] + 1722 1760 Format(HelpText.Lookup('SPECIALFOOD'), [i]); 1723 i := ProdRes[ special] - ProdRes[0];1761 i := ProdRes[Special] - ProdRes[0]; 1724 1762 if i <> 0 then 1725 1763 MainText[Count - 1] := MainText[Count - 1] + 1726 1764 Format(HelpText.Lookup('SPECIALPROD'), [i]); 1727 i := TradeRes[ special] - TradeRes[0];1765 i := TradeRes[Special] - TradeRes[0]; 1728 1766 if i <> 0 then 1729 1767 MainText[Count - 1] := MainText[Count - 1] + … … 1733 1771 if no = 3 * 12 then 1734 1772 begin 1735 L F;1773 LineFeed; 1736 1774 AddTextual(HelpText.Lookup('RARE')); 1737 1775 end; … … 1739 1777 begin 1740 1778 NextSection('SEEALSO'); 1741 AddImp (woGardens);1779 AddImprovement(woGardens); 1742 1780 CheckSeeAlso := true 1743 1781 end … … 1750 1788 Caption := HelpText.Lookup('HELPTITLE_FEATURELIST'); 1751 1789 List := THyperText.Create; 1752 for special := 0 to 2 do1790 for Special := 0 to 2 do 1753 1791 begin 1754 if special > 0 then 1755 begin 1756 LF; 1757 LF 1758 end; 1759 case special of 1760 0: 1761 AddLine(HelpText.Lookup('HELPTITLE_FEATURE1LIST'), pkSection); 1762 1: 1763 AddLine(HelpText.Lookup('HELPTITLE_FEATURE2LIST'), pkSection); 1764 2: 1765 AddLine(HelpText.Lookup('HELPTITLE_FEATURE3LIST'), pkSection); 1792 if Special > 0 then 1793 begin 1794 LineFeed; 1795 LineFeed; 1796 end; 1797 case Special of 1798 0: AddLine(HelpText.Lookup('HELPTITLE_FEATURE1LIST'), pkSection); 1799 1: AddLine(HelpText.Lookup('HELPTITLE_FEATURE2LIST'), pkSection); 1800 2: AddLine(HelpText.Lookup('HELPTITLE_FEATURE3LIST'), pkSection); 1766 1801 end; 1767 1802 List.Clear; … … 1775 1810 else 1776 1811 j := 1; 1777 if j = special then1812 if j = Special then 1778 1813 List.AddLine(Phrases.Lookup('FEATURES', i), pkFeature, i, 1779 1814 hkFeature, i); 1780 1815 end; 1781 1816 List.Sort; 1782 A ddStrings(List);1817 AppendList(List); 1783 1818 end; 1784 List.Free 1819 List.Free; 1785 1820 end 1786 1821 else 1787 1822 begin // single feature 1788 1823 Caption := Phrases.Lookup('FEATURES', no); 1789 L F;1824 LineFeed; 1790 1825 AddLine(Phrases.Lookup('FEATURES', no), pkBigFeature, no); 1791 1826 if no < mcFirstNonCap then … … 1815 1850 if Feature[no].Preq <> preNone then 1816 1851 begin 1817 L F;1852 LineFeed; 1818 1853 if Feature[no].Preq = preSun then 1819 1854 AddPreqImp(woSun) // sun tsu feature … … 1824 1859 end; 1825 1860 NextSection('SEEALSO'); 1826 CheckSeeAlso := true1861 CheckSeeAlso := True; 1827 1862 end; 1828 1863 … … 1833 1868 if i <> 2 then 1834 1869 AddModelText(i); 1835 L F;1870 LineFeed; 1836 1871 AddItem('MODELNOTE'); 1837 1872 end; … … 1842 1877 if (SeeAlso[i].Kind = Kind) and (SeeAlso[i].no = no) then 1843 1878 case SeeAlso[i].SeeKind of 1844 hkImp: 1845 AddImp(SeeAlso[i].SeeNo); 1846 hkAdv: 1847 AddAdv(SeeAlso[i].SeeNo); 1848 hkFeature: 1849 AddFeature(SeeAlso[i].SeeNo); 1879 hkImp: AddImprovement(SeeAlso[i].SeeNo); 1880 hkAdv: AddAdvance(SeeAlso[i].SeeNo); 1881 hkFeature: AddFeature(SeeAlso[i].SeeNo); 1850 1882 end; 1851 1883 if (Headline >= 0) and (Count = Headline + 1) then 1852 1884 Delete(Headline) 1853 1885 else 1854 L F;1886 LineFeed; 1855 1887 1856 1888 //Self.Show; 1857 sb.Init(Count - 1, InnerHeight div 24);1858 sb.SetPos(sbPos);1859 BackBtn.Visible := nHist > 0;1860 TopBtn.Visible := ( nHist > 0) or (Kind <> hkMisc) or (no <> miscMain);1889 ScrollBar.Init(Count - 1, InnerHeight div 24); 1890 ScrollBar.SetPos(sbPos); 1891 BackBtn.Visible := HistItems.Count > 1; 1892 TopBtn.Visible := (HistItems.Count > 1) or (Kind <> hkMisc) or (no <> miscMain); 1861 1893 Sel := -1; 1862 1894 end; // with MainText 1863 end; { Prepare }1864 1865 procedure THelpDlg.ShowNewContent(NewMode, Category, Index: integer);1895 end; 1896 1897 procedure THelpDlg.ShowNewContent(NewMode, Category, Index: Integer); 1866 1898 begin 1867 1899 if (Category <> Kind) or (Index <> no) or (Category = hkMisc) and 1868 (Index = miscSearchResult) then 1869 begin 1870 if nHist = MaxHist then 1871 begin 1872 move(HistKind[2], HistKind[1], 4 * (nHist - 2)); 1873 move(HistNo[2], HistNo[1], 4 * (nHist - 2)); 1874 move(HistPos[2], HistPos[1], 4 * (nHist - 2)); 1875 move(HistSearchContent[2], HistSearchContent[1], 1876 sizeof(shortstring) * (nHist - 2)); 1877 end 1878 else 1879 inc(nHist); 1880 if nHist > 0 then 1881 begin 1882 HistKind[nHist - 1] := Kind; 1883 HistNo[nHist - 1] := no; 1884 HistPos[nHist - 1] := sb.Position; 1885 HistSearchContent[nHist - 1] := SearchContent 1886 end 1900 (Index = miscSearchResult) then begin 1901 if HistItems.Count = MaxHist then HistItems.Delete(0); 1902 if HistItems.Count = 0 then 1903 HistItems.AddNew(Category, Index, ScrollBar.Position, NewSearchContent) 1904 else HistItems.AddNew(Kind, No, ScrollBar.Position, SearchContent); 1887 1905 end; 1888 1906 Kind := Category; … … 1897 1915 x, y: integer); 1898 1916 var 1899 i0, Sel0: integer;1917 i0, Sel0: Integer; 1900 1918 begin 1901 1919 y := y - WideFrame; 1902 i0 := sb.Position;1920 i0 := ScrollBar.Position; 1903 1921 Sel0 := Sel; 1904 1922 if (x >= SideFrame) and (x < SideFrame + InnerWidth) and (y >= 0) and … … 1913 1931 begin 1914 1932 if Sel0 <> -1 then 1915 line(Canvas, Sel0, false);1933 Line(Canvas, Sel0, False); 1916 1934 if Sel <> -1 then 1917 line(Canvas, Sel, true)1935 Line(Canvas, Sel, True) 1918 1936 end 1919 1937 end; … … 1923 1941 begin 1924 1942 if Sel >= 0 then 1925 with THelpLineInfo(MainText.Objects[Sel + sb.Position]) do1943 with THelpLineInfo(MainText.Objects[Sel + ScrollBar.Position]) do 1926 1944 if Link shr 8 and $3F = hkInternet then 1927 1945 case Link and $FF of … … 1942 1960 1943 1961 procedure THelpDlg.BackBtnClick(Sender: TObject); 1944 begin 1945 if nHist > 0 then 1946 begin 1947 dec(nHist); 1948 if (HistKind[nHist] = hkMisc) and (HistNo[nHist] = miscSearchResult) and 1949 (HistSearchContent[nHist] <> SearchContent) then 1962 var 1963 HistItem: THistItem; 1964 begin 1965 if HistItems.Count > 1 then begin 1966 HistItem := THistItem.Create; 1967 HistItem.Assign(HistItems.Last); 1968 HistItems.Delete(HistItems.Count - 1); 1969 if (HistItem.Kind = hkMisc) and (HistItem.No = miscSearchResult) and 1970 (HistItem.SearchContent <> SearchContent) then 1950 1971 begin 1951 SearchContent := Hist SearchContent[nHist];1972 SearchContent := HistItem.SearchContent; 1952 1973 Search(SearchContent); 1953 1974 end; 1954 Kind := Hist Kind[nHist];1955 no := Hist No[nHist];1956 Prepare(Hist Pos[nHist]);1975 Kind := HistItem.Kind; 1976 no := HistItem.No; 1977 Prepare(HistItem.Pos); 1957 1978 OffscreenPaint; 1958 1979 Invalidate; 1959 end 1980 HistItem.Free; 1981 end; 1960 1982 end; 1961 1983 1962 1984 procedure THelpDlg.TopBtnClick(Sender: TObject); 1963 1985 begin 1964 nHist := 0;1986 while HistItems.Count > 1 do HistItems.Delete(HistItems.Count - 1); 1965 1987 Kind := hkMisc; 1966 1988 no := miscMain; … … 1976 1998 end; 1977 1999 1978 function THelpDlg.TextIndex(Item: string): integer;1979 begin 1980 result := HelpText.Gethandle(Item)2000 function THelpDlg.TextIndex(Item: string): Integer; 2001 begin 2002 Result := HelpText.Gethandle(Item) 1981 2003 end; 1982 2004 … … 1995 2017 InputDlg.CenterToRect(BoundsRect); 1996 2018 InputDlg.ShowModal; 1997 if (InputDlg.ModalResult = mrOK) and ( length(InputDlg.EInput.Text) >= 2) then2019 if (InputDlg.ModalResult = mrOK) and (Length(InputDlg.EInput.Text) >= 2) then 1998 2020 begin 1999 2021 Search(InputDlg.EInput.Text); … … 2012 2034 NewSearchContent := InputDlg.EInput.Text; 2013 2035 ShowNewContent(FWindowMode, hkMisc, miscSearchResult); 2014 end 2015 end 2016 end 2036 end; 2037 end; 2038 end; 2017 2039 end; 2018 2040 2019 2041 procedure THelpDlg.Search(SearchString: string); 2020 2042 var 2021 h, i, PrevHandle, PrevIndex, p, RightMargin: integer;2043 h, i, PrevHandle, PrevIndex, p, RightMargin: Integer; 2022 2044 s: string; 2023 2045 mADVHELP, mIMPHELP, mFEATUREHELP: set of 0 .. 255; 2024 bGOVHELP, bSPECIALMODEL, bJOBHELP: boolean;2046 bGOVHELP, bSPECIALMODEL, bJOBHELP: Boolean; 2025 2047 begin 2026 2048 SearchResult.Clear; … … 2028 2050 mIMPHELP := []; 2029 2051 mFEATUREHELP := []; 2030 bGOVHELP := false;2031 bSPECIALMODEL := false;2032 bJOBHELP := false;2052 bGOVHELP := False; 2053 bSPECIALMODEL := False; 2054 bJOBHELP := False; 2033 2055 2034 2056 // search in generic reference 2035 2057 SearchString := UpperCase(SearchString); 2036 for i := 0 to 35 + 4 do 2037 begin 2058 for i := 0 to 35 + 4 do begin 2038 2059 s := Phrases.Lookup('TERRAIN', i); 2039 2060 if pos(SearchString, UpperCase(s)) > 0 then … … 2050 2071 imShipComp + i - 37) + ' ' + HelpText.Lookup('HELPSPEC_SHIPPART'), 2051 2072 pkNormal, 0, hkImp + hkCrossLink, imShipComp + i - 37); 2052 Break 2053 end 2073 Break; 2074 end; 2054 2075 end; 2055 2076 for i := 0 to nJobHelp - 1 do … … 2059 2080 SearchResult.AddLine(HelpText.Lookup('HELPTITLE_JOBLIST'), pkNormal, 0, 2060 2081 hkMisc + hkCrossLink, miscJobList); 2061 bJOBHELP := true;2062 Break 2082 bJOBHELP := True; 2083 Break; 2063 2084 end; 2064 2085 for i := 0 to nAdv - 1 do … … 2073 2094 SearchResult.AddLine(s, pkNormal, 0, hkAdv + hkCrossLink, i); 2074 2095 include(mADVHELP, i); 2075 end 2096 end; 2076 2097 end; 2077 2098 for i := 0 to nSpecialModel - 1 do … … 2082 2103 SearchResult.AddLine(HelpText.Lookup('HELPTITLE_MODELLIST'), pkNormal, 0, 2083 2104 hkModel + hkCrossLink, 0); 2084 bSPECIALMODEL := true;2085 Break 2105 bSPECIALMODEL := True; 2106 Break; 2086 2107 end; 2087 2108 end; … … 2089 2110 begin 2090 2111 s := Phrases.Lookup('FEATURES', i); 2091 if pos(SearchString, UpperCase(s)) > 0 then2112 if Pos(SearchString, UpperCase(s)) > 0 then 2092 2113 begin 2093 2114 if i < mcFirstNonCap then … … 2098 2119 s := s + ' ' + HelpText.Lookup('HELPSPEC_FEATURE'); 2099 2120 SearchResult.AddLine(s, pkNormal, 0, hkFeature + hkCrossLink, i); 2100 include(mFEATUREHELP, i);2101 end 2121 Include(mFEATUREHELP, i); 2122 end; 2102 2123 end; 2103 2124 for i := 0 to nImp - 1 do 2104 2125 begin 2105 2126 s := Phrases.Lookup('IMPROVEMENTS', i); 2106 if pos(SearchString, UpperCase(s)) > 0 then2127 if Pos(SearchString, UpperCase(s)) > 0 then 2107 2128 begin 2108 2129 case Imp[i].Kind of … … 2117 2138 end; 2118 2139 SearchResult.AddLine(s, pkNormal, 0, hkImp + hkCrossLink, i); 2119 include(mIMPHELP, i);2140 Include(mIMPHELP, i); 2120 2141 end 2121 2142 end; 2122 2143 for i := 0 to nGov - 1 do 2123 if pos(SearchString, UpperCase(Phrases.Lookup('GOVERNMENT', i))) > 0 then2144 if Pos(SearchString, UpperCase(Phrases.Lookup('GOVERNMENT', i))) > 0 then 2124 2145 begin 2125 2146 SearchResult.AddLine(HelpText.Lookup('HELPTITLE_GOVLIST'), pkNormal, 0, 2126 2147 hkMisc + hkCrossLink, miscGovList); 2127 bGOVHELP := true;2128 Break 2148 bGOVHELP := True; 2149 Break; 2129 2150 end; 2130 2151 … … 2147 2168 s := s + ' ' + HelpText.Lookup('HELPSPEC_ADV'); 2148 2169 SearchResult.AddLine(s, pkNormal, 0, hkAdv + hkCrossLink, i) 2149 end 2170 end; 2150 2171 end 2151 2172 else if h = hIMPHELP then … … 2166 2187 end; 2167 2188 SearchResult.AddLine(s, pkNormal, 0, hkImp + hkCrossLink, i) 2168 end 2189 end; 2169 2190 end 2170 2191 else if h = hFEATUREHELP then … … 2181 2202 s := s + ' ' + HelpText.Lookup('HELPSPEC_FEATURE'); 2182 2203 SearchResult.AddLine(s, pkNormal, 0, hkFeature + hkCrossLink, i); 2183 end 2204 end; 2184 2205 end 2185 2206 else if h = hGOVHELP then … … 2204 2225 begin 2205 2226 s := HelpText.LookupByHandle(h); 2206 p := pos('$', s);2227 p := Pos('$', s); 2207 2228 if p > 0 then 2208 2229 begin 2209 s := copy(s, p + 1, maxint);2210 p := pos('\', s);2230 s := Copy(s, p + 1, maxint); 2231 p := Pos('\', s); 2211 2232 if p > 0 then 2212 s := copy(s, 1, p - 1);2233 s := Copy(s, 1, p - 1); 2213 2234 SearchResult.AddLine(s, pkNormal, 0, hkText + hkCrossLink, h); 2214 end 2215 end 2216 until false;2235 end; 2236 end; 2237 until False; 2217 2238 2218 2239 // cut lines to fit to window
Note:
See TracChangeset
for help on using the changeset viewer.