Ignore:
Timestamp:
Nov 30, 2023, 10:16:14 PM (5 months ago)
Author:
chronos
Message:
  • Modified: Updated high dpi branch from trunk.
  • Modified: Use generics.collections instead of fgl.
  • Modified: Compile with Delphi syntax.
File:
1 edited

Legend:

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

    r378 r465  
    55
    66uses
    7   UDpiControls, Protocol, ClientTools, Term, ScreenTools, IsoEngine, PVSB, BaseWin,
     7  UDpiControls, Protocol, ClientTools, ScreenTools, PVSB, BaseWin,
    88  LCLIntf, LCLType, Messages, SysUtils, Classes, Graphics, Controls, Forms,
    99  ExtCtrls, ButtonB, ButtonBase, Menus, Types;
     
    2727    ToggleBtn: TButtonB;
    2828    Popup: TDpiPopupMenu;
     29    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    2930    procedure FormMouseWheel(Sender: TObject; Shift: TShiftState;
    3031      WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
    3132    procedure PaintBox1MouseMove(Sender: TObject; Shift: TShiftState;
    32       x, y: integer);
     33      X, Y: Integer);
    3334    procedure FormCreate(Sender: TObject);
    3435    procedure FormDestroy(Sender: TObject);
    3536    procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
    36       Shift: TShiftState; x, y: integer);
     37      Shift: TShiftState; X, Y: Integer);
    3738    procedure FormPaint(Sender: TObject);
    3839    procedure CloseBtnClick(Sender: TObject);
    39     procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
     40    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    4041    procedure FormShow(Sender: TObject);
    4142    procedure ModeBtnClick(Sender: TObject);
    4243    procedure ToggleBtnClick(Sender: TObject);
    43     procedure FormKeyDown(Sender: TObject; var Key: word; Shift: TShiftState);
     44    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    4445    procedure PlayerClick(Sender: TObject);
    4546  private
     
    4950    cixProject: Integer;
    5051    pView: Integer;
    51     Sel: Integer;
     52    Selected: Integer;
    5253    DispLines: Integer;
    5354    Layer: Integer;
     
    5556    TechNameSpace: Integer;
    5657    ScienceNation: Integer;
    57     sb: TPVScrollbar;
    58     Lines, FirstShrinkedLine: array [0 .. MaxLayer - 1] of integer;
    59     code: array [0 .. MaxLayer - 1, 0 .. 4095] of integer;
    60     Column: array [0 .. nPl - 1] of integer;
     58    ScrollBar: TPVScrollbar;
     59    Lines: array [0 .. MaxLayer - 1] of Integer;
     60    FirstShrinkedLine: array [0 .. MaxLayer - 1] of Integer;
     61    Code: array [0 .. MaxLayer - 1, 0 .. 4095] of Integer;
     62    Column: array [0 .. nPl - 1] of Integer;
    6163    Closable: Boolean;
    6264    MultiPage: Boolean;
     
    6466    procedure ScrollBarUpdate(Sender: TObject);
    6567    procedure InitLines;
    66     procedure line(ca: TDpiCanvas; l: integer; NonText, lit: boolean);
    67     function RenameCity(cix: integer): boolean;
    68     function RenameModel(mix: integer): boolean;
     68    procedure Line(ca: TDpiCanvas; L: Integer; NonText, lit: Boolean);
     69    function RenameCity(cix: Integer): Boolean;
     70    function RenameModel(mix: Integer): Boolean;
    6971    procedure OnScroll(var Msg: TMessage); message WM_VSCROLL;
    7072    procedure OnMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE;
    7173  public
    72     result: integer;
    73     function OnlyChoice(TestKind: TListKind): integer;
     74    Result: Integer;
     75    function OnlyChoice(TestKind: TListKind): Integer;
    7476    // -2=empty, -1=ambiguous, other=only choice
    7577    procedure OffscreenPaint; override;
    76     procedure ShowNewContent(NewMode: integer; ListKind: TListKind);
    77     procedure ShowNewContent_CityProject(NewMode, cix: integer);
    78     procedure ShowNewContent_MilReport(NewMode, p: integer);
     78    procedure ShowNewContent(NewMode: TWindowMode; ListKind: TListKind);
     79    procedure ShowNewContent_CityProject(NewMode: TWindowMode; cix: Integer);
     80    procedure ShowNewContent_MilReport(NewMode: TWindowMode; P: Integer);
    7981    procedure EcoChange;
    8082    procedure TechChange;
     
    9092  adAll = $10000;
    9193
    92 var
    93   ListDlg: TListDlg;
    94   ModalSelectDlg: TModalSelectDlg;
    95 
    9694
    9795implementation
    9896
    9997uses
    100   CityScreen, Help, UnitStat, Tribes, Inp;
     98  Term, CityScreen, Help, UnitStat, Tribes, Inp, CmdList;
    10199
    102100{$R *.lfm}
     
    111109  inherited;
    112110  Canvas.Font.Assign(UniFont[ftNormal]);
    113   sb := TPVScrollbar.Create(Self);
    114   sb.SetBorderSpacing(36, 10, 36);
    115   sb.OnUpdate := ScrollBarUpdate;
     111  ScrollBar := TPVScrollbar.Create(Self);
     112  ScrollBar.SetBorderSpacing(36, 10, 36);
     113  ScrollBar.OnUpdate := ScrollBarUpdate;
    116114  InitButtons;
    117115  Kind := kMission;
     
    127125procedure TListDlg.FormDestroy(Sender: TObject);
    128126begin
    129   FreeAndNil(sb);
     127  FreeAndNil(ScrollBar);
    130128  FreeAndNil(ScienceNationDotBuffer);
    131129end;
     
    133131procedure TListDlg.CloseBtnClick(Sender: TObject);
    134132begin
    135   Closable := true;
     133  Closable := True;
    136134  Close;
    137135end;
    138136
    139 procedure TListDlg.FormCloseQuery(Sender: TObject; var CanClose: boolean);
     137procedure TListDlg.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    140138begin
    141139  CanClose := Closable or not(Kind in MustChooseKind);
     
    145143begin
    146144  { TODO: Handled by MouseWheel event
    147   if sb.Process(Msg) then  begin
    148     Sel := -2;
    149     SmartUpdateContent(true);
     145  if ScrollBar.Process(Msg) then  begin
     146    Selected := -2;
     147    SmartUpdateContent(True);
    150148  end;
    151149  }
     
    154152procedure TListDlg.OnMouseLeave(var Msg: TMessage);
    155153begin
    156   if not Closable and (Sel <> -2) then
    157   begin
    158     line(Canvas, Sel, false, false);
    159     Sel := -2;
     154  if not Closable and (Selected <> -2) then
     155  begin
     156    Line(Canvas, Selected, False, False);
     157    Selected := -2;
    160158  end;
    161159end;
     
    163161procedure TListDlg.FormPaint(Sender: TObject);
    164162var
    165   s: string;
     163  S: string;
    166164begin
    167165  inherited;
    168166  Canvas.Font.Assign(UniFont[ftNormal]);
    169   if Sel <> -2 then
    170     line(Canvas, Sel, false, true);
    171   s := '';
     167  if Selected <> -2 then
     168    Line(Canvas, Selected, False, True);
     169  S := '';
    172170  if (Kind = kAdvance) and (MyData.FarTech <> adNone) then
    173     s := Format(Phrases.Lookup('TECHFOCUS'),
     171    S := Format(Phrases.Lookup('TECHFOCUS'),
    174172      [Phrases.Lookup('ADVANCES', MyData.FarTech)])
    175173  else if Kind = kModels then
    176     s := Tribe[me].TPhrase('SHORTNAME')
     174    S := Tribe[Me].TPhrase('SHORTNAME')
    177175  else if Kind = kEModels then
    178     s := Tribe[pView].TPhrase('SHORTNAME') + ' (' +
     176    S := Tribe[pView].TPhrase('SHORTNAME') + ' (' +
    179177      TurnToString(MyRO.EnemyReport[pView].TurnOfMilReport) + ')';
    180   if s <> '' then
     178  if S <> '' then
    181179    LoweredTextOut(Canvas, -1, MainTexture,
    182       (ClientWidth - BiColorTextWidth(Canvas, s)) div 2, 31, s);
     180      (ClientWidth - BiColorTextWidth(Canvas, S)) div 2, 31, S);
    183181  if not MultiPage and (Kind in [kProject, kAdvance, kFarAdvance]) and not Phrases2FallenBackToEnglish
    184182  then
    185183  begin
    186     s := Phrases2.Lookup('SHIFTCLICK');
     184    S := Phrases2.Lookup('SHIFTCLICK');
    187185    LoweredTextOut(Canvas, -2, MainTexture,
    188       (ClientWidth - BiColorTextWidth(Canvas, s)) div 2, ClientHeight - 29, s);
    189   end;
    190 end;
    191 
    192 procedure TListDlg.line(ca: TDpiCanvas; l: integer; NonText, lit: boolean);
     186      (ClientWidth - BiColorTextWidth(Canvas, S)) div 2, ClientHeight - 29, S);
     187  end;
     188end;
     189
     190procedure TListDlg.Line(ca: TDpiCanvas; L: Integer; NonText, lit: Boolean);
    193191// paint a line
    194192
    195   procedure DisplayProject(x, y, pix: integer);
     193  procedure DisplayProject(X, Y, pix: Integer);
    196194  begin
    197195    if pix and (cpType or cpImp) = 0 then
    198       with Tribe[me].ModelPicture[pix and cpIndex] do
    199         Sprite(offscreen, HGr, x, y, 64, 48, pix mod 10 * 65 + 1,
     196      with Tribe[Me].ModelPicture[pix and cpIndex] do
     197        Sprite(Offscreen, HGr, X, Y, 64, 48, pix mod 10 * 65 + 1,
    200198          pix div 10 * 49 + 1)
    201199    else
    202200    begin
    203       Frame(offscreen.Canvas, x + (16 - 1), y + (16 - 2), x + (16 + xSizeSmall),
    204         y + (16 - 1 + ySizeSmall), MainTexture.ColorBevelLight,
     201      Frame(Offscreen.Canvas, X + (16 - 1), Y + (16 - 2), X + (16 + xSizeSmall),
     202        Y + (16 - 1 + ySizeSmall), MainTexture.ColorBevelLight,
    205203        MainTexture.ColorBevelShade);
    206204      if pix and cpType = 0 then
    207205        if (pix and cpIndex = imPalace) and (MyRO.Government <> gAnarchy) then
    208           DpiBitCanvas(offscreen.Canvas, x + 16, y + (16 - 1), xSizeSmall,
     206          DpiBitBltCanvas(Offscreen.Canvas, X + 16, Y + (16 - 1), xSizeSmall,
    209207            ySizeSmall, SmallImp.Canvas, (MyRO.Government - 1) *
    210208            xSizeSmall, ySizeSmall)
    211209        else
    212           DpiBitCanvas(offscreen.Canvas, x + 16, y + (16 - 1), xSizeSmall,
     210          DpiBitBltCanvas(Offscreen.Canvas, X + 16, Y + (16 - 1), xSizeSmall,
    213211            ySizeSmall, SmallImp.Canvas, pix and cpIndex mod 7 *
    214212            xSizeSmall, (pix and cpIndex + SystemIconLines * 7) div 7 *
    215213            ySizeSmall)
    216214      else
    217         DpiBitCanvas(offscreen.Canvas, x + 16, y + (16 - 1), xSizeSmall,
     215        DpiBitBltCanvas(Offscreen.Canvas, X + 16, Y + (16 - 1), xSizeSmall,
    218216          ySizeSmall, SmallImp.Canvas, (3 + pix and cpIndex) *
    219217          xSizeSmall, 0);
     
    221219  end;
    222220
    223   procedure ReplaceText(x, y, Color: integer; s: string);
     221  procedure ReplaceText(X, Y, Color: Integer; S: string);
    224222  var
    225223    TextSize: TSize;
     
    227225    if ca = Canvas then
    228226    begin
    229       TextSize.cx := BiColorTextWidth(ca, s);
    230       TextSize.cy := ca.TextHeight(s);
    231       if y + TextSize.cy >= TitleHeight + InnerHeight then
    232         TextSize.cy := TitleHeight + InnerHeight - y;
    233       Fill(ca, x, y, TextSize.cx, TextSize.cy, (Maintexture.Width - ClientWidth)
     227      TextSize.cx := BiColorTextWidth(ca, S);
     228      TextSize.cy := ca.TextHeight(S);
     229      if Y + TextSize.cy >= TitleHeight + InnerHeight then
     230        TextSize.cy := TitleHeight + InnerHeight - Y;
     231      Fill(ca, X, Y, TextSize.cx, TextSize.cy, (Maintexture.Width - ClientWidth)
    234232        div 2, (Maintexture.Height - ClientHeight) div 2);
    235233    end;
    236     LoweredTextOut(ca, Color, MainTexture, x, y, s);
     234    LoweredTextOut(ca, Color, MainTexture, X, Y, S);
    237235  end;
    238236
    239237var
    240   icon, ofs, x, y, y0, lix, i, j, TextColor, Available, first, test,
    241     FutureCount, growth, TrueFood, TrueProd: integer;
     238  icon, ofs, X, Y, y0, lix, I, J, TextColor, Available, first, Test,
     239    FutureCount, growth, TrueFood, TrueProd: Integer;
    242240  CityReport: TCityReportNew;
    243241  mox: ^TModelInfo;
    244   s, number: string;
    245   CanGrow: boolean;
    246 begin
    247   lix := code[Layer, sb.Position + l];
    248   y0 := 2 + (l + 1) * LineDistance;
    249   if sb.Position + l >= FirstShrinkedLine[Layer] then
    250     ofs := (sb.Position + l - FirstShrinkedLine[Layer]) and 1 * 33
     242  S, number: string;
     243  CanGrow: Boolean;
     244begin
     245  lix := Code[Layer, ScrollBar.Position + L];
     246  y0 := 2 + (L + 1) * LineDistance;
     247  if ScrollBar.Position + L >= FirstShrinkedLine[Layer] then
     248    ofs := (ScrollBar.Position + L - FirstShrinkedLine[Layer]) and 1 * 33
    251249  else { if FirstShrinkedLine[Layer]<Lines[Layer] then }
    252250    ofs := 33;
     
    255253    with MyCity[lix] do
    256254    begin
    257       x := 104 - 76;
    258       y := y0;
     255      X := 104 - 76;
     256      Y := y0;
    259257      if ca = Canvas then
    260258      begin
    261         x := x + SideFrame;
    262         y := y + TitleHeight;
     259        X := X + SideFrame;
     260        Y := Y + TitleHeight;
    263261      end;
    264262      if lit then
     
    266264      else
    267265        TextColor := -1;
    268       s := CityName(ID);
    269       while BiColorTextWidth(ca, s) > CityNameSpace do
    270         delete(s, length(s), 1);
    271       ReplaceText(x + 15, y, TextColor, s);
     266      S := CityName(ID);
     267      while BiColorTextWidth(ca, S) > CityNameSpace do
     268        Delete(S, Length(S), 1);
     269      ReplaceText(X + 15, Y, TextColor, S);
    272270
    273271      if NonText then
    274         with offscreen.Canvas do
     272        with Offscreen.Canvas do
    275273        begin // city size
    276           brush.Color := $000000;
    277           fillrect(rect(x - 4 - 11, y + 1, x - 4 + 13, y + 21));
    278           brush.Color := $FFFFFF;
    279           fillrect(rect(x - 4 - 12, y, x - 4 + 12, y + 20));
    280           brush.style := bsClear;
     274          Brush.Color := $000000;
     275          FillRect(rect(X - 4 - 11, Y + 1, X - 4 + 13, Y + 21));
     276          Brush.Color := $FFFFFF;
     277          FillRect(rect(X - 4 - 12, Y, X - 4 + 12, Y + 20));
     278          Brush.style := bsClear;
    281279          Font.Color := $000000;
    282           s := inttostr(MyCity[lix].Size);
    283           TextOut(x - 4 - textwidth(s) div 2, y, s);
     280          S := IntToStr(MyCity[lix].Size);
     281          TextOut(X - 4 - textwidth(S) div 2, Y, S);
    284282        end;
    285283
     
    287285      begin
    288286        first := -1;
    289         for j := 0 to nCityEventPriority - 1 do
    290           if (Flags and CityRepMask and CityEventPriority[j] <> 0) then
    291           begin
    292             first := j;
    293             Break
     287        for J := 0 to nCityEventPriority - 1 do
     288          if (Flags and CityRepMask and CityEventPriority[J] <> 0) then
     289          begin
     290            first := J;
     291            Break;
    294292          end;
    295293        if first >= 0 then
    296294        begin
    297           i := 0;
    298           test := 1;
    299           while test < CityEventPriority[first] do
    300           begin
    301             inc(i);
    302             inc(test, test)
    303           end;
    304           s := CityEventName(i);
     295          I := 0;
     296          Test := 1;
     297          while Test < CityEventPriority[first] do
     298          begin
     299            Inc(I);
     300            Inc(Test, Test);
     301          end;
     302          S := CityEventName(I);
    305303          { if CityEventPriority[first]=chNoGrowthWarning then
    306304            if Built[imAqueduct]=0 then
    307             s:=Format(s,[Phrases.Lookup('IMPROVEMENTS',imAqueduct)])
    308             else begin s:=Format(s,[Phrases.Lookup('IMPROVEMENTS',imSewer)]); i:=17 end; }
    309           ReplaceText(x + (CityNameSpace + 4 + 40 + 18 + 8), y, TextColor, s);
     305            S:=Format(S,[Phrases.Lookup('IMPROVEMENTS',imAqueduct)])
     306            else begin S:=Format(S,[Phrases.Lookup('IMPROVEMENTS',imSewer)]); I:=17 end; }
     307          ReplaceText(X + (CityNameSpace + 4 + 40 + 18 + 8), Y, TextColor, S);
    310308          if NonText then
    311309          begin
    312             Sprite(offscreen, HGrSystem, 105 - 76 + CityNameSpace + 4 + 40,
    313               y0 + 1, 18, 18, 1 + i mod 3 * 19, 1 + i div 3 * 19);
    314             x := InnerWidth - 26;
    315             for j := nCityEventPriority - 1 downto first + 1 do
    316               if (Flags and CityRepMask and CityEventPriority[j] <> 0) then
     310            Sprite(Offscreen, HGrSystem, 105 - 76 + CityNameSpace + 4 + 40,
     311              y0 + 1, 18, 18, 1 + I mod 3 * 19, 1 + I div 3 * 19);
     312            X := InnerWidth - 26;
     313            for J := nCityEventPriority - 1 downto first + 1 do
     314              if (Flags and CityRepMask and CityEventPriority[J] <> 0) then
    317315              begin
    318                 i := 0;
    319                 test := 1;
    320                 while test < CityEventPriority[j] do
     316                I := 0;
     317                Test := 1;
     318                while Test < CityEventPriority[J] do
    321319                begin
    322                   inc(i);
    323                   inc(test, test)
     320                  Inc(I);
     321                  Inc(Test, Test);
    324322                end;
    325                 if (CityEventPriority[j] = chNoGrowthWarning) and
     323                if (CityEventPriority[J] = chNoGrowthWarning) and
    326324                  (Built[imAqueduct] > 0) then
    327                   i := 17;
    328                 Sprite(offscreen, HGrSystem, x, y0 + 1, 18, 18,
    329                   1 + i mod 3 * 19, 1 + i div 3 * 19);
    330                 dec(x, 20)
    331               end
    332           end
    333         end
     325                  I := 17;
     326                Sprite(Offscreen, HGrSystem, X, y0 + 1, 18, 18,
     327                  1 + I mod 3 * 19, 1 + I div 3 * 19);
     328                Dec(X, 20);
     329              end;
     330          end;
     331        end;
    334332      end
    335333      else
     
    338336        CityReport.HypoTaxRate := -1;
    339337        CityReport.HypoLuxuryRate := -1;
    340         Server(sGetCityReportNew, me, lix, CityReport);
     338        Server(sGetCityReportNew, Me, lix, CityReport);
    341339        TrueFood := Food;
    342340        TrueProd := Prod;
    343         if supervising then
     341        if Supervising then
    344342        begin // normalize city from after-turn state
    345           dec(TrueFood, CityReport.FoodSurplus);
     343          Dec(TrueFood, CityReport.FoodSurplus);
    346344          if TrueFood < 0 then
    347345            TrueFood := 0; // shouldn't happen
    348           dec(TrueProd, CityReport.Production);
     346          Dec(TrueProd, CityReport.Production);
    349347          if TrueProd < 0 then
    350348            TrueProd := 0; // shouldn't happen
    351349        end;
    352350
    353         s := ''; // disorder info
     351        S := ''; // disorder info
    354352        if Flags and chCaptured <> 0 then
    355           s := Phrases.Lookup('CITYEVENTS', 14)
     353          S := Phrases.Lookup('CITYEVENTS', 14)
    356354        else if CityReport.HappinessBalance < 0 then
    357           s := Phrases.Lookup('CITYEVENTS', 0);
    358         if s <> '' then
     355          S := Phrases.Lookup('CITYEVENTS', 0);
     356        if S <> '' then
    359357        begin { disorder }
    360358          if NonText then
    361359          begin
    362             DarkGradient(offscreen.Canvas, 99 + 31 + CityNameSpace + 4,
     360            DarkGradient(Offscreen.Canvas, 99 + 31 + CityNameSpace + 4,
    363361              y0 + 2, 131, 3);
    364362            ca.Font.Assign(UniFont[ftSmall]);
    365             RisedTextout(offscreen.Canvas, 103 + CityNameSpace + 4 + 31,
    366               y0 + 1, s);
     363            RisedTextout(Offscreen.Canvas, 103 + CityNameSpace + 4 + 31,
     364              y0 + 1, S);
    367365            ca.Font.Assign(UniFont[ftNormal]);
    368           end
     366          end;
    369367        end
    370368        else
    371369        begin
    372370          { s:=IntToStr(CityReport.FoodSurplus);
    373             ReplaceText(x+(CityNameSpace+4+48)-BiColorTextWidth(ca,s),y,TextColor,s); }
    374           s := inttostr(CityReport.Science);
    375           ReplaceText(x + CityNameSpace + 4 + 370 + 48 - BiColorTextWidth(ca,
    376             s), y, TextColor, s);
    377           s := inttostr(CityReport.Production);
    378           ReplaceText(x + CityNameSpace + 4 + 132 - BiColorTextWidth(ca, s), y,
    379             TextColor, s);
     371            ReplaceText(X+(CityNameSpace+4+48)-BiColorTextWidth(ca,S),Y,TextColor,S); }
     372          S := IntToStr(CityReport.Science);
     373          ReplaceText(X + CityNameSpace + 4 + 370 + 48 - BiColorTextWidth(ca,
     374            S), Y, TextColor, S);
     375          S := IntToStr(CityReport.Production);
     376          ReplaceText(X + CityNameSpace + 4 + 132 - BiColorTextWidth(ca, S), Y,
     377            TextColor, S);
    380378          if NonText then
    381379          begin
    382380            // Sprite(offscreen,HGrSystem,x+CityNameSpace+4+333+1,y+6,10,10,66,115);
    383             Sprite(offscreen, HGrSystem, x + CityNameSpace + 4 + 370 + 48 + 1,
    384               y + 6, 10, 10, 77, 126);
    385             Sprite(offscreen, HGrSystem, x + CityNameSpace + 4 + 132 + 1, y + 6,
     381            Sprite(Offscreen, HGrSystem, X + CityNameSpace + 4 + 370 + 48 + 1,
     382              Y + 6, 10, 10, 77, 126);
     383            Sprite(Offscreen, HGrSystem, X + CityNameSpace + 4 + 132 + 1, Y + 6,
    386384              10, 10, 88, 115);
    387           end
    388         end;
    389         s := inttostr(CityTaxBalance(lix, CityReport));
    390         ReplaceText(x + CityNameSpace + 4 + 370 - BiColorTextWidth(ca, s), y,
    391           TextColor, s);
     385          end;
     386        end;
     387        S := IntToStr(CityTaxBalance(lix, CityReport));
     388        ReplaceText(X + CityNameSpace + 4 + 370 - BiColorTextWidth(ca, S), Y,
     389          TextColor, S);
    392390        // if Project and (cpImp+cpIndex)<>cpImp+imTrGoods then
    393391        // ReplaceText(x+CityNameSpace+4+333+1,y,TextColor,Format('%d/%d',[TrueProd,CityReport.ProjectCost]));
    394392        if NonText then
    395393        begin
    396           Sprite(offscreen, HGrSystem, x + CityNameSpace + 4 + 370 + 1, y + 6,
     394          Sprite(Offscreen, HGrSystem, X + CityNameSpace + 4 + 370 + 1, Y + 6,
    397395            10, 10, 132, 115);
    398396
     
    402400            ((Size < NeedAqueductSize) or (Built[imAqueduct] = 1) and
    403401            (Size < NeedSewerSize) or (Built[imSewer] = 1));
    404           PaintRelativeProgressBar(offscreen.Canvas, 1, x + 15 + CityNameSpace +
    405             4, y + 7, 68, TrueFood, CutCityFoodSurplus(CityReport.FoodSurplus,
     402          PaintRelativeProgressBar(Offscreen.Canvas, 1, X + 15 + CityNameSpace +
     403            4, Y + 7, 68, TrueFood, CutCityFoodSurplus(CityReport.FoodSurplus,
    406404            (MyRO.Government <> gAnarchy) and (Flags and chCaptured = 0),
    407405            MyRO.Government, Size), CityReport.Storage, CanGrow, MainTexture);
     
    409407          if Project <> cpImp + imTrGoods then
    410408          begin
    411             DisplayProject(ofs + 104 - 76 + x - 28 + CityNameSpace + 4 + 206 -
     409            DisplayProject(ofs + 104 - 76 + X - 28 + CityNameSpace + 4 + 206 -
    412410              60, y0 - 15, Project);
    413411
     
    417415              (Flags and chCaptured <> 0) then
    418416              growth := 0;
    419             PaintRelativeProgressBar(offscreen.Canvas, 4,
    420               x + CityNameSpace + 4 + 304 - 60 + 9, y + 7, 68, TrueProd, growth,
    421               CityReport.ProjectCost, true, MainTexture);
    422           end;
    423         end
     417            PaintRelativeProgressBar(Offscreen.Canvas, 4,
     418              X + CityNameSpace + 4 + 304 - 60 + 9, Y + 7, 68, TrueProd, growth,
     419              CityReport.ProjectCost, True, MainTexture);
     420          end;
     421        end;
    424422      end;
    425423    end
    426424  else if Kind in [kModels, kEModels] then
    427425  begin
    428     x := 104;
    429     y := y0;
     426    X := 104;
     427    Y := y0;
    430428    if ca = Canvas then
    431429    begin
    432       x := x + SideFrame;
    433       y := y + TitleHeight
     430      X := X + SideFrame;
     431      Y := Y + TitleHeight;
    434432    end;
    435433    if lit then
     
    440438    begin
    441439      Available := 0;
    442       for j := 0 to MyRO.nUn - 1 do
    443         if (MyUn[j].Loc >= 0) and (MyUn[j].mix = lix) then
    444           inc(Available);
     440      for J := 0 to MyRO.nUn - 1 do
     441        if (MyUn[J].Loc >= 0) and (MyUn[J].mix = lix) then
     442          Inc(Available);
    445443      if MainScreen.mNames.Checked then
    446         s := Tribe[me].ModelName[lix]
     444        S := Tribe[Me].ModelName[lix]
    447445      else
    448         s := Format(Tribe[me].TPhrase('GENMODEL'), [lix]);
     446        S := Format(Tribe[Me].TPhrase('GENMODEL'), [lix]);
    449447      if NonText then
    450448        DisplayProject(8 + ofs, y0 - 15, lix);
     
    454452      Available := MyRO.EnemyReport[pView].UnCount[lix];
    455453      if MainScreen.mNames.Checked then
    456         s := Tribe[pView].ModelName[lix]
     454        S := Tribe[pView].ModelName[lix]
    457455      else
    458         s := Format(Tribe[pView].TPhrase('GENMODEL'), [lix]);
     456        S := Format(Tribe[pView].TPhrase('GENMODEL'), [lix]);
    459457      if NonText then
    460458        with Tribe[pView].ModelPicture[lix] do
    461           Sprite(offscreen, HGr, 8 + ofs, y0 - 15, 64, 48, pix mod 10 * 65 + 1,
     459          Sprite(Offscreen, HGr, 8 + ofs, y0 - 15, 64, 48, pix mod 10 * 65 + 1,
    462460            pix div 10 * 49 + 1);
    463461    end;
    464462    if Available > 0 then
    465       ReplaceText(x + 32 - BiColorTextWidth(ca, inttostr(Available)), y,
    466         TextColor, inttostr(Available));
    467     ReplaceText(x + 40, y, TextColor, s);
     463      ReplaceText(X + 32 - BiColorTextWidth(ca, IntToStr(Available)), Y,
     464        TextColor, IntToStr(Available));
     465    ReplaceText(X + 40, Y, TextColor, S);
    468466  end
    469467  else
     
    472470      kAllEModels, kChooseEModel:
    473471        if lix = mixAll then
    474           s := Phrases.Lookup('PRICECAT_ALLMODEL')
     472          S := Phrases.Lookup('PRICECAT_ALLMODEL')
    475473        else
    476474        begin
     
    478476          if MainScreen.mNames.Checked then
    479477          begin
    480             s := Tribe[mox.Owner].ModelName[mox.mix];
    481             if (Kind = kAllEModels) and (code[1, sb.Position + l] = 0) then
    482               s := Format(Tribe[mox.Owner].TPhrase('OWNED'), [s]);
     478            S := Tribe[mox.Owner].ModelName[mox.mix];
     479            if (Kind = kAllEModels) and (Code[1, ScrollBar.Position + L] = 0) then
     480              S := Format(Tribe[mox.Owner].TPhrase('OWNED'), [S]);
    483481          end
    484482          else
    485             s := Format(Tribe[mox.Owner].TPhrase('GENMODEL'), [mox.mix]);
     483            S := Format(Tribe[mox.Owner].TPhrase('GENMODEL'), [mox.mix]);
    486484          if NonText then
    487485            with Tribe[mox.Owner].ModelPicture[mox.mix] do
    488               Sprite(offscreen, HGr, 8 + ofs, y0 - 15, 64, 48,
     486              Sprite(Offscreen, HGr, 8 + ofs, y0 - 15, 64, 48,
    489487                pix mod 10 * 65 + 1, pix div 10 * 49 + 1);
    490488        end;
    491489      kChooseModel:
    492490        if lix = mixAll then
    493           s := Phrases.Lookup('PRICECAT_ALLMODEL')
     491          S := Phrases.Lookup('PRICECAT_ALLMODEL')
    494492        else
    495493        begin
    496           s := Tribe[me].ModelName[lix];
     494          S := Tribe[Me].ModelName[lix];
    497495          if NonText then
    498496            DisplayProject(8 + ofs, y0 - 15, lix);
     
    501499        begin
    502500          if lix and cpType <> 0 then
    503             s := Phrases.Lookup('CITYTYPE', lix and cpIndex)
     501            S := Phrases.Lookup('CITYTYPE', lix and cpIndex)
    504502          else if lix and cpImp = 0 then
    505503            with MyModel[lix and cpIndex] do
    506504            begin
    507               s := Tribe[me].ModelName[lix and cpIndex];
     505              S := Tribe[Me].ModelName[lix and cpIndex];
    508506              if lix and cpConscripts <> 0 then
    509                 s := Format(Phrases.Lookup('CONSCRIPTS'), [s]);
     507                S := Format(Phrases.Lookup('CONSCRIPTS'), [S]);
    510508            end
    511509          else
    512510          begin
    513             s := Phrases.Lookup('IMPROVEMENTS', lix and cpIndex);
     511            S := Phrases.Lookup('IMPROVEMENTS', lix and cpIndex);
    514512            if (Imp[lix and cpIndex].Kind in [ikNatLocal, ikNatGlobal]) and
    515513              (MyRO.NatBuilt[lix and cpIndex] > 0) or
     
    517515              (MyCity[cixProject].Built[imPower] + MyCity[cixProject].Built
    518516              [imHydro] + MyCity[cixProject].Built[imNuclear] > 0) then
    519               s := Format(Phrases.Lookup('NATEXISTS'), [s]);
     517              S := Format(Phrases.Lookup('NATEXISTS'), [S]);
    520518          end;
    521519          if NonText then
     
    525523        begin
    526524          if lix = adAll then
    527             s := Phrases.Lookup('PRICECAT_ALLTECH')
     525            S := Phrases.Lookup('PRICECAT_ALLTECH')
    528526          else
    529527          begin
    530528            if lix = adNexus then
    531               s := Phrases.Lookup('NEXUS')
     529              S := Phrases.Lookup('NEXUS')
    532530            else if lix = adNone then
    533               s := Phrases.Lookup('NOFARTECH')
     531              S := Phrases.Lookup('NOFARTECH')
    534532            else if lix = adMilitary then
    535               s := Phrases.Lookup('INITUNIT')
     533              S := Phrases.Lookup('INITUNIT')
    536534            else
    537535            begin
    538               s := Phrases.Lookup('ADVANCES', lix);
     536              S := Phrases.Lookup('ADVANCES', lix);
    539537              if (Kind = kAdvance) and (lix in FutureTech) then
    540538                if MyRO.Tech[lix] < tsApplicable then
    541                   s := s + ' 1'
     539                  S := S + ' 1'
    542540                else
    543                   s := s + ' ' + inttostr(MyRO.Tech[lix] + 1);
     541                  S := S + ' ' + IntToStr(MyRO.Tech[lix] + 1);
    544542            end;
    545             if BiColorTextWidth(ca, s) > TechNameSpace + 8 then
     543            if BiColorTextWidth(ca, S) > TechNameSpace + 8 then
    546544            begin
    547545              repeat
    548                 delete(s, length(s), 1);
    549               until BiColorTextWidth(ca, s) <= TechNameSpace + 5;
    550               s := s + '.';
     546                Delete(S, Length(S), 1);
     547              until BiColorTextWidth(ca, S) <= TechNameSpace + 5;
     548              S := S + '.';
    551549            end;
    552550
     
    555553              if lix = adNexus then
    556554              begin
    557                 Frame(offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36),
     555                Frame(Offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36),
    558556                  y0 + 20, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
    559                 Dump(offscreen, HGrSystem, (8 + 16), y0, 36, 20, 223, 295)
     557                Dump(Offscreen, HGrSystem, (8 + 16), y0, 36, 20, 223, 295)
    560558              end
    561559              else if lix = adNone then
    562560              begin
    563                 Frame(offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36),
     561                Frame(Offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36),
    564562                  y0 + 20, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
    565                 Dump(offscreen, HGrSystem, (8 + 16), y0, 36, 20, 260, 295)
     563                Dump(Offscreen, HGrSystem, (8 + 16), y0, 36, 20, 260, 295)
    566564              end
    567565              else if lix = adMilitary then
    568566              begin
    569                 Frame(offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36),
     567                Frame(Offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36),
    570568                  y0 + 20, MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
    571                 Dump(offscreen, HGrSystem, (8 + 16), y0, 36, 20, 38, 295)
     569                Dump(Offscreen, HGrSystem, (8 + 16), y0, 36, 20, 38, 295)
    572570              end
    573571              else
    574572              begin
    575                 Frame(offscreen.Canvas, (8 + 16 - 1), y0 - 1,
     573                Frame(Offscreen.Canvas, (8 + 16 - 1), y0 - 1,
    576574                  (8 + 16 + xSizeSmall), y0 + ySizeSmall,
    577575                  MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
    578576                if AdvIcon[lix] < 84 then
    579                   DpiBitCanvas(offscreen.Canvas, (8 + 16), y0, xSizeSmall,
     577                  DpiBitBltCanvas(Offscreen.Canvas, (8 + 16), y0, xSizeSmall,
    580578                    ySizeSmall, SmallImp.Canvas,
    581579                    (AdvIcon[lix] + SystemIconLines * 7) mod 7 * xSizeSmall,
     
    583581                    ySizeSmall)
    584582                else
    585                   Dump(offscreen, HGrSystem, (8 + 16), y0, 36, 20,
     583                  Dump(Offscreen, HGrSystem, (8 + 16), y0, 36, 20,
    586584                    1 + (AdvIcon[lix] - 84) mod 8 * 37,
    587585                    295 + (AdvIcon[lix] - 84) div 8 * 21);
    588                 j := AdvValue[lix] div 1000;
    589                 DpiBitCanvas(offscreen.Canvas, (8 + 16 - 4), y0 + 2, 14, 14,
    590                   HGrSystem.Mask.Canvas, 127 + j * 15,
     586                J := AdvValue[lix] div 1000;
     587                DpiBitBltCanvas(Offscreen.Canvas, (8 + 16 - 4), y0 + 2, 14, 14,
     588                  HGrSystem.Mask.Canvas, 127 + J * 15,
    591589                  85, SRCAND);
    592                 Sprite(offscreen, HGrSystem, (8 + 16 - 5), y0 + 1, 14, 14,
    593                   127 + j * 15, 85);
     590                Sprite(Offscreen, HGrSystem, (8 + 16 - 5), y0 + 1, 14, 14,
     591                  127 + J * 15, 85);
    594592              end;
    595593            end;
     
    598596          if NonText and (Kind in [kAdvance, kScience]) then
    599597          begin // show research state
    600             for j := 0 to nColumn - 1 do
     598            for J := 0 to nColumn - 1 do
    601599            begin
    602600              FutureCount := 0;
    603               if j = 0 then // own science
     601              if J = 0 then // own science
    604602                if lix = MyRO.ResearchTech then
    605603                begin
    606                   Server(sGetTechCost, me, 0, icon);
     604                  Server(sGetTechCost, Me, 0, icon);
    607605                  icon := 4 + MyRO.Research * 4 div icon;
    608606                  if icon > 4 + 3 then
     
    623621                  icon := -1
    624622              else
    625                 with MyRO.EnemyReport[Column[j]]^ do // enemy science
    626                   if (MyRO.Alive and (1 shl Column[j]) <> 0) and
     623                with MyRO.EnemyReport[Column[J]]^ do // enemy science
     624                  if (MyRO.Alive and (1 shl Column[J]) <> 0) and
    627625                    (TurnOfCivilReport >= 0) and (lix = ResearchTech) and
    628626                    ((lix = adMilitary) or (lix in FutureTech) or
     
    631629                    icon := 4 + ResearchDone div 25;
    632630                    if icon > 4 + 3 then
    633                       icon := 4 + 3
     631                      icon := 4 + 3;
    634632                  end
    635633                  else if lix = adMilitary then
     
    647645                    icon := -1;
    648646              if icon >= 0 then
    649                 Sprite(offscreen, HGrSystem, 104 - 33 + 15 + 3 + TechNameSpace +
    650                   24 * j, y0 + 3, 14, 14, 67 + icon * 15, 85)
     647                Sprite(Offscreen, HGrSystem, 104 - 33 + 15 + 3 + TechNameSpace +
     648                  24 * J, y0 + 3, 14, 14, 67 + icon * 15, 85)
    651649              else if (Kind = kScience) and (FutureCount > 0) then
    652650              begin
    653                 number := inttostr(FutureCount);
    654                 RisedTextout(ca, 104 - 33 + 15 + 10 + TechNameSpace + 24 * j -
     651                number := IntToStr(FutureCount);
     652                RisedTextout(ca, 104 - 33 + 15 + 10 + TechNameSpace + 24 * J -
    655653                  BiColorTextWidth(ca, number) div 2, y0, number);
    656               end
    657             end
     654              end;
     655            end;
    658656          end;
    659657        end; // kAdvance, kScience
    660658      kTribe:
    661         s := TribeNames[lix];
     659        S := TribeNames[lix];
    662660      kShipPart:
    663661        begin
    664           s := Phrases.Lookup('IMPROVEMENTS', imShipComp + lix) + ' (' +
    665             inttostr(MyRO.Ship[me].Parts[lix]) + ')';
     662          S := Phrases.Lookup('IMPROVEMENTS', imShipComp + lix) + ' (' +
     663            IntToStr(MyRO.Ship[Me].Parts[lix]) + ')';
    666664          if NonText then
    667665            DisplayProject(8 + ofs, y0 - 15, cpImp + imShipComp + lix);
     
    669667      kEShipPart:
    670668        begin
    671           s := Phrases.Lookup('IMPROVEMENTS', imShipComp + lix) + ' (' +
    672             inttostr(MyRO.Ship[DipMem[me].pContact].Parts[lix]) + ')';
     669          S := Phrases.Lookup('IMPROVEMENTS', imShipComp + lix) + ' (' +
     670            IntToStr(MyRO.Ship[DipMem[Me].pContact].Parts[lix]) + ')';
    673671          if NonText then
    674672            DisplayProject(8 + ofs, y0 - 15, cpImp + imShipComp + lix);
     
    676674      kGov:
    677675        begin
    678           s := Phrases.Lookup('GOVERNMENT', lix);
     676          S := Phrases.Lookup('GOVERNMENT', lix);
    679677          if NonText then
    680678          begin
    681             Frame(offscreen.Canvas, 8 + 16 - 1, y0 - 15 + (16 - 2),
     679            Frame(Offscreen.Canvas, 8 + 16 - 1, y0 - 15 + (16 - 2),
    682680              8 + 16 + xSizeSmall, y0 - 15 + (16 - 1 + ySizeSmall),
    683681              MainTexture.ColorBevelLight, MainTexture.ColorBevelShade);
    684             DpiBitCanvas(offscreen.Canvas, 8 + 16, y0 - 15 + (16 - 1),
     682            DpiBitBltCanvas(Offscreen.Canvas, 8 + 16, y0 - 15 + (16 - 1),
    685683              xSizeSmall, ySizeSmall, SmallImp.Canvas,
    686684              (lix - 1) * xSizeSmall, ySizeSmall);
    687           end
     685          end;
    688686        end;
    689687      kMission:
    690         s := Phrases.Lookup('SPYMISSION', lix);
     688        S := Phrases.Lookup('SPYMISSION', lix);
    691689    end;
    692690    case Kind of
    693691      kTribe, kMission: // center text
    694692        if Lines[0] > MaxLines then
    695           x := (InnerWidth - DpiGetSystemMetrics(SM_CXVSCROLL)) div 2 -
    696             BiColorTextWidth(ca, s) div 2
     693          X := (InnerWidth - DpiGetSystemMetrics(SM_CXVSCROLL)) div 2 -
     694            BiColorTextWidth(ca, S) div 2
    697695        else
    698           x := InnerWidth div 2 - BiColorTextWidth(ca, s) div 2;
     696          X := InnerWidth div 2 - BiColorTextWidth(ca, S) div 2;
    699697      kAdvance, kFarAdvance, kScience, kChooseTech, kChooseETech,
    700698        kStealTech, kGov:
    701         x := 104 - 33;
     699        X := 104 - 33;
    702700      kAllEModels:
    703         x := 104;
     701        X := 104;
    704702    else
    705       x := 104 + 15;
     703      X := 104 + 15;
    706704    end;
    707     y := y0;
     705    Y := y0;
    708706    if ca = Canvas then
    709707    begin
    710       x := x + SideFrame;
    711       y := y + TitleHeight
     708      X := X + SideFrame;
     709      Y := Y + TitleHeight;
    712710    end;
    713711    if lit then
     
    716714      TextColor := -1;
    717715    { if Kind=kTribe then ReplaceText_Tribe(x,y,TextColor,
    718       integer(TribeNames.Objects[lix]),s)
    719       else } ReplaceText(x, y, TextColor, s);
    720   end
     716      Integer(TribeNames.Objects[lix]),S)
     717      else } ReplaceText(X, Y, TextColor, S);
     718  end;
    721719end;
    722720
    723721procedure TListDlg.OffscreenPaint;
    724722var
    725   i, j: integer;
     723  I, J: Integer;
    726724begin
    727725  case Kind of
    728726    kCities:
    729       Caption := Tribe[me].TPhrase('TITLE_CITIES');
     727      Caption := Tribe[Me].TPhrase('TITLE_CITIES');
    730728    kCityEvents:
    731729      Caption := Format(Phrases.Lookup('TITLE_EVENTS'),
     
    734732
    735733  inherited;
    736   offscreen.Canvas.Font.Assign(UniFont[ftNormal]);
     734  Offscreen.Canvas.Font.Assign(UniFont[ftNormal]);
    737735  FillOffscreen(0, 0, InnerWidth, InnerHeight);
    738   with offscreen.Canvas do
     736  with Offscreen.Canvas do
    739737  begin
    740738    if Kind = kScience then
    741       for i := 1 to nColumn - 1 do
     739      for I := 1 to nColumn - 1 do
    742740      begin
    743741        Pen.Color := $000000;
    744         MoveTo(104 - 33 + 15 + TechNameSpace + 24 * i, 0);
    745         LineTo(104 - 33 + 15 + TechNameSpace + 24 * i, InnerHeight);
    746         MoveTo(104 - 33 + 15 + TechNameSpace + 9 * 2 + 24 * i, 0);
    747         LineTo(104 - 33 + 15 + TechNameSpace + 9 * 2 + 24 * i, InnerHeight);
    748         if MyRO.EnemyReport[Column[i]].TurnOfCivilReport >= MyRO.Turn - 1 then
    749         begin
    750           brush.Color := Tribe[Column[i]].Color;
    751           fillrect(rect(104 - 33 + 14 + TechNameSpace + 24 * i + 1 * 2, 0,
    752             104 - 33 + 17 + TechNameSpace + 24 * i + 8 * 2, InnerHeight));
    753           brush.style := bsClear;
     742        MoveTo(104 - 33 + 15 + TechNameSpace + 24 * I, 0);
     743        LineTo(104 - 33 + 15 + TechNameSpace + 24 * I, InnerHeight);
     744        MoveTo(104 - 33 + 15 + TechNameSpace + 9 * 2 + 24 * I, 0);
     745        LineTo(104 - 33 + 15 + TechNameSpace + 9 * 2 + 24 * I, InnerHeight);
     746        if MyRO.EnemyReport[Column[I]].TurnOfCivilReport >= MyRO.Turn - 1 then
     747        begin
     748          Brush.Color := Tribe[Column[I]].Color;
     749          FillRect(rect(104 - 33 + 14 + TechNameSpace + 24 * I + 1 * 2, 0,
     750            104 - 33 + 17 + TechNameSpace + 24 * I + 8 * 2, InnerHeight));
     751          Brush.style := bsClear;
    754752        end
    755753        else
    756754        begin // colored player columns
    757           Pen.Color := Tribe[Column[i]].Color;
    758           for j := 1 to 8 do
    759           begin
    760             MoveTo(104 - 33 + 15 + TechNameSpace + 24 * i + j * 2, 0);
    761             LineTo(104 - 33 + 15 + TechNameSpace + 24 * i + j * 2, InnerHeight);
    762           end
    763         end;
    764       end;
    765 
    766     for i := -1 to DispLines do
    767       if (i + sb.Position >= 0) and (i + sb.Position < Lines[Layer]) then
    768         Self.line(offscreen.Canvas, i, true, false)
     755          Pen.Color := Tribe[Column[I]].Color;
     756          for J := 1 to 8 do
     757          begin
     758            MoveTo(104 - 33 + 15 + TechNameSpace + 24 * I + J * 2, 0);
     759            LineTo(104 - 33 + 15 + TechNameSpace + 24 * I + J * 2, InnerHeight);
     760          end;
     761        end;
     762      end;
     763
     764    for I := -1 to DispLines do
     765      if (I + ScrollBar.Position >= 0) and (I + ScrollBar.Position < Lines[Layer]) then
     766        Self.Line(Offscreen.Canvas, I, True, False);
    769767  end;
    770768  MarkUsedOffscreen(InnerWidth, 8 + 48 + DispLines * LineDistance);
     
    772770
    773771procedure TListDlg.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState;
    774   x, y: integer);
     772  X, Y: Integer);
    775773var
    776   i0, Sel0, iColumn, OldScienceNation, xScreen: integer;
    777   s: string;
    778 begin
    779   y := y - TitleHeight;
    780   i0 := sb.Position;
    781   Sel0 := Sel;
    782   if (x >= SideFrame) and (x < SideFrame + InnerWidth) and (y >= 0) and
    783     (y < InnerHeight) and (y mod LineDistance >= 4) and (y mod LineDistance < 20)
     774  i0, Sel0, iColumn, OldScienceNation, xScreen: Integer;
     775  S: string;
     776begin
     777  Y := Y - TitleHeight;
     778  i0 := ScrollBar.Position;
     779  Sel0 := Selected;
     780  if (X >= SideFrame) and (X < SideFrame + InnerWidth) and (Y >= 0) and
     781    (Y < InnerHeight) and (Y mod LineDistance >= 4) and (Y mod LineDistance < 20)
    784782  then
    785     Sel := y div LineDistance - 1
     783    Selected := Y div LineDistance - 1
    786784  else
    787     Sel := -2;
    788   if (Sel < -1) or (Sel > DispLines) or (Sel + i0 < 0) or
    789     (Sel + i0 >= Lines[Layer]) then
    790     Sel := -2;
    791   if Sel <> Sel0 then
     785    Selected := -2;
     786  if (Selected < -1) or (Selected > DispLines) or (Selected + i0 < 0) or
     787    (Selected + i0 >= Lines[Layer]) then
     788    Selected := -2;
     789  if Selected <> Sel0 then
    792790  begin
    793791    if Sel0 <> -2 then
    794       line(Canvas, Sel0, false, false);
    795     if Sel <> -2 then
    796       line(Canvas, Sel, false, true)
     792      Line(Canvas, Sel0, False, False);
     793    if Selected <> -2 then
     794      Line(Canvas, Selected, False, True);
    797795  end;
    798796
     
    801799    OldScienceNation := ScienceNation;
    802800    ScienceNation := -1;
    803     if (x >= SideFrame + (104 - 33 + 15 + TechNameSpace)) and
    804       ((x - SideFrame - (104 - 33 + 15 + TechNameSpace)) mod 24 <= 18) and
    805       (y >= 0) and (y < InnerHeight) then
     801    if (X >= SideFrame + (104 - 33 + 15 + TechNameSpace)) and
     802      ((X - SideFrame - (104 - 33 + 15 + TechNameSpace)) mod 24 <= 18) and
     803      (Y >= 0) and (Y < InnerHeight) then
    806804    begin
    807       iColumn := (x - SideFrame - (104 - 33 + 15 + TechNameSpace)) div 24;
     805      iColumn := (X - SideFrame - (104 - 33 + 15 + TechNameSpace)) div 24;
    808806      if (iColumn >= 1) and (iColumn < nColumn) then
    809807        ScienceNation := Column[iColumn];
     
    816814      if ScienceNation >= 0 then
    817815      begin
    818         s := Tribe[ScienceNation].TPhrase('SHORTNAME');
     816        S := Tribe[ScienceNation].TPhrase('SHORTNAME');
    819817        if MyRO.Alive and (1 shl ScienceNation) = 0 then
    820           s := Format(Phrases.Lookup('SCIENCEREPORT_EXTINCT'), [s]) // extinct
     818          S := Format(Phrases.Lookup('SCIENCEREPORT_EXTINCT'), [S]) // extinct
    821819        else if MyRO.EnemyReport[ScienceNation].TurnOfCivilReport < MyRO.Turn - 1
    822820        then
    823           s := s + ' (' + TurnToString(MyRO.EnemyReport[ScienceNation]
     821          S := S + ' (' + TurnToString(MyRO.EnemyReport[ScienceNation]
    824822            .TurnOfCivilReport) + ')'; // old report
    825         xScreen := (ClientWidth - BiColorTextWidth(Canvas, s)) div 2;
     823        xScreen := (ClientWidth - BiColorTextWidth(Canvas, S)) div 2;
    826824        LoweredTextOut(Canvas, -1, MainTexture, xScreen + 10,
    827           ClientHeight - 29, s);
    828         DpiBitCanvas(ScienceNationDotBuffer.Canvas, 0, 0, ScienceNationDot.Width,
     825          ClientHeight - 29, S);
     826        DpiBitBltCanvas(ScienceNationDotBuffer.Canvas, 0, 0, ScienceNationDot.Width,
    829827          ScienceNationDot.Height, Canvas, xScreen - 10, ClientHeight - 27);
    830828        ImageOp_BCC(ScienceNationDotBuffer, Templates.Data, Point(0, 0),
    831829          ScienceNationDot.BoundsRect, MainTexture.ColorBevelShade, Tribe[ScienceNation].Color);
    832         DpiBitCanvas(Canvas, xScreen - 10, ClientHeight - 27, ScienceNationDot.Width,
     830        DpiBitBltCanvas(Canvas, xScreen - 10, ClientHeight - 27, ScienceNationDot.Width,
    833831          ScienceNationDot.Height, ScienceNationDotBuffer.Canvas, 0, 0);
    834832      end;
     
    840838  WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
    841839begin
    842   if sb.ProcessMouseWheel(WheelDelta) then begin
     840  if ScrollBar.ProcessMouseWheel(WheelDelta) then begin
    843841    PaintBox1MouseMove(nil, [], MousePos.X - Left,
    844842      MousePos.Y - Top);
     
    846844end;
    847845
    848 function TListDlg.RenameCity(cix: integer): boolean;
     846procedure TListDlg.FormClose(Sender: TObject; var CloseAction: TCloseAction);
     847begin
     848  //Gtk2Fix;
     849end;
     850
     851function TListDlg.RenameCity(cix: Integer): Boolean;
    849852var
    850853  CityNameInfo: TCityNameInfo;
     
    859862    CityNameInfo.ID := MyCity[cix].ID;
    860863    CityNameInfo.NewName := InputDlg.EInput.Text;
    861     Server(cSetCityName + (length(CityNameInfo.NewName) + 8) div 4, me, 0,
    862       CityNameInfo);
    863     if CityDlg.Visible then
     864    if CityNameInfo.GetCommandDataSize > CommandDataMaxSize then
     865      Delete(CityNameInfo.NewName, Length(CityNameInfo.NewName) -
     866        (CityNameInfo.GetCommandDataSize - 1 - CommandDataMaxSize), MaxInt);
     867    Server(CommandWithData(cSetCityName, CityNameInfo.GetCommandDataSize),
     868      Me, 0, CityNameInfo);
     869    if MainScreen.CityDlg.Visible then
    864870    begin
    865       CityDlg.FormShow(nil);
    866       CityDlg.Invalidate;
     871      MainScreen.CityDlg.FormShow(nil);
     872      MainScreen.CityDlg.Invalidate;
    867873    end;
    868     result := true;
     874    Result := True;
    869875  end
    870876  else
    871     result := false;
    872 end;
    873 
    874 function TListDlg.RenameModel(mix: integer): boolean;
     877    Result := False;
     878end;
     879
     880function TListDlg.RenameModel(mix: Integer): Boolean;
    875881var
    876882  ModelNameInfo: TModelNameInfo;
    877883begin
    878884  InputDlg.Caption := Phrases.Lookup('TITLE_MODELNAME');
    879   InputDlg.EInput.Text := Tribe[me].ModelName[mix];
     885  InputDlg.EInput.Text := Tribe[Me].ModelName[mix];
    880886  InputDlg.CenterToRect(BoundsRect);
    881887  InputDlg.ShowModal;
    882888  if (InputDlg.ModalResult = mrOK) and (InputDlg.EInput.Text <> '') and
    883     (InputDlg.EInput.Text <> Tribe[me].ModelName[mix]) then
     889    (InputDlg.EInput.Text <> Tribe[Me].ModelName[mix]) then
    884890  begin
    885891    ModelNameInfo.mix := mix;
    886892    ModelNameInfo.NewName := InputDlg.EInput.Text;
    887     Server(cSetModelName + (length(ModelNameInfo.NewName) + 1 + 4 + 3) div 4,
    888       me, 0, ModelNameInfo);
    889     if UnitStatDlg.Visible then
     893    if ModelNameInfo.GetCommandDataSize > CommandDataMaxSize then
     894      Delete(ModelNameInfo.NewName, Length(ModelNameInfo.NewName) -
     895        (ModelNameInfo.GetCommandDataSize - 1 - CommandDataMaxSize), MaxInt);
     896    Server(CommandWithData(cSetModelName, ModelNameInfo.GetCommandDataSize),
     897      Me, 0, ModelNameInfo);
     898    if MainScreen.UnitStatDlg.Visible then
    890899    begin
    891       UnitStatDlg.FormShow(nil);
    892       UnitStatDlg.Invalidate;
     900      MainScreen.UnitStatDlg.FormShow(nil);
     901      MainScreen.UnitStatDlg.Invalidate;
    893902    end;
    894     result := true;
     903    Result := True;
    895904  end
    896905  else
    897     result := false;
     906    Result := False;
    898907end;
    899908
    900909procedure TListDlg.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
    901   Shift: TShiftState; x, y: integer);
     910  Shift: TShiftState; X, Y: Integer);
    902911var
    903   lix: integer;
    904 begin
    905   if sb.Position + Sel >= 0 then
    906     lix := code[Layer, sb.Position + Sel];
     912  lix: Integer;
     913begin
     914  if ScrollBar.Position + Selected >= 0 then
     915    lix := Code[Layer, ScrollBar.Position + Selected];
    907916  if Kind in [kScience, kCities, kCityEvents, kModels, kEModels, kAllEModels]
    908917  then
    909     include(Shift, ssShift); // don't close list window
     918    Include(Shift, ssShift); // don't close list window
    910919  if (ssLeft in Shift) and not(ssShift in Shift) then
    911920  begin
    912     if Sel <> -2 then
     921    if Selected <> -2 then
    913922    begin
    914       result := lix;
    915       Closable := true;
     923      Result := lix;
     924      Closable := True;
    916925      Close;
    917926    end;
     
    919928  else if (ssLeft in Shift) and (ssShift in Shift) then
    920929  begin // show help/info popup
    921     if Sel <> -2 then
     930    if Selected <> -2 then
    922931      case Kind of
    923932        kCities:
    924933          MainScreen.ZoomToCity(MyCity[lix].Loc);
    925934        kCityEvents:
    926           MainScreen.ZoomToCity(MyCity[lix].Loc, false, MyCity[lix].Flags and
     935          MainScreen.ZoomToCity(MyCity[lix].Loc, False, MyCity[lix].Flags and
    927936            CityRepMask);
    928937        kModels, kChooseModel:
    929938          if lix <> mixAll then
    930             UnitStatDlg.ShowNewContent_OwnModel(FWindowMode or
    931               wmPersistent, lix);
     939            MainScreen.UnitStatDlg.ShowNewContent_OwnModel(wmPersistent, lix);
    932940        kEModels:
    933           UnitStatDlg.ShowNewContent_EnemyModel(FWindowMode or wmPersistent,
    934             code[1, sb.Position + Sel]);
     941          MainScreen.UnitStatDlg.ShowNewContent_EnemyModel(wmPersistent,
     942            Code[1, ScrollBar.Position + Selected]);
    935943        kAllEModels, kChooseEModel:
    936944          if lix <> mixAll then
    937             UnitStatDlg.ShowNewContent_EnemyModel(FWindowMode or
    938               wmPersistent, lix);
     945            MainScreen.UnitStatDlg.ShowNewContent_EnemyModel(wmPersistent, lix);
    939946        kAdvance, kFarAdvance, kScience, kChooseTech, kChooseETech, kStealTech:
    940947          if lix = adMilitary then
    941             HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkText,
    942               HelpDlg.TextIndex('MILRES'))
     948            MainScreen.HelpDlg.ShowNewContent(wmPersistent, hkText,
     949              MainScreen.HelpDlg.TextIndex('MILRES'))
    943950          else if lix < adMilitary then
    944             HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkAdv, lix);
     951            MainScreen.HelpDlg.ShowNewContent(wmPersistent, hkAdv, lix);
    945952        kProject:
    946953          if lix = cpImp + imTrGoods then
    947             HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkText,
    948               HelpDlg.TextIndex('TRADINGGOODS'))
     954            MainScreen.HelpDlg.ShowNewContent(wmPersistent, hkText,
     955              MainScreen.HelpDlg.TextIndex('TRADINGGOODS'))
    949956          else if lix and (cpImp + cpType) = 0 then
    950             UnitStatDlg.ShowNewContent_OwnModel(FWindowMode or wmPersistent,
     957            MainScreen.UnitStatDlg.ShowNewContent_OwnModel(wmPersistent,
    951958              lix and cpIndex)
    952959          else if (lix and cpType = 0) and (lix <> cpImp + imTrGoods) then
    953             HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkImp,
     960            MainScreen.HelpDlg.ShowNewContent(wmPersistent, hkImp,
    954961              lix and cpIndex);
    955962        kGov:
    956           HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkMisc,
    957             miscGovList);
     963          MainScreen.HelpDlg.ShowNewContent(wmPersistent, hkMisc,
     964            Integer(miscGovList));
    958965        kShipPart, kEShipPart:
    959966          ;
     
    962969  else if ssRight in Shift then
    963970  begin
    964     if Sel <> -2 then
     971    if Selected <> -2 then
    965972      case Kind of
    966973        kCities, kCityEvents:
     
    976983procedure TListDlg.InitLines;
    977984var
    978   required: array [0 .. nAdv - 1] of integer;
    979 
    980   procedure TryAddImpLine(Layer, Project: integer);
    981   begin
    982     if Server(sSetCityProject - sExecute, me, cixProject, Project) >= rExecuted
     985  required: array [0 .. nAdv - 1] of Integer;
     986
     987  procedure TryAddImpLine(Layer, Project: Integer);
     988  begin
     989    if Server(sSetCityProject - sExecute, Me, cixProject, Project) >= rExecuted
    983990    then
    984991    begin
    985       code[Layer, Lines[Layer]] := Project;
    986       inc(Lines[Layer]);
     992      Code[Layer, Lines[Layer]] := Project;
     993      Inc(Lines[Layer]);
    987994    end;
    988995  end;
     
    990997  procedure SortTechs;
    991998  var
    992     i, j, swap: integer;
     999    I, J, swap: Integer;
    9931000  begin // sort by advancedness
    994     for i := 0 to Lines[0] - 2 do
    995       if code[0, i] < adMilitary then
    996         for j := i + 1 to Lines[0] - 1 do
    997           if AdvValue[code[0, i]] * nAdv + code[0, i] < AdvValue[code[0, j]] *
    998             nAdv + code[0, j] then
    999           begin
    1000             swap := code[0, i];
    1001             code[0, i] := code[0, j];
    1002             code[0, j] := swap;
     1001    for I := 0 to Lines[0] - 2 do
     1002      if Code[0, I] < adMilitary then
     1003        for J := I + 1 to Lines[0] - 1 do
     1004          if AdvValue[Code[0, I]] * nAdv + Code[0, I] < AdvValue[Code[0, J]] *
     1005            nAdv + Code[0, J] then
     1006          begin
     1007            swap := Code[0, I];
     1008            Code[0, I] := Code[0, J];
     1009            Code[0, J] := swap;
    10031010          end;
    10041011  end;
     
    10061013  procedure SortCities;
    10071014  var
    1008     i, j, swap: integer;
    1009   begin
    1010     for i := 0 to Lines[0] - 2 do
    1011       for j := i + 1 to Lines[0] - 1 do
    1012         if CityName(MyCity[code[0, i]].ID) > CityName(MyCity[code[0, j]].ID)
     1015    I, J, swap: Integer;
     1016  begin
     1017    for I := 0 to Lines[0] - 2 do
     1018      for J := I + 1 to Lines[0] - 1 do
     1019        if CityName(MyCity[Code[0, I]].ID) > CityName(MyCity[Code[0, J]].ID)
    10131020        then
    10141021        begin
    1015           swap := code[0, i];
    1016           code[0, i] := code[0, j];
    1017           code[0, j] := swap;
     1022          swap := Code[0, I];
     1023          Code[0, I] := Code[0, J];
     1024          Code[0, J] := swap;
    10181025        end;
    10191026  end;
    10201027
    10211028  function ModelSortValue(const mi: TModelInfo;
    1022     MixPlayers: boolean = false): integer;
    1023   begin
    1024     result := (mi.Domain + 1) shl 28 - mi.mix;
     1029    MixPlayers: Boolean = False): Integer;
     1030  begin
     1031    Result := (mi.Domain + 1) shl 28 - mi.mix;
    10251032    if MixPlayers then
    1026       dec(result, ModelCode(mi) shl 16);
     1033      Dec(Result, ModelCode(mi) shl 16);
    10271034  end;
    10281035
    10291036  procedure SortModels;
    10301037  var
    1031     i, j, swap: integer;
     1038    I, J, swap: Integer;
    10321039  begin // sort by code[2]
    1033     for i := 0 to Lines[0] - 2 do
    1034       for j := i + 1 to Lines[0] - 1 do
    1035         if code[2, i] > code[2, j] then
    1036         begin
    1037           swap := code[0, i];
    1038           code[0, i] := code[0, j];
    1039           code[0, j] := swap;
    1040           swap := code[1, i];
    1041           code[1, i] := code[1, j];
    1042           code[1, j] := swap;
    1043           swap := code[2, i];
    1044           code[2, i] := code[2, j];
    1045           code[2, j] := swap;
    1046         end;
    1047   end;
    1048 
    1049   procedure MarkPreqs(i: integer);
    1050   begin
    1051     required[i] := 1;
    1052     if MyRO.Tech[i] < tsSeen then
     1040    for I := 0 to Lines[0] - 2 do
     1041      for J := I + 1 to Lines[0] - 1 do
     1042        if Code[2, I] > Code[2, J] then
     1043        begin
     1044          swap := Code[0, I];
     1045          Code[0, I] := Code[0, J];
     1046          Code[0, J] := swap;
     1047          swap := Code[1, I];
     1048          Code[1, I] := Code[1, J];
     1049          Code[1, J] := swap;
     1050          swap := Code[2, I];
     1051          Code[2, I] := Code[2, J];
     1052          Code[2, J] := swap;
     1053        end;
     1054  end;
     1055
     1056  procedure MarkPreqs(I: Integer);
     1057  begin
     1058    required[I] := 1;
     1059    if MyRO.Tech[I] < tsSeen then
    10531060    begin
    1054       if (AdvPreq[i, 0] >= 0) then
    1055         MarkPreqs(AdvPreq[i, 0]);
    1056       if (AdvPreq[i, 1] >= 0) then
    1057         MarkPreqs(AdvPreq[i, 1]);
     1061      if (AdvPreq[I, 0] >= 0) then
     1062        MarkPreqs(AdvPreq[I, 0]);
     1063      if (AdvPreq[I, 1] >= 0) then
     1064        MarkPreqs(AdvPreq[I, 1]);
    10581065    end;
    10591066  end;
    10601067
    10611068var
    1062   Loc1, i, j, p1, dx, dy, mix, emix, EnemyType, TestEnemyType: integer;
     1069  Loc1, I, J, p1, dx, dy, mix, emix, EnemyType, TestEnemyType: Integer;
    10631070  mi: TModelInfo;
    10641071  PPicture, PTestPicture: ^TModelPicture;
    1065   ModelOk: array [0 .. 4095] of boolean;
    1066   ok: boolean;
    1067 begin
    1068   for i := 0 to MaxLayer - 1 do
    1069   begin
    1070     Lines[i] := 0;
    1071     FirstShrinkedLine[i] := MaxInt;
     1072  ModelOk: array [0 .. 4095] of Boolean;
     1073  ok: Boolean;
     1074begin
     1075  for I := 0 to MaxLayer - 1 do
     1076  begin
     1077    Lines[I] := 0;
     1078    FirstShrinkedLine[I] := MaxInt;
    10721079  end;
    10731080  case Kind of
     
    10751082      begin
    10761083        // improvements
    1077         code[0, 0] := cpImp + imTrGoods;
     1084        Code[0, 0] := cpImp + imTrGoods;
    10781085        Lines[0] := 1;
    1079         for i := nWonder to nImp - 1 do
    1080           if Imp[i].Kind = ikCommon then
    1081             TryAddImpLine(0, i + cpImp);
    1082         for i := nWonder to nImp - 1 do
    1083           if not(Imp[i].Kind in [ikCommon, ikTrGoods]) and
    1084             ((MyRO.NatBuilt[i] = 0) or (Imp[i].Kind = ikNatLocal)) then
    1085             TryAddImpLine(0, i + cpImp);
    1086         for i := 0 to nCityType - 1 do
    1087           if MyData.ImpOrder[i, 0] >= 0 then
    1088           begin
    1089             code[0, Lines[0]] := cpType + i;
    1090             inc(Lines[0]);
     1086        for I := nWonder to nImp - 1 do
     1087          if Imp[I].Kind = ikCommon then
     1088            TryAddImpLine(0, I + cpImp);
     1089        for I := nWonder to nImp - 1 do
     1090          if not(Imp[I].Kind in [ikCommon, ikTrGoods]) and
     1091            ((MyRO.NatBuilt[I] = 0) or (Imp[I].Kind = ikNatLocal)) then
     1092            TryAddImpLine(0, I + cpImp);
     1093        for I := 0 to nCityType - 1 do
     1094          if MyData.ImpOrder[I, 0] >= 0 then
     1095          begin
     1096            Code[0, Lines[0]] := cpType + I;
     1097            Inc(Lines[0]);
    10911098          end;
    10921099
    10931100        // wonders
    1094         for i := 0 to nWonder - 1 do
    1095           TryAddImpLine(1, i + cpImp);
     1101        for I := 0 to nWonder - 1 do
     1102          TryAddImpLine(1, I + cpImp);
    10961103
    10971104        // units
    1098         for i := 0 to MyRO.nModel - 1 do
     1105        for I := 0 to MyRO.nModel - 1 do
    10991106        begin
    11001107          { if MyModel[i].Kind=mkSlaves then
    1101             ok:= MyRO.Wonder[woPyramids].EffectiveOwner=me
    1102             else } if MyModel[i].Domain = dSea then
    1103           begin
    1104             ok := false;
     1108            ok:= MyRO.Wonder[woPyramids].EffectiveOwner=Me
     1109            else } if MyModel[I].Domain = dSea then
     1110          begin
     1111            ok := False;
    11051112            for dx := -2 to 2 do
    11061113              for dy := -2 to 2 do
     
    11111118                    ((MyMap[Loc1] and fTerrain = fShore) or
    11121119                    (MyMap[Loc1] and fCanal > 0)) then
    1113                     ok := true;
     1120                    ok := True;
    11141121                end;
    11151122          end
    11161123          else
    1117             ok := true;
     1124            ok := True;
    11181125          if ok then
    11191126          begin
    1120             if MyModel[i].Status and msObsolete = 0 then
     1127            if MyModel[I].Status and msObsolete = 0 then
    11211128            begin
    1122               code[2, Lines[2]] := i;
    1123               inc(Lines[2]);
     1129              Code[2, Lines[2]] := I;
     1130              Inc(Lines[2]);
    11241131            end;
    1125             if MyModel[i].Status and msAllowConscripts <> 0 then
     1132            if MyModel[I].Status and msAllowConscripts <> 0 then
    11261133            begin
    1127               code[2, Lines[2]] := i + cpConscripts;
    1128               inc(Lines[2]);
     1134              Code[2, Lines[2]] := I + cpConscripts;
     1135              Inc(Lines[2]);
    11291136            end;
    11301137          end;
     
    11401147          MarkPreqs(MyData.FarTech);
    11411148        end;
    1142         for i := 0 to nAdv - 1 do
    1143           if ((i in FutureTech) or (MyRO.Tech[i] < tsApplicable)) and
    1144             (Server(sSetResearch - sExecute, me, i, nil^) >= rExecuted) and
    1145             ((MyData.FarTech = adNone) or (required[i] > 0)) then
    1146           begin
    1147             code[0, Lines[0]] := i;
    1148             inc(Lines[0]);
     1149        for I := 0 to nAdv - 1 do
     1150          if ((I in FutureTech) or (MyRO.Tech[I] < tsApplicable)) and
     1151            (Server(sSetResearch - sExecute, Me, I, nil^) >= rExecuted) and
     1152            ((MyData.FarTech = adNone) or (required[I] > 0)) then
     1153          begin
     1154            Code[0, Lines[0]] := I;
     1155            Inc(Lines[0]);
    11491156          end;
    11501157        SortTechs;
    11511158        if Lines[0] = 0 then // no more techs -- offer nexus
    11521159        begin
    1153           code[0, Lines[0]] := adNexus;
    1154           inc(Lines[0]);
    1155         end;
    1156         ok := false;
    1157         for i := 0 to nDomains - 1 do
    1158           if (upgrade[i, 0].Preq = preNone) or
    1159             (MyRO.Tech[upgrade[i, 0].Preq] >= tsApplicable) then
    1160             ok := true;
     1160          Code[0, Lines[0]] := adNexus;
     1161          Inc(Lines[0]);
     1162        end;
     1163        ok := False;
     1164        for I := 0 to nDomains - 1 do
     1165          if (upgrade[I, 0].Preq = preNone) or
     1166            (MyRO.Tech[upgrade[I, 0].Preq] >= tsApplicable) then
     1167            ok := True;
    11611168        if ok then { new unit class }
    11621169        begin
    1163           code[0, Lines[0]] := adMilitary;
    1164           inc(Lines[0]);
     1170          Code[0, Lines[0]] := adMilitary;
     1171          Inc(Lines[0]);
    11651172        end;
    11661173      end;
    11671174    kFarAdvance:
    11681175      begin
    1169         code[0, Lines[0]] := adNone;
    1170         inc(Lines[0]);
    1171         for i := 0 to nAdv - 1 do
    1172           if not(i in FutureTech) and (MyRO.Tech[i] < tsApplicable) and
    1173             ((AdvValue[i] < 2000) or (MyRO.Tech[adMassProduction] > tsNA)) and
    1174             ((AdvValue[i] < 1000) or (MyRO.Tech[adScience] > tsNA)) then
    1175           begin
    1176             code[0, Lines[0]] := i;
    1177             inc(Lines[0]);
     1176        Code[0, Lines[0]] := adNone;
     1177        Inc(Lines[0]);
     1178        for I := 0 to nAdv - 1 do
     1179          if not(I in FutureTech) and (MyRO.Tech[I] < tsApplicable) and
     1180            ((AdvValue[I] < 2000) or (MyRO.Tech[adMassProduction] > tsNA)) and
     1181            ((AdvValue[I] < 1000) or (MyRO.Tech[adScience] > tsNA)) then
     1182          begin
     1183            Code[0, Lines[0]] := I;
     1184            Inc(Lines[0]);
    11781185          end;
    11791186        SortTechs;
     
    11811188    kChooseTech:
    11821189      begin
    1183         for i := 0 to nAdv - 1 do
    1184           if not(i in FutureTech) and (MyRO.Tech[i] >= tsApplicable) and
    1185             (MyRO.EnemyReport[DipMem[me].pContact].Tech[i] < tsSeen) then
    1186           begin
    1187             code[0, Lines[0]] := i;
    1188             inc(Lines[0]);
     1190        for I := 0 to nAdv - 1 do
     1191          if not(I in FutureTech) and (MyRO.Tech[I] >= tsApplicable) and
     1192            (MyRO.EnemyReport[DipMem[Me].pContact].Tech[I] < tsSeen) then
     1193          begin
     1194            Code[0, Lines[0]] := I;
     1195            Inc(Lines[0]);
    11891196          end;
    11901197        SortTechs;
    11911198        // if Lines[0]>1 then
    11921199        begin
    1193           code[0, Lines[0]] := adAll;
    1194           inc(Lines[0]);
     1200          Code[0, Lines[0]] := adAll;
     1201          Inc(Lines[0]);
    11951202        end;
    11961203      end;
    11971204    kChooseETech:
    11981205      begin
    1199         for i := 0 to nAdv - 1 do
    1200           if not(i in FutureTech) and (MyRO.Tech[i] < tsSeen) and
    1201             (MyRO.EnemyReport[DipMem[me].pContact].Tech[i] >= tsApplicable) then
    1202           begin
    1203             code[0, Lines[0]] := i;
    1204             inc(Lines[0]);
     1206        for I := 0 to nAdv - 1 do
     1207          if not(I in FutureTech) and (MyRO.Tech[I] < tsSeen) and
     1208            (MyRO.EnemyReport[DipMem[Me].pContact].Tech[I] >= tsApplicable) then
     1209          begin
     1210            Code[0, Lines[0]] := I;
     1211            Inc(Lines[0]);
    12051212          end;
    12061213        SortTechs;
    12071214        // if Lines[0]>1 then
    12081215        begin
    1209           code[0, Lines[0]] := adAll;
    1210           inc(Lines[0]);
     1216          Code[0, Lines[0]] := adAll;
     1217          Inc(Lines[0]);
    12111218        end;
    12121219      end;
    12131220    kStealTech:
    12141221      begin
    1215         for i := 0 to nAdv - 1 do
    1216           if Server(sStealTech - sExecute, me, i, nil^) >= rExecuted then
    1217           begin
    1218             code[0, Lines[0]] := i;
    1219             inc(Lines[0]);
     1222        for I := 0 to nAdv - 1 do
     1223          if Server(sStealTech - sExecute, Me, I, nil^) >= rExecuted then
     1224          begin
     1225            Code[0, Lines[0]] := I;
     1226            Inc(Lines[0]);
    12201227          end;
    12211228        SortTechs;
     
    12231230    kScience:
    12241231      begin
    1225         Column[0] := me;
     1232        Column[0] := Me;
    12261233        nColumn := 1;
    12271234        for EnemyType := 0 to 2 do
     
    12411248              begin
    12421249                Column[nColumn] := p1;
    1243                 inc(nColumn);
     1250                Inc(nColumn);
    12441251              end;
    12451252            end;
    1246         for i := 0 to nAdv - 1 do
    1247         begin
    1248           ok := (MyRO.Tech[i] <> tsNA) or (MyRO.ResearchTech = i);
    1249           for j := 1 to nColumn - 1 do
    1250             with MyRO.EnemyReport[Column[j]]^ do
    1251               if (Tech[i] <> tsNA) or (TurnOfCivilReport >= 0) and
    1252                 (ResearchTech = i) then
    1253                 ok := true;
     1253        for I := 0 to nAdv - 1 do
     1254        begin
     1255          ok := (MyRO.Tech[I] <> tsNA) or (MyRO.ResearchTech = I);
     1256          for J := 1 to nColumn - 1 do
     1257            with MyRO.EnemyReport[Column[J]]^ do
     1258              if (Tech[I] <> tsNA) or (TurnOfCivilReport >= 0) and
     1259                (ResearchTech = I) then
     1260                ok := True;
    12541261          if ok then
    12551262          begin
    1256             code[0, Lines[0]] := i;
    1257             inc(Lines[0]);
     1263            Code[0, Lines[0]] := I;
     1264            Inc(Lines[0]);
    12581265          end;
    12591266        end;
     
    12611268
    12621269        ok := MyRO.ResearchTech = adMilitary;
    1263         for j := 1 to nColumn - 1 do
    1264           with MyRO.EnemyReport[Column[j]]^ do
    1265             if (MyRO.Alive and (1 shl Column[j]) <> 0) and
     1270        for J := 1 to nColumn - 1 do
     1271          with MyRO.EnemyReport[Column[J]]^ do
     1272            if (MyRO.Alive and (1 shl Column[J]) <> 0) and
    12661273              (TurnOfCivilReport >= 0) and (ResearchTech = adMilitary) then
    1267               ok := true;
     1274              ok := True;
    12681275        if ok then
    12691276        begin
    1270           code[0, Lines[0]] := adMilitary;
    1271           inc(Lines[0]);
     1277          Code[0, Lines[0]] := adMilitary;
     1278          Inc(Lines[0]);
    12721279        end
    12731280      end;
     
    12751282      begin
    12761283        if ClientMode < scContact then
    1277           for i := 0 to MyRO.nCity - 1 do
    1278             if MyCity[i].Loc >= 0 then
     1284          for I := 0 to MyRO.nCity - 1 do
     1285            if MyCity[I].Loc >= 0 then
    12791286            begin
    1280               code[0, Lines[0]] := i;
    1281               inc(Lines[0]);
     1287              Code[0, Lines[0]] := I;
     1288              Inc(Lines[0]);
    12821289            end;
    12831290        SortCities;
     
    12861293    kCityEvents:
    12871294      begin
    1288         for i := 0 to MyRO.nCity - 1 do
    1289           if (MyCity[i].Loc >= 0) and (MyCity[i].Flags and CityRepMask <> 0)
     1295        for I := 0 to MyRO.nCity - 1 do
     1296          if (MyCity[I].Loc >= 0) and (MyCity[I].Flags and CityRepMask <> 0)
    12901297          then
    12911298          begin
    1292             code[0, Lines[0]] := i;
    1293             inc(Lines[0]);
     1299            Code[0, Lines[0]] := I;
     1300            Inc(Lines[0]);
    12941301          end;
    12951302        SortCities;
     
    12981305    { kChooseECity:
    12991306      begin
    1300       for i:=0 to MyRO.nEnemyCity-1 do
    1301       if (MyRO.EnemyCity[i].Loc>=0)
    1302       and (MyRO.EnemyCity[i].owner=DipMem[me].pContact) then
    1303       begin code[0,Lines[0]]:=i; inc(Lines[0]); end;
     1307      for I:=0 to MyRO.nEnemyCity-1 do
     1308      if (MyRO.EnemyCity[I].Loc>=0)
     1309      and (MyRO.EnemyCity[I].owner=DipMem[Me].pContact) then
     1310      begin Code[0,Lines[0]]:=I; Inc(Lines[0]); end;
    13041311      FirstShrinkedLine:=0
    13051312      end; }
     
    13081315        for mix := 0 to MyRO.nModel - 1 do
    13091316        begin
    1310           code[0, mix] := mix;
    1311           MakeModelInfo(me, mix, MyModel[mix], mi);
    1312           code[2, mix] := ModelSortValue(mi);
     1317          Code[0, mix] := mix;
     1318          MakeModelInfo(Me, mix, MyModel[mix], mi);
     1319          Code[2, mix] := ModelSortValue(mi);
    13131320        end;
    13141321        Lines[0] := MyRO.nModel;
     
    13201327        for mix := 3 to MyRO.nModel - 1 do
    13211328        begin // check if opponent already has this model
    1322           MakeModelInfo(me, mix, MyModel[mix], mi);
    1323           ok := true;
     1329          MakeModelInfo(Me, mix, MyModel[mix], mi);
     1330          ok := True;
    13241331          for emix := 0 to MyRO.nEnemyModel - 1 do
    1325             if (MyRO.EnemyModel[emix].Owner = DipMem[me].pContact) and
     1332            if (MyRO.EnemyModel[emix].Owner = DipMem[Me].pContact) and
    13261333              IsSameModel(MyRO.EnemyModel[emix], mi) then
    1327               ok := false;
     1334              ok := False;
    13281335          if ok then
    13291336          begin
    1330             code[0, Lines[0]] := mix;
    1331             MakeModelInfo(me, mix, MyModel[mix], mi);
    1332             code[2, Lines[0]] := ModelSortValue(mi);
    1333             inc(Lines[0]);
     1337            Code[0, Lines[0]] := mix;
     1338            MakeModelInfo(Me, mix, MyModel[mix], mi);
     1339            Code[2, Lines[0]] := ModelSortValue(mi);
     1340            Inc(Lines[0]);
    13341341          end;
    13351342        end;
     
    13371344        // if Lines[0]>1 then
    13381345        begin
    1339           code[0, Lines[0]] := mixAll;
    1340           inc(Lines[0]);;
     1346          Code[0, Lines[0]] := mixAll;
     1347          Inc(Lines[0]);;
    13411348        end;
    13421349        FirstShrinkedLine[0] := 0;
     
    13451352      begin
    13461353        if MyRO.TestFlags and tfUncover <> 0 then
    1347           Server(sGetModels, me, 0, nil^);
     1354          Server(sGetModels, Me, 0, nil^);
    13481355        for emix := 0 to MyRO.nEnemyModel - 1 do
    1349           ModelOk[emix] := MyRO.EnemyModel[emix].Owner = DipMem[me].pContact;
     1356          ModelOk[emix] := MyRO.EnemyModel[emix].Owner = DipMem[Me].pContact;
    13501357        for mix := 0 to MyRO.nModel - 1 do
    13511358        begin // don't list models I already have
    1352           MakeModelInfo(me, mix, MyModel[mix], mi);
     1359          MakeModelInfo(Me, mix, MyModel[mix], mi);
    13531360          for emix := 0 to MyRO.nEnemyModel - 1 do
    13541361            ModelOk[emix] := ModelOk[emix] and
     
    13581365          if ModelOk[emix] then
    13591366          begin
    1360             if not Assigned(Tribe[DipMem[me].pContact].ModelPicture
     1367            if not Assigned(Tribe[DipMem[Me].pContact].ModelPicture
    13611368              [MyRO.EnemyModel[emix].mix].HGr) then
    13621369              InitEnemyModel(emix);
    1363             code[0, Lines[0]] := emix;
    1364             code[2, Lines[0]] := ModelSortValue(MyRO.EnemyModel[emix]);
    1365             inc(Lines[0]);
     1370            Code[0, Lines[0]] := emix;
     1371            Code[2, Lines[0]] := ModelSortValue(MyRO.EnemyModel[emix]);
     1372            Inc(Lines[0]);
    13661373          end;
    13671374        SortModels;
    13681375        // if not IsMilReportNew(DipMem[me].pContact) or (Lines[0]>1) then
    13691376        begin
    1370           code[0, Lines[0]] := mixAll;
    1371           inc(Lines[0]);
     1377          Code[0, Lines[0]] := mixAll;
     1378          Inc(Lines[0]);
    13721379        end;
    13731380        FirstShrinkedLine[0] := 0;
     
    13751382    kEModels:
    13761383      begin
    1377         for i := 0 to MyRO.EnemyReport[pView].nModelCounted - 1 do
    1378         begin
    1379           code[1, Lines[0]] := MyRO.nEnemyModel - 1;
    1380           while (code[1, Lines[0]] >= 0) and
    1381             not((MyRO.EnemyModel[code[1, Lines[0]]].Owner = pView) and
    1382             (MyRO.EnemyModel[code[1, Lines[0]]].mix = i)) do
    1383             dec(code[1, Lines[0]]);
    1384           if not Assigned(Tribe[pView].ModelPicture[i].HGr) then
    1385             InitEnemyModel(code[1, Lines[0]]);
    1386           code[0, Lines[0]] := i;
    1387           code[2, Lines[0]] :=
    1388             ModelSortValue(MyRO.EnemyModel[code[1, Lines[0]]]);
    1389           inc(Lines[0]);
     1384        for I := 0 to MyRO.EnemyReport[pView].nModelCounted - 1 do
     1385        begin
     1386          Code[1, Lines[0]] := MyRO.nEnemyModel - 1;
     1387          while (Code[1, Lines[0]] >= 0) and
     1388            not((MyRO.EnemyModel[Code[1, Lines[0]]].Owner = pView) and
     1389            (MyRO.EnemyModel[Code[1, Lines[0]]].mix = I)) do
     1390            Dec(Code[1, Lines[0]]);
     1391          if not Assigned(Tribe[pView].ModelPicture[I].HGr) then
     1392            InitEnemyModel(Code[1, Lines[0]]);
     1393          Code[0, Lines[0]] := I;
     1394          Code[2, Lines[0]] :=
     1395            ModelSortValue(MyRO.EnemyModel[Code[1, Lines[0]]]);
     1396          Inc(Lines[0]);
    13901397        end;
    13911398        SortModels;
     
    13941401    kAllEModels:
    13951402      begin
    1396         if (MyRO.TestFlags and tfUncover <> 0) or (G.Difficulty[me] = 0) then
    1397           Server(sGetModels, me, 0, nil^);
     1403        if (MyRO.TestFlags and tfUncover <> 0) or (G.Difficulty[Me] = 0) then
     1404          Server(sGetModels, Me, 0, nil^);
    13981405        for emix := 0 to MyRO.nEnemyModel - 1 do
    13991406          if (MyRO.EnemyModel[emix].mix >= 3) and
     
    14051412            if not Assigned(PPicture.HGr) then
    14061413              InitEnemyModel(emix);
    1407             ok := true;
     1414            ok := True;
    14081415            if MainScreen.mNames.Checked then
    1409               for j := 0 to Lines[0] - 1 do
     1416              for J := 0 to Lines[0] - 1 do
    14101417              begin
    1411                 PTestPicture := @Tribe[MyRO.EnemyModel[code[0, j]].Owner]
    1412                   .ModelPicture[MyRO.EnemyModel[code[0, j]].mix];
     1418                PTestPicture := @Tribe[MyRO.EnemyModel[Code[0, J]].Owner]
     1419                  .ModelPicture[MyRO.EnemyModel[Code[0, J]].mix];
    14131420                if (PPicture.HGr = PTestPicture.HGr) and
    14141421                  (PPicture.pix = PTestPicture.pix) and
    14151422                  (ModelHash(MyRO.EnemyModel[emix])
    1416                   = ModelHash(MyRO.EnemyModel[code[0, j]])) then
     1423                  = ModelHash(MyRO.EnemyModel[Code[0, J]])) then
    14171424                begin
    1418                   code[1, j] := 1;
    1419                   ok := false;
     1425                  Code[1, J] := 1;
     1426                  ok := False;
    14201427                  Break;
    14211428                end;
     
    14231430            if ok then
    14241431            begin
    1425               code[0, Lines[0]] := emix;
    1426               code[1, Lines[0]] := 0;
    1427               code[2, Lines[0]] := ModelSortValue(MyRO.EnemyModel[emix], true);
    1428               inc(Lines[0]);
     1432              Code[0, Lines[0]] := emix;
     1433              Code[1, Lines[0]] := 0;
     1434              Code[2, Lines[0]] := ModelSortValue(MyRO.EnemyModel[emix], True);
     1435              Inc(Lines[0]);
    14291436            end;
    14301437          end;
     
    14331440      end;
    14341441    kTribe:
    1435       for i := 0 to TribeNames.Count - 1 do
    1436       begin
    1437         code[0, Lines[0]] := i;
    1438         inc(Lines[0]);
     1442      for I := 0 to TribeNames.Count - 1 do
     1443      begin
     1444        Code[0, Lines[0]] := I;
     1445        Inc(Lines[0]);
    14391446      end;
    14401447    (* kDeliver:
    1441       if MyRO.Treaty[DipMem[me].pContact]<trAlliance then
     1448      if MyRO.Treaty[DipMem[Me].pContact]<trAlliance then
    14421449      begin // suggest next treaty level
    1443       code[0,Lines[0]]:=opTreaty+MyRO.Treaty[DipMem[me].pContact]+1;
    1444       inc(Lines[0]);
    1445       end;
    1446       if MyRO.Treaty[DipMem[me].pContact]=trNone then
     1450      Code[0,Lines[0]]:=opTreaty+MyRO.Treaty[DipMem[Me].pContact]+1;
     1451      Inc(Lines[0]);
     1452      end;
     1453      if MyRO.Treaty[DipMem[Me].pContact]=trNone then
    14471454      begin // suggest peace
    1448       code[0,Lines[0]]:=opTreaty+trPeace;
    1449       inc(Lines[0]);
    1450       end;
    1451       if MyRO.Treaty[DipMem[me].pContact]>trNone then
     1455      Code[0,Lines[0]]:=opTreaty+trPeace;
     1456      Inc(Lines[0]);
     1457      end;
     1458      if MyRO.Treaty[DipMem[Me].pContact]>trNone then
    14521459      begin // suggest next treaty level
    1453       code[0,Lines[0]]:=opTreaty+MyRO.Treaty[DipMem[me].pContact]-1;
    1454       inc(Lines[0]);
     1460      Code[0,Lines[0]]:=opTreaty+MyRO.Treaty[DipMem[Me].pContact]-1;
     1461      Inc(Lines[0]);
    14551462      end; *)
    14561463    kShipPart:
    14571464      begin
    14581465        Lines[0] := 0;
    1459         for i := 0 to nShipPart - 1 do
    1460           if MyRO.Ship[me].Parts[i] > 0 then
    1461           begin
    1462             code[0, Lines[0]] := i;
    1463             inc(Lines[0]);
     1466        for I := 0 to nShipPart - 1 do
     1467          if MyRO.Ship[Me].Parts[I] > 0 then
     1468          begin
     1469            Code[0, Lines[0]] := I;
     1470            Inc(Lines[0]);
    14641471          end;
    14651472      end;
     
    14671474      begin
    14681475        Lines[0] := 0;
    1469         for i := 0 to nShipPart - 1 do
    1470           if MyRO.Ship[DipMem[me].pContact].Parts[i] > 0 then
    1471           begin
    1472             code[0, Lines[0]] := i;
    1473             inc(Lines[0]);
     1476        for I := 0 to nShipPart - 1 do
     1477          if MyRO.Ship[DipMem[Me].pContact].Parts[I] > 0 then
     1478          begin
     1479            Code[0, Lines[0]] := I;
     1480            Inc(Lines[0]);
    14741481          end;
    14751482      end;
    14761483    kGov:
    1477       for i := 1 to nGov - 1 do
    1478         if (GovPreq[i] <> preNA) and
    1479           ((GovPreq[i] = preNone) or (MyRO.Tech[GovPreq[i]] >= tsApplicable))
     1484      for I := 1 to nGov - 1 do
     1485        if (GovPreq[I] <> preNA) and
     1486          ((GovPreq[I] = preNone) or (MyRO.Tech[GovPreq[I]] >= tsApplicable))
    14801487        then
    14811488        begin
    1482           code[0, Lines[0]] := i;
    1483           inc(Lines[0]);
     1489          Code[0, Lines[0]] := I;
     1490          Inc(Lines[0]);
    14841491        end;
    14851492    kMission:
    1486       for i := 0 to nSpyMission - 1 do
    1487       begin
    1488         code[0, Lines[0]] := i;
    1489         inc(Lines[0]);
     1493      for I := 0 to nSpyMission - 1 do
     1494      begin
     1495        Code[0, Lines[0]] := I;
     1496        Inc(Lines[0]);
    14901497      end;
    14911498  end;
     
    14941501    if Lines[0] + Lines[1] + Lines[2] <= MaxLines then
    14951502    begin
    1496       for i := 0 to Lines[1] - 1 do // add wonders to first page
    1497       begin
    1498         code[0, Lines[0]] := code[1, i];
    1499         inc(Lines[0]);
     1503      for I := 0 to Lines[1] - 1 do // add wonders to first page
     1504      begin
     1505        Code[0, Lines[0]] := Code[1, I];
     1506        Inc(Lines[0]);
    15001507      end;
    15011508      Lines[1] := 0;
    15021509      FirstShrinkedLine[0] := Lines[0];
    1503       for i := 0 to Lines[2] - 1 do // add models to first page
    1504       begin
    1505         code[0, Lines[0]] := code[2, i];
    1506         inc(Lines[0]);
     1510      for I := 0 to Lines[2] - 1 do // add models to first page
     1511      begin
     1512        Code[0, Lines[0]] := Code[2, I];
     1513        Inc(Lines[0]);
    15071514      end;
    15081515      Lines[2] := 0;
    15091516    end;
    1510 end; // InitLines
    1511 
    1512 function TListDlg.OnlyChoice(TestKind: TListKind): integer;
     1517end;
     1518
     1519function TListDlg.OnlyChoice(TestKind: TListKind): Integer;
    15131520begin
    15141521  Kind := TestKind;
    15151522  InitLines;
    15161523  if Lines[0] = 0 then
    1517     result := -2
     1524    Result := -2
    15181525  else if Lines[0] > 1 then
    1519     result := -1
     1526    Result := -1
    15201527  else
    1521     result := code[0, 0];
     1528    Result := Code[0, 0];
    15221529end;
    15231530
    15241531procedure TListDlg.FormShow(Sender: TObject);
    15251532var
    1526   i: integer;
    1527 begin
    1528   result := -1;
    1529   Closable := false;
     1533  I: Integer;
     1534begin
     1535  Result := -1;
     1536  Closable := False;
    15301537
    15311538  if Kind = kTribe then
     
    15431550  InitLines;
    15441551
    1545   MultiPage := false;
    1546   for i := 1 to MaxLayer - 1 do
    1547     if Lines[i] > 0 then
    1548       MultiPage := true;
     1552  MultiPage := False;
     1553  for I := 1 to MaxLayer - 1 do
     1554    if Lines[I] > 0 then
     1555      MultiPage := True;
    15491556  WideBottom := MultiPage or (Kind = kScience) or
    15501557    not Phrases2FallenBackToEnglish and
     
    15521559  if (Kind = kAdvance) and (MyData.FarTech <> adNone) or (Kind = kModels) or
    15531560    (Kind = kEModels) then begin
    1554     sb.SetBorderSpacing(56, 10, 10);
     1561    ScrollBar.SetBorderSpacing(56, 10, 10);
    15551562    TitleHeight := WideFrame + 20;
    15561563  end else begin
    1557     sb.SetBorderSpacing(36, 10, 34);
     1564    ScrollBar.SetBorderSpacing(36, 10, 34);
    15581565    TitleHeight := WideFrame;
    15591566  end;
    15601567
    15611568  DispLines := Lines[0];
    1562   for i := 0 to MaxLayer - 1 do
    1563     if Lines[i] > DispLines then
    1564       DispLines := Lines[i];
     1569  for I := 0 to MaxLayer - 1 do
     1570    if Lines[I] > DispLines then
     1571      DispLines := Lines[I];
    15651572  if WideBottom then
    15661573  begin
     
    15771584    ClientHeight := InnerHeight + TitleHeight + NarrowFrame;
    15781585  end;
    1579   assert(ClientHeight <= Maintexture.Height);
     1586  Assert(ClientHeight <= Maintexture.Height);
    15801587
    15811588  TechNameSpace := 224;
     
    16151622  CaptionRight := CloseBtn.Left;
    16161623  { TODO:
    1617   SetWindowPos(sb.ScrollBar.Handle, 0, SideFrame + InnerWidth - DpiGetSystemMetrics(SM_CXVSCROLL),
     1624  SetWindowPos(ScrollBar.ScrollBar.Handle, 0, SideFrame + InnerWidth - DpiGetSystemMetrics(SM_CXVSCROLL),
    16181625    TitleHeight, DpiGetSystemMetrics(SM_CXVSCROLL), LineDistance * DispLines + 48,
    16191626    SWP_NOZORDER or SWP_NOREDRAW);
     
    16381645    Layer0Btn.Top := ClientHeight - 31;
    16391646    Layer0Btn.Left := ClientWidth div 2 - (12 + 29);
    1640     Layer0Btn.Down := true;
     1647    Layer0Btn.Down := True;
    16411648    Layer1Btn.Top := ClientHeight - 31;
    16421649    Layer1Btn.Left := ClientWidth div 2 - (12 - 29);
    1643     Layer1Btn.Down := false;
     1650    Layer1Btn.Down := False;
    16441651    Layer2Btn.Top := ClientHeight - 31;
    16451652    Layer2Btn.Left := ClientWidth div 2 - 12;
    1646     Layer2Btn.Down := false;
     1653    Layer2Btn.Down := False;
    16471654  end;
    16481655
    16491656  Layer := 0;
    1650   Sel := -2;
     1657  Selected := -2;
    16511658  ScienceNation := -1;
    1652   sb.Init(Lines[Layer] - 1, DispLines);
     1659  ScrollBar.Init(Lines[Layer] - 1, DispLines);
    16531660
    16541661  OffscreenPaint;
    16551662end;
    16561663
    1657 procedure TListDlg.ShowNewContent(NewMode: integer; ListKind: TListKind);
     1664procedure TListDlg.ShowNewContent(NewMode: TWindowMode; ListKind: TListKind);
    16581665var
    1659   i: integer;
    1660   ShowFocus, forceclose: boolean;
     1666  I: Integer;
     1667  ShowFocus, forceclose: Boolean;
    16611668begin
    16621669  forceclose := (ListKind <> Kind) and
     
    17221729  if Kind = kAdvance then // show focus button?
    17231730    if MyData.FarTech <> adNone then
    1724       ShowFocus := true
     1731      ShowFocus := True
    17251732    else
    17261733    begin
    1727       ShowFocus := false;
    1728       for i := 0 to nAdv - 1 do
    1729         if not(i in FutureTech) and (MyRO.Tech[i] < tsApplicable) and
    1730           ((AdvValue[i] < 2000) or (MyRO.Tech[adMassProduction] > tsNA)) and
    1731           ((AdvValue[i] < 1000) or (MyRO.Tech[adScience] > tsNA)) and
    1732           (Server(sSetResearch - sExecute, me, i, nil^) < rExecuted) then
    1733           ShowFocus := true;
     1734      ShowFocus := False;
     1735      for I := 0 to nAdv - 1 do
     1736        if not(I in FutureTech) and (MyRO.Tech[I] < tsApplicable) and
     1737          ((AdvValue[I] < 2000) or (MyRO.Tech[adMassProduction] > tsNA)) and
     1738          ((AdvValue[I] < 1000) or (MyRO.Tech[adScience] > tsNA)) and
     1739          (Server(sSetResearch - sExecute, Me, I, nil^) < rExecuted) then
     1740          ShowFocus := True;
    17341741    end;
    1735   ToggleBtn.Visible := (Kind = kCities) and not supervising or (Kind = kAdvance)
     1742  ToggleBtn.Visible := (Kind = kCities) and not Supervising or (Kind = kAdvance)
    17361743    and ShowFocus or (Kind = kModels) or (Kind = kEModels);
    17371744  CloseBtn.Visible := not(Kind in MustChooseKind);
    17381745
    17391746  inherited ShowNewContent(NewMode, forceclose);
    1740 end; // ShowNewContent
    1741 
    1742 procedure TListDlg.ShowNewContent_CityProject(NewMode, cix: integer);
     1747end;
     1748
     1749procedure TListDlg.ShowNewContent_CityProject(NewMode: TWindowMode; cix: Integer);
    17431750begin
    17441751  cixProject := cix;
     
    17461753end;
    17471754
    1748 procedure TListDlg.ShowNewContent_MilReport(NewMode, p: integer);
    1749 begin
    1750   pView := p;
    1751   if p = me then
     1755procedure TListDlg.ShowNewContent_MilReport(NewMode: TWindowMode; P: Integer);
     1756begin
     1757  pView := P;
     1758  if P = Me then
    17521759    ShowNewContent(NewMode, kModels)
    17531760  else
     
    17571764procedure TListDlg.PlayerClick(Sender: TObject);
    17581765begin
    1759   if TComponent(Sender).Tag = me then
     1766  if TComponent(Sender).Tag = Me then
    17601767    Kind := kModels
    17611768  else
     
    17651772  end;
    17661773  InitLines;
    1767   Sel := -2;
    1768   sb.Init(Lines[Layer] - 1, DispLines);
     1774  Selected := -2;
     1775  ScrollBar.Init(Lines[Layer] - 1, DispLines);
    17691776  OffscreenPaint;
    17701777  Invalidate;
     
    17781785  Layer := TComponent(Sender).Tag;
    17791786
    1780   Sel := -2;
    1781   sb.Init(Lines[Layer] - 1, DispLines);
     1787  Selected := -2;
     1788  ScrollBar.Init(Lines[Layer] - 1, DispLines);
    17821789  SmartUpdateContent;
    17831790end;
     
    17851792procedure TListDlg.ToggleBtnClick(Sender: TObject);
    17861793var
    1787   p1: integer;
    1788   m: TDpiMenuItem;
     1794  p1: Integer;
     1795  M: TDpiMenuItem;
    17891796begin
    17901797  case Kind of
    17911798    kAdvance:
    17921799      begin
    1793         result := adFar;
    1794         Closable := true;
     1800        Result := adFar;
     1801        Closable := True;
    17951802        Close;
    17961803      end;
     
    18071814      begin
    18081815        EmptyMenu(Popup.Items);
    1809         if G.Difficulty[me] > 0 then
    1810         begin
    1811           m := TDpiMenuItem.Create(Popup);
    1812           m.RadioItem := true;
    1813           m.Caption := Tribe[me].TPhrase('SHORTNAME');
    1814           m.Tag := me;
    1815           m.OnClick := PlayerClick;
     1816        if G.Difficulty[Me] > 0 then
     1817        begin
     1818          M := TDpiMenuItem.Create(Popup);
     1819          M.RadioItem := True;
     1820          M.Caption := Tribe[Me].TPhrase('SHORTNAME');
     1821          M.Tag := Me;
     1822          M.OnClick := PlayerClick;
    18161823          if Kind = kModels then
    1817             m.Checked := true;
    1818           Popup.Items.Add(m);
     1824            M.Checked := True;
     1825          Popup.Items.Add(M);
    18191826        end;
    18201827        for p1 := 0 to nPl - 1 do
    1821           if (p1 <> me) and (MyRO.EnemyReport[p1] <> nil) and
     1828          if (p1 <> Me) and (MyRO.EnemyReport[p1] <> nil) and
    18221829            (MyRO.EnemyReport[p1].TurnOfMilReport >= 0) then
    18231830          begin
    1824             m := TDpiMenuItem.Create(Popup);
    1825             m.RadioItem := true;
    1826             m.Caption := Tribe[p1].TPhrase('SHORTNAME');
    1827             m.Tag := p1;
    1828             m.OnClick := PlayerClick;
     1831            M := TDpiMenuItem.Create(Popup);
     1832            M.RadioItem := True;
     1833            M.Caption := Tribe[p1].TPhrase('SHORTNAME');
     1834            M.Tag := p1;
     1835            M.OnClick := PlayerClick;
    18291836            if (Kind = kEModels) and (p1 = pView) then
    1830               m.Checked := true;
    1831             Popup.Items.Add(m);
     1837              M.Checked := True;
     1838            Popup.Items.Add(M);
    18321839          end;
    18331840        Popup.Popup(Left + ToggleBtn.Left, Top + ToggleBtn.Top +
     
    18371844end;
    18381845
    1839 procedure TListDlg.FormKeyDown(Sender: TObject; var Key: word;
     1846procedure TListDlg.FormKeyDown(Sender: TObject; var Key: Word;
    18401847  Shift: TShiftState);
    18411848begin
     
    18761883procedure TListDlg.RemoveUnit;
    18771884begin
    1878   if ListDlg.Visible and (Kind = kModels) then
     1885  if Visible and (Kind = kModels) then
    18791886    SmartUpdateContent;
    18801887end;
     
    18821889procedure TListDlg.ScrollBarUpdate(Sender: TObject);
    18831890begin
    1884   Sel := -2;
    1885   SmartUpdateContent(true);
     1891  Selected := -2;
     1892  SmartUpdateContent(True);
    18861893end;
    18871894
Note: See TracChangeset for help on using the changeset viewer.