Ignore:
Timestamp:
May 9, 2020, 4:02:07 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Improved HighDPI branch. Imported new changes from trunk branch.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/highdpi/LocalPlayer/Help.pas

    r193 r210  
    55
    66uses
    7   Protocol, ScreenTools, BaseWin, StringTables, Math, UDpiControls,
    8   LCLIntf, LCLType, LMessages, Messages, SysUtils, Classes, Graphics, Controls, Forms,
    9   ExtCtrls, ButtonB, PVSB, Types;
     7  UDpiControls, Protocol, ScreenTools, BaseWin, StringTables, Math, LCLIntf, LCLType,
     8  Messages, SysUtils, Classes, Graphics, Controls, Forms, ExtCtrls,
     9  ButtonB, PVSB, Types, fgl;
    1010
    1111const
     
    4141  THyperText = class(TStringList)
    4242  public
    43     procedure AddLine(s: String = ''; Format: integer = 0; Picpix: integer = 0;
     43    procedure AddLine(s: String = ''; Format: integer = 0; Picpix: Integer = 0;
    4444      LinkCategory: integer = 0; LinkIndex: integer = 0);
    45     procedure LF;
     45    procedure LineFeed;
     46    procedure AppendList(Source: THyperText);
    4647    destructor Destroy; override;
     48  end;
     49
     50  { THistItem }
     51
     52  THistItem = class
     53    Kind: Integer;
     54    No: Integer;
     55    Pos: Integer;
     56    SearchContent: string;
     57    procedure Assign(Source: THistItem);
     58  end;
     59
     60  { THistItems }
     61
     62  THistItems = class(TFPGObjectList<THistItem>)
     63    function AddNew(Kind, No, Pos: Integer; SearchContent: string): THistItem;
    4764  end;
    4865
     
    7289    procedure OffscreenPaint; override;
    7390  private
    74     Kind, no, Sel, nHist, CaptionColor: integer;
    75     hADVHELP, hIMPHELP, hFEATUREHELP, hGOVHELP, hSPECIALMODEL,
    76       hJOBHELP: integer;
    77     SearchContent, NewSearchContent: string;
     91    Kind: Integer;
     92    no: Integer;
     93    Sel: Integer;
     94    CaptionColor: Integer;
     95    hADVHELP, hIMPHELP, hFEATUREHELP, hGOVHELP, hSPECIALMODEL, hJOBHELP: Integer;
     96    SearchContent: string;
     97    NewSearchContent: string;
    7898    CaptionFont: TDpiFont;
    79     MainText, SearchResult: THyperText;
     99    MainText: THyperText;
     100    SearchResult: THyperText;
    80101    HelpText: TStringTable;
    81102    ExtPic, TerrIcon: TDpiBitmap;
    82     sb: TPVScrollbar;
    83     x0: array [-2 .. 180] of integer;
    84     HistKind: array [0 .. MaxHist - 1] of integer;
    85     HistNo: array [0 .. MaxHist - 1] of integer;
    86     HistPos: array [0 .. MaxHist - 1] of integer;
    87     HistSearchContent: array [0 .. MaxHist - 1] of shortstring;
     103    ScrollBar: TPVScrollbar;
     104    x0: array [-2..180] of Integer;
     105    procedure PaintTerrIcon(x, y, xSrc, ySrc: Integer);
    88106    procedure ScrollBarUpdate(Sender: TObject);
    89     procedure line(ca: TDpiCanvas; i: integer; lit: boolean);
    90     procedure Prepare(sbPos: integer = 0);
    91     procedure WaterSign(x0, y0, iix: integer);
     107    procedure Line(ca: TDpiCanvas; i: Integer; lit: Boolean);
     108    procedure Prepare(sbPos: Integer = 0);
     109    procedure ShowNewContentProcExecute(NewMode: Integer; HelpContext: string);
     110    procedure WaterSign(x0, y0, iix: Integer);
    92111    procedure Search(SearchString: string);
    93112    procedure OnScroll(var m: TMessage); message WM_VSCROLL;
    94113    procedure OnMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE;
    95114  public
    96     Difficulty: integer;
    97     procedure ShowNewContent(NewMode, Category, Index: integer);
     115    HistItems: THistItems;
     116    Difficulty: Integer;
    98117    procedure ClearHistory;
    99     function TextIndex(Item: string): integer;
     118    procedure ShowNewContent(NewMode, Category, Index: Integer);
     119    function TextIndex(Item: string): Integer;
    100120  end;
    101121
     
    103123  HelpDlg: THelpDlg;
    104124
     125
    105126implementation
    106127
    107128uses
    108   Directories, ClientTools, Term, Tribes, Inp, Messg;
     129  Directories, ClientTools, Term, Tribes, Inp, Messg, UPixelPointer, Global;
    109130
    110131{$R *.lfm}
    111132
    112133type
     134
     135  { THelpLineInfo }
     136
    113137  THelpLineInfo = class
    114     Format, Picpix: Byte;
     138    Format: Byte;
     139    Picpix: Byte;
    115140    Link: Word;
    116   end;
     141    procedure Assign(Source: THelpLineInfo);
     142  end;
     143
     144{ THelpLineInfo }
     145
     146procedure THelpLineInfo.Assign(Source: THelpLineInfo);
     147begin
     148  Format := Source.Format;
     149  PicPix := Source.PicPix;
     150  Link := Source.Link;
     151end;
     152
     153{ THistItem }
     154
     155procedure THistItem.Assign(Source: THistItem);
     156begin
     157  Kind := Source.Kind;
     158  No := Source.No;
     159  Pos := Source.Pos;
     160  SearchContent := Source.SearchContent;
     161end;
     162
     163{ THistItems }
     164
     165function THistItems.AddNew(Kind, No, Pos: Integer; SearchContent: string
     166  ): THistItem;
     167begin
     168  Result := THistItem.Create;
     169  Result.Kind := Kind;
     170  Result.No := No;
     171  Result.Pos := Pos;
     172  Result.SearchContent := SearchContent;
     173  Add(Result);
     174end;
    117175
    118176procedure THyperText.AddLine(s: String; Format: integer; Picpix: integer;
     
    130188end;
    131189
    132 procedure THyperText.LF;
     190procedure THyperText.LineFeed;
    133191begin
    134192  AddLine;
     193end;
     194
     195procedure THyperText.AppendList(Source: THyperText);
     196var
     197  I: Integer;
     198  HelpLineInfo: THelpLineInfo;
     199begin
     200  for I := 0 to Source.Count - 1 do begin
     201    HelpLineInfo := THelpLineInfo.Create;
     202    HelpLineInfo.Assign(THelpLineInfo(Source.Objects[I]));
     203    AddObject(Source.Strings[I], HelpLineInfo);
     204  end;
    135205end;
    136206
     
    198268begin
    199269  inherited;
     270  HistItems := THistItems.Create;
     271
    200272  CaptionLeft := BackBtn.Left + BackBtn.Width;
    201273  CaptionRight := SearchBtn.Left;
     
    205277  SearchResult := THyperText.Create;
    206278  SearchResult.OwnsObjects := True;
    207   sb := TPVScrollbar.Create(Self);
    208   sb.SetBorderSpacing(36, 9, 11);
    209   sb.OnUpdate := ScrollBarUpdate;
     279  ScrollBar := TPVScrollbar.Create(Self);
     280  ScrollBar.SetBorderSpacing(36, 9, 11);
     281  ScrollBar.OnUpdate := ScrollBarUpdate;
    210282
    211283  HelpText := TStringTable.Create;
     
    218290  hJOBHELP := HelpText.Gethandle('JOBHELP');
    219291
    220   CaptionFont := TDpiFont.Create;
     292  CaptionFont := Font.Create;
    221293  CaptionFont.Assign(UniFont[ftNormal]);
    222294  CaptionFont.Style := CaptionFont.Style + [fsItalic, fsBold];
     
    233305  TerrIcon.Canvas.FillRect(0, 0, TerrIcon.Width, TerrIcon.Height);
    234306  SearchContent := '';
    235   nHist := -1;
    236 end;
    237 
    238 procedure THelpDlg.ClearHistory;
    239 begin
    240   nHist := -1;
     307  ShowNewContentProc := ShowNewContentProcExecute;
     308end;
     309
     310procedure THelpDlg.ShowNewContentProcExecute(NewMode: Integer;
     311  HelpContext: string);
     312begin
     313  HelpDlg.ShowNewContent(NewMode, hkText,
     314    HelpDlg.TextIndex(HelpContext))
    241315end;
    242316
    243317procedure THelpDlg.FormDestroy(Sender: TObject);
    244318begin
    245   FreeAndNil(sb);
     319  ShowNewContentProc := nil;
     320  FreeAndNil(ScrollBar);
    246321  FreeAndNil(MainText);
    247322  FreeAndNil(SearchResult);
     
    250325  FreeAndNil(HelpText);
    251326  // FreeAndNil(CaptionFont);
     327  FreeAndNil(HistItems);
    252328end;
    253329
     
    255331  WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
    256332begin
    257   if sb.ProcessMouseWheel(WheelDelta) then begin
     333  if ScrollBar.ProcessMouseWheel(WheelDelta) then begin
    258334    PaintBox1MouseMove(nil, [], MousePos.X - Left,
    259335      MousePos.Y - Top);
     
    269345begin
    270346  { TODO: Handled by MouseWheel event
    271   if sb.Process(m) then begin
     347  if ScrollBar.Process(m) then begin
    272348    Sel := -1;
    273349    SmartUpdateContent(true)
     
    279355begin
    280356  if Sel <> -1 then begin
    281     line(Canvas, Sel, false);
     357    Line(Canvas, Sel, false);
    282358    Sel := -1
    283359  end
    284360end;
    285361
     362procedure THelpDlg.ClearHistory;
     363begin
     364  HistItems.Clear;
     365end;
     366
    286367procedure THelpDlg.FormPaint(Sender: TObject);
    287368begin
     
    290371end;
    291372
    292 procedure THelpDlg.line(ca: TDpiCanvas; i: integer; lit: boolean);
     373procedure THelpDlg.Line(ca: TDpiCanvas; i: Integer; lit: Boolean);
    293374var
    294   TextColor, x, y: integer;
     375  TextColor, x, y: Integer;
    295376  TextSize: TSize;
    296377  s: string;
    297378begin
    298   s := MainText[sb.Position + i];
     379  s := MainText[ScrollBar.Position + i];
    299380  if s = '' then
    300     exit;
     381    Exit;
    301382  x := x0[i];
    302383  y := 2 + i * 24;
     
    306387    y := y + WideFrame
    307388  end;
    308   if THelpLineInfo(MainText.Objects[sb.Position + i]).Format
     389  if THelpLineInfo(MainText.Objects[ScrollBar.Position + i]).Format
    309390    in [pkCaption, pkBigTer, pkRightIcon, pkBigFeature] then
    310391  begin
     
    315396      ca.FrameRect(rect(x+1,i*24+1,x+24-1,i*24+24-1));
    316397      ca.Brush.Style:=bsClear; }
    317     DpiBitBlt(ca.Handle, x, y - 4, 24, 24, GrExt[HGrSystem].Data.Canvas.Handle, 1,
    318       146, SRCCOPY);
     398    DpiBitCanvas(ca, x, y - 4, 24, 24, GrExt[HGrSystem].Data.Canvas, 1,
     399      146);
    319400    BiColorTextOut(ca, $FFFFFF, $7F007F, x + 10 - ca.Textwidth(s[1]) div 2,
    320401      y - 3, s[1]);
     
    322403    ca.Font.Assign(UniFont[ftNormal]);
    323404  end
    324   else if THelpLineInfo(MainText.Objects[sb.Position + i]).Format = pkSection
     405  else if THelpLineInfo(MainText.Objects[ScrollBar.Position + i]).Format = pkSection
    325406  then
    326407  begin
     
    341422        TextSize.cy := WideFrame + InnerHeight - y;
    342423      FillSeamless(ca, x, y, TextSize.cx, TextSize.cy, -SideFrame,
    343         sb.Position * 24 - WideFrame, Paper);
     424        ScrollBar.Position * 24 - WideFrame, Paper);
    344425    end;
    345426    BiColorTextOut(ca, TextColor, $7F007F, x, y, s);
     
    347428      with ca do
    348429      begin
    349         assert(ca = Canvas);
    350         pen.color := TextColor;
    351         moveto(x + 1, y + TextSize.cy - 2);
    352         lineto(x + TextSize.cx, y + TextSize.cy - 2);
     430        Assert(ca = Canvas);
     431        Pen.Color := TextColor;
     432        MoveTo(x + 1, y + TextSize.cy - 2);
     433        LineTo(x + TextSize.cx, y + TextSize.cy - 2);
    353434      end;
    354435    if (Kind = hkMisc) and (no = miscMain) then
     
    363444var
    364445  x, y, dx, dy, xSrc, ySrc, sum, xx: integer;
    365   Heaven: array [0 .. nHeaven] of integer;
     446  Heaven: array [0..nHeaven] of integer;
    366447  PaintPtr, CoalPtr: TPixelPointer;
    367   ImpPtr: array [-1 .. 1] of TPixelPointer;
    368 begin
    369   { TODO
     448  ImpPtr: array [-1..1] of TPixelPointer;
     449begin
    370450  // assume eiffel tower has free common heaven
    371451  for dy := 0 to nHeaven - 1 do
     
    377457  xSrc := iix mod 7 * xSizeBig;
    378458  ySrc := (iix div 7 + 1) * ySizeBig;
    379   for y := 0 to ScaleToVcl(ySizeBig * 2) - 1 do
     459  for y := 0 to ySizeBig * 2 - 1 do
    380460    if ((y0 + y) >= 0) and ((y0 + y) < InnerHeight) then begin
    381       PaintPtr.Init(OffScreen, 0, ScaleToVcl(y0 + y));
    382       CoalPtr.Init(Templates, 0, ScaleToVcl(yCoal + y));
     461      PaintPtr := PixelPointer(OffScreen, 0, y0 + y);
     462      CoalPtr := PixelPointer(Templates, 0, yCoal + y);
    383463      for dy := -1 to 1 do
    384464        if ((Max(y + dy, 0) shr 1) >= 0) and ((Max(y + dy, 0) shr 1) < ySizeBig) then
    385           ImpPtr[dy].Init(BigImp, 0, ScaleToVcl(ySrc + (Max(y + dy, 0) shr 1)));
    386       for x := 0 to ScaleToVcl(xSizeBig * 2) - 1 do begin
     465          ImpPtr[dy] := PixelPointer(BigImp, 0, ySrc + (Max(y + dy, 0) shr 1));
     466      for x := 0 to xSizeBig * 2 - 1 do begin
    387467        sum := 0;
    388468        for dx := -1 to 1 do begin
     
    413493  Offscreen.EndUpdate;
    414494  BigImp.EndUpdate;
    415   }
     495end;
     496
     497procedure THelpDlg.PaintTerrIcon(x, y, xSrc, ySrc: integer);
     498begin
     499  Frame(OffScreen.Canvas, x - 1, y - 1, x + xSizeBig, y + ySizeBig,
     500    $000000, $000000);
     501  if 2 * yyt < 40 then begin
     502    Sprite(OffScreen, HGrTerrain, x, y, 56, 2 * yyt, xSrc, ySrc);
     503    Sprite(OffScreen, HGrTerrain, x, y + 2 * yyt, 56, 40 - 2 * yyt,
     504      xSrc, ySrc);
     505  end else
     506    Sprite(OffScreen, HGrTerrain, x, y, 56, 40, xSrc, ySrc);
     507  Sprite(OffScreen, HGrTerrain, x, y, xxt, yyt, xSrc + xxt, ySrc + yyt);
     508  Sprite(OffScreen, HGrTerrain, x, y + yyt, xxt, 40 - yyt, xSrc + xxt, ySrc);
     509  Sprite(OffScreen, HGrTerrain, x + xxt, y, 56 - xxt, yyt, xSrc, ySrc + yyt);
     510  Sprite(OffScreen, HGrTerrain, x + xxt, y + yyt, 56 - xxt, 40 - yyt,
     511    xSrc, ySrc);
    416512end;
    417513
    418514procedure THelpDlg.OffscreenPaint;
    419 
    420   procedure PaintTerrIcon(x, y, xSrc, ySrc: integer);
    421   begin
    422     Frame(OffScreen.Canvas, x - 1, y - 1, x + xSizeBig, y + ySizeBig,
    423       $000000, $000000);
    424     if 2 * yyt < 40 then
    425     begin
    426       Sprite(OffScreen, HGrTerrain, x, y, 56, 2 * yyt, xSrc, ySrc);
    427       Sprite(OffScreen, HGrTerrain, x, y + 2 * yyt, 56, 40 - 2 * yyt,
    428         xSrc, ySrc);
    429     end
    430     else
    431       Sprite(OffScreen, HGrTerrain, x, y, 56, 40, xSrc, ySrc);
    432     Sprite(OffScreen, HGrTerrain, x, y, xxt, yyt, xSrc + xxt, ySrc + yyt);
    433     Sprite(OffScreen, HGrTerrain, x, y + yyt, xxt, 40 - yyt, xSrc + xxt, ySrc);
    434     Sprite(OffScreen, HGrTerrain, x + xxt, y, 56 - xxt, yyt, xSrc, ySrc + yyt);
    435     Sprite(OffScreen, HGrTerrain, x + xxt, y + yyt, 56 - xxt, 40 - yyt,
    436       xSrc, ySrc);
    437   end;
    438 
    439515var
    440   i, j, yl, srcno, ofs, cnt, y: integer;
     516  i, j, yl, srcno, ofs, cnt, y: Integer;
    441517  s: string;
    442518  HelpLineInfo: THelpLineInfo;
     
    445521  CaptionColor := Colors.Canvas.Pixels[clkMisc, cliPaperCaption];
    446522  FillSeamless(OffScreen.Canvas, 0, 0, InnerWidth, InnerHeight, 0,
    447     sb.Position * 24, Paper);
     523    ScrollBar.Position * 24, Paper);
    448524  with OffScreen.Canvas do
    449525  begin
    450526    Font.Assign(UniFont[ftNormal]);
    451     for i := -sb.Position to InnerHeight div 24 do
    452       if sb.Position + i < MainText.Count then
     527    for i := -ScrollBar.Position to InnerHeight div 24 do
     528      if ScrollBar.Position + i < MainText.Count then
    453529      begin
    454         HelpLineInfo := THelpLineInfo(MainText.Objects[sb.Position + i]);
     530        HelpLineInfo := THelpLineInfo(MainText.Objects[ScrollBar.Position + i]);
    455531        if HelpLineInfo.Format = pkExternal then
    456532        begin
     
    458534          if 4 + i * 24 + yl > InnerHeight then
    459535            yl := InnerHeight - (4 + i * 24);
    460           DpiBitBlt(Handle, 8, 4 + i * 24, ExtPic.Width, yl, ExtPic.Canvas.Handle,
    461             0, 0, SRCCOPY);
     536          DpiBitCanvas(OffScreen.Canvas, 8, 4 + i * 24, ExtPic.Width, yl, ExtPic.Canvas,
     537            0, 0);
    462538        end;
    463539      end;
    464540    for i := -2 to InnerHeight div 24 do
    465       if (sb.Position + i >= 0) and (sb.Position + i < MainText.Count) then
     541      if (ScrollBar.Position + i >= 0) and (ScrollBar.Position + i < MainText.Count) then
    466542      begin
    467         HelpLineInfo := THelpLineInfo(MainText.Objects[sb.Position + i]);
     543        HelpLineInfo := THelpLineInfo(MainText.Objects[ScrollBar.Position + i]);
    468544        if HelpLineInfo.Link <> 0 then
    469545        begin
     
    499575                8 + xSizeSmall + x0[i], 2 + 20 + i * 24, $000000, $000000);
    500576              if HelpLineInfo.Picpix = imPalace then
    501                 DpiBitBlt(OffScreen.Canvas.Handle, 8 + x0[i], 2 + i * 24,
    502                   xSizeSmall, ySizeSmall, SmallImp.Canvas.Handle,
    503                   0 * xSizeSmall, 1 * ySizeSmall, SRCCOPY)
     577                DpiBitCanvas(OffScreen.Canvas, 8 + x0[i], 2 + i * 24,
     578                  xSizeSmall, ySizeSmall, SmallImp.Canvas,
     579                  0 * xSizeSmall, 1 * ySizeSmall)
    504580              else
    505                 DpiBitBlt(OffScreen.Canvas.Handle, 8 + x0[i], 2 + i * 24,
    506                   xSizeSmall, ySizeSmall, SmallImp.Canvas.Handle,
     581                DpiBitCanvas(OffScreen.Canvas, 8 + x0[i], 2 + i * 24,
     582                  xSizeSmall, ySizeSmall, SmallImp.Canvas,
    507583                  HelpLineInfo.Picpix mod 7 * xSizeSmall,
    508584                  (HelpLineInfo.Picpix + SystemIconLines * 7) div 7 *
    509                   ySizeSmall, SRCCOPY);
     585                  ySizeSmall);
    510586              x0[i] := x0[i] + (8 + 8 + 36);
    511587            end;
     
    566642                $000000, $000000);
    567643              if AdvIcon[HelpLineInfo.Picpix] < 84 then
    568                 DpiBitBlt(OffScreen.Canvas.Handle, 8 + x0[i], 2 + i * 24,
    569                   xSizeSmall, ySizeSmall, SmallImp.Canvas.Handle,
     644                DpiBitCanvas(OffScreen.Canvas, 8 + x0[i], 2 + i * 24,
     645                  xSizeSmall, ySizeSmall, SmallImp.Canvas,
    570646                  (AdvIcon[HelpLineInfo.Picpix] + SystemIconLines * 7) mod 7 *
    571647                  xSizeSmall, (AdvIcon[HelpLineInfo.Picpix] + SystemIconLines *
    572                   7) div 7 * ySizeSmall, SRCCOPY)
     648                  7) div 7 * ySizeSmall)
    573649              else
    574650                Dump(OffScreen, HGrSystem, 8 + x0[i], 2 + i * 24, 36, 20,
     
    576652                  295 + (AdvIcon[HelpLineInfo.Picpix] - 84) div 8 * 21);
    577653              j := AdvValue[HelpLineInfo.Picpix] div 1000;
    578               DpiBitBlt(Handle, x0[i] + 4, 4 + i * 24, 14, 14,
    579                 GrExt[HGrSystem].Mask.Canvas.Handle, 127 + j * 15, 85, SRCAND);
     654              DpiBitCanvas(OffScreen.Canvas, x0[i] + 4, 4 + i * 24, 14, 14,
     655                GrExt[HGrSystem].Mask.Canvas, 127 + j * 15, 85, SRCAND);
    580656              Sprite(OffScreen, HGrSystem, x0[i] + 3, 3 + i * 24, 14, 14,
    581657                127 + j * 15, 85);
     
    753829              ScreenTools.Frame(OffScreen.Canvas, 8 - 1 + x0[i], 2 - 1 + i * 24,
    754830                8 + xSizeSmall + x0[i], 2 + 20 + i * 24, $000000, $000000);
    755               DpiBitBlt(OffScreen.Canvas.Handle, 8 + x0[i], 2 + i * 24, xSizeSmall,
    756                 ySizeSmall, SmallImp.Canvas.Handle, (HelpLineInfo.Picpix - 1) *
    757                 xSizeSmall, ySizeSmall, SRCCOPY);
     831              DpiBitCanvas(OffScreen.Canvas, 8 + x0[i], 2 + i * 24, xSizeSmall,
     832                ySizeSmall, SmallImp.Canvas, (HelpLineInfo.Picpix - 1) *
     833                xSizeSmall, ySizeSmall);
    758834              x0[i] := x0[i] + (8 + 8 + 36);
    759835            end;
     
    769845            x0[i] := 64 + 8 + 8;
    770846        else
    771           x0[i] := x0[i] + 8
     847          x0[i] := x0[i] + 8;
    772848        end;
    773         Self.line(OffScreen.Canvas, i, false)
     849        Self.Line(OffScreen.Canvas, i, False)
    774850      end;
    775851  end;
    776852  MarkUsedOffscreen(InnerWidth, InnerHeight + 13 + 48);
    777 end; { OffscreenPaint }
     853end;
    778854
    779855procedure THelpDlg.ScrollBarUpdate(Sender: TObject);
     
    785861procedure THelpDlg.Prepare(sbPos: integer = 0);
    786862var
    787   i, j, special, Domain, Headline, TerrType, TerrSubType: integer;
     863  i, j, Special, Domain, Headline, TerrType, TerrSubType: integer;
    788864  s: string;
    789865  ps: pchar;
    790866  List: THyperText;
    791   CheckSeeAlso: boolean;
    792 
    793   procedure AddAdv(i: integer);
     867  CheckSeeAlso: Boolean;
     868
     869  procedure AddAdvance(i: integer);
    794870  begin
    795871    MainText.AddLine(Phrases.Lookup('ADVANCES', i), pkAdvIcon, i,
     
    803879  end;
    804880
    805   procedure AddImp(i: integer);
     881  procedure AddImprovement(i: integer);
    806882  begin
    807883    MainText.AddLine(Phrases.Lookup('IMPROVEMENTS', i), pkSmallIcon, i,
     
    815891  end;
    816892
    817   procedure AddTer(i: integer);
     893  procedure AddTerrain(i: integer);
    818894  begin
    819895    if MainText.Count > 1 then
    820896    begin
    821       MainText.LF;
     897      MainText.LineFeed;
    822898    end;
    823899    MainText.AddLine(Phrases.Lookup('TERRAIN', i), pkTer, i, hkTer, i);
     
    836912  begin
    837913    if MainText.Count > 1 then
    838       MainText.LF;
     914      MainText.LineFeed;
    839915    FindStdModelPicture(SpecialModelPictureCode[i], pix, Name);
    840916    MainText.AddLine(Name, pkModel, pix, hkModel + hkCrossLink, i)
     
    850926      begin
    851927        AddLine('', pkLogo);
    852         LF;
     928        LineFeed;
    853929      end
    854930      else if Item = 'TECHFORMULA' then
     
    866942        for i := 1 to 3 do
    867943        begin
    868           LF;
     944          LineFeed;
    869945          AddLine(Phrases.Lookup('TERRAIN', 3 * 12 + i), pkTer, 3 * 12 + i);
    870946        end
     
    877953  end;
    878954
    879   procedure DecodeItem(s: string; var Category, Index: integer);
     955  procedure DecodeItem(s: string; var Category, Index: Integer);
    880956  var
    881     i: integer;
    882   begin
    883     if (length(s) > 0) and (s[1] = ':') then
    884     begin
     957    i: Integer;
     958  begin
     959    if (Length(s) > 0) and (s[1] = ':') then begin
    885960      Category := hkMisc;
    886961      Index := 0;
    887962      for i := 3 to length(s) do
    888         Index := Index * 10 + ord(s[i]) - 48;
     963        Index := Index * 10 + Ord(s[i]) - 48;
    889964      case s[2] of
    890         'A':
    891           Category := hkAdv;
    892         'B':
    893           Category := hkImp;
    894         'T':
    895           Category := hkTer;
    896         'F':
    897           Category := hkFeature;
    898         'E':
    899           Category := hkInternet;
    900         'S':
    901           Category := hkModel;
    902         'C':
    903           Index := miscCredits;
    904         'J':
    905           Index := miscJobList;
    906         'G':
    907           Index := miscGovList;
     965        'A': Category := hkAdv;
     966        'B': Category := hkImp;
     967        'T': Category := hkTer;
     968        'F': Category := hkFeature;
     969        'E': Category := hkInternet;
     970        'S': Category := hkModel;
     971        'C': Index := miscCredits;
     972        'J': Index := miscJobList;
     973        'G': Index := miscGovList;
    908974      end;
    909975      if (Category <> hkMisc) and (Index = 0) then
    910976        Index := 200;
    911     end
    912     else
    913     begin
     977    end else begin
    914978      Category := hkText;
    915       Index := HelpText.Gethandle(copy(s, 1, 255));
     979      Index := HelpText.Gethandle(Copy(s, 1, 255));
    916980    end;
    917981  end;
     
    935999        repeat
    9361000          inc(p)
    937         until (p > length(s)) or (s[p] = '\');
    938         Caption := copy(s, 2, p - 2);
     1001        until (p > Length(s)) or (s[p] = '\');
     1002        Caption := Copy(s, 2, p - 2);
    9391003        Delete(s, 1, p);
    9401004      end
     
    9441008        repeat
    9451009          inc(p)
    946         until (p > length(s)) or (s[p] = '\');
    947         AddStandardBlock(copy(s, 2, p - 2));
     1010        until (p > Length(s)) or (s[p] = '\');
     1011        AddStandardBlock(Copy(s, 2, p - 2));
    9481012        Delete(s, 1, p);
    9491013      end
    9501014      else if s[1] = '@' then
    9511015      begin // image
    952         if (length(s) >= 2) and (s[2] = '@') then
     1016        if (Length(s) >= 2) and (s[2] = '@') then
    9531017        begin // generate from icon
    9541018          Picpix := 0;
    9551019          p := 3;
    956           while (p <= length(s)) and (s[p] <> '\') do
     1020          while (p <= Length(s)) and (s[p] <> '\') do
    9571021          begin
    958             Picpix := Picpix * 10 + ord(s[p]) - 48;
     1022            Picpix := Picpix * 10 + Ord(s[p]) - 48;
    9591023            inc(p)
    9601024          end;
     
    9621026            Picpix := 0;
    9631027          MainText.AddLine('', pkIllu, Picpix);
    964           MainText.LF;
    965           MainText.LF;
     1028          MainText.LineFeed;
     1029          MainText.LineFeed;
    9661030        end
    9671031        else
     
    9691033          p := 1;
    9701034          repeat
    971             inc(p)
    972           until (p > length(s)) or (s[p] = '\');
     1035            Inc(p)
     1036          until (p > Length(s)) or (s[p] = '\');
    9731037          if LoadGraphicFile(ExtPic, LocalizedFilePath('Help' +
    974             DirectorySeparator + copy(s, 2, p - 2)) + '.png') then
     1038            DirectorySeparator + Copy(s, 2, p - 2)) + '.png') then
    9751039          begin
    9761040            MainText.AddLine('', pkExternal);
    9771041            for i := 0 to (ExtPic.Height - 12) div 24 do
    978               MainText.LF;
     1042              MainText.LineFeed;
    9791043          end;
    9801044        end;
     
    9891053              repeat
    9901054                inc(p)
    991               until (p > length(s)) or (s[p] = '\') or (s[p] = ' ');
    992               DecodeItem(copy(s, 2, p - 2), LinkCategory, LinkIndex);
     1055              until (p > Length(s)) or (s[p] = '\') or (s[p] = ' ');
     1056              DecodeItem(Copy(s, 2, p - 2), LinkCategory, LinkIndex);
    9931057              CurrentFormat := 0;
    9941058              if (LinkCategory <> hkText) and (LinkIndex < 200) then
     
    10081072                    begin
    10091073                      CurrentFormat := pkTer;
    1010                       Picpix := LinkIndex
     1074                      Picpix := LinkIndex;
    10111075                    end;
    10121076                  hkFeature:
     
    10241088              if s[1] = ':' then
    10251089                LinkCategory := LinkCategory + hkCrossLink;
    1026               if (p > length(s)) or (s[p] = ' ') then
     1090              if (p > Length(s)) or (s[p] = ' ') then
    10271091                Delete(s, 1, p)
    10281092              else
     
    10301094            end;
    10311095          '!': // highlited
    1032             if (length(s) >= 2) and (s[2] = '!') then
     1096            if (Length(s) >= 2) and (s[2] = '!') then
    10331097            begin
    10341098              if MainText.Count > 1 then
    1035                 MainText.LF;
     1099                MainText.LineFeed;
    10361100              FollowFormat := pkCaption;
    10371101              CurrentFormat := pkCaption;
     
    10601124        repeat
    10611125          repeat
    1062             inc(p)
    1063           until (p > length(s)) or (s[p] = ' ') or (s[p] = '\');
    1064           if (BiColorTextWidth(OffScreen.Canvas, copy(s, 1, p - 1)) <=
     1126            Inc(p)
     1127          until (p > Length(s)) or (s[p] = ' ') or (s[p] = '\');
     1128          if (BiColorTextWidth(OffScreen.Canvas, Copy(s, 1, p - 1)) <=
    10651129            RightMargin - ofs) then
    10661130            l := p - 1
    10671131          else
    10681132            Break;
    1069         until (p >= length(s)) or (s[l + 1] = '\');
    1070         MainText.AddLine(copy(s, 1, l), CurrentFormat, Picpix, LinkCategory,
     1133        until (p >= Length(s)) or (s[l + 1] = '\');
     1134        MainText.AddLine(Copy(s, 1, l), CurrentFormat, Picpix, LinkCategory,
    10711135          LinkIndex);
    1072         if (l < length(s)) and (s[l + 1] = '\') then
     1136        if (l < Length(s)) and (s[l + 1] = '\') then
    10731137          FollowFormat := pkNormal;
    10741138        Delete(s, 1, l + 1);
     
    10821146  end;
    10831147
    1084   procedure AddModelText(i: integer);
     1148  procedure AddModelText(i: Integer);
    10851149  var
    1086     pix: integer;
     1150    pix: Integer;
    10871151    s: string;
    10881152  begin
    1089     with MainText do
    1090     begin
    1091       if Count > 1 then
    1092       begin
    1093         LF;
    1094         LF;
     1153    with MainText do begin
     1154      if Count > 1 then begin
     1155        LineFeed;
     1156        LineFeed;
    10951157      end;
    10961158      FindStdModelPicture(SpecialModelPictureCode[i], pix, s);
     
    11261188  procedure AddJobList;
    11271189  var
    1128     i, JobCost: integer;
    1129   begin
    1130     with MainText do
    1131     begin
    1132       for i := 0 to nJobHelp - 1 do
    1133       begin
    1134         if i > 0 then
    1135         begin
    1136           LF;
    1137           LF
     1190    i, JobCost: Integer;
     1191  begin
     1192    with MainText do begin
     1193      for i := 0 to nJobHelp - 1 do begin
     1194        if i > 0 then begin
     1195          LineFeed;
     1196          LineFeed;
    11381197        end;
    11391198        AddLine(Phrases.Lookup('JOBRESULT', JobHelp[i]), pkSection);
     
    11441203        JobCost := -1;
    11451204        case JobHelp[i] of
    1146           jCanal:
    1147             JobCost := CanalWork;
    1148           jFort:
    1149             JobCost := FortWork;
    1150           jBase:
    1151             JobCost := BaseWork;
     1205          jCanal: JobCost := CanalWork;
     1206          jFort: JobCost := FortWork;
     1207          jBase: JobCost := BaseWork;
    11521208        end;
    11531209        if JobCost >= 0 then
     
    11561212        else
    11571213          AddTextual(HelpText.Lookup('JOBCOSTVAR'));
    1158         if JobPreq[JobHelp[i]] <> preNone then
    1159         begin
     1214        if JobPreq[JobHelp[i]] <> preNone then begin
    11601215          AddPreqAdv(JobPreq[JobHelp[i]]);
    11611216          MainText[Count - 1] := Format(HelpText.Lookup('REQUIRED'),
     
    11681223  procedure AddGraphicCredits;
    11691224  var
    1170     i: integer;
     1225    i: Integer;
    11711226    s: string;
    11721227    sr: TSearchRec;
    1173     List, plus: TStringList;
     1228    List, Plus: TStringList;
    11741229  begin
    11751230    List := TStringList.Create;
    1176     plus := TStringList.Create;
    1177     if FindFirst(HomeDir + 'Graphics' + DirectorySeparator + '*.credits.txt', $27, sr) = 0 then
     1231    Plus := TStringList.Create;
     1232    if FindFirst(GetGraphicsDir + DirectorySeparator + '*.credits.txt', $27, sr) = 0 then
    11781233      repeat
    1179         plus.LoadFromFile(HomeDir + 'Graphics' + DirectorySeparator + sr.Name);
    1180         List.AddStrings(plus);
     1234        Plus.LoadFromFile(GetGraphicsDir + DirectorySeparator + sr.Name);
     1235        List.AddStrings(Plus);
    11811236      until FindNext(sr) <> 0;
    11821237    FindClose(sr);
    1183     plus.Free;
     1238    Plus.Free;
    11841239
    11851240    List.Sort;
     
    11891244        List.Delete(i)
    11901245      else
    1191         inc(i);
    1192 
    1193     for i := 0 to List.Count - 1 do
    1194     begin
     1246        Inc(i);
     1247
     1248    for i := 0 to List.Count - 1 do begin
    11951249      s := List[i];
    11961250      while BiColorTextWidth(OffScreen.Canvas, s) > InnerWidth - 16 -
     
    12041258  procedure AddSoundCredits;
    12051259  var
    1206     i: integer;
     1260    i: Integer;
    12071261    s: string;
    12081262    List: TStringList;
    12091263  begin
    12101264    List := TStringList.Create;
    1211     List.LoadFromFile(HomeDir + 'Sounds' + DirectorySeparator + 'sound.credits.txt');
    1212     for i := 0 to List.Count - 1 do
    1213     begin
     1265    List.LoadFromFile(GetSoundsDir + DirectorySeparator + 'sound.credits.txt');
     1266    for i := 0 to List.Count - 1 do begin
    12141267      s := List[i];
    12151268      while BiColorTextWidth(OffScreen.Canvas, s) > InnerWidth - 16 -
     
    12271280        MainText.Delete(Headline)
    12281281      else
    1229         MainText.LF;
     1282        MainText.LineFeed;
    12301283    MainText.AddLine(HelpText.Lookup(Item), pkSection);
    12311284    Headline := MainText.Count - 1;
     
    12331286
    12341287begin { Prepare }
    1235   with MainText do
    1236   begin
     1288  with MainText do begin
    12371289    OffScreen.Canvas.Font.Assign(UniFont[ftNormal]);
    1238     CheckSeeAlso := false;
     1290    CheckSeeAlso := False;
    12391291    Clear;
    12401292    Headline := -1;
    12411293    if (no >= 200) or not(Kind in [hkAdv, hkImp, hkTer, hkFeature]) then
    1242       LF;
     1294      LineFeed;
    12431295    case Kind of
    12441296      hkText:
     
    12521304                AddLine(HelpText.Lookup('HELPTITLE_QUICKSTART'), pkSpecialIcon,
    12531305                  0, { pkBigIcon,22, } hkText, HelpText.Gethandle('QUICK'));
    1254                 LF;
     1306                LineFeed;
    12551307                AddLine(HelpText.Lookup('HELPTITLE_CONCEPTS'), pkBigIcon, 6,
    12561308                  hkText, HelpText.Gethandle('CONCEPTS'));
    1257                 LF;
     1309                LineFeed;
    12581310                AddLine(HelpText.Lookup('HELPTITLE_TERLIST'), pkSpecialIcon, 1,
    12591311                  hkTer, 200);
    1260                 LF;
     1312                LineFeed;
    12611313                AddLine(HelpText.Lookup('HELPTITLE_JOBLIST'), pkSpecialIcon, 2,
    12621314                  hkMisc, miscJobList);
    1263                 LF;
     1315                LineFeed;
    12641316                AddLine(HelpText.Lookup('HELPTITLE_TECHLIST'), pkBigIcon, 39,
    12651317                  hkAdv, 200);
    1266                 LF;
     1318                LineFeed;
    12671319                FindStdModelPicture(SpecialModelPictureCode[6], i, s);
    12681320                AddLine(HelpText.Lookup('HELPTITLE_MODELLIST'), pkModel, i,
    12691321                  hkModel, 0);
    1270                 LF;
     1322                LineFeed;
    12711323                AddLine(HelpText.Lookup('HELPTITLE_FEATURELIST'), pkBigIcon, 28,
    12721324                  hkFeature, 200);
    1273                 LF;
     1325                LineFeed;
    12741326                AddLine(HelpText.Lookup('HELPTITLE_IMPLIST'), pkBigIcon,
    12751327                  7 * SystemIconLines + imCourt, hkImp, 200);
    1276                 LF;
     1328                LineFeed;
    12771329                AddLine(HelpText.Lookup('HELPTITLE_UNIQUELIST'), pkBigIcon,
    12781330                  7 * SystemIconLines + imStockEx, hkImp, 201);
    1279                 LF;
     1331                LineFeed;
    12801332                AddLine(HelpText.Lookup('HELPTITLE_WONDERLIST'), pkBigIcon,
    12811333                  7 * SystemIconLines, hkImp, 202);
    1282                 LF;
     1334                LineFeed;
    12831335                AddLine(HelpText.Lookup('HELPTITLE_GOVLIST'), pkBigIcon,
    12841336                  gDemocracy + 6, hkMisc, miscGovList);
    1285                 LF;
     1337                LineFeed;
    12861338                AddLine(HelpText.Lookup('HELPTITLE_KEYS'), pkBigIcon, 2, hkText,
    12871339                  HelpText.Gethandle('HOTKEYS'));
    1288                 LF;
     1340                LineFeed;
    12891341                AddLine(HelpText.Lookup('HELPTITLE_ABOUT'), pkBigIcon, 1,
    12901342                  hkText, HelpText.Gethandle('ABOUT'));
    1291                 LF;
     1343                LineFeed;
    12921344                AddLine(HelpText.Lookup('HELPTITLE_CREDITS'), pkBigIcon, 22,
    12931345                  hkMisc, miscCredits);
     
    12961348              begin
    12971349                AddItem('CREDITS');
    1298                 LF;
     1350                LineFeed;
    12991351                AddGraphicCredits;
    13001352                NextSection('CRED_CAPSOUND');
     
    13101362                Caption := HelpText.Lookup('HELPTITLE_JOBLIST');
    13111363                AddJobList;
    1312                 LF;
     1364                LineFeed;
    13131365                AddItem('TERIMPEXCLUDE');
    1314                 LF;
     1366                LineFeed;
    13151367                AddItem('TERIMPCITY');
    13161368              end;
     
    13211373                begin
    13221374                  AddLine(Phrases.Lookup('GOVERNMENT', i mod nGov), pkSection);
    1323                   LF;
     1375                  LineFeed;
    13241376                  if i = nGov then
    13251377                    AddLine('', pkBigIcon, 7 * SystemIconLines + imPalace)
    13261378                  else
    13271379                    AddLine('', pkBigIcon, i + 6);
    1328                   LF;
     1380                  LineFeed;
    13291381                  AddTextual(HelpText.LookupByHandle(hGOVHELP, i mod nGov));
    13301382                  if i mod nGov >= 2 then
     
    13361388                  if i < nGov then
    13371389                  begin
    1338                     LF;
    1339                     LF;
     1390                    LineFeed;
     1391                    LineFeed;
    13401392                  end
    13411393                end
     
    13451397                Caption := HelpText.Lookup('HELPTITLE_SEARCHRESULTS');
    13461398                AddTextual(Format(HelpText.Lookup('MATCHES'), [SearchContent]));
    1347                 MainText.AddStrings(SearchResult);
    1348               end
     1399                MainText.AppendList(SearchResult);
     1400              end;
    13491401          end; // case no
    13501402        end;
     
    13551407          Caption := HelpText.Lookup('HELPTITLE_TECHLIST');
    13561408          List := THyperText.Create;
     1409          List.OwnsObjects := True;
    13571410          for j := 0 to 3 do
    13581411          begin
    13591412            if j > 0 then
    13601413            begin
    1361               LF;
    1362               LF;
     1414              LineFeed;
     1415              LineFeed;
    13631416            end;
    13641417            AddLine(HelpText.Lookup('TECHAGE', j), pkSection);
     
    13781431                  hkAdv, i);
    13791432            List.Sort;
    1380             AddStrings(List);
     1433            AppendList(List);
    13811434          end;
    1382           List.Free
     1435          List.Free;
    13831436        end
    13841437        else // single advance
    13851438        begin
    13861439          Caption := Phrases.Lookup('ADVANCES', no);
    1387           LF;
     1440          LineFeed;
    13881441          AddLine(Phrases.Lookup('ADVANCES', no), pkCaption);
    13891442          if no in FutureTech then
    13901443          begin
    13911444            AddLine(HelpText.Lookup('HELPSPEC_FUTURE'));
    1392             LF;
     1445            LineFeed;
    13931446            if no = futResearchTechnology then
    13941447              AddItem('FUTURETECHHELP100')
     
    14131466          for i := 0 to 27 do
    14141467            if Imp[i].Preq = no then
    1415               AddImp(i);
     1468              AddImprovement(i);
    14161469          for i := 28 to nImp - 1 do
    14171470            if (Imp[i].Preq = no) and (Imp[i].Kind <> ikCommon) then
    1418               AddImp(i);
     1471              AddImprovement(i);
    14191472          for i := 28 to nImp - 1 do
    14201473            if (Imp[i].Preq = no) and (Imp[i].Kind = ikCommon) then
    1421               AddImp(i);
     1474              AddImprovement(i);
    14221475          NextSection('MODELALLOW');
    14231476          for i := 0 to nSpecialModel - 1 do
     
    14321485            if (AdvPreq[i, 0] = no) or (AdvPreq[i, 1] = no) or
    14331486              (AdvPreq[i, 2] = no) then
    1434               AddAdv(i);
     1487              AddAdvance(i);
    14351488          NextSection('UPGRADEALLOW');
    14361489          for Domain := 0 to nDomains - 1 do
     
    14561509          for i := 0 to 27 do
    14571510            if (Imp[i].Preq <> preNA) and (Imp[i].Expiration = no) then
    1458               AddImp(i);
     1511              AddImprovement(i);
    14591512          NextSection('ADVEFFECT');
    14601513          s := HelpText.LookupByHandle(hADVHELP, no);
     
    14711524          // AddLine(HelpText.Lookup('HELPTITLE_IMPLIST'),pkSection);
    14721525          List := THyperText.Create;
     1526          List.OwnsObjects := True;
    14731527          for i := 28 to nImp - 1 do
    14741528            if (i <> imTrGoods) and (Imp[i].Preq <> preNA) and
     
    14771531                i, hkImp, i);
    14781532          List.Sort;
    1479           AddStrings(List);
    1480           List.Free
     1533          AppendList(List);
     1534          List.Free;
    14811535        end
    14821536        else if no = 201 then
     
    14891543              AddLine(Phrases.Lookup('IMPROVEMENTS', i), pkSmallIcon, i,
    14901544                hkImp, i);
    1491           { LF;
    1492             LF;
     1545          { LineFeed;
     1546            LineFeed;
    14931547            AddLine(HelpText.Lookup('HELPTITLE_SHIPPARTLIST'),pkSection);
    14941548            for i:=28 to nImp-1 do
     
    15081562        begin // single building
    15091563          Caption := Phrases.Lookup('IMPROVEMENTS', no);
    1510           LF;
     1564          LineFeed;
    15111565          AddLine(Phrases.Lookup('IMPROVEMENTS', no), pkRightIcon, no);
    15121566          case Imp[no].Kind of
    1513             ikWonder:
    1514               AddLine(HelpText.Lookup('HELPSPEC_WONDER'));
    1515             ikCommon:
    1516               AddLine(HelpText.Lookup('HELPSPEC_IMP'));
    1517             ikShipPart:
    1518               AddLine(HelpText.Lookup('HELPSPEC_SHIPPART'));
     1567            ikWonder: AddLine(HelpText.Lookup('HELPSPEC_WONDER'));
     1568            ikCommon: AddLine(HelpText.Lookup('HELPSPEC_IMP'));
     1569            ikShipPart: AddLine(HelpText.Lookup('HELPSPEC_SHIPPART'));
    15191570          else
    15201571            AddLine(HelpText.Lookup('HELPSPEC_NAT'))
    15211572          end;
    1522           if Imp[no].Kind <> ikShipPart then
    1523           begin
     1573          if Imp[no].Kind <> ikShipPart then begin
    15241574            NextSection('EFFECT');
    15251575            AddTextual(HelpText.LookupByHandle(hIMPHELP, no));
    15261576          end;
    1527           if no = woSun then
    1528           begin
     1577          if no = woSun then begin
    15291578            AddFeature(mcFirst);
    15301579            AddFeature(mcWill);
     
    15331582          if (no < 28) and not Phrases2FallenBackToEnglish then
    15341583          begin
    1535             LF;
     1584            LineFeed;
    15361585            if Imp[no].Expiration >= 0 then
    15371586              AddTextual(Phrases2.Lookup('HELP_WONDERMORALE1'))
     
    15631612                j := 1
    15641613              end;
    1565               AddImp(ImpReplacement[i].OldImp);
     1614              AddImprovement(ImpReplacement[i].OldImp);
    15661615            end;
    15671616          if Imp[no].Kind = ikShipPart then
    15681617          begin
    1569             LF;
     1618            LineFeed;
    15701619            if no = imShipComp then
    15711620              i := 1
     
    15881637          NextSection('SEEALSO');
    15891638          if (no < 28) and (Imp[no].Expiration >= 0) then
    1590             AddImp(woEiffel);
     1639            AddImprovement(woEiffel);
    15911640          for i := 0 to nImpReplacement - 1 do
    15921641            if ImpReplacement[i].OldImp = no then
    1593               AddImp(ImpReplacement[i].NewImp);
     1642              AddImprovement(ImpReplacement[i].NewImp);
    15941643          if no = imSupermarket then
    15951644            AddLine(HelpText.Lookup('HELPTITLE_JOBLIST'), pkNormal, 0,
     
    16041653          // AddLine(HelpText.Lookup('HELPTITLE_TERLIST'),pkSection);
    16051654          for i := 0 to nTerrainHelp - 1 do
    1606             AddTer(TerrainHelp[i]);
     1655            AddTerrain(TerrainHelp[i]);
    16071656        end
    16081657        else
     
    16201669          begin
    16211670            Caption := Phrases.Lookup('TERRAIN', no);
    1622             LF;
     1671            LineFeed;
    16231672            AddLine(Phrases.Lookup('TERRAIN', no), pkBigTer, no);
    16241673            AddLine(HelpText.Lookup('HELPSPEC_TER'));
    1625             LF;
     1674            LineFeed;
    16261675            if (ProdRes[TerrSubType] > 0) or (MineEff > 0) then
    16271676              AddLine(Format(HelpText.Lookup('RESPROD'),
     
    16491698            if no = 3 * 12 then
    16501699            begin
    1651               LF;
     1700              LineFeed;
    16521701              AddTextual(HelpText.Lookup('DEADLANDS'));
    16531702            end;
    16541703            if (TerrType = fDesert) and (no <> fDesert + 12) then
    16551704            begin
    1656               LF;
     1705              LineFeed;
    16571706              AddTextual(Format(HelpText.Lookup('HOSTILE'), [DesertThurst]));
    16581707            end;
    16591708            if TerrType = fArctic then
    16601709            begin
    1661               LF;
     1710              LineFeed;
    16621711              AddTextual(Format(HelpText.Lookup('HOSTILE'), [ArcticThurst]));
    16631712            end;
    16641713            if (no < 3 * 12) and (TransTerrain >= 0) then
    16651714            begin
    1666               LF;
     1715              LineFeed;
    16671716              i := TransTerrain;
    16681717              if (TerrType <> fGrass) and (i <> fGrass) then
    16691718                i := i + TerrSubType * 12;
    1670               // trafo to same special resource group
     1719              // trafo to same Special resource group
    16711720              AddLine(Format(HelpText.Lookup('TRAFO'),
    16721721                [Phrases.Lookup('TERRAIN', i)]), pkTer, i,
     
    16741723              if no = fSwamp + 12 then
    16751724              begin
    1676                 LF;
     1725                LineFeed;
    16771726                AddLine(Format(HelpText.Lookup('TRAFO'),
    16781727                  [Phrases.Lookup('TERRAIN', TransTerrain + 24)]), pkTer,
     
    16811730              else if i = fGrass then
    16821731              begin
    1683                 LF;
     1732                LineFeed;
    16841733                AddLine(Format(HelpText.Lookup('TRAFO'),
    16851734                  [Phrases.Lookup('TERRAIN', fGrass + 12)]), pkTer, fGrass + 12,
     
    16901739            if no = 3 * 12 then
    16911740            begin
    1692               LF;
    1693               for special := 1 to 3 do
     1741              LineFeed;
     1742              for Special := 1 to 3 do
    16941743              begin
    1695                 if special > 1 then
    1696                   LF;
    1697                 AddLine(Phrases.Lookup('TERRAIN', 3 * 12 + special), pkTer,
    1698                   3 * 12 + special);
     1744                if Special > 1 then
     1745                  LineFeed;
     1746                AddLine(Phrases.Lookup('TERRAIN', 3 * 12 + Special), pkTer,
     1747                  3 * 12 + Special);
    16991748              end
    17001749            end
    17011750            else if (no < 12) and (no <> fGrass) and (no <> fOcean) then
    17021751            begin
    1703               LF;
    1704               for special := 1 to 2 do
    1705                 if (no <> fArctic) and (no <> fSwamp) or (special < 2) then
     1752              LineFeed;
     1753              for Special := 1 to 2 do
     1754                if (no <> fArctic) and (no <> fSwamp) or (Special < 2) then
    17061755                begin
    1707                   if special > 1 then
    1708                     LF;
    1709                   AddLine(Phrases.Lookup('TERRAIN', no + special * 12), pkTer,
    1710                     no + special * 12);
    1711                   i := FoodRes[special] - FoodRes[0];
     1756                  if Special > 1 then
     1757                    LineFeed;
     1758                  AddLine(Phrases.Lookup('TERRAIN', no + Special * 12), pkTer,
     1759                    no + Special * 12);
     1760                  i := FoodRes[Special] - FoodRes[0];
    17121761                  if i <> 0 then
    17131762                    MainText[Count - 1] := MainText[Count - 1] +
    17141763                      Format(HelpText.Lookup('SPECIALFOOD'), [i]);
    1715                   i := ProdRes[special] - ProdRes[0];
     1764                  i := ProdRes[Special] - ProdRes[0];
    17161765                  if i <> 0 then
    17171766                    MainText[Count - 1] := MainText[Count - 1] +
    17181767                      Format(HelpText.Lookup('SPECIALPROD'), [i]);
    1719                   i := TradeRes[special] - TradeRes[0];
     1768                  i := TradeRes[Special] - TradeRes[0];
    17201769                  if i <> 0 then
    17211770                    MainText[Count - 1] := MainText[Count - 1] +
     
    17251774            if no = 3 * 12 then
    17261775            begin
    1727               LF;
     1776              LineFeed;
    17281777              AddTextual(HelpText.Lookup('RARE'));
    17291778            end;
     
    17311780            begin
    17321781              NextSection('SEEALSO');
    1733               AddImp(woGardens);
     1782              AddImprovement(woGardens);
    17341783              CheckSeeAlso := true
    17351784            end
     
    17421791          Caption := HelpText.Lookup('HELPTITLE_FEATURELIST');
    17431792          List := THyperText.Create;
    1744           for special := 0 to 2 do
     1793          List.OwnsObjects := True;
     1794          for Special := 0 to 2 do
    17451795          begin
    1746             if special > 0 then
    1747             begin
    1748               LF;
    1749               LF
    1750             end;
    1751             case special of
    1752               0:
    1753                 AddLine(HelpText.Lookup('HELPTITLE_FEATURE1LIST'), pkSection);
    1754               1:
    1755                 AddLine(HelpText.Lookup('HELPTITLE_FEATURE2LIST'), pkSection);
    1756               2:
    1757                 AddLine(HelpText.Lookup('HELPTITLE_FEATURE3LIST'), pkSection);
     1796            if Special > 0 then
     1797            begin
     1798              LineFeed;
     1799              LineFeed;
     1800            end;
     1801            case Special of
     1802              0: AddLine(HelpText.Lookup('HELPTITLE_FEATURE1LIST'), pkSection);
     1803              1: AddLine(HelpText.Lookup('HELPTITLE_FEATURE2LIST'), pkSection);
     1804              2: AddLine(HelpText.Lookup('HELPTITLE_FEATURE3LIST'), pkSection);
    17581805            end;
    17591806            List.Clear;
     
    17671814                else
    17681815                  j := 1;
    1769                 if j = special then
     1816                if j = Special then
    17701817                  List.AddLine(Phrases.Lookup('FEATURES', i), pkFeature, i,
    17711818                    hkFeature, i);
    17721819              end;
    17731820            List.Sort;
    1774             AddStrings(List);
     1821            AppendList(List);
    17751822          end;
    1776           List.Free
     1823          List.Free;
    17771824        end
    17781825        else
    17791826        begin // single feature
    17801827          Caption := Phrases.Lookup('FEATURES', no);
    1781           LF;
     1828          LineFeed;
    17821829          AddLine(Phrases.Lookup('FEATURES', no), pkBigFeature, no);
    17831830          if no < mcFirstNonCap then
     
    18071854          if Feature[no].Preq <> preNone then
    18081855          begin
    1809             LF;
     1856            LineFeed;
    18101857            if Feature[no].Preq = preSun then
    18111858              AddPreqImp(woSun) // sun tsu feature
     
    18161863          end;
    18171864          NextSection('SEEALSO');
    1818           CheckSeeAlso := true
     1865          CheckSeeAlso := True;
    18191866        end;
    18201867
     
    18251872            if i <> 2 then
    18261873              AddModelText(i);
    1827           LF;
     1874          LineFeed;
    18281875          AddItem('MODELNOTE');
    18291876        end;
     
    18341881        if (SeeAlso[i].Kind = Kind) and (SeeAlso[i].no = no) then
    18351882          case SeeAlso[i].SeeKind of
    1836             hkImp:
    1837               AddImp(SeeAlso[i].SeeNo);
    1838             hkAdv:
    1839               AddAdv(SeeAlso[i].SeeNo);
    1840             hkFeature:
    1841               AddFeature(SeeAlso[i].SeeNo);
     1883            hkImp: AddImprovement(SeeAlso[i].SeeNo);
     1884            hkAdv: AddAdvance(SeeAlso[i].SeeNo);
     1885            hkFeature: AddFeature(SeeAlso[i].SeeNo);
    18421886          end;
    18431887    if (Headline >= 0) and (Count = Headline + 1) then
    18441888      Delete(Headline)
    18451889    else
    1846       LF;
     1890      LineFeed;
    18471891
    18481892    //Self.Show;
    1849     sb.Init(Count - 1, InnerHeight div 24);
    1850     sb.SetPos(sbPos);
    1851     BackBtn.Visible := nHist > 0;
    1852     TopBtn.Visible := (nHist > 0) or (Kind <> hkMisc) or (no <> miscMain);
     1893    ScrollBar.Init(Count - 1, InnerHeight div 24);
     1894    ScrollBar.SetPos(sbPos);
     1895    BackBtn.Visible := HistItems.Count > 1;
     1896    TopBtn.Visible := (HistItems.Count > 1) or (Kind <> hkMisc) or (no <> miscMain);
    18531897    Sel := -1;
    18541898  end; // with MainText
    1855 end; { Prepare }
    1856 
    1857 procedure THelpDlg.ShowNewContent(NewMode, Category, Index: integer);
     1899end;
     1900
     1901procedure THelpDlg.ShowNewContent(NewMode, Category, Index: Integer);
    18581902begin
    18591903  if (Category <> Kind) or (Index <> no) or (Category = hkMisc) and
    1860     (Index = miscSearchResult) then
    1861   begin
    1862     if nHist = MaxHist then
    1863     begin
    1864       move(HistKind[2], HistKind[1], 4 * (nHist - 2));
    1865       move(HistNo[2], HistNo[1], 4 * (nHist - 2));
    1866       move(HistPos[2], HistPos[1], 4 * (nHist - 2));
    1867       move(HistSearchContent[2], HistSearchContent[1],
    1868         sizeof(shortstring) * (nHist - 2));
    1869     end
    1870     else
    1871       inc(nHist);
    1872     if nHist > 0 then
    1873     begin
    1874       HistKind[nHist - 1] := Kind;
    1875       HistNo[nHist - 1] := no;
    1876       HistPos[nHist - 1] := sb.Position;
    1877       HistSearchContent[nHist - 1] := SearchContent
    1878     end
     1904    (Index = miscSearchResult) then begin
     1905    if HistItems.Count = MaxHist then HistItems.Delete(0);
     1906    if HistItems.Count = 0 then
     1907      HistItems.AddNew(Category, Index, ScrollBar.Position, NewSearchContent)
     1908      else HistItems.AddNew(Kind, No, ScrollBar.Position, SearchContent);
    18791909  end;
    18801910  Kind := Category;
     
    18891919  x, y: integer);
    18901920var
    1891   i0, Sel0: integer;
     1921  i0, Sel0: Integer;
    18921922begin
    18931923  y := y - WideFrame;
    1894   i0 := sb.Position;
     1924  i0 := ScrollBar.Position;
    18951925  Sel0 := Sel;
    18961926  if (x >= SideFrame) and (x < SideFrame + InnerWidth) and (y >= 0) and
     
    19051935  begin
    19061936    if Sel0 <> -1 then
    1907       line(Canvas, Sel0, false);
     1937      Line(Canvas, Sel0, False);
    19081938    if Sel <> -1 then
    1909       line(Canvas, Sel, true)
     1939      Line(Canvas, Sel, True)
    19101940  end
    19111941end;
     
    19151945begin
    19161946  if Sel >= 0 then
    1917     with THelpLineInfo(MainText.Objects[Sel + sb.Position]) do
     1947    with THelpLineInfo(MainText.Objects[Sel + ScrollBar.Position]) do
    19181948      if Link shr 8 and $3F = hkInternet then
    19191949        case Link and $FF of
    1920           1: OpenDocument(pchar(HomeDir + 'AI Template' + DirectorySeparator + 'AI development manual.html'));
    1921           2: OpenURL('http://c-evo.org');
    1922           3: OpenURL('http://c-evo.org/_sg/contact');
     1950          1: OpenDocument(HomeDir + AITemplateFileName);
     1951          2: OpenURL(CevoHomepage);
     1952          3: OpenURL(CevoContact);
    19231953        end
    19241954      else
     
    19341964
    19351965procedure THelpDlg.BackBtnClick(Sender: TObject);
    1936 begin
    1937   if nHist > 0 then
    1938   begin
    1939     dec(nHist);
    1940     if (HistKind[nHist] = hkMisc) and (HistNo[nHist] = miscSearchResult) and
    1941       (HistSearchContent[nHist] <> SearchContent) then
     1966var
     1967  HistItem: THistItem;
     1968begin
     1969  if HistItems.Count > 1 then begin
     1970    HistItem := THistItem.Create;
     1971    HistItem.Assign(HistItems.Last);
     1972    HistItems.Delete(HistItems.Count - 1);
     1973    if (HistItem.Kind = hkMisc) and (HistItem.No = miscSearchResult) and
     1974      (HistItem.SearchContent <> SearchContent) then
    19421975    begin
    1943       SearchContent := HistSearchContent[nHist];
     1976      SearchContent := HistItem.SearchContent;
    19441977      Search(SearchContent);
    19451978    end;
    1946     Kind := HistKind[nHist];
    1947     no := HistNo[nHist];
    1948     Prepare(HistPos[nHist]);
     1979    Kind := HistItem.Kind;
     1980    no := HistItem.No;
     1981    Prepare(HistItem.Pos);
    19491982    OffscreenPaint;
    19501983    Invalidate;
    1951   end
     1984    HistItem.Free;
     1985  end;
    19521986end;
    19531987
    19541988procedure THelpDlg.TopBtnClick(Sender: TObject);
    19551989begin
    1956   nHist := 0;
     1990  while HistItems.Count > 1 do HistItems.Delete(HistItems.Count - 1);
    19571991  Kind := hkMisc;
    19581992  no := miscMain;
     
    19682002end;
    19692003
    1970 function THelpDlg.TextIndex(Item: string): integer;
    1971 begin
    1972   result := HelpText.Gethandle(Item)
     2004function THelpDlg.TextIndex(Item: string): Integer;
     2005begin
     2006  Result := HelpText.Gethandle(Item)
    19732007end;
    19742008
     
    19872021  InputDlg.CenterToRect(BoundsRect);
    19882022  InputDlg.ShowModal;
    1989   if (InputDlg.ModalResult = mrOK) and (length(InputDlg.EInput.Text) >= 2) then
     2023  if (InputDlg.ModalResult = mrOK) and (Length(InputDlg.EInput.Text) >= 2) then
    19902024  begin
    19912025    Search(InputDlg.EInput.Text);
     
    20042038        NewSearchContent := InputDlg.EInput.Text;
    20052039        ShowNewContent(FWindowMode, hkMisc, miscSearchResult);
    2006       end
    2007     end
    2008   end
     2040      end;
     2041    end;
     2042  end;
    20092043end;
    20102044
    20112045procedure THelpDlg.Search(SearchString: string);
    20122046var
    2013   h, i, PrevHandle, PrevIndex, p, RightMargin: integer;
     2047  h, i, PrevHandle, PrevIndex, p, RightMargin: Integer;
    20142048  s: string;
    20152049  mADVHELP, mIMPHELP, mFEATUREHELP: set of 0 .. 255;
    2016   bGOVHELP, bSPECIALMODEL, bJOBHELP: boolean;
     2050  bGOVHELP, bSPECIALMODEL, bJOBHELP: Boolean;
    20172051begin
    20182052  SearchResult.Clear;
     
    20202054  mIMPHELP := [];
    20212055  mFEATUREHELP := [];
    2022   bGOVHELP := false;
    2023   bSPECIALMODEL := false;
    2024   bJOBHELP := false;
     2056  bGOVHELP := False;
     2057  bSPECIALMODEL := False;
     2058  bJOBHELP := False;
    20252059
    20262060  // search in generic reference
    20272061  SearchString := UpperCase(SearchString);
    2028   for i := 0 to 35 + 4 do
    2029   begin
     2062  for i := 0 to 35 + 4 do begin
    20302063    s := Phrases.Lookup('TERRAIN', i);
    20312064    if pos(SearchString, UpperCase(s)) > 0 then
     
    20422075            imShipComp + i - 37) + ' ' + HelpText.Lookup('HELPSPEC_SHIPPART'),
    20432076            pkNormal, 0, hkImp + hkCrossLink, imShipComp + i - 37);
    2044         Break
    2045       end
     2077        Break;
     2078      end;
    20462079  end;
    20472080  for i := 0 to nJobHelp - 1 do
     
    20512084      SearchResult.AddLine(HelpText.Lookup('HELPTITLE_JOBLIST'), pkNormal, 0,
    20522085        hkMisc + hkCrossLink, miscJobList);
    2053       bJOBHELP := true;
    2054       Break
     2086      bJOBHELP := True;
     2087      Break;
    20552088    end;
    20562089  for i := 0 to nAdv - 1 do
     
    20652098      SearchResult.AddLine(s, pkNormal, 0, hkAdv + hkCrossLink, i);
    20662099      include(mADVHELP, i);
    2067     end
     2100    end;
    20682101  end;
    20692102  for i := 0 to nSpecialModel - 1 do
     
    20742107      SearchResult.AddLine(HelpText.Lookup('HELPTITLE_MODELLIST'), pkNormal, 0,
    20752108        hkModel + hkCrossLink, 0);
    2076       bSPECIALMODEL := true;
    2077       Break
     2109      bSPECIALMODEL := True;
     2110      Break;
    20782111    end;
    20792112  end;
     
    20812114  begin
    20822115    s := Phrases.Lookup('FEATURES', i);
    2083     if pos(SearchString, UpperCase(s)) > 0 then
     2116    if Pos(SearchString, UpperCase(s)) > 0 then
    20842117    begin
    20852118      if i < mcFirstNonCap then
     
    20902123        s := s + ' ' + HelpText.Lookup('HELPSPEC_FEATURE');
    20912124      SearchResult.AddLine(s, pkNormal, 0, hkFeature + hkCrossLink, i);
    2092       include(mFEATUREHELP, i);
    2093     end
     2125      Include(mFEATUREHELP, i);
     2126    end;
    20942127  end;
    20952128  for i := 0 to nImp - 1 do
    20962129  begin
    20972130    s := Phrases.Lookup('IMPROVEMENTS', i);
    2098     if pos(SearchString, UpperCase(s)) > 0 then
     2131    if Pos(SearchString, UpperCase(s)) > 0 then
    20992132    begin
    21002133      case Imp[i].Kind of
     
    21092142      end;
    21102143      SearchResult.AddLine(s, pkNormal, 0, hkImp + hkCrossLink, i);
    2111       include(mIMPHELP, i);
     2144      Include(mIMPHELP, i);
    21122145    end
    21132146  end;
    21142147  for i := 0 to nGov - 1 do
    2115     if pos(SearchString, UpperCase(Phrases.Lookup('GOVERNMENT', i))) > 0 then
     2148    if Pos(SearchString, UpperCase(Phrases.Lookup('GOVERNMENT', i))) > 0 then
    21162149    begin
    21172150      SearchResult.AddLine(HelpText.Lookup('HELPTITLE_GOVLIST'), pkNormal, 0,
    21182151        hkMisc + hkCrossLink, miscGovList);
    2119       bGOVHELP := true;
    2120       Break
     2152      bGOVHELP := True;
     2153      Break;
    21212154    end;
    21222155
     
    21392172          s := s + ' ' + HelpText.Lookup('HELPSPEC_ADV');
    21402173        SearchResult.AddLine(s, pkNormal, 0, hkAdv + hkCrossLink, i)
    2141       end
     2174      end;
    21422175    end
    21432176    else if h = hIMPHELP then
     
    21582191        end;
    21592192        SearchResult.AddLine(s, pkNormal, 0, hkImp + hkCrossLink, i)
    2160       end
     2193      end;
    21612194    end
    21622195    else if h = hFEATUREHELP then
     
    21732206          s := s + ' ' + HelpText.Lookup('HELPSPEC_FEATURE');
    21742207        SearchResult.AddLine(s, pkNormal, 0, hkFeature + hkCrossLink, i);
    2175       end
     2208      end;
    21762209    end
    21772210    else if h = hGOVHELP then
     
    21962229    begin
    21972230      s := HelpText.LookupByHandle(h);
    2198       p := pos('$', s);
     2231      p := Pos('$', s);
    21992232      if p > 0 then
    22002233      begin
    2201         s := copy(s, p + 1, maxint);
    2202         p := pos('\', s);
     2234        s := Copy(s, p + 1, maxint);
     2235        p := Pos('\', s);
    22032236        if p > 0 then
    2204           s := copy(s, 1, p - 1);
     2237          s := Copy(s, 1, p - 1);
    22052238        SearchResult.AddLine(s, pkNormal, 0, hkText + hkCrossLink, h);
    2206       end
    2207     end
    2208     until false;
     2239      end;
     2240    end;
     2241    until False;
    22092242
    22102243    // cut lines to fit to window
Note: See TracChangeset for help on using the changeset viewer.