Ignore:
Timestamp:
Nov 27, 2023, 12:10:57 AM (6 months ago)
Author:
chronos
Message:
  • Modified: Use enumeration type in Help unit for better readability.
  • Fixed: Corruption external help image referenced with incorrect file name case.
  • Fixed: Chinese translation converted to UTF-8.
  • Modified: Code cleanup.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/Help.pas

    r456 r457  
    1212  MaxHist = 16;
    1313
    14   { link categories }
    15   hkNoLink = 0;
    16   hkAdv = 1;
    17   hkImp = 2;
    18   hkTer = 3;
    19   hkFeature = 4;
    20   hkInternet = 5;
    21   hkModel = 6;
    22   hkMisc = 7;
    23   hkCrossLink = $40;
    24   hkText = $80;
    25 
    26   liInvalid = $3FFF; // link index indicates invalid link
    27 
    28   { link indices for category hkMisc }
    29   miscMain = 0;
    30   miscCredits = 1;
    31   miscGovList = 2;
    32   miscJobList = 3;
    33   miscSearchResult = 7;
    34 
    35   fJungle = 8; // pseudo terrain
     14  fJungle = 8; // Pseudo terrain
    3615
    3716type
     17  { Link categories }
     18  TLinkCategory = (
     19    hkNoLink,
     20    hkAdv,
     21    hkImp,
     22    hkTer,
     23    hkFeature ,
     24    hkInternet,
     25    hkModel,
     26    hkMisc,
     27    hkText);
     28
     29  { Link indices for category hkMisc }
     30  TMiscLinkIndex = (
     31    miscMain,
     32    miscCredits,
     33    miscGovList,
     34    miscJobList,
     35    miscSearchResult);
     36
     37  TTextFormat = (
     38    pkNormal,
     39    pkCaption,
     40    pkSmallIcon,
     41    pkBigIcon,
     42    pkAdvIcon,
     43    pkTer,
     44    pkBigTer,
     45    pkFeature,
     46    pkDot,
     47    pkNormal_Dot,
     48    pkDomain,
     49    pkSection,
     50    pkBigFeature,
     51    pkExp,
     52    pkAITStat,
     53    pkExternal,
     54    pkModel,
     55    pkNormal_64,
     56    pkIllu,
     57    pkLogo,
     58    pkTerImp,
     59    pkRightIcon,
     60    pkAdvIcon_AsPreq,
     61    pkSmallIcon_AsPreq,
     62    pkSpecialIcon,
     63    pkGov);
    3864
    3965  { THyperText }
     
    4167  THyperText = class(TStringList)
    4268  public
    43     procedure AddLine(S: String = ''; Format: Integer = 0; Picpix: Integer = 0;
    44       LinkCategory: Integer = 0; LinkIndex: Integer = 0);
     69    procedure AddLine(S: String = ''; Format: TTextFormat = pkNormal; Picpix: Integer = 0;
     70      LinkCategory: TLinkCategory = hkNoLink; LinkIndex: Integer = 0; CrossLink: Boolean = False);
    4571    procedure LineFeed;
    4672    procedure AppendList(Source: THyperText);
    47     destructor Destroy; override;
    4873  end;
    4974
     
    5176
    5277  THistItem = class
    53     Kind: Integer;
     78    Kind: TLinkCategory;
    5479    No: Integer;
    5580    Pos: Integer;
     
    6186
    6287  THistItems = class(TObjectList<THistItem>)
    63     function AddNew(Kind, No, Pos: Integer; SearchContent: string): THistItem;
     88    function AddNew(Kind: TLinkCategory; No, Pos: Integer; SearchContent: string): THistItem;
    6489  end;
    6590
     
    89114    procedure OffscreenPaint; override;
    90115  private
    91     Kind: Integer;
    92     no: Integer;
     116    Kind: TLinkCategory;
     117    No: Integer;
    93118    Sel: Integer;
    94119    CaptionColor: Integer;
     
    100125    SearchResult: THyperText;
    101126    HelpText: TStringTable;
    102     ExtPic, TerrIcon: TBitmap;
     127    ExtPic: TBitmap;
     128    TerrIcon: TBitmap;
    103129    ScrollBar: TPVScrollbar;
    104130    NoMap: TIsoMap;
     
    106132    procedure PaintTerrIcon(X, Y, xSrc, ySrc: Integer);
    107133    procedure ScrollBarUpdate(Sender: TObject);
    108     procedure Line(ca: TCanvas; I: Integer; lit: Boolean);
     134    procedure Line(ACanvas: TCanvas; I: Integer; Lit: Boolean);
    109135    procedure Prepare(sbPos: Integer = 0);
    110136    procedure ShowNewContentProcExecute(NewMode: TWindowMode; HelpContext: string);
     
    117143    Difficulty: Integer;
    118144    procedure ClearHistory;
    119     procedure ShowNewContent(NewMode: TWindowMode; Category, Index: Integer);
     145    procedure ShowNewContent(NewMode: TWindowMode; Category: TLinkCategory; Index: Integer);
    120146    function TextIndex(Item: string): Integer;
    121147  end;
     
    138164
    139165  THelpLineInfo = class
    140     Format: Byte;
     166    Format: TTextFormat;
    141167    Picpix: Byte;
    142     Link: Word;
     168    Category: TLinkCategory;
     169    Index: Integer;
     170    CrossLink: Boolean;
    143171    procedure Assign(Source: THelpLineInfo);
    144172  end;
    145173
    146 { THelpLineInfo }
    147 
    148 procedure THelpLineInfo.Assign(Source: THelpLineInfo);
    149 begin
    150   Format := Source.Format;
    151   PicPix := Source.PicPix;
    152   Link := Source.Link;
    153 end;
    154 
    155 { THistItem }
    156 
    157 procedure THistItem.Assign(Source: THistItem);
    158 begin
    159   Kind := Source.Kind;
    160   No := Source.No;
    161   Pos := Source.Pos;
    162   SearchContent := Source.SearchContent;
    163 end;
    164 
    165 { THistItems }
    166 
    167 function THistItems.AddNew(Kind, No, Pos: Integer; SearchContent: string
    168   ): THistItem;
    169 begin
    170   Result := THistItem.Create;
    171   Result.Kind := Kind;
    172   Result.No := No;
    173   Result.Pos := Pos;
    174   Result.SearchContent := SearchContent;
    175   Add(Result);
    176 end;
    177 
    178 procedure THyperText.AddLine(S: String; Format: Integer; Picpix: Integer;
    179   LinkCategory: Integer; LinkIndex: Integer);
    180 var
    181   HelpLineInfo: THelpLineInfo;
    182 begin
    183   HelpLineInfo := THelpLineInfo.Create;
    184   if LinkIndex < 0 then
    185     LinkIndex := liInvalid;
    186   HelpLineInfo.Format := Format;
    187   HelpLineInfo.Picpix := Picpix;
    188   HelpLineInfo.Link := LinkCategory shl 8 + LinkIndex;
    189   AddObject(S, TObject(HelpLineInfo));
    190 end;
    191 
    192 procedure THyperText.LineFeed;
    193 begin
    194   AddLine;
    195 end;
    196 
    197 procedure THyperText.AppendList(Source: THyperText);
    198 var
    199   I: Integer;
    200   HelpLineInfo: THelpLineInfo;
    201 begin
    202   for I := 0 to Source.Count - 1 do begin
    203     HelpLineInfo := THelpLineInfo.Create;
    204     HelpLineInfo.Assign(THelpLineInfo(Source.Objects[I]));
    205     AddObject(Source.Strings[I], HelpLineInfo);
    206   end;
    207 end;
    208 
    209 destructor THyperText.Destroy;
    210 begin
    211   inherited;
    212 end;
     174  TSeeAlso = record
     175    Kind: TLinkCategory;
     176    No: Integer;
     177    SeeKind: TLinkCategory;
     178    SeeNo: Integer;
     179  end;
    213180
    214181const
    215   { text formats }
    216   pkNormal = 0;
    217   pkCaption = 1;
    218   pkSmallIcon = 2;
    219   pkBigIcon = 3;
    220   pkAdvIcon = 4;
    221   pkTer = 5;
    222   pkBigTer = 6;
    223   pkFeature = 7;
    224   pkDot = 8;
    225   pkNormal_Dot = 9;
    226   pkDomain = 10;
    227   pkSection = 11;
    228   pkBigFeature = 12;
    229   pkExp = 13;
    230   pkAITStat = 14;
    231   pkExternal = 15;
    232   pkModel = 16;
    233   pkNormal_64 = 17;
    234   pkIllu = 18;
    235   pkLogo = 19;
    236   pkTerImp = 20;
    237   pkRightIcon = 21;
    238   pkAdvIcon_AsPreq = 22;
    239   pkSmallIcon_AsPreq = 23;
    240   pkSpecialIcon = 24;
    241   pkGov = 25;
    242 
    243   nSeeAlso = 14;
    244   SeeAlso: array [0 .. nSeeAlso - 1] of record
    245     Kind: Integer;
    246     no: Integer;
    247     SeeKind: Integer;
    248     SeeNo: Integer;
    249   end = ((Kind: hkImp; no: imWalls; SeeKind: hkFeature;
     182  SeeAlso: array[0..13] of TSeeAlso = ((Kind: hkImp; no: imWalls; SeeKind: hkFeature;
    250183    SeeNo: mcArtillery), (Kind: hkImp; no: imHydro; SeeKind: hkImp;
    251184    SeeNo: woHoover), (Kind: hkImp; no: imWalls; SeeKind: hkImp;
     
    262195    SeeKind: hkFeature; SeeNo: mcDefense));
    263196
    264   nTerrainHelp = 14;
    265   TerrainHelp: array [0 .. nTerrainHelp - 1] of Integer = (fGrass, fGrass + 12,
     197  TerrainHelp: array[0..13] of Integer = (fGrass, fGrass + 12,
    266198    fPrairie, fForest, fJungle, fHills, fMountains, fSwamp, fTundra, fArctic,
    267     fDesert, 3 * 12 { DeadLands } , fShore, fOcean);
    268 
    269   nJobHelp = 8;
    270   JobHelp: array [0 .. nJobHelp - 1] of Integer = (jRoad, jRR, jCanal, jIrr,
     199    fDesert, 3 * 12 { DeadLands }, fShore, fOcean);
     200
     201  JobHelp: array[0..7] of Integer = (jRoad, jRR, jCanal, jIrr,
    271202    jFarm, jMine, jFort, jBase);
     203
     204{ THelpLineInfo }
     205
     206procedure THelpLineInfo.Assign(Source: THelpLineInfo);
     207begin
     208  Format := Source.Format;
     209  PicPix := Source.PicPix;
     210  Category := Source.Category;
     211  Index := Source.Index;
     212end;
     213
     214{ THistItem }
     215
     216procedure THistItem.Assign(Source: THistItem);
     217begin
     218  Kind := Source.Kind;
     219  No := Source.No;
     220  Pos := Source.Pos;
     221  SearchContent := Source.SearchContent;
     222end;
     223
     224{ THistItems }
     225
     226function THistItems.AddNew(Kind: TLinkCategory; No, Pos: Integer; SearchContent: string
     227  ): THistItem;
     228begin
     229  Result := THistItem.Create;
     230  Result.Kind := Kind;
     231  Result.No := No;
     232  Result.Pos := Pos;
     233  Result.SearchContent := SearchContent;
     234  Add(Result);
     235end;
     236
     237procedure THyperText.AddLine(S: String; Format: TTextFormat; Picpix: Integer;
     238  LinkCategory: TLinkCategory = hkNoLink; LinkIndex: Integer = 0;
     239  CrossLink: Boolean = False);
     240var
     241  HelpLineInfo: THelpLineInfo;
     242begin
     243  HelpLineInfo := THelpLineInfo.Create;
     244  HelpLineInfo.Format := Format;
     245  HelpLineInfo.Picpix := Picpix;
     246  HelpLineInfo.Category := LinkCategory;
     247  HelpLineInfo.Index := LinkIndex;
     248  HelpLineInfo.CrossLink := CrossLink;
     249  AddObject(S, HelpLineInfo);
     250end;
     251
     252procedure THyperText.LineFeed;
     253begin
     254  AddLine;
     255end;
     256
     257procedure THyperText.AppendList(Source: THyperText);
     258var
     259  I: Integer;
     260  HelpLineInfo: THelpLineInfo;
     261begin
     262  for I := 0 to Source.Count - 1 do begin
     263    HelpLineInfo := THelpLineInfo.Create;
     264    HelpLineInfo.Assign(THelpLineInfo(Source.Objects[I]));
     265    AddObject(Source.Strings[I], HelpLineInfo);
     266  end;
     267end;
    272268
    273269procedure THelpDlg.FormCreate(Sender: TObject);
     
    365361  if Sel <> -1 then begin
    366362    Line(Canvas, Sel, False);
    367     Sel := -1
     363    Sel := -1;
    368364  end;
    369365end;
     
    380376end;
    381377
    382 procedure THelpDlg.Line(ca: TCanvas; I: Integer; lit: Boolean);
     378procedure THelpDlg.Line(ACanvas: TCanvas; I: Integer; Lit: Boolean);
    383379var
    384   TextColor, X, Y: Integer;
     380  TextColor: TColor;
     381  X, Y: Integer;
    385382  TextSize: TSize;
    386383  S: string;
     
    391388  X := x0[I];
    392389  Y := 2 + I * 24;
    393   if ca = Canvas then
     390  if ACanvas = Canvas then
    394391  begin
    395392    X := X + SideFrame;
    396     Y := Y + WideFrame
     393    Y := Y + WideFrame;
    397394  end;
    398395  if THelpLineInfo(MainText.Objects[ScrollBar.Position + I]).Format
    399396    in [pkCaption, pkBigTer, pkRightIcon, pkBigFeature] then
    400397  begin
    401     ca.Font.Assign(CaptionFont);
    402     { ca.brush.color:=CaptionColor;
    403       ca.FillRect(rect(X,I*24,X+24,I*24+24));
    404       ca.Brush.Color:=$FFFFFF;
    405       ca.FrameRect(rect(X+1,I*24+1,X+24-1,I*24+24-1));
    406       ca.Brush.Style:=bsClear; }
    407     BitBltCanvas(ca, X, Y - 4, 24, 24, HGrSystem.Data.Canvas, 1,
     398    ACanvas.Font.Assign(CaptionFont);
     399    { ACanvas.brush.color:=CaptionColor;
     400      ACanvas.FillRect(rect(X,I*24,X+24,I*24+24));
     401      ACanvas.Brush.Color:=$FFFFFF;
     402      ACanvas.FrameRect(rect(X+1,I*24+1,X+24-1,I*24+24-1));
     403      ACanvas.Brush.Style:=bsClear; }
     404    BitBltCanvas(ACanvas, X, Y - 4, 24, 24, HGrSystem.Data.Canvas, 1,
    408405      146);
    409     BiColorTextOut(ca, $FFFFFF, $7F007F, X + 10 - ca.Textwidth(S[1]) div 2,
     406    BiColorTextOut(ACanvas, $FFFFFF, $7F007F, X + 10 - ACanvas.Textwidth(S[1]) div 2,
    410407      Y - 3, S[1]);
    411     BiColorTextOut(ca, CaptionColor, $7F007F, X + 24, Y - 3, Copy(S, 2, 255));
    412     ca.Font.Assign(UniFont[ftNormal]);
     408    BiColorTextOut(ACanvas, CaptionColor, $7F007F, X + 24, Y - 3, Copy(S, 2, 255));
     409    ACanvas.Font.Assign(UniFont[ftNormal]);
    413410  end
    414   else if THelpLineInfo(MainText.Objects[ScrollBar.Position + I]).Format = pkSection
    415   then
    416   begin
    417     ca.Font.Assign(CaptionFont);
    418     BiColorTextOut(ca, CaptionColor, $7F007F, X, Y - 3, S);
    419     ca.Font.Assign(UniFont[ftNormal]);
     411  else if THelpLineInfo(MainText.Objects[ScrollBar.Position + I]).Format = pkSection then
     412  begin
     413    ACanvas.Font.Assign(CaptionFont);
     414    BiColorTextOut(ACanvas, CaptionColor, $7F007F, X, Y - 3, S);
     415    ACanvas.Font.Assign(UniFont[ftNormal]);
    420416  end
    421417  else
    422418  begin
    423     if (Kind = hkMisc) and (no = miscMain) then
    424       ca.Font.Assign(CaptionFont);
     419    if (Kind = hkMisc) and (No = Integer(miscMain)) then
     420      ACanvas.Font.Assign(CaptionFont);
    425421    TextColor := Colors.Canvas.Pixels[clkMisc, cliPaperText];
    426     if ca = Canvas then
     422    if ACanvas = Canvas then
    427423    begin
    428       TextSize.cx := BiColorTextWidth(ca, S);
    429       TextSize.cy := ca.TextHeight(S);
     424      TextSize.cx := BiColorTextWidth(ACanvas, S);
     425      TextSize.cy := ACanvas.TextHeight(S);
    430426      if Y + TextSize.cy >= WideFrame + InnerHeight then
    431427        TextSize.cy := WideFrame + InnerHeight - Y;
    432       FillSeamless(ca, X, Y, TextSize.cx, TextSize.cy, -SideFrame,
     428      FillSeamless(ACanvas, X, Y, TextSize.cx, TextSize.cy, -SideFrame,
    433429        ScrollBar.Position * 24 - WideFrame, Paper);
    434430    end;
    435     BiColorTextOut(ca, TextColor, $7F007F, X, Y, S);
     431    BiColorTextOut(ACanvas, TextColor, $7F007F, X, Y, S);
    436432    if lit then
    437       with ca do
     433      with ACanvas do
    438434      begin
    439         Assert(ca = Canvas);
     435        Assert(ACanvas = Canvas);
    440436        Pen.Color := TextColor;
    441437        MoveTo(X + 1, Y + TextSize.cy - 2);
    442438        LineTo(X + TextSize.cx, Y + TextSize.cy - 2);
    443439      end;
    444     if (Kind = hkMisc) and (no = miscMain) then
    445       ca.Font.Assign(UniFont[ftNormal]);
     440    if (Kind = hkMisc) and (No = Integer(miscMain)) then
     441      ACanvas.Font.Assign(UniFont[ftNormal]);
    446442  end;
    447443end;
     
    493489          end;
    494490        end;
    495         if Sum < MaxSum then begin // no saturation
     491        if Sum < MaxSum then begin // No saturation
    496492          Sum := 1 shl 22 - (MaxSum - Sum) * (256 - CoalPtr.Pixel^.B * 2);
    497493          PaintPtr.Pixel^.B := Min(PaintPtr.Pixel^.B * Sum shr 22, 255);
     
    559555      begin
    560556        HelpLineInfo := THelpLineInfo(MainText.Objects[ScrollBar.Position + I]);
    561         if HelpLineInfo.Link <> 0 then
     557        if (HelpLineInfo.Category <> hkNoLink) or (HelpLineInfo.Index <> 0) then
    562558        begin
    563           if (Kind = hkMisc) and (no = miscSearchResult) then
     559          if (Kind = hkMisc) and (No = Integer(miscSearchResult)) then
    564560            Sprite(OffScreen, HGrSystem, 18, 9 + I * 24, 8, 8, 90, 16)
    565561          else if HelpLineInfo.Format in [pkSmallIcon_AsPreq, pkAdvIcon_AsPreq]
    566562          then
    567563            Sprite(OffScreen, HGrSystem, 12, I * 24 + 5, 14, 14, 65, 20)
    568           else if HelpLineInfo.Link and (hkCrossLink shl 8) <> 0 then
     564          else if HelpLineInfo.CrossLink then
    569565            Sprite(OffScreen, HGrSystem, 12, I * 24 + 5, 14, 14, 80, 1)
    570           else if not((Kind = hkMisc) and (no = miscMain)) then
     566          else if not((Kind = hkMisc) and (No = Integer(miscMain))) then
    571567            Sprite(OffScreen, HGrSystem, 10, I * 24 + 6, 14, 14, 65, 1);
    572568          x0[I] := 24;
     
    873869begin
    874870  Sel := -1;
    875   SmartUpdateContent(True)
     871  SmartUpdateContent(True);
    876872end;
    877873
     
    887883  begin
    888884    MainText.AddLine(Phrases.Lookup('ADVANCES', I), pkAdvIcon, I,
    889       hkAdv + hkCrossLink, I);
     885      hkAdv, I, True);
    890886  end;
    891887
     
    893889  begin
    894890    MainText.AddLine(Phrases.Lookup('ADVANCES', I), pkAdvIcon_AsPreq, I,
    895       hkAdv + hkCrossLink, I);
     891      hkAdv, I, True);
    896892  end;
    897893
     
    899895  begin
    900896    MainText.AddLine(Phrases.Lookup('IMPROVEMENTS', I), pkSmallIcon, I,
    901       hkImp + hkCrossLink, I);
     897      hkImp, I, True);
    902898  end;
    903899
     
    905901  begin
    906902    MainText.AddLine(Phrases.Lookup('IMPROVEMENTS', I), pkSmallIcon_AsPreq, I,
    907       hkImp + hkCrossLink, I);
     903      hkImp, I, True);
    908904  end;
    909905
     
    920916  begin
    921917    MainText.AddLine(Phrases.Lookup('FEATURES', I), pkFeature, I,
    922       hkFeature + hkCrossLink, I);
     918      hkFeature, I, True);
    923919  end;
    924920
     
    931927      MainText.LineFeed;
    932928    FindStdModelPicture(SpecialModelPictureCode[I], pix, Name);
    933     MainText.AddLine(Name, pkModel, pix, hkModel + hkCrossLink, I)
     929    MainText.AddLine(Name, pkModel, pix, hkModel, I, True);
    934930  end;
    935931
     
    951947          I := 2;
    952948        AddLine(Format(HelpText.Lookup('TECHFORMULA'), [TechFormula_M[I],
    953           TechFormula_D[I]]))
     949          TechFormula_D[I]]));
    954950      end
    955951      else if Item = 'EXPERIENCE' then
     
    967963        for I := 0 to 3 do
    968964          AddLine(Phrases2.Lookup('AITSTAT', I), pkAITStat, I)
    969     end
    970   end;
    971 
    972   procedure DecodeItem(S: string; var Category, Index: Integer);
     965    end;
     966  end;
     967
     968  procedure DecodeItem(S: string; var Category: TLinkCategory; var Index: Integer);
    973969  var
    974970    I: Integer;
     
    986982        'E': Category := hkInternet;
    987983        'S': Category := hkModel;
    988         'C': Index := miscCredits;
    989         'J': Index := miscJobList;
    990         'G': Index := miscGovList;
     984        'C': Index := Integer(miscCredits);
     985        'J': Index := Integer(miscJobList);
     986        'G': Index := Integer(miscGovList);
    991987      end;
    992988      if (Category <> hkMisc) and (Index = 0) then
     
    994990    end else begin
    995991      Category := hkText;
    996       Index := HelpText.Gethandle(Copy(S, 1, 255));
     992      Index := HelpText.GetHandle(Copy(S, 1, 255));
    997993    end;
    998994  end;
     
    10041000    L: Integer;
    10051001    ofs: Integer;
    1006     CurrentFormat: Integer;
    1007     FollowFormat: Integer;
     1002    CurrentFormat: TTextFormat;
     1003    FollowFormat: TTextFormat;
    10081004    Picpix: Integer;
    1009     LinkCategory: Integer;
     1005    LinkCategory: TLinkCategory;
     1006    CrossLink: Boolean;
    10101007    LinkIndex: Integer;
    10111008    RightMargin: Integer;
     
    10131010    Text: string;
    10141011  begin
     1012    CrossLink := False;
    10151013    RightMargin := InnerWidth - 16 - GetSystemMetrics(SM_CXVSCROLL);
    10161014    FollowFormat := pkNormal;
     
    10181016    begin
    10191017      Picpix := 0;
    1020       LinkCategory := 0;
     1018      LinkCategory := hkNoLink;
    10211019      LinkIndex := 0;
    10221020      if S[1] = '$' then
    1023       begin // window caption
     1021      begin // Window caption
    10241022        P := 1;
    10251023        repeat
     
    10301028      end
    10311029      else if S[1] = '&' then
    1032       begin // standard block
     1030      begin // Standard block
    10331031        P := 1;
    10341032        repeat
     
    10391037      end
    10401038      else if S[1] = '@' then
    1041       begin // image
     1039      begin // Image
    10421040        if (Length(S) >= 2) and (S[2] = '@') then
    1043         begin // generate from icon
     1041        begin // Generate from icon
    10441042          Picpix := 0;
    10451043          P := 3;
     
    10781076              P := 1;
    10791077              repeat
    1080                 Inc(P)
     1078                Inc(P);
    10811079              until (P > Length(S)) or (S[P] = '\') or (S[P] = ' ');
    10821080              DecodeItem(Copy(S, 2, P - 2), LinkCategory, LinkIndex);
    1083               CurrentFormat := 0;
     1081              CurrentFormat := pkNormal;
    10841082              if (LinkCategory <> hkText) and (LinkIndex < 200) then
    10851083              // show icon
     
    10881086                    begin
    10891087                      CurrentFormat := pkAdvIcon;
    1090                       Picpix := LinkIndex
     1088                      Picpix := LinkIndex;
    10911089                    end;
    10921090                  hkImp:
    10931091                    begin
    10941092                      CurrentFormat := pkSmallIcon;
    1095                       Picpix := LinkIndex
     1093                      Picpix := LinkIndex;
    10961094                    end;
    10971095                  hkTer:
     
    11031101                    begin
    11041102                      CurrentFormat := pkFeature;
    1105                       Picpix := LinkIndex
     1103                      Picpix := LinkIndex;
    11061104                    end;
    11071105                  hkModel:
     
    11131111                end;
    11141112              if S[1] = ':' then
    1115                 LinkCategory := LinkCategory + hkCrossLink;
     1113                CrossLink := True;
    11161114              if (P > Length(S)) or (S[P] = ' ') then
    11171115                Delete(S, 1, P)
     
    11191117                Delete(S, 1, P - 1)
    11201118            end;
    1121           '!': // highlited
     1119          '!': // highlighted
    11221120            if (Length(S) >= 2) and (S[2] = '!') then
    11231121            begin
     
    11591157        until (P >= Length(S)) or (S[L + 1] = '\');
    11601158        Text := Copy(S, 1, L);
    1161         if LinkCategory and $3F = hkInternet then begin
     1159        if LinkCategory = hkInternet then begin
    11621160          if LinkIndex = 1 then Text := AITemplateManual
    11631161          else if LinkIndex = 2 then Text := CevoHomepageShort
     
    11651163        end;
    11661164        MainText.AddLine(Text, CurrentFormat, Picpix, LinkCategory,
    1167           LinkIndex);
     1165          LinkIndex, CrossLink);
    11681166        if (L < Length(S)) and (S[L + 1] = '\') then
    11691167          FollowFormat := pkNormal;
    11701168        Delete(S, 1, L + 1);
    1171       end
    1172     end
     1169      end;
     1170    end;
    11731171  end;
    11741172
     
    12231221  begin
    12241222    with MainText do begin
    1225       for I := 0 to nJobHelp - 1 do begin
     1223      for I := 0 to Length(JobHelp) - 1 do begin
    12261224        if I > 0 then begin
    12271225          LineFeed;
     
    13231321    Clear;
    13241322    Headline := -1;
    1325     if (no >= 200) or not(Kind in [hkAdv, hkImp, hkTer, hkFeature]) then
     1323    if (No >= 200) or not (Kind in [hkAdv, hkImp, hkTer, hkFeature]) then
    13261324      LineFeed;
    13271325    case Kind of
    13281326      hkText:
    1329         AddTextual(HelpText.LookupByHandle(no));
     1327        AddTextual(HelpText.LookupByHandle(No));
    13301328      hkMisc:
    13311329        begin
    1332           case no of
    1333             miscMain:
     1330          case No of
     1331            Integer(miscMain):
    13341332              begin
    13351333                Caption := HelpText.Lookup('HELPTITLE_MAIN');
    13361334                AddLine(HelpText.Lookup('HELPTITLE_QUICKSTART'), pkSpecialIcon,
    1337                   0, { pkBigIcon,22, } hkText, HelpText.Gethandle('QUICK'));
     1335                  0, { pkBigIcon,22, } hkText, HelpText.GetHandle('QUICK'));
    13381336                LineFeed;
    13391337                AddLine(HelpText.Lookup('HELPTITLE_CONCEPTS'), pkBigIcon, 6,
     
    13441342                LineFeed;
    13451343                AddLine(HelpText.Lookup('HELPTITLE_JOBLIST'), pkSpecialIcon, 2,
    1346                   hkMisc, miscJobList);
     1344                  hkMisc, Integer(miscJobList));
    13471345                LineFeed;
    13481346                AddLine(HelpText.Lookup('HELPTITLE_TECHLIST'), pkBigIcon, 39,
     
    13661364                LineFeed;
    13671365                AddLine(HelpText.Lookup('HELPTITLE_GOVLIST'), pkBigIcon,
    1368                   gDemocracy + 6, hkMisc, miscGovList);
     1366                  gDemocracy + 6, hkMisc, Integer(miscGovList));
    13691367                LineFeed;
    13701368                AddLine(HelpText.Lookup('HELPTITLE_KEYS'), pkBigIcon, 2, hkText,
     
    13751373                LineFeed;
    13761374                AddLine(HelpText.Lookup('HELPTITLE_CREDITS'), pkBigIcon, 22,
    1377                   hkMisc, miscCredits);
     1375                  hkMisc, Integer(miscCredits));
    13781376              end;
    1379             miscCredits:
     1377            Integer(miscCredits):
    13801378              begin
    13811379                AddItem('CREDITS');
     
    13901388                AddItem('AUTHOR');
    13911389              end;
    1392             miscJobList:
     1390            Integer(miscJobList):
    13931391              begin
    13941392                Caption := HelpText.Lookup('HELPTITLE_JOBLIST');
     
    13991397                AddItem('TERIMPCITY');
    14001398              end;
    1401             miscGovList:
     1399            Integer(miscGovList):
    14021400              begin
    14031401                Caption := HelpText.Lookup('HELPTITLE_GOVLIST');
     
    14251423                end;
    14261424              end;
    1427             miscSearchResult:
     1425            Integer(miscSearchResult):
    14281426              begin
    14291427                Caption := HelpText.Lookup('HELPTITLE_SEARCHRESULTS');
     
    14311429                MainText.AppendList(SearchResult);
    14321430              end;
    1433           end; // case no
     1431          end; // case No
    14341432        end;
    14351433
    14361434      hkAdv:
    1437         if no = 200 then
     1435        if No = 200 then
    14381436        begin // complete advance list
    14391437          Caption := HelpText.Lookup('HELPTITLE_TECHLIST');
     
    14691467        else // single advance
    14701468        begin
    1471           Caption := Phrases.Lookup('ADVANCES', no);
     1469          Caption := Phrases.Lookup('ADVANCES', No);
    14721470          LineFeed;
    1473           AddLine(Phrases.Lookup('ADVANCES', no), pkCaption);
    1474           if no in FutureTech then
     1471          AddLine(Phrases.Lookup('ADVANCES', No), pkCaption);
     1472          if No in FutureTech then
    14751473          begin
    14761474            AddLine(HelpText.Lookup('HELPSPEC_FUTURE'));
    14771475            LineFeed;
    1478             if no = futResearchTechnology then
     1476            if No = futResearchTechnology then
    14791477              AddItem('FUTURETECHHELP100')
    14801478            else
     
    14831481          else
    14841482            AddLine(HelpText.Lookup('HELPSPEC_ADV'));
    1485           if AdvPreq[no, 2] <> preNone then
     1483          if AdvPreq[No, 2] <> preNone then
    14861484            NextSection('PREREQALT')
    14871485          else
    14881486            NextSection('PREREQ');
    14891487          for I := 0 to 2 do
    1490             if AdvPreq[no, I] <> preNone then
    1491               AddPreqAdv(AdvPreq[no, I]);
     1488            if AdvPreq[No, I] <> preNone then
     1489              AddPreqAdv(AdvPreq[No, I]);
    14921490          NextSection('GOVALLOW');
    14931491          for I := 2 to nGov - 1 do
    1494             if GovPreq[I] = no then
     1492            if GovPreq[I] = No then
    14951493              AddLine(Phrases.Lookup('GOVERNMENT', I), pkGov, I,
    1496                 hkMisc + hkCrossLink, miscGovList);
     1494                hkMisc, Integer(miscGovList), True);
    14971495          NextSection('BUILDALLOW');
    14981496          for I := 0 to nWonder - 1 do
    1499             if Imp[I].Preq = no then
     1497            if Imp[I].Preq = No then
    15001498              AddImprovement(I);
    15011499          for I := nWonder to nImp - 1 do
    1502             if (Imp[I].Preq = no) and (Imp[I].Kind <> ikCommon) then
     1500            if (Imp[I].Preq = No) and (Imp[I].Kind <> ikCommon) then
    15031501              AddImprovement(I);
    15041502          for I := nWonder to nImp - 1 do
    1505             if (Imp[I].Preq = no) and (Imp[I].Kind = ikCommon) then
     1503            if (Imp[I].Preq = No) and (Imp[I].Kind = ikCommon) then
    15061504              AddImprovement(I);
    15071505          NextSection('MODELALLOW');
    15081506          for I := 0 to nSpecialModel - 1 do
    1509             if SpecialModelPreq[I] = no then
     1507            if SpecialModelPreq[I] = No then
    15101508              AddModel(I);
    15111509          NextSection('FEATALLOW');
    15121510          for I := 0 to nFeature - 1 do
    1513             if Feature[I].Preq = no then
     1511            if Feature[I].Preq = No then
    15141512              AddFeature(I);
    15151513          NextSection('FOLLOWADV');
    15161514          for I := 0 to nAdv - 1 do
    1517             if (AdvPreq[I, 0] = no) or (AdvPreq[I, 1] = no) or
    1518               (AdvPreq[I, 2] = no) then
     1515            if (AdvPreq[I, 0] = No) or (AdvPreq[I, 1] = No) or
     1516              (AdvPreq[I, 2] = No) then
    15191517              AddAdvance(I);
    15201518          NextSection('UPGRADEALLOW');
    15211519          for Domain := 0 to nDomains - 1 do
    15221520            for I := 1 to nUpgrade - 1 do
    1523               if upgrade[Domain, I].Preq = no then
     1521              if upgrade[Domain, I].Preq = No then
    15241522              begin
    15251523                if upgrade[Domain, I].Strength > 0 then
     
    15311529                    [Phrases.Lookup('DOMAIN', Domain), upgrade[Domain, I].Trans]
    15321530                    ), pkDomain, Domain);
    1533                 if no in FutureTech then
     1531                if No in FutureTech then
    15341532                  AddLine(Format(HelpText.Lookup('COSTUP'),
    15351533                    [upgrade[Domain, I].Cost]), pkNormal_Dot)
     
    15401538          NextSection('EXPIRATION');
    15411539          for I := 0 to nWonder - 1 do
    1542             if (Imp[I].Preq <> preNA) and (Imp[I].Expiration = no) then
     1540            if (Imp[I].Preq <> preNA) and (Imp[I].Expiration = No) then
    15431541              AddImprovement(I);
    15441542          NextSection('ADVEFFECT');
    1545           S := HelpText.LookupByHandle(hADVHELP, no);
     1543          S := HelpText.LookupByHandle(hADVHELP, No);
    15461544          if S <> '*' then
    15471545            AddTextual(S);
    15481546          NextSection('SEEALSO');
    1549           CheckSeeAlso := True
     1547          CheckSeeAlso := True;
    15501548        end;
    15511549
    15521550      hkImp:
    1553         if no = 200 then
     1551        if No = 200 then
    15541552        begin // complete city improvement list
    15551553          Caption := HelpText.Lookup('HELPTITLE_IMPLIST');
     
    15661564          FreeAndNil(List);
    15671565        end
    1568         else if no = 201 then
     1566        else if No = 201 then
    15691567        begin // complete nat. project list
    15701568          Caption := HelpText.Lookup('HELPTITLE_UNIQUELIST');
     
    15821580            AddLine(Phrases.Lookup('IMPROVEMENTS',I),pkSmallIcon,I,hkImp,I); }
    15831581        end
    1584         else if no = 202 then
     1582        else if No = 202 then
    15851583        begin // complete wonder list
    15861584          Caption := HelpText.Lookup('HELPTITLE_WONDERLIST');
     
    15931591        else
    15941592        begin // single building
    1595           Caption := Phrases.Lookup('IMPROVEMENTS', no);
     1593          Caption := Phrases.Lookup('IMPROVEMENTS', No);
    15961594          LineFeed;
    1597           AddLine(Phrases.Lookup('IMPROVEMENTS', no), pkRightIcon, no);
    1598           case Imp[no].Kind of
     1595          AddLine(Phrases.Lookup('IMPROVEMENTS', No), pkRightIcon, No);
     1596          case Imp[No].Kind of
    15991597            ikWonder: AddLine(HelpText.Lookup('HELPSPEC_WONDER'));
    16001598            ikCommon: AddLine(HelpText.Lookup('HELPSPEC_IMP'));
     
    16031601            AddLine(HelpText.Lookup('HELPSPEC_NAT'))
    16041602          end;
    1605           if Imp[no].Kind <> ikShipPart then begin
     1603          if Imp[No].Kind <> ikShipPart then begin
    16061604            NextSection('EFFECT');
    1607             AddTextual(HelpText.LookupByHandle(hIMPHELP, no));
     1605            AddTextual(HelpText.LookupByHandle(hIMPHELP, No));
    16081606          end;
    1609           if no = woSun then begin
     1607          if No = woSun then begin
    16101608            AddFeature(mcFirst);
    16111609            AddFeature(mcWill);
    16121610            AddFeature(mcAcademy);
    16131611          end;
    1614           if (no < nWonder) and not Phrases2FallenBackToEnglish then
     1612          if (No < nWonder) and not Phrases2FallenBackToEnglish then
    16151613          begin
    16161614            LineFeed;
    1617             if Imp[no].Expiration >= 0 then
     1615            if Imp[No].Expiration >= 0 then
    16181616              AddTextual(Phrases2.Lookup('HELP_WONDERMORALE1'))
    16191617            else
    16201618              AddTextual(Phrases2.Lookup('HELP_WONDERMORALE2'));
    16211619          end;
    1622           if Imp[no].Preq <> preNone then
     1620          if Imp[No].Preq <> preNone then
    16231621          begin
    16241622            NextSection('PREREQ');
    1625             AddPreqAdv(Imp[no].Preq);
     1623            AddPreqAdv(Imp[No].Preq);
    16261624          end;
    16271625          NextSection('COSTS');
    16281626          if Difficulty = 0 then
    1629             S := Format(HelpText.Lookup('BUILDCOST'), [Imp[no].Cost])
     1627            S := Format(HelpText.Lookup('BUILDCOST'), [Imp[No].Cost])
    16301628          else
    16311629            S := Format(HelpText.Lookup('BUILDCOST'),
    1632               [Imp[no].Cost * BuildCostMod[Difficulty] div 12]);
     1630              [Imp[No].Cost * BuildCostMod[Difficulty] div 12]);
    16331631          AddLine(S);
    1634           if Imp[no].Maint > 0 then
    1635             AddLine(Format(HelpText.Lookup('MAINTCOST'), [Imp[no].Maint]));
     1632          if Imp[No].Maint > 0 then
     1633            AddLine(Format(HelpText.Lookup('MAINTCOST'), [Imp[No].Maint]));
    16361634          J := 0;
    16371635          for I := 0 to nImpReplacement - 1 do
    1638             if ImpReplacement[I].NewImp = no then
     1636            if ImpReplacement[I].NewImp = No then
    16391637            begin
    16401638              if J = 0 then
     
    16461644              AddImprovement(ImpReplacement[I].OldImp);
    16471645            end;
    1648           if Imp[no].Kind = ikShipPart then
     1646          if Imp[No].Kind = ikShipPart then
    16491647          begin
    16501648            LineFeed;
    1651             if no = imShipComp then
     1649            if No = imShipComp then
    16521650              I := 1
    1653             else if no = imShipPow then
     1651            else if No = imShipPow then
    16541652              I := 2
    1655             else { if no=imShipHab then }
     1653            else { if No=imShipHab then }
    16561654              I := 3;
    16571655            AddLine(Format(HelpText.Lookup('RAREREQUIRED'),
    16581656              [Phrases.Lookup('TERRAIN', 3 * 12 + I)]), pkTer, 3 * 12 + I);
    16591657          end;
    1660           if (no < nWonder) and (Imp[no].Expiration >= 0) then
     1658          if (No < nWonder) and (Imp[No].Expiration >= 0) then
    16611659          begin
    16621660            NextSection('EXPIRATION');
    16631661            S := Format(HelpText.Lookup('EXPWITH'),
    1664               [Phrases.Lookup('ADVANCES', Imp[no].Expiration)]);
    1665             if no = woPyramids then
     1662              [Phrases.Lookup('ADVANCES', Imp[No].Expiration)]);
     1663            if No = woPyramids then
    16661664              S := S + ' ' + HelpText.Lookup('EXPSLAVE');
    16671665            AddTextual(S);
    16681666          end;
    16691667          NextSection('SEEALSO');
    1670           if (no < nWonder) and (Imp[no].Expiration >= 0) then
     1668          if (No < nWonder) and (Imp[No].Expiration >= 0) then
    16711669            AddImprovement(woEiffel);
    16721670          for I := 0 to nImpReplacement - 1 do
    1673             if ImpReplacement[I].OldImp = no then
     1671            if ImpReplacement[I].OldImp = No then
    16741672              AddImprovement(ImpReplacement[I].NewImp);
    1675           if no = imSupermarket then
     1673          if No = imSupermarket then
    16761674            AddLine(HelpText.Lookup('HELPTITLE_JOBLIST'), pkNormal, 0,
    1677               hkMisc + hkCrossLink, miscJobList);
     1675              hkMisc, Integer(miscJobList), True);
    16781676          CheckSeeAlso := True;
    16791677        end;
    16801678
    16811679      hkTer:
    1682         if no = 200 then
     1680        if No = 200 then
    16831681        begin // complete terrain type list
    16841682          Caption := HelpText.Lookup('HELPTITLE_TERLIST');
    16851683          // AddLine(HelpText.Lookup('HELPTITLE_TERLIST'),pkSection);
    1686           for I := 0 to nTerrainHelp - 1 do
     1684          for I := 0 to Length(TerrainHelp) - 1 do
    16871685            AddTerrain(TerrainHelp[I]);
    16881686        end
    16891687        else
    16901688        begin // sigle terrain type
    1691           TerrType := no mod 12;
     1689          TerrType := No mod 12;
    16921690          if TerrType = fJungle then
    16931691            TerrType := fForest;
    1694           TerrSubType := no div 12;
    1695           if no = 3 * 12 then
     1692          TerrSubType := No div 12;
     1693          if No = 3 * 12 then
    16961694          begin
    16971695            TerrType := fDesert;
     
    17001698          with Terrain[TerrType] do
    17011699          begin
    1702             Caption := Phrases.Lookup('TERRAIN', no);
     1700            Caption := Phrases.Lookup('TERRAIN', No);
    17031701            LineFeed;
    1704             AddLine(Phrases.Lookup('TERRAIN', no), pkBigTer, no);
     1702            AddLine(Phrases.Lookup('TERRAIN', No), pkBigTer, No);
    17051703            AddLine(HelpText.Lookup('HELPSPEC_TER'));
    17061704            LineFeed;
     
    17081706              AddLine(Format(HelpText.Lookup('RESPROD'),
    17091707                [ProdRes[TerrSubType]]));
    1710             if (no < 3 * 12) and (MineEff > 0) then
     1708            if (No < 3 * 12) and (MineEff > 0) then
    17111709              MainText[Count - 1] := MainText[Count - 1] + ' ' +
    17121710                Format(HelpText.Lookup('MOREMINE'), [MineEff]);
     
    17141712              AddLine(Format(HelpText.Lookup('RESFOOD'),
    17151713                [FoodRes[TerrSubType]]));
    1716             if (no < 3 * 12) and (IrrEff > 0) then
     1714            if (No < 3 * 12) and (IrrEff > 0) then
    17171715              MainText[Count - 1] := MainText[Count - 1] + ' ' +
    17181716                Format(HelpText.Lookup('MOREIRR'), [IrrEff]);
     
    17281726              else
    17291727                AddLine(HelpText.Lookup('MOVEPLAIN'));
    1730             if no = 3 * 12 then
     1728            if No = 3 * 12 then
    17311729            begin
    17321730              LineFeed;
    17331731              AddTextual(HelpText.Lookup('DEADLANDS'));
    17341732            end;
    1735             if (TerrType = fDesert) and (no <> fDesert + 12) then
     1733            if (TerrType = fDesert) and (No <> fDesert + 12) then
    17361734            begin
    17371735              LineFeed;
     
    17431741              AddTextual(Format(HelpText.Lookup('HOSTILE'), [ArcticThurst]));
    17441742            end;
    1745             if (no < 3 * 12) and (TransTerrain >= 0) then
     1743            if (No < 3 * 12) and (TransTerrain >= 0) then
    17461744            begin
    17471745              LineFeed;
     
    17521750              AddLine(Format(HelpText.Lookup('TRAFO'),
    17531751                [Phrases.Lookup('TERRAIN', I)]), pkTer, I,
    1754                 hkTer + hkCrossLink, I);
    1755               if no = fSwamp + 12 then
     1752                hkTer, I, True);
     1753              if No = fSwamp + 12 then
    17561754              begin
    17571755                LineFeed;
    17581756                AddLine(Format(HelpText.Lookup('TRAFO'),
    17591757                  [Phrases.Lookup('TERRAIN', TransTerrain + 24)]), pkTer,
    1760                   TransTerrain + 24, hkTer + hkCrossLink, TransTerrain + 24);
     1758                  TransTerrain + 24, hkTer, TransTerrain + 24, True);
    17611759              end
    17621760              else if I = fGrass then
     
    17651763                AddLine(Format(HelpText.Lookup('TRAFO'),
    17661764                  [Phrases.Lookup('TERRAIN', fGrass + 12)]), pkTer, fGrass + 12,
    1767                   hkTer + hkCrossLink, fGrass + 12);
     1765                  hkTer, fGrass + 12, True);
    17681766              end;
    17691767            end;
    17701768            NextSection('SPECIAL');
    1771             if no = 3 * 12 then
     1769            if No = 3 * 12 then
    17721770            begin
    17731771              LineFeed;
     
    17801778              end;
    17811779            end
    1782             else if (no < 12) and (no <> fGrass) and (no <> fOcean) then
     1780            else if (No < 12) and (No <> fGrass) and (No <> fOcean) then
    17831781            begin
    17841782              LineFeed;
    17851783              for Special := 1 to 2 do
    1786                 if (no <> fArctic) and (no <> fSwamp) or (Special < 2) then
     1784                if (No <> fArctic) and (No <> fSwamp) or (Special < 2) then
    17871785                begin
    17881786                  if Special > 1 then
    17891787                    LineFeed;
    1790                   AddLine(Phrases.Lookup('TERRAIN', no + Special * 12), pkTer,
    1791                     no + Special * 12);
     1788                  AddLine(Phrases.Lookup('TERRAIN', No + Special * 12), pkTer,
     1789                    No + Special * 12);
    17921790                  I := FoodRes[Special] - FoodRes[0];
    17931791                  if I <> 0 then
     
    18041802                end;
    18051803            end;
    1806             if no = 3 * 12 then
     1804            if No = 3 * 12 then
    18071805            begin
    18081806              LineFeed;
    18091807              AddTextual(HelpText.Lookup('RARE'));
    18101808            end;
    1811             if (no < 3 * 12) and (TerrType in [fDesert, fArctic]) then
     1809            if (No < 3 * 12) and (TerrType in [fDesert, fArctic]) then
    18121810            begin
    18131811              NextSection('SEEALSO');
    18141812              AddImprovement(woGardens);
    1815               CheckSeeAlso := True
     1813              CheckSeeAlso := True;
    18161814            end;
    18171815          end;
     
    18191817
    18201818      hkFeature:
    1821         if no = 200 then
     1819        if No = 200 then
    18221820        begin // complete feature list
    18231821          Caption := HelpText.Lookup('HELPTITLE_FEATURELIST');
     
    18571855        else
    18581856        begin // single feature
    1859           Caption := Phrases.Lookup('FEATURES', no);
     1857          Caption := Phrases.Lookup('FEATURES', No);
    18601858          LineFeed;
    1861           AddLine(Phrases.Lookup('FEATURES', no), pkBigFeature, no);
    1862           if no < mcFirstNonCap then
     1859          AddLine(Phrases.Lookup('FEATURES', No), pkBigFeature, No);
     1860          if No < mcFirstNonCap then
    18631861            AddLine(HelpText.Lookup('HELPSPEC_CAP'))
    1864           else if no in AutoFeature then
     1862          else if No in AutoFeature then
    18651863            AddLine(HelpText.Lookup('HELPSPEC_STANDARD'))
    18661864          else
    18671865            AddLine(HelpText.Lookup('HELPSPEC_FEATURE'));
    18681866          NextSection('EFFECT');
    1869           AddTextual(HelpText.LookupByHandle(hFEATUREHELP, no));
    1870           if (Feature[no].Weight <> 0) or (Feature[no].Cost <> 0) then
     1867          AddTextual(HelpText.LookupByHandle(hFEATUREHELP, No));
     1868          if (Feature[No].Weight <> 0) or (Feature[No].Cost <> 0) then
    18711869          begin
    18721870            NextSection('COSTS');
    1873             S := IntToStr(Feature[no].Cost);
    1874             if Feature[no].Cost >= 0 then
     1871            S := IntToStr(Feature[No].Cost);
     1872            if Feature[No].Cost >= 0 then
    18751873              S := '+' + S;
    18761874            AddLine(Format(HelpText.Lookup('COSTBASE'), [S]));
    1877             if Feature[no].Weight > 0 then
     1875            if Feature[No].Weight > 0 then
    18781876            begin
    18791877              AddLine(Format(HelpText.Lookup('WEIGHT'),
    1880                 ['+' + IntToStr(Feature[no].Weight)]));
    1881               if no = mcDefense then
     1878                ['+' + IntToStr(Feature[No].Weight)]));
     1879              if No = mcDefense then
    18821880                AddLine(Format(HelpText.Lookup('WEIGHT'), ['+2']),
    18831881                  pkDomain, dGround);
    18841882            end;
    18851883          end;
    1886           if Feature[no].Preq <> preNone then
     1884          if Feature[No].Preq <> preNone then
    18871885          begin
    18881886            LineFeed;
    1889             if Feature[no].Preq = preSun then
     1887            if Feature[No].Preq = preSun then
    18901888              AddPreqImp(woSun) // sun tsu feature
    18911889            else
    1892               AddPreqAdv(Feature[no].Preq);
     1890              AddPreqAdv(Feature[No].Preq);
    18931891            MainText[Count - 1] := Format(HelpText.Lookup('REQUIRED'),
    18941892              [MainText[Count - 1]]);
     
    19101908    end;
    19111909    if CheckSeeAlso then
    1912       for I := 0 to nSeeAlso - 1 do
    1913         if (SeeAlso[I].Kind = Kind) and (SeeAlso[I].no = no) then
     1910      for I := 0 to Length(SeeAlso) - 1 do
     1911        if (SeeAlso[I].Kind = Kind) and (SeeAlso[I].No = No) then
    19141912          case SeeAlso[I].SeeKind of
    19151913            hkImp: AddImprovement(SeeAlso[I].SeeNo);
     
    19261924    ScrollBar.SetPos(sbPos);
    19271925    BackBtn.Visible := HistItems.Count > 1;
    1928     TopBtn.Visible := (HistItems.Count > 1) or (Kind <> hkMisc) or (no <> miscMain);
     1926    TopBtn.Visible := (HistItems.Count > 1) or (Kind <> hkMisc) or (No <> Integer(miscMain));
    19291927    Sel := -1;
    19301928  end; // with MainText
    19311929end;
    19321930
    1933 procedure THelpDlg.ShowNewContent(NewMode: TWindowMode; Category, Index: Integer);
    1934 begin
    1935   if (Category <> Kind) or (Index <> no) or (Category = hkMisc) and
    1936     (Index = miscSearchResult) then begin
     1931procedure THelpDlg.ShowNewContent(NewMode: TWindowMode; Category: TLinkCategory;
     1932  Index: Integer);
     1933begin
     1934  if (Category <> Kind) or (Index <> No) or (Category = hkMisc) and
     1935    (Index = Integer(miscSearchResult)) then begin
    19371936    if HistItems.Count = MaxHist then HistItems.Delete(0);
    19381937    if HistItems.Count = 0 then
     
    19411940  end;
    19421941  Kind := Category;
    1943   no := Index;
     1942  No := Index;
    19441943  SearchContent := NewSearchContent;
    19451944  Prepare;
     
    19621961    Sel := -1;
    19631962  if (Sel + i0 >= MainText.Count) or (Sel >= 0) and
    1964     (THelpLineInfo(MainText.Objects[Sel + i0]).Link = 0) then
     1963    (THelpLineInfo(MainText.Objects[Sel + i0]).Category = hkNoLink) and
     1964    (THelpLineInfo(MainText.Objects[Sel + i0]).Index = 0)then
    19651965    Sel := -1;
    19661966  if Sel <> Sel0 then
     
    19781978  if Sel >= 0 then
    19791979    with THelpLineInfo(MainText.Objects[Sel + ScrollBar.Position]) do
    1980       if Link shr 8 and $3F = hkInternet then
    1981         case Link and $FF of
     1980      if Category = hkInternet then
     1981        case Index of
    19821982          1: OpenDocument(HomeDir + AITemplateFileName);
    19831983          2: OpenURL(CevoHomepage);
     
    19861986      else
    19871987      begin
    1988         if (Link >= $8000) and (Link and $3FFF = liInvalid) then
    1989           Exit; // invalid link;
    1990         if Link >= $8000 then
    1991           ShowNewContent(FWindowMode, hkText, Link and $3FFF)
    1992         else
    1993           ShowNewContent(FWindowMode, Link shr 8 and $3F, Link and $FF);
     1988        if Index < 0 then Exit; // invalid link;
     1989        ShowNewContent(FWindowMode, Category, Index);
    19941990      end;
    19951991end;
     
    20031999    HistItem.Assign(HistItems.Last);
    20042000    HistItems.Delete(HistItems.Count - 1);
    2005     if (HistItem.Kind = hkMisc) and (HistItem.No = miscSearchResult) and
     2001    if (HistItem.Kind = hkMisc) and (HistItem.No = Integer(miscSearchResult)) and
    20062002      (HistItem.SearchContent <> SearchContent) then
    20072003    begin
     
    20102006    end;
    20112007    Kind := HistItem.Kind;
    2012     no := HistItem.No;
     2008    No := HistItem.No;
    20132009    Prepare(HistItem.Pos);
    20142010    OffscreenPaint;
     
    20222018  while HistItems.Count > 1 do HistItems.Delete(HistItems.Count - 1);
    20232019  Kind := hkMisc;
    2024   no := miscMain;
     2020  No := Integer(miscMain);
    20252021  Prepare;
    20262022  OffscreenPaint;
     
    20362032function THelpDlg.TextIndex(Item: string): Integer;
    20372033begin
    2038   Result := HelpText.Gethandle(Item);
     2034  Result := HelpText.GetHandle(Item);
    20392035end;
    20402036
     
    20642060      1:
    20652061        with THelpLineInfo(SearchResult.Objects[0]) do
    2066           if Link >= $8000 then
    2067             ShowNewContent(FWindowMode, hkText, Link and $3FFF)
    2068           else
    2069             ShowNewContent(FWindowMode, Link shr 8 and $3F, Link and $FF);
    2070     else
    2071       begin
     2062          ShowNewContent(FWindowMode, Category, Index);
     2063      else begin
    20722064        NewSearchContent := InputDlg.EInput.Text;
    2073         ShowNewContent(FWindowMode, hkMisc, miscSearchResult);
     2065        ShowNewContent(FWindowMode, hkMisc, Integer(miscSearchResult));
    20742066      end;
    20752067    end;
     
    20812073  H, I, PrevHandle, PrevIndex, P, RightMargin: Integer;
    20822074  S: string;
    2083   mADVHELP, mIMPHELP, mFEATUREHELP: set of 0 .. 255;
     2075  mADVHELP, mIMPHELP, mFEATUREHELP: set of 0..255;
    20842076  bGOVHELP, bSPECIALMODEL, bJOBHELP: Boolean;
    20852077begin
     
    20922084  bJOBHELP := False;
    20932085
    2094   // search in generic reference
     2086  // Search in generic reference
    20952087  SearchString := UpperCase(SearchString);
    20962088  for I := 0 to 35 + 4 do begin
     
    20992091      if I < 36 then
    21002092        SearchResult.AddLine(S + ' ' + HelpText.Lookup('HELPSPEC_TER'),
    2101           pkNormal, 0, hkTer + hkCrossLink, I)
     2093          pkNormal, 0, hkTer, I, True)
    21022094      else
    21032095      begin
    21042096        SearchResult.AddLine(Phrases.Lookup('TERRAIN', 36) + ' ' +
    21052097          HelpText.Lookup('HELPSPEC_TER'), pkNormal, 0,
    2106           hkTer + hkCrossLink, 36);
     2098          hkTer, 36, True);
    21072099        if I > 36 then
    21082100          SearchResult.AddLine(Phrases.Lookup('IMPROVEMENTS',
    21092101            imShipComp + I - 37) + ' ' + HelpText.Lookup('HELPSPEC_SHIPPART'),
    2110             pkNormal, 0, hkImp + hkCrossLink, imShipComp + I - 37);
     2102            pkNormal, 0, hkImp, imShipComp + I - 37, True);
    21112103        Break;
    21122104      end;
    21132105  end;
    2114   for I := 0 to nJobHelp - 1 do
     2106  for I := 0 to Length(JobHelp) - 1 do
    21152107    if Pos(SearchString, UpperCase(Phrases.Lookup('JOBRESULT', JobHelp[I]))) > 0
    21162108    then
    21172109    begin
    21182110      SearchResult.AddLine(HelpText.Lookup('HELPTITLE_JOBLIST'), pkNormal, 0,
    2119         hkMisc + hkCrossLink, miscJobList);
     2111        hkMisc, Integer(miscJobList), True);
    21202112      bJOBHELP := True;
    21212113      Break;
     
    21302122      else
    21312123        S := S + ' ' + HelpText.Lookup('HELPSPEC_ADV');
    2132       SearchResult.AddLine(S, pkNormal, 0, hkAdv + hkCrossLink, I);
     2124      SearchResult.AddLine(S, pkNormal, 0, hkAdv, I, True);
    21332125      Include(mADVHELP, I);
    21342126    end;
     
    21402132    begin
    21412133      SearchResult.AddLine(HelpText.Lookup('HELPTITLE_MODELLIST'), pkNormal, 0,
    2142         hkModel + hkCrossLink, 0);
     2134        hkModel, 0, True);
    21432135      bSPECIALMODEL := True;
    21442136      Break;
     
    21562148      else
    21572149        S := S + ' ' + HelpText.Lookup('HELPSPEC_FEATURE');
    2158       SearchResult.AddLine(S, pkNormal, 0, hkFeature + hkCrossLink, I);
     2150      SearchResult.AddLine(S, pkNormal, 0, hkFeature, I, True);
    21592151      Include(mFEATUREHELP, I);
    21602152    end;
     
    21752167        S := S + ' ' + HelpText.Lookup('HELPSPEC_NAT')
    21762168      end;
    2177       SearchResult.AddLine(S, pkNormal, 0, hkImp + hkCrossLink, I);
     2169      SearchResult.AddLine(S, pkNormal, 0, hkImp, I, True);
    21782170      Include(mIMPHELP, I);
    21792171    end
     
    21832175    begin
    21842176      SearchResult.AddLine(HelpText.Lookup('HELPTITLE_GOVLIST'), pkNormal, 0,
    2185         hkMisc + hkCrossLink, miscGovList);
     2177        hkMisc, Integer(miscGovList), True);
    21862178      bGOVHELP := True;
    21872179      Break;
    21882180    end;
    21892181
    2190   // full text search
     2182  // Full text search
    21912183  H := -1;
    21922184  repeat
     
    22052197        else
    22062198          S := S + ' ' + HelpText.Lookup('HELPSPEC_ADV');
    2207         SearchResult.AddLine(S, pkNormal, 0, hkAdv + hkCrossLink, I)
     2199        SearchResult.AddLine(S, pkNormal, 0, hkAdv, I, True);
    22082200      end;
    22092201    end
     
    22242216          S := S + ' ' + HelpText.Lookup('HELPSPEC_NAT')
    22252217        end;
    2226         SearchResult.AddLine(S, pkNormal, 0, hkImp + hkCrossLink, I)
     2218        SearchResult.AddLine(S, pkNormal, 0, hkImp, I, True);
    22272219      end;
    22282220    end
     
    22392231        else
    22402232          S := S + ' ' + HelpText.Lookup('HELPSPEC_FEATURE');
    2241         SearchResult.AddLine(S, pkNormal, 0, hkFeature + hkCrossLink, I);
     2233        SearchResult.AddLine(S, pkNormal, 0, hkFeature, I, True);
    22422234      end;
    22432235    end
     
    22462238      if (I >= 0) and (H <> PrevHandle) and not bGOVHELP then
    22472239        SearchResult.AddLine(HelpText.Lookup('HELPTITLE_GOVLIST'), pkNormal, 0,
    2248           hkMisc + hkCrossLink, miscGovList)
     2240          hkMisc, Integer(miscGovList), True);
    22492241    end
    22502242    else if H = hSPECIALMODEL then
     
    22522244      if (I >= 0) and (H <> PrevHandle) and not bSPECIALMODEL then
    22532245        SearchResult.AddLine(HelpText.Lookup('HELPTITLE_MODELLIST'), pkNormal,
    2254           0, hkModel + hkCrossLink, 0)
     2246          0, hkModel, 0, True);
    22552247    end
    22562248    else if H = hJOBHELP then
     
    22582250      if (I >= 0) and (H <> PrevHandle) and not bJOBHELP then
    22592251        SearchResult.AddLine(HelpText.Lookup('HELPTITLE_JOBLIST'), pkNormal, 0,
    2260           hkMisc + hkCrossLink, miscJobList)
     2252          hkMisc, Integer(miscJobList), True);
    22612253    end
    22622254    else if { (h<>hMAIN) and } (H <> PrevHandle) then
     
    22662258      if P > 0 then
    22672259      begin
    2268         S := Copy(S, P + 1, maxint);
     2260        S := Copy(S, P + 1, MaxInt);
    22692261        P := Pos('\', S);
    22702262        if P > 0 then
    22712263          S := Copy(S, 1, P - 1);
    2272         SearchResult.AddLine(S, pkNormal, 0, hkText + hkCrossLink, H);
     2264        SearchResult.AddLine(S, pkNormal, 0, hkText, H, True);
    22732265      end;
    22742266    end;
    2275     until False;
    2276 
    2277     // cut lines to fit to window
    2278     RightMargin := InnerWidth - 16 - GetSystemMetrics(SM_CXVSCROLL);
    2279     OffScreen.Canvas.Font.Assign(UniFont[ftNormal]);
    2280     for I := 0 to SearchResult.Count - 1 do
    2281     begin
    2282       while BiColorTextWidth(OffScreen.Canvas, SearchResult[I]) >
    2283         RightMargin - 32 do
    2284         SearchResult[I] := Copy(SearchResult[I], 1, Length(SearchResult[I]) - 1)
    2285     end;
    2286   end;
     2267  until False;
     2268
     2269  // Cut lines to fit to window
     2270  RightMargin := InnerWidth - 16 - GetSystemMetrics(SM_CXVSCROLL);
     2271  OffScreen.Canvas.Font.Assign(UniFont[ftNormal]);
     2272  for I := 0 to SearchResult.Count - 1 do
     2273  begin
     2274    while BiColorTextWidth(OffScreen.Canvas, SearchResult[I]) >
     2275      RightMargin - 32 do
     2276      SearchResult[I] := Copy(SearchResult[I], 1, Length(SearchResult[I]) - 1)
     2277  end;
     2278end;
    22872279
    22882280end.
Note: See TracChangeset for help on using the changeset viewer.