Changeset 178 for branches/highdpi/LocalPlayer/Help.pas
- Timestamp:
- Jun 23, 2019, 3:15:29 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/LocalPlayer/Help.pas
r172 r178 5 5 6 6 uses 7 Protocol, ScreenTools, BaseWin, StringTables, Math, 7 Protocol, ScreenTools, BaseWin, StringTables, Math, UDpiControls, 8 8 LCLIntf, LCLType, LMessages, Messages, SysUtils, Classes, Graphics, Controls, Forms, 9 ExtCtrls, ButtonB, PVSB, Types , fgl;9 ExtCtrls, ButtonB, PVSB, Types; 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 LineFeed; 46 procedure AppendList(Source: THyperText); 45 procedure LF; 47 46 destructor Destroy; override; 48 end;49 50 { THistItem }51 52 THistItem = class53 Kind: Integer;54 No: Integer;55 Pos: Integer;56 SearchContent: string;57 procedure Assign(Source: THistItem);58 end;59 60 { THistItems }61 62 THistItems = class(TFPGObjectList<THistItem>)63 function AddNew(Kind, No, Pos: Integer; SearchContent: string): THistItem;64 47 end; 65 48 … … 89 72 procedure OffscreenPaint; override; 90 73 private 91 Kind: Integer; 92 no: Integer; 93 Sel: Integer; 94 CaptionColor: Integer; 95 hADVHELP, hIMPHELP, hFEATUREHELP, hGOVHELP, hSPECIALMODEL, hJOBHELP: Integer; 96 SearchContent: string; 97 NewSearchContent: string; 98 CaptionFont: TFont; 99 MainText: THyperText; 100 SearchResult: THyperText; 74 Kind, no, Sel, nHist, CaptionColor: integer; 75 hADVHELP, hIMPHELP, hFEATUREHELP, hGOVHELP, hSPECIALMODEL, 76 hJOBHELP: integer; 77 SearchContent, NewSearchContent: string; 78 CaptionFont: TDpiFont; 79 MainText, SearchResult: THyperText; 101 80 HelpText: TStringTable; 102 ExtPic, TerrIcon: TBitmap; 103 ScrollBar: TPVScrollbar; 104 x0: array [-2..180] of Integer; 105 procedure PaintTerrIcon(x, y, xSrc, ySrc: Integer); 81 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; 106 88 procedure ScrollBarUpdate(Sender: TObject); 107 procedure Line(ca: TCanvas; i: Integer; lit: Boolean); 108 procedure Prepare(sbPos: Integer = 0); 109 procedure ShowNewContentProcExecute(NewMode: Integer; HelpContext: string); 110 procedure WaterSign(x0, y0, iix: Integer); 89 procedure line(ca: TDpiCanvas; i: integer; lit: boolean); 90 procedure Prepare(sbPos: integer = 0); 91 procedure WaterSign(x0, y0, iix: integer); 111 92 procedure Search(SearchString: string); 112 93 procedure OnScroll(var m: TMessage); message WM_VSCROLL; 113 94 procedure OnMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE; 114 95 public 115 HistItems: THistItems;116 Difficulty: Integer;96 Difficulty: integer; 97 procedure ShowNewContent(NewMode, Category, Index: integer); 117 98 procedure ClearHistory; 118 procedure ShowNewContent(NewMode, Category, Index: Integer); 119 function TextIndex(Item: string): Integer; 99 function TextIndex(Item: string): integer; 120 100 end; 121 101 … … 126 106 127 107 uses 128 Directories, ClientTools, Term, Tribes, Inp, Messg , PixelPointer;108 Directories, ClientTools, Term, Tribes, Inp, Messg; 129 109 130 110 {$R *.lfm} 131 111 132 112 type 133 134 { THelpLineInfo }135 136 113 THelpLineInfo = class 137 Format: Byte; 138 Picpix: Byte; 114 Format, Picpix: Byte; 139 115 Link: Word; 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; 116 end; 174 117 175 118 procedure THyperText.AddLine(s: String; Format: integer; Picpix: integer; … … 187 130 end; 188 131 189 procedure THyperText.L ineFeed;132 procedure THyperText.LF; 190 133 begin 191 134 AddLine; 192 end;193 194 procedure THyperText.AppendList(Source: THyperText);195 var196 I: Integer;197 HelpLineInfo: THelpLineInfo;198 begin199 for I := 0 to Source.Count - 1 do begin200 HelpLineInfo := THelpLineInfo.Create;201 HelpLineInfo.Assign(THelpLineInfo(Source.Objects[I]));202 AddObject(Source.Strings[I], HelpLineInfo);203 end;204 135 end; 205 136 … … 267 198 begin 268 199 inherited; 269 HistItems := THistItems.Create;270 271 200 CaptionLeft := BackBtn.Left + BackBtn.Width; 272 201 CaptionRight := SearchBtn.Left; … … 276 205 SearchResult := THyperText.Create; 277 206 SearchResult.OwnsObjects := True; 278 ScrollBar:= TPVScrollbar.Create(Self);279 ScrollBar.SetBorderSpacing(36, 9, 11);280 ScrollBar.OnUpdate := ScrollBarUpdate;207 sb := TPVScrollbar.Create(Self); 208 sb.SetBorderSpacing(36, 9, 11); 209 sb.OnUpdate := ScrollBarUpdate; 281 210 282 211 HelpText := TStringTable.Create; … … 289 218 hJOBHELP := HelpText.Gethandle('JOBHELP'); 290 219 291 CaptionFont := Font.Create;220 CaptionFont := TDpiFont.Create; 292 221 CaptionFont.Assign(UniFont[ftNormal]); 293 222 CaptionFont.Style := CaptionFont.Style + [fsItalic, fsBold]; … … 298 227 SearchBtn.Hint := Phrases.Lookup('BTN_SEARCH'); 299 228 300 ExtPic := T Bitmap.Create;301 TerrIcon := T Bitmap.Create;229 ExtPic := TDpiBitmap.Create; 230 TerrIcon := TDpiBitmap.Create; 302 231 TerrIcon.PixelFormat := pf24bit; 303 232 TerrIcon.SetSize(xSizeBig, ySizeBig); 304 233 TerrIcon.Canvas.FillRect(0, 0, TerrIcon.Width, TerrIcon.Height); 305 234 SearchContent := ''; 306 ShowNewContentProc := ShowNewContentProcExecute;235 nHist := -1; 307 236 end; 308 237 309 procedure THelpDlg.ShowNewContentProcExecute(NewMode: Integer; 310 HelpContext: string); 311 begin 312 HelpDlg.ShowNewContent(NewMode, hkText, 313 HelpDlg.TextIndex(HelpContext)) 238 procedure THelpDlg.ClearHistory; 239 begin 240 nHist := -1; 314 241 end; 315 242 316 243 procedure THelpDlg.FormDestroy(Sender: TObject); 317 244 begin 318 ShowNewContentProc := nil; 319 FreeAndNil(ScrollBar); 245 FreeAndNil(sb); 320 246 FreeAndNil(MainText); 321 247 FreeAndNil(SearchResult); … … 324 250 FreeAndNil(HelpText); 325 251 // FreeAndNil(CaptionFont); 326 FreeAndNil(HistItems);327 252 end; 328 253 … … 330 255 WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); 331 256 begin 332 if ScrollBar.ProcessMouseWheel(WheelDelta) then begin257 if sb.ProcessMouseWheel(WheelDelta) then begin 333 258 PaintBox1MouseMove(nil, [], MousePos.X - Left, 334 259 MousePos.Y - Top); … … 344 269 begin 345 270 { TODO: Handled by MouseWheel event 346 if ScrollBar.Process(m) then begin271 if sb.Process(m) then begin 347 272 Sel := -1; 348 273 SmartUpdateContent(true) … … 354 279 begin 355 280 if Sel <> -1 then begin 356 Line(Canvas, Sel, false);281 line(Canvas, Sel, false); 357 282 Sel := -1 358 283 end 359 284 end; 360 285 361 procedure THelpDlg.ClearHistory;362 begin363 HistItems.Clear;364 end;365 366 286 procedure THelpDlg.FormPaint(Sender: TObject); 367 287 begin … … 370 290 end; 371 291 372 procedure THelpDlg. Line(ca: TCanvas; i: Integer; lit: Boolean);292 procedure THelpDlg.line(ca: TDpiCanvas; i: integer; lit: boolean); 373 293 var 374 TextColor, x, y: Integer;294 TextColor, x, y: integer; 375 295 TextSize: TSize; 376 296 s: string; 377 297 begin 378 s := MainText[ ScrollBar.Position + i];298 s := MainText[sb.Position + i]; 379 299 if s = '' then 380 Exit;300 exit; 381 301 x := x0[i]; 382 302 y := 2 + i * 24; … … 386 306 y := y + WideFrame 387 307 end; 388 if THelpLineInfo(MainText.Objects[ ScrollBar.Position + i]).Format308 if THelpLineInfo(MainText.Objects[sb.Position + i]).Format 389 309 in [pkCaption, pkBigTer, pkRightIcon, pkBigFeature] then 390 310 begin … … 402 322 ca.Font.Assign(UniFont[ftNormal]); 403 323 end 404 else if THelpLineInfo(MainText.Objects[ ScrollBar.Position + i]).Format = pkSection324 else if THelpLineInfo(MainText.Objects[sb.Position + i]).Format = pkSection 405 325 then 406 326 begin … … 421 341 TextSize.cy := WideFrame + InnerHeight - y; 422 342 FillSeamless(ca, x, y, TextSize.cx, TextSize.cy, -SideFrame, 423 ScrollBar.Position * 24 - WideFrame, Paper);343 sb.Position * 24 - WideFrame, Paper); 424 344 end; 425 345 BiColorTextOut(ca, TextColor, $7F007F, x, y, s); … … 427 347 with ca do 428 348 begin 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);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); 433 353 end; 434 354 if (Kind = hkMisc) and (no = miscMain) then … … 443 363 var 444 364 x, y, dx, dy, xSrc, ySrc, sum, xx: integer; 445 Heaven: array [0 ..nHeaven] of integer;365 Heaven: array [0 .. nHeaven] of integer; 446 366 PaintPtr, CoalPtr: TPixelPointer; 447 ImpPtr: array [-1 ..1] of TPixelPointer;367 ImpPtr: array [-1 .. 1] of TPixelPointer; 448 368 begin 449 369 // assume eiffel tower has free common heaven … … 494 414 end; 495 415 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, 416 procedure THelpDlg.OffscreenPaint; 417 418 procedure PaintTerrIcon(x, y, xSrc, ySrc: integer); 419 begin 420 Frame(OffScreen.Canvas, x - 1, y - 1, x + xSizeBig, y + ySizeBig, 421 $000000, $000000); 422 if 2 * yyt < 40 then 423 begin 424 Sprite(OffScreen, HGrTerrain, x, y, 56, 2 * yyt, xSrc, ySrc); 425 Sprite(OffScreen, HGrTerrain, x, y + 2 * yyt, 56, 40 - 2 * yyt, 426 xSrc, ySrc); 427 end 428 else 429 Sprite(OffScreen, HGrTerrain, x, y, 56, 40, xSrc, ySrc); 430 Sprite(OffScreen, HGrTerrain, x, y, xxt, yyt, xSrc + xxt, ySrc + yyt); 431 Sprite(OffScreen, HGrTerrain, x, y + yyt, xxt, 40 - yyt, xSrc + xxt, ySrc); 432 Sprite(OffScreen, HGrTerrain, x + xxt, y, 56 - xxt, yyt, xSrc, ySrc + yyt); 433 Sprite(OffScreen, HGrTerrain, x + xxt, y + yyt, 56 - xxt, 40 - yyt, 503 434 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 513 procedure THelpDlg.OffscreenPaint; 435 end; 436 514 437 var 515 i, j, yl, srcno, ofs, cnt, y: Integer;438 i, j, yl, srcno, ofs, cnt, y: integer; 516 439 s: string; 517 440 HelpLineInfo: THelpLineInfo; … … 520 443 CaptionColor := Colors.Canvas.Pixels[clkMisc, cliPaperCaption]; 521 444 FillSeamless(OffScreen.Canvas, 0, 0, InnerWidth, InnerHeight, 0, 522 ScrollBar.Position * 24, Paper);445 sb.Position * 24, Paper); 523 446 with OffScreen.Canvas do 524 447 begin 525 448 Font.Assign(UniFont[ftNormal]); 526 for i := - ScrollBar.Position to InnerHeight div 24 do527 if ScrollBar.Position + i < MainText.Count then449 for i := -sb.Position to InnerHeight div 24 do 450 if sb.Position + i < MainText.Count then 528 451 begin 529 HelpLineInfo := THelpLineInfo(MainText.Objects[ ScrollBar.Position + i]);452 HelpLineInfo := THelpLineInfo(MainText.Objects[sb.Position + i]); 530 453 if HelpLineInfo.Format = pkExternal then 531 454 begin … … 538 461 end; 539 462 for i := -2 to InnerHeight div 24 do 540 if ( ScrollBar.Position + i >= 0) and (ScrollBar.Position + i < MainText.Count) then463 if (sb.Position + i >= 0) and (sb.Position + i < MainText.Count) then 541 464 begin 542 HelpLineInfo := THelpLineInfo(MainText.Objects[ ScrollBar.Position + i]);465 HelpLineInfo := THelpLineInfo(MainText.Objects[sb.Position + i]); 543 466 if HelpLineInfo.Link <> 0 then 544 467 begin … … 844 767 x0[i] := 64 + 8 + 8; 845 768 else 846 x0[i] := x0[i] + 8 ;769 x0[i] := x0[i] + 8 847 770 end; 848 Self. Line(OffScreen.Canvas, i, False)771 Self.line(OffScreen.Canvas, i, false) 849 772 end; 850 773 end; 851 774 MarkUsedOffscreen(InnerWidth, InnerHeight + 13 + 48); 852 end; 775 end; { OffscreenPaint } 853 776 854 777 procedure THelpDlg.ScrollBarUpdate(Sender: TObject); … … 860 783 procedure THelpDlg.Prepare(sbPos: integer = 0); 861 784 var 862 i, j, Special, Domain, Headline, TerrType, TerrSubType: integer;785 i, j, special, Domain, Headline, TerrType, TerrSubType: integer; 863 786 s: string; 864 787 ps: pchar; 865 788 List: THyperText; 866 CheckSeeAlso: Boolean;867 868 procedure AddAdv ance(i: integer);789 CheckSeeAlso: boolean; 790 791 procedure AddAdv(i: integer); 869 792 begin 870 793 MainText.AddLine(Phrases.Lookup('ADVANCES', i), pkAdvIcon, i, … … 878 801 end; 879 802 880 procedure AddImp rovement(i: integer);803 procedure AddImp(i: integer); 881 804 begin 882 805 MainText.AddLine(Phrases.Lookup('IMPROVEMENTS', i), pkSmallIcon, i, … … 890 813 end; 891 814 892 procedure AddTer rain(i: integer);815 procedure AddTer(i: integer); 893 816 begin 894 817 if MainText.Count > 1 then 895 818 begin 896 MainText.L ineFeed;819 MainText.LF; 897 820 end; 898 821 MainText.AddLine(Phrases.Lookup('TERRAIN', i), pkTer, i, hkTer, i); … … 911 834 begin 912 835 if MainText.Count > 1 then 913 MainText.L ineFeed;836 MainText.LF; 914 837 FindStdModelPicture(SpecialModelPictureCode[i], pix, Name); 915 838 MainText.AddLine(Name, pkModel, pix, hkModel + hkCrossLink, i) … … 925 848 begin 926 849 AddLine('', pkLogo); 927 L ineFeed;850 LF; 928 851 end 929 852 else if Item = 'TECHFORMULA' then … … 941 864 for i := 1 to 3 do 942 865 begin 943 L ineFeed;866 LF; 944 867 AddLine(Phrases.Lookup('TERRAIN', 3 * 12 + i), pkTer, 3 * 12 + i); 945 868 end … … 952 875 end; 953 876 954 procedure DecodeItem(s: string; var Category, Index: Integer);877 procedure DecodeItem(s: string; var Category, Index: integer); 955 878 var 956 i: Integer; 957 begin 958 if (Length(s) > 0) and (s[1] = ':') then begin 879 i: integer; 880 begin 881 if (length(s) > 0) and (s[1] = ':') then 882 begin 959 883 Category := hkMisc; 960 884 Index := 0; 961 885 for i := 3 to length(s) do 962 Index := Index * 10 + Ord(s[i]) - 48;886 Index := Index * 10 + ord(s[i]) - 48; 963 887 case s[2] of 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; 888 'A': 889 Category := hkAdv; 890 'B': 891 Category := hkImp; 892 'T': 893 Category := hkTer; 894 'F': 895 Category := hkFeature; 896 'E': 897 Category := hkInternet; 898 'S': 899 Category := hkModel; 900 'C': 901 Index := miscCredits; 902 'J': 903 Index := miscJobList; 904 'G': 905 Index := miscGovList; 973 906 end; 974 907 if (Category <> hkMisc) and (Index = 0) then 975 908 Index := 200; 976 end else begin 909 end 910 else 911 begin 977 912 Category := hkText; 978 Index := HelpText.Gethandle( Copy(s, 1, 255));913 Index := HelpText.Gethandle(copy(s, 1, 255)); 979 914 end; 980 915 end; … … 998 933 repeat 999 934 inc(p) 1000 until (p > Length(s)) or (s[p] = '\');1001 Caption := Copy(s, 2, p - 2);935 until (p > length(s)) or (s[p] = '\'); 936 Caption := copy(s, 2, p - 2); 1002 937 Delete(s, 1, p); 1003 938 end … … 1007 942 repeat 1008 943 inc(p) 1009 until (p > Length(s)) or (s[p] = '\');1010 AddStandardBlock( Copy(s, 2, p - 2));944 until (p > length(s)) or (s[p] = '\'); 945 AddStandardBlock(copy(s, 2, p - 2)); 1011 946 Delete(s, 1, p); 1012 947 end 1013 948 else if s[1] = '@' then 1014 949 begin // image 1015 if ( Length(s) >= 2) and (s[2] = '@') then950 if (length(s) >= 2) and (s[2] = '@') then 1016 951 begin // generate from icon 1017 952 Picpix := 0; 1018 953 p := 3; 1019 while (p <= Length(s)) and (s[p] <> '\') do954 while (p <= length(s)) and (s[p] <> '\') do 1020 955 begin 1021 Picpix := Picpix * 10 + Ord(s[p]) - 48;956 Picpix := Picpix * 10 + ord(s[p]) - 48; 1022 957 inc(p) 1023 958 end; … … 1025 960 Picpix := 0; 1026 961 MainText.AddLine('', pkIllu, Picpix); 1027 MainText.L ineFeed;1028 MainText.L ineFeed;962 MainText.LF; 963 MainText.LF; 1029 964 end 1030 965 else … … 1032 967 p := 1; 1033 968 repeat 1034 Inc(p)1035 until (p > Length(s)) or (s[p] = '\');969 inc(p) 970 until (p > length(s)) or (s[p] = '\'); 1036 971 if LoadGraphicFile(ExtPic, LocalizedFilePath('Help' + 1037 DirectorySeparator + Copy(s, 2, p - 2)) + '.png') then972 DirectorySeparator + copy(s, 2, p - 2)) + '.png') then 1038 973 begin 1039 974 MainText.AddLine('', pkExternal); 1040 975 for i := 0 to (ExtPic.Height - 12) div 24 do 1041 MainText.L ineFeed;976 MainText.LF; 1042 977 end; 1043 978 end; … … 1052 987 repeat 1053 988 inc(p) 1054 until (p > Length(s)) or (s[p] = '\') or (s[p] = ' ');1055 DecodeItem( Copy(s, 2, p - 2), LinkCategory, LinkIndex);989 until (p > length(s)) or (s[p] = '\') or (s[p] = ' '); 990 DecodeItem(copy(s, 2, p - 2), LinkCategory, LinkIndex); 1056 991 CurrentFormat := 0; 1057 992 if (LinkCategory <> hkText) and (LinkIndex < 200) then … … 1071 1006 begin 1072 1007 CurrentFormat := pkTer; 1073 Picpix := LinkIndex ;1008 Picpix := LinkIndex 1074 1009 end; 1075 1010 hkFeature: … … 1087 1022 if s[1] = ':' then 1088 1023 LinkCategory := LinkCategory + hkCrossLink; 1089 if (p > Length(s)) or (s[p] = ' ') then1024 if (p > length(s)) or (s[p] = ' ') then 1090 1025 Delete(s, 1, p) 1091 1026 else … … 1093 1028 end; 1094 1029 '!': // highlited 1095 if ( Length(s) >= 2) and (s[2] = '!') then1030 if (length(s) >= 2) and (s[2] = '!') then 1096 1031 begin 1097 1032 if MainText.Count > 1 then 1098 MainText.L ineFeed;1033 MainText.LF; 1099 1034 FollowFormat := pkCaption; 1100 1035 CurrentFormat := pkCaption; … … 1123 1058 repeat 1124 1059 repeat 1125 Inc(p)1126 until (p > Length(s)) or (s[p] = ' ') or (s[p] = '\');1127 if (BiColorTextWidth(OffScreen.Canvas, Copy(s, 1, p - 1)) <=1060 inc(p) 1061 until (p > length(s)) or (s[p] = ' ') or (s[p] = '\'); 1062 if (BiColorTextWidth(OffScreen.Canvas, copy(s, 1, p - 1)) <= 1128 1063 RightMargin - ofs) then 1129 1064 l := p - 1 1130 1065 else 1131 1066 Break; 1132 until (p >= Length(s)) or (s[l + 1] = '\');1133 MainText.AddLine( Copy(s, 1, l), CurrentFormat, Picpix, LinkCategory,1067 until (p >= length(s)) or (s[l + 1] = '\'); 1068 MainText.AddLine(copy(s, 1, l), CurrentFormat, Picpix, LinkCategory, 1134 1069 LinkIndex); 1135 if (l < Length(s)) and (s[l + 1] = '\') then1070 if (l < length(s)) and (s[l + 1] = '\') then 1136 1071 FollowFormat := pkNormal; 1137 1072 Delete(s, 1, l + 1); … … 1145 1080 end; 1146 1081 1147 procedure AddModelText(i: Integer);1082 procedure AddModelText(i: integer); 1148 1083 var 1149 pix: Integer;1084 pix: integer; 1150 1085 s: string; 1151 1086 begin 1152 with MainText do begin 1153 if Count > 1 then begin 1154 LineFeed; 1155 LineFeed; 1087 with MainText do 1088 begin 1089 if Count > 1 then 1090 begin 1091 LF; 1092 LF; 1156 1093 end; 1157 1094 FindStdModelPicture(SpecialModelPictureCode[i], pix, s); … … 1187 1124 procedure AddJobList; 1188 1125 var 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; 1126 i, JobCost: integer; 1127 begin 1128 with MainText do 1129 begin 1130 for i := 0 to nJobHelp - 1 do 1131 begin 1132 if i > 0 then 1133 begin 1134 LF; 1135 LF 1196 1136 end; 1197 1137 AddLine(Phrases.Lookup('JOBRESULT', JobHelp[i]), pkSection); … … 1202 1142 JobCost := -1; 1203 1143 case JobHelp[i] of 1204 jCanal: JobCost := CanalWork; 1205 jFort: JobCost := FortWork; 1206 jBase: JobCost := BaseWork; 1144 jCanal: 1145 JobCost := CanalWork; 1146 jFort: 1147 JobCost := FortWork; 1148 jBase: 1149 JobCost := BaseWork; 1207 1150 end; 1208 1151 if JobCost >= 0 then … … 1211 1154 else 1212 1155 AddTextual(HelpText.Lookup('JOBCOSTVAR')); 1213 if JobPreq[JobHelp[i]] <> preNone then begin 1156 if JobPreq[JobHelp[i]] <> preNone then 1157 begin 1214 1158 AddPreqAdv(JobPreq[JobHelp[i]]); 1215 1159 MainText[Count - 1] := Format(HelpText.Lookup('REQUIRED'), … … 1222 1166 procedure AddGraphicCredits; 1223 1167 var 1224 i: Integer;1168 i: integer; 1225 1169 s: string; 1226 1170 sr: TSearchRec; 1227 List, Plus: TStringList;1171 List, plus: TStringList; 1228 1172 begin 1229 1173 List := TStringList.Create; 1230 Plus := TStringList.Create;1174 plus := TStringList.Create; 1231 1175 if FindFirst(HomeDir + 'Graphics' + DirectorySeparator + '*.credits.txt', $27, sr) = 0 then 1232 1176 repeat 1233 Plus.LoadFromFile(HomeDir + 'Graphics' + DirectorySeparator + sr.Name);1234 List.AddStrings( Plus);1177 plus.LoadFromFile(HomeDir + 'Graphics' + DirectorySeparator + sr.Name); 1178 List.AddStrings(plus); 1235 1179 until FindNext(sr) <> 0; 1236 1180 FindClose(sr); 1237 Plus.Free;1181 plus.Free; 1238 1182 1239 1183 List.Sort; … … 1243 1187 List.Delete(i) 1244 1188 else 1245 Inc(i); 1246 1247 for i := 0 to List.Count - 1 do begin 1189 inc(i); 1190 1191 for i := 0 to List.Count - 1 do 1192 begin 1248 1193 s := List[i]; 1249 1194 while BiColorTextWidth(OffScreen.Canvas, s) > InnerWidth - 16 - … … 1257 1202 procedure AddSoundCredits; 1258 1203 var 1259 i: Integer;1204 i: integer; 1260 1205 s: string; 1261 1206 List: TStringList; … … 1263 1208 List := TStringList.Create; 1264 1209 List.LoadFromFile(HomeDir + 'Sounds' + DirectorySeparator + 'sound.credits.txt'); 1265 for i := 0 to List.Count - 1 do begin 1210 for i := 0 to List.Count - 1 do 1211 begin 1266 1212 s := List[i]; 1267 1213 while BiColorTextWidth(OffScreen.Canvas, s) > InnerWidth - 16 - … … 1279 1225 MainText.Delete(Headline) 1280 1226 else 1281 MainText.L ineFeed;1227 MainText.LF; 1282 1228 MainText.AddLine(HelpText.Lookup(Item), pkSection); 1283 1229 Headline := MainText.Count - 1; … … 1285 1231 1286 1232 begin { Prepare } 1287 with MainText do begin 1233 with MainText do 1234 begin 1288 1235 OffScreen.Canvas.Font.Assign(UniFont[ftNormal]); 1289 CheckSeeAlso := False;1236 CheckSeeAlso := false; 1290 1237 Clear; 1291 1238 Headline := -1; 1292 1239 if (no >= 200) or not(Kind in [hkAdv, hkImp, hkTer, hkFeature]) then 1293 L ineFeed;1240 LF; 1294 1241 case Kind of 1295 1242 hkText: … … 1303 1250 AddLine(HelpText.Lookup('HELPTITLE_QUICKSTART'), pkSpecialIcon, 1304 1251 0, { pkBigIcon,22, } hkText, HelpText.Gethandle('QUICK')); 1305 L ineFeed;1252 LF; 1306 1253 AddLine(HelpText.Lookup('HELPTITLE_CONCEPTS'), pkBigIcon, 6, 1307 1254 hkText, HelpText.Gethandle('CONCEPTS')); 1308 L ineFeed;1255 LF; 1309 1256 AddLine(HelpText.Lookup('HELPTITLE_TERLIST'), pkSpecialIcon, 1, 1310 1257 hkTer, 200); 1311 L ineFeed;1258 LF; 1312 1259 AddLine(HelpText.Lookup('HELPTITLE_JOBLIST'), pkSpecialIcon, 2, 1313 1260 hkMisc, miscJobList); 1314 L ineFeed;1261 LF; 1315 1262 AddLine(HelpText.Lookup('HELPTITLE_TECHLIST'), pkBigIcon, 39, 1316 1263 hkAdv, 200); 1317 L ineFeed;1264 LF; 1318 1265 FindStdModelPicture(SpecialModelPictureCode[6], i, s); 1319 1266 AddLine(HelpText.Lookup('HELPTITLE_MODELLIST'), pkModel, i, 1320 1267 hkModel, 0); 1321 L ineFeed;1268 LF; 1322 1269 AddLine(HelpText.Lookup('HELPTITLE_FEATURELIST'), pkBigIcon, 28, 1323 1270 hkFeature, 200); 1324 L ineFeed;1271 LF; 1325 1272 AddLine(HelpText.Lookup('HELPTITLE_IMPLIST'), pkBigIcon, 1326 1273 7 * SystemIconLines + imCourt, hkImp, 200); 1327 L ineFeed;1274 LF; 1328 1275 AddLine(HelpText.Lookup('HELPTITLE_UNIQUELIST'), pkBigIcon, 1329 1276 7 * SystemIconLines + imStockEx, hkImp, 201); 1330 L ineFeed;1277 LF; 1331 1278 AddLine(HelpText.Lookup('HELPTITLE_WONDERLIST'), pkBigIcon, 1332 1279 7 * SystemIconLines, hkImp, 202); 1333 L ineFeed;1280 LF; 1334 1281 AddLine(HelpText.Lookup('HELPTITLE_GOVLIST'), pkBigIcon, 1335 1282 gDemocracy + 6, hkMisc, miscGovList); 1336 L ineFeed;1283 LF; 1337 1284 AddLine(HelpText.Lookup('HELPTITLE_KEYS'), pkBigIcon, 2, hkText, 1338 1285 HelpText.Gethandle('HOTKEYS')); 1339 L ineFeed;1286 LF; 1340 1287 AddLine(HelpText.Lookup('HELPTITLE_ABOUT'), pkBigIcon, 1, 1341 1288 hkText, HelpText.Gethandle('ABOUT')); 1342 L ineFeed;1289 LF; 1343 1290 AddLine(HelpText.Lookup('HELPTITLE_CREDITS'), pkBigIcon, 22, 1344 1291 hkMisc, miscCredits); … … 1347 1294 begin 1348 1295 AddItem('CREDITS'); 1349 L ineFeed;1296 LF; 1350 1297 AddGraphicCredits; 1351 1298 NextSection('CRED_CAPSOUND'); … … 1361 1308 Caption := HelpText.Lookup('HELPTITLE_JOBLIST'); 1362 1309 AddJobList; 1363 L ineFeed;1310 LF; 1364 1311 AddItem('TERIMPEXCLUDE'); 1365 L ineFeed;1312 LF; 1366 1313 AddItem('TERIMPCITY'); 1367 1314 end; … … 1372 1319 begin 1373 1320 AddLine(Phrases.Lookup('GOVERNMENT', i mod nGov), pkSection); 1374 L ineFeed;1321 LF; 1375 1322 if i = nGov then 1376 1323 AddLine('', pkBigIcon, 7 * SystemIconLines + imPalace) 1377 1324 else 1378 1325 AddLine('', pkBigIcon, i + 6); 1379 L ineFeed;1326 LF; 1380 1327 AddTextual(HelpText.LookupByHandle(hGOVHELP, i mod nGov)); 1381 1328 if i mod nGov >= 2 then … … 1387 1334 if i < nGov then 1388 1335 begin 1389 L ineFeed;1390 L ineFeed;1336 LF; 1337 LF; 1391 1338 end 1392 1339 end … … 1396 1343 Caption := HelpText.Lookup('HELPTITLE_SEARCHRESULTS'); 1397 1344 AddTextual(Format(HelpText.Lookup('MATCHES'), [SearchContent])); 1398 MainText.A ppendList(SearchResult);1399 end ;1345 MainText.AddStrings(SearchResult); 1346 end 1400 1347 end; // case no 1401 1348 end; … … 1406 1353 Caption := HelpText.Lookup('HELPTITLE_TECHLIST'); 1407 1354 List := THyperText.Create; 1408 List.OwnsObjects := True;1409 1355 for j := 0 to 3 do 1410 1356 begin 1411 1357 if j > 0 then 1412 1358 begin 1413 L ineFeed;1414 L ineFeed;1359 LF; 1360 LF; 1415 1361 end; 1416 1362 AddLine(HelpText.Lookup('TECHAGE', j), pkSection); … … 1430 1376 hkAdv, i); 1431 1377 List.Sort; 1432 A ppendList(List);1378 AddStrings(List); 1433 1379 end; 1434 List.Free ;1380 List.Free 1435 1381 end 1436 1382 else // single advance 1437 1383 begin 1438 1384 Caption := Phrases.Lookup('ADVANCES', no); 1439 L ineFeed;1385 LF; 1440 1386 AddLine(Phrases.Lookup('ADVANCES', no), pkCaption); 1441 1387 if no in FutureTech then 1442 1388 begin 1443 1389 AddLine(HelpText.Lookup('HELPSPEC_FUTURE')); 1444 L ineFeed;1390 LF; 1445 1391 if no = futResearchTechnology then 1446 1392 AddItem('FUTURETECHHELP100') … … 1465 1411 for i := 0 to 27 do 1466 1412 if Imp[i].Preq = no then 1467 AddImp rovement(i);1413 AddImp(i); 1468 1414 for i := 28 to nImp - 1 do 1469 1415 if (Imp[i].Preq = no) and (Imp[i].Kind <> ikCommon) then 1470 AddImp rovement(i);1416 AddImp(i); 1471 1417 for i := 28 to nImp - 1 do 1472 1418 if (Imp[i].Preq = no) and (Imp[i].Kind = ikCommon) then 1473 AddImp rovement(i);1419 AddImp(i); 1474 1420 NextSection('MODELALLOW'); 1475 1421 for i := 0 to nSpecialModel - 1 do … … 1484 1430 if (AdvPreq[i, 0] = no) or (AdvPreq[i, 1] = no) or 1485 1431 (AdvPreq[i, 2] = no) then 1486 AddAdv ance(i);1432 AddAdv(i); 1487 1433 NextSection('UPGRADEALLOW'); 1488 1434 for Domain := 0 to nDomains - 1 do … … 1508 1454 for i := 0 to 27 do 1509 1455 if (Imp[i].Preq <> preNA) and (Imp[i].Expiration = no) then 1510 AddImp rovement(i);1456 AddImp(i); 1511 1457 NextSection('ADVEFFECT'); 1512 1458 s := HelpText.LookupByHandle(hADVHELP, no); … … 1523 1469 // AddLine(HelpText.Lookup('HELPTITLE_IMPLIST'),pkSection); 1524 1470 List := THyperText.Create; 1525 List.OwnsObjects := True;1526 1471 for i := 28 to nImp - 1 do 1527 1472 if (i <> imTrGoods) and (Imp[i].Preq <> preNA) and … … 1530 1475 i, hkImp, i); 1531 1476 List.Sort; 1532 A ppendList(List);1533 List.Free ;1477 AddStrings(List); 1478 List.Free 1534 1479 end 1535 1480 else if no = 201 then … … 1542 1487 AddLine(Phrases.Lookup('IMPROVEMENTS', i), pkSmallIcon, i, 1543 1488 hkImp, i); 1544 { L ineFeed;1545 L ineFeed;1489 { LF; 1490 LF; 1546 1491 AddLine(HelpText.Lookup('HELPTITLE_SHIPPARTLIST'),pkSection); 1547 1492 for i:=28 to nImp-1 do … … 1561 1506 begin // single building 1562 1507 Caption := Phrases.Lookup('IMPROVEMENTS', no); 1563 L ineFeed;1508 LF; 1564 1509 AddLine(Phrases.Lookup('IMPROVEMENTS', no), pkRightIcon, no); 1565 1510 case Imp[no].Kind of 1566 ikWonder: AddLine(HelpText.Lookup('HELPSPEC_WONDER')); 1567 ikCommon: AddLine(HelpText.Lookup('HELPSPEC_IMP')); 1568 ikShipPart: AddLine(HelpText.Lookup('HELPSPEC_SHIPPART')); 1511 ikWonder: 1512 AddLine(HelpText.Lookup('HELPSPEC_WONDER')); 1513 ikCommon: 1514 AddLine(HelpText.Lookup('HELPSPEC_IMP')); 1515 ikShipPart: 1516 AddLine(HelpText.Lookup('HELPSPEC_SHIPPART')); 1569 1517 else 1570 1518 AddLine(HelpText.Lookup('HELPSPEC_NAT')) 1571 1519 end; 1572 if Imp[no].Kind <> ikShipPart then begin 1520 if Imp[no].Kind <> ikShipPart then 1521 begin 1573 1522 NextSection('EFFECT'); 1574 1523 AddTextual(HelpText.LookupByHandle(hIMPHELP, no)); 1575 1524 end; 1576 if no = woSun then begin 1525 if no = woSun then 1526 begin 1577 1527 AddFeature(mcFirst); 1578 1528 AddFeature(mcWill); … … 1581 1531 if (no < 28) and not Phrases2FallenBackToEnglish then 1582 1532 begin 1583 L ineFeed;1533 LF; 1584 1534 if Imp[no].Expiration >= 0 then 1585 1535 AddTextual(Phrases2.Lookup('HELP_WONDERMORALE1')) … … 1611 1561 j := 1 1612 1562 end; 1613 AddImp rovement(ImpReplacement[i].OldImp);1563 AddImp(ImpReplacement[i].OldImp); 1614 1564 end; 1615 1565 if Imp[no].Kind = ikShipPart then 1616 1566 begin 1617 L ineFeed;1567 LF; 1618 1568 if no = imShipComp then 1619 1569 i := 1 … … 1636 1586 NextSection('SEEALSO'); 1637 1587 if (no < 28) and (Imp[no].Expiration >= 0) then 1638 AddImp rovement(woEiffel);1588 AddImp(woEiffel); 1639 1589 for i := 0 to nImpReplacement - 1 do 1640 1590 if ImpReplacement[i].OldImp = no then 1641 AddImp rovement(ImpReplacement[i].NewImp);1591 AddImp(ImpReplacement[i].NewImp); 1642 1592 if no = imSupermarket then 1643 1593 AddLine(HelpText.Lookup('HELPTITLE_JOBLIST'), pkNormal, 0, … … 1652 1602 // AddLine(HelpText.Lookup('HELPTITLE_TERLIST'),pkSection); 1653 1603 for i := 0 to nTerrainHelp - 1 do 1654 AddTer rain(TerrainHelp[i]);1604 AddTer(TerrainHelp[i]); 1655 1605 end 1656 1606 else … … 1668 1618 begin 1669 1619 Caption := Phrases.Lookup('TERRAIN', no); 1670 L ineFeed;1620 LF; 1671 1621 AddLine(Phrases.Lookup('TERRAIN', no), pkBigTer, no); 1672 1622 AddLine(HelpText.Lookup('HELPSPEC_TER')); 1673 L ineFeed;1623 LF; 1674 1624 if (ProdRes[TerrSubType] > 0) or (MineEff > 0) then 1675 1625 AddLine(Format(HelpText.Lookup('RESPROD'), … … 1697 1647 if no = 3 * 12 then 1698 1648 begin 1699 L ineFeed;1649 LF; 1700 1650 AddTextual(HelpText.Lookup('DEADLANDS')); 1701 1651 end; 1702 1652 if (TerrType = fDesert) and (no <> fDesert + 12) then 1703 1653 begin 1704 L ineFeed;1654 LF; 1705 1655 AddTextual(Format(HelpText.Lookup('HOSTILE'), [DesertThurst])); 1706 1656 end; 1707 1657 if TerrType = fArctic then 1708 1658 begin 1709 L ineFeed;1659 LF; 1710 1660 AddTextual(Format(HelpText.Lookup('HOSTILE'), [ArcticThurst])); 1711 1661 end; 1712 1662 if (no < 3 * 12) and (TransTerrain >= 0) then 1713 1663 begin 1714 L ineFeed;1664 LF; 1715 1665 i := TransTerrain; 1716 1666 if (TerrType <> fGrass) and (i <> fGrass) then 1717 1667 i := i + TerrSubType * 12; 1718 // trafo to same Special resource group1668 // trafo to same special resource group 1719 1669 AddLine(Format(HelpText.Lookup('TRAFO'), 1720 1670 [Phrases.Lookup('TERRAIN', i)]), pkTer, i, … … 1722 1672 if no = fSwamp + 12 then 1723 1673 begin 1724 L ineFeed;1674 LF; 1725 1675 AddLine(Format(HelpText.Lookup('TRAFO'), 1726 1676 [Phrases.Lookup('TERRAIN', TransTerrain + 24)]), pkTer, … … 1729 1679 else if i = fGrass then 1730 1680 begin 1731 L ineFeed;1681 LF; 1732 1682 AddLine(Format(HelpText.Lookup('TRAFO'), 1733 1683 [Phrases.Lookup('TERRAIN', fGrass + 12)]), pkTer, fGrass + 12, … … 1738 1688 if no = 3 * 12 then 1739 1689 begin 1740 L ineFeed;1741 for Special := 1 to 3 do1690 LF; 1691 for special := 1 to 3 do 1742 1692 begin 1743 if Special > 1 then1744 L ineFeed;1745 AddLine(Phrases.Lookup('TERRAIN', 3 * 12 + Special), pkTer,1746 3 * 12 + Special);1693 if special > 1 then 1694 LF; 1695 AddLine(Phrases.Lookup('TERRAIN', 3 * 12 + special), pkTer, 1696 3 * 12 + special); 1747 1697 end 1748 1698 end 1749 1699 else if (no < 12) and (no <> fGrass) and (no <> fOcean) then 1750 1700 begin 1751 L ineFeed;1752 for Special := 1 to 2 do1753 if (no <> fArctic) and (no <> fSwamp) or ( Special < 2) then1701 LF; 1702 for special := 1 to 2 do 1703 if (no <> fArctic) and (no <> fSwamp) or (special < 2) then 1754 1704 begin 1755 if Special > 1 then1756 L ineFeed;1757 AddLine(Phrases.Lookup('TERRAIN', no + Special * 12), pkTer,1758 no + Special * 12);1759 i := FoodRes[ Special] - FoodRes[0];1705 if special > 1 then 1706 LF; 1707 AddLine(Phrases.Lookup('TERRAIN', no + special * 12), pkTer, 1708 no + special * 12); 1709 i := FoodRes[special] - FoodRes[0]; 1760 1710 if i <> 0 then 1761 1711 MainText[Count - 1] := MainText[Count - 1] + 1762 1712 Format(HelpText.Lookup('SPECIALFOOD'), [i]); 1763 i := ProdRes[ Special] - ProdRes[0];1713 i := ProdRes[special] - ProdRes[0]; 1764 1714 if i <> 0 then 1765 1715 MainText[Count - 1] := MainText[Count - 1] + 1766 1716 Format(HelpText.Lookup('SPECIALPROD'), [i]); 1767 i := TradeRes[ Special] - TradeRes[0];1717 i := TradeRes[special] - TradeRes[0]; 1768 1718 if i <> 0 then 1769 1719 MainText[Count - 1] := MainText[Count - 1] + … … 1773 1723 if no = 3 * 12 then 1774 1724 begin 1775 L ineFeed;1725 LF; 1776 1726 AddTextual(HelpText.Lookup('RARE')); 1777 1727 end; … … 1779 1729 begin 1780 1730 NextSection('SEEALSO'); 1781 AddImp rovement(woGardens);1731 AddImp(woGardens); 1782 1732 CheckSeeAlso := true 1783 1733 end … … 1790 1740 Caption := HelpText.Lookup('HELPTITLE_FEATURELIST'); 1791 1741 List := THyperText.Create; 1792 List.OwnsObjects := True; 1793 for Special := 0 to 2 do 1742 for special := 0 to 2 do 1794 1743 begin 1795 if Special > 0 then 1796 begin 1797 LineFeed; 1798 LineFeed; 1799 end; 1800 case Special of 1801 0: AddLine(HelpText.Lookup('HELPTITLE_FEATURE1LIST'), pkSection); 1802 1: AddLine(HelpText.Lookup('HELPTITLE_FEATURE2LIST'), pkSection); 1803 2: AddLine(HelpText.Lookup('HELPTITLE_FEATURE3LIST'), pkSection); 1744 if special > 0 then 1745 begin 1746 LF; 1747 LF 1748 end; 1749 case special of 1750 0: 1751 AddLine(HelpText.Lookup('HELPTITLE_FEATURE1LIST'), pkSection); 1752 1: 1753 AddLine(HelpText.Lookup('HELPTITLE_FEATURE2LIST'), pkSection); 1754 2: 1755 AddLine(HelpText.Lookup('HELPTITLE_FEATURE3LIST'), pkSection); 1804 1756 end; 1805 1757 List.Clear; … … 1813 1765 else 1814 1766 j := 1; 1815 if j = Special then1767 if j = special then 1816 1768 List.AddLine(Phrases.Lookup('FEATURES', i), pkFeature, i, 1817 1769 hkFeature, i); 1818 1770 end; 1819 1771 List.Sort; 1820 A ppendList(List);1772 AddStrings(List); 1821 1773 end; 1822 List.Free ;1774 List.Free 1823 1775 end 1824 1776 else 1825 1777 begin // single feature 1826 1778 Caption := Phrases.Lookup('FEATURES', no); 1827 L ineFeed;1779 LF; 1828 1780 AddLine(Phrases.Lookup('FEATURES', no), pkBigFeature, no); 1829 1781 if no < mcFirstNonCap then … … 1853 1805 if Feature[no].Preq <> preNone then 1854 1806 begin 1855 L ineFeed;1807 LF; 1856 1808 if Feature[no].Preq = preSun then 1857 1809 AddPreqImp(woSun) // sun tsu feature … … 1862 1814 end; 1863 1815 NextSection('SEEALSO'); 1864 CheckSeeAlso := True;1816 CheckSeeAlso := true 1865 1817 end; 1866 1818 … … 1871 1823 if i <> 2 then 1872 1824 AddModelText(i); 1873 L ineFeed;1825 LF; 1874 1826 AddItem('MODELNOTE'); 1875 1827 end; … … 1880 1832 if (SeeAlso[i].Kind = Kind) and (SeeAlso[i].no = no) then 1881 1833 case SeeAlso[i].SeeKind of 1882 hkImp: AddImprovement(SeeAlso[i].SeeNo); 1883 hkAdv: AddAdvance(SeeAlso[i].SeeNo); 1884 hkFeature: AddFeature(SeeAlso[i].SeeNo); 1834 hkImp: 1835 AddImp(SeeAlso[i].SeeNo); 1836 hkAdv: 1837 AddAdv(SeeAlso[i].SeeNo); 1838 hkFeature: 1839 AddFeature(SeeAlso[i].SeeNo); 1885 1840 end; 1886 1841 if (Headline >= 0) and (Count = Headline + 1) then 1887 1842 Delete(Headline) 1888 1843 else 1889 L ineFeed;1844 LF; 1890 1845 1891 1846 //Self.Show; 1892 ScrollBar.Init(Count - 1, InnerHeight div 24);1893 ScrollBar.SetPos(sbPos);1894 BackBtn.Visible := HistItems.Count > 1;1895 TopBtn.Visible := ( HistItems.Count > 1) or (Kind <> hkMisc) or (no <> miscMain);1847 sb.Init(Count - 1, InnerHeight div 24); 1848 sb.SetPos(sbPos); 1849 BackBtn.Visible := nHist > 0; 1850 TopBtn.Visible := (nHist > 0) or (Kind <> hkMisc) or (no <> miscMain); 1896 1851 Sel := -1; 1897 1852 end; // with MainText 1898 end; 1899 1900 procedure THelpDlg.ShowNewContent(NewMode, Category, Index: Integer);1853 end; { Prepare } 1854 1855 procedure THelpDlg.ShowNewContent(NewMode, Category, Index: integer); 1901 1856 begin 1902 1857 if (Category <> Kind) or (Index <> no) or (Category = hkMisc) and 1903 (Index = miscSearchResult) then begin 1904 if HistItems.Count = MaxHist then HistItems.Delete(0); 1905 if HistItems.Count = 0 then 1906 HistItems.AddNew(Category, Index, ScrollBar.Position, NewSearchContent) 1907 else HistItems.AddNew(Kind, No, ScrollBar.Position, SearchContent); 1858 (Index = miscSearchResult) then 1859 begin 1860 if nHist = MaxHist then 1861 begin 1862 move(HistKind[2], HistKind[1], 4 * (nHist - 2)); 1863 move(HistNo[2], HistNo[1], 4 * (nHist - 2)); 1864 move(HistPos[2], HistPos[1], 4 * (nHist - 2)); 1865 move(HistSearchContent[2], HistSearchContent[1], 1866 sizeof(shortstring) * (nHist - 2)); 1867 end 1868 else 1869 inc(nHist); 1870 if nHist > 0 then 1871 begin 1872 HistKind[nHist - 1] := Kind; 1873 HistNo[nHist - 1] := no; 1874 HistPos[nHist - 1] := sb.Position; 1875 HistSearchContent[nHist - 1] := SearchContent 1876 end 1908 1877 end; 1909 1878 Kind := Category; … … 1918 1887 x, y: integer); 1919 1888 var 1920 i0, Sel0: Integer;1889 i0, Sel0: integer; 1921 1890 begin 1922 1891 y := y - WideFrame; 1923 i0 := ScrollBar.Position;1892 i0 := sb.Position; 1924 1893 Sel0 := Sel; 1925 1894 if (x >= SideFrame) and (x < SideFrame + InnerWidth) and (y >= 0) and … … 1934 1903 begin 1935 1904 if Sel0 <> -1 then 1936 Line(Canvas, Sel0, False);1905 line(Canvas, Sel0, false); 1937 1906 if Sel <> -1 then 1938 Line(Canvas, Sel, True)1907 line(Canvas, Sel, true) 1939 1908 end 1940 1909 end; … … 1944 1913 begin 1945 1914 if Sel >= 0 then 1946 with THelpLineInfo(MainText.Objects[Sel + ScrollBar.Position]) do1915 with THelpLineInfo(MainText.Objects[Sel + sb.Position]) do 1947 1916 if Link shr 8 and $3F = hkInternet then 1948 1917 case Link and $FF of … … 1963 1932 1964 1933 procedure THelpDlg.BackBtnClick(Sender: TObject); 1965 var 1966 HistItem: THistItem; 1967 begin 1968 if HistItems.Count > 1 then begin 1969 HistItem := THistItem.Create; 1970 HistItem.Assign(HistItems.Last); 1971 HistItems.Delete(HistItems.Count - 1); 1972 if (HistItem.Kind = hkMisc) and (HistItem.No = miscSearchResult) and 1973 (HistItem.SearchContent <> SearchContent) then 1974 begin 1975 SearchContent := HistItem.SearchContent; 1934 begin 1935 if nHist > 0 then 1936 begin 1937 dec(nHist); 1938 if (HistKind[nHist] = hkMisc) and (HistNo[nHist] = miscSearchResult) and 1939 (HistSearchContent[nHist] <> SearchContent) then 1940 begin 1941 SearchContent := HistSearchContent[nHist]; 1976 1942 Search(SearchContent); 1977 1943 end; 1978 Kind := Hist Item.Kind;1979 no := Hist Item.No;1980 Prepare(Hist Item.Pos);1944 Kind := HistKind[nHist]; 1945 no := HistNo[nHist]; 1946 Prepare(HistPos[nHist]); 1981 1947 OffscreenPaint; 1982 1948 Invalidate; 1983 HistItem.Free; 1984 end; 1949 end 1985 1950 end; 1986 1951 1987 1952 procedure THelpDlg.TopBtnClick(Sender: TObject); 1988 1953 begin 1989 while HistItems.Count > 1 do HistItems.Delete(HistItems.Count - 1);1954 nHist := 0; 1990 1955 Kind := hkMisc; 1991 1956 no := miscMain; … … 2001 1966 end; 2002 1967 2003 function THelpDlg.TextIndex(Item: string): Integer;2004 begin 2005 Result := HelpText.Gethandle(Item)1968 function THelpDlg.TextIndex(Item: string): integer; 1969 begin 1970 result := HelpText.Gethandle(Item) 2006 1971 end; 2007 1972 … … 2020 1985 InputDlg.CenterToRect(BoundsRect); 2021 1986 InputDlg.ShowModal; 2022 if (InputDlg.ModalResult = mrOK) and ( Length(InputDlg.EInput.Text) >= 2) then1987 if (InputDlg.ModalResult = mrOK) and (length(InputDlg.EInput.Text) >= 2) then 2023 1988 begin 2024 1989 Search(InputDlg.EInput.Text); … … 2037 2002 NewSearchContent := InputDlg.EInput.Text; 2038 2003 ShowNewContent(FWindowMode, hkMisc, miscSearchResult); 2039 end ;2040 end ;2041 end ;2004 end 2005 end 2006 end 2042 2007 end; 2043 2008 2044 2009 procedure THelpDlg.Search(SearchString: string); 2045 2010 var 2046 h, i, PrevHandle, PrevIndex, p, RightMargin: Integer;2011 h, i, PrevHandle, PrevIndex, p, RightMargin: integer; 2047 2012 s: string; 2048 2013 mADVHELP, mIMPHELP, mFEATUREHELP: set of 0 .. 255; 2049 bGOVHELP, bSPECIALMODEL, bJOBHELP: Boolean;2014 bGOVHELP, bSPECIALMODEL, bJOBHELP: boolean; 2050 2015 begin 2051 2016 SearchResult.Clear; … … 2053 2018 mIMPHELP := []; 2054 2019 mFEATUREHELP := []; 2055 bGOVHELP := False;2056 bSPECIALMODEL := False;2057 bJOBHELP := False;2020 bGOVHELP := false; 2021 bSPECIALMODEL := false; 2022 bJOBHELP := false; 2058 2023 2059 2024 // search in generic reference 2060 2025 SearchString := UpperCase(SearchString); 2061 for i := 0 to 35 + 4 do begin 2026 for i := 0 to 35 + 4 do 2027 begin 2062 2028 s := Phrases.Lookup('TERRAIN', i); 2063 2029 if pos(SearchString, UpperCase(s)) > 0 then … … 2074 2040 imShipComp + i - 37) + ' ' + HelpText.Lookup('HELPSPEC_SHIPPART'), 2075 2041 pkNormal, 0, hkImp + hkCrossLink, imShipComp + i - 37); 2076 Break ;2077 end ;2042 Break 2043 end 2078 2044 end; 2079 2045 for i := 0 to nJobHelp - 1 do … … 2083 2049 SearchResult.AddLine(HelpText.Lookup('HELPTITLE_JOBLIST'), pkNormal, 0, 2084 2050 hkMisc + hkCrossLink, miscJobList); 2085 bJOBHELP := True;2086 Break ;2051 bJOBHELP := true; 2052 Break 2087 2053 end; 2088 2054 for i := 0 to nAdv - 1 do … … 2097 2063 SearchResult.AddLine(s, pkNormal, 0, hkAdv + hkCrossLink, i); 2098 2064 include(mADVHELP, i); 2099 end ;2065 end 2100 2066 end; 2101 2067 for i := 0 to nSpecialModel - 1 do … … 2106 2072 SearchResult.AddLine(HelpText.Lookup('HELPTITLE_MODELLIST'), pkNormal, 0, 2107 2073 hkModel + hkCrossLink, 0); 2108 bSPECIALMODEL := True;2109 Break ;2074 bSPECIALMODEL := true; 2075 Break 2110 2076 end; 2111 2077 end; … … 2113 2079 begin 2114 2080 s := Phrases.Lookup('FEATURES', i); 2115 if Pos(SearchString, UpperCase(s)) > 0 then2081 if pos(SearchString, UpperCase(s)) > 0 then 2116 2082 begin 2117 2083 if i < mcFirstNonCap then … … 2122 2088 s := s + ' ' + HelpText.Lookup('HELPSPEC_FEATURE'); 2123 2089 SearchResult.AddLine(s, pkNormal, 0, hkFeature + hkCrossLink, i); 2124 Include(mFEATUREHELP, i);2125 end ;2090 include(mFEATUREHELP, i); 2091 end 2126 2092 end; 2127 2093 for i := 0 to nImp - 1 do 2128 2094 begin 2129 2095 s := Phrases.Lookup('IMPROVEMENTS', i); 2130 if Pos(SearchString, UpperCase(s)) > 0 then2096 if pos(SearchString, UpperCase(s)) > 0 then 2131 2097 begin 2132 2098 case Imp[i].Kind of … … 2141 2107 end; 2142 2108 SearchResult.AddLine(s, pkNormal, 0, hkImp + hkCrossLink, i); 2143 Include(mIMPHELP, i);2109 include(mIMPHELP, i); 2144 2110 end 2145 2111 end; 2146 2112 for i := 0 to nGov - 1 do 2147 if Pos(SearchString, UpperCase(Phrases.Lookup('GOVERNMENT', i))) > 0 then2113 if pos(SearchString, UpperCase(Phrases.Lookup('GOVERNMENT', i))) > 0 then 2148 2114 begin 2149 2115 SearchResult.AddLine(HelpText.Lookup('HELPTITLE_GOVLIST'), pkNormal, 0, 2150 2116 hkMisc + hkCrossLink, miscGovList); 2151 bGOVHELP := True;2152 Break ;2117 bGOVHELP := true; 2118 Break 2153 2119 end; 2154 2120 … … 2171 2137 s := s + ' ' + HelpText.Lookup('HELPSPEC_ADV'); 2172 2138 SearchResult.AddLine(s, pkNormal, 0, hkAdv + hkCrossLink, i) 2173 end ;2139 end 2174 2140 end 2175 2141 else if h = hIMPHELP then … … 2190 2156 end; 2191 2157 SearchResult.AddLine(s, pkNormal, 0, hkImp + hkCrossLink, i) 2192 end ;2158 end 2193 2159 end 2194 2160 else if h = hFEATUREHELP then … … 2205 2171 s := s + ' ' + HelpText.Lookup('HELPSPEC_FEATURE'); 2206 2172 SearchResult.AddLine(s, pkNormal, 0, hkFeature + hkCrossLink, i); 2207 end ;2173 end 2208 2174 end 2209 2175 else if h = hGOVHELP then … … 2228 2194 begin 2229 2195 s := HelpText.LookupByHandle(h); 2230 p := Pos('$', s);2196 p := pos('$', s); 2231 2197 if p > 0 then 2232 2198 begin 2233 s := Copy(s, p + 1, maxint);2234 p := Pos('\', s);2199 s := copy(s, p + 1, maxint); 2200 p := pos('\', s); 2235 2201 if p > 0 then 2236 s := Copy(s, 1, p - 1);2202 s := copy(s, 1, p - 1); 2237 2203 SearchResult.AddLine(s, pkNormal, 0, hkText + hkCrossLink, h); 2238 end ;2239 end ;2240 until False;2204 end 2205 end 2206 until false; 2241 2207 2242 2208 // cut lines to fit to window
Note:
See TracChangeset
for help on using the changeset viewer.