Ignore:
Timestamp:
Jan 7, 2017, 11:32:14 AM (7 years ago)
Author:
chronos
Message:
  • Modified: Formated all project source files using Delphi formatter as original indentation and other formatting was really bad.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/Select.pas

    r2 r6  
    11{$INCLUDE switches}
    2 
    32unit Select;
    43
     
    65
    76uses
    8   Protocol,ClientTools,Term,ScreenTools,IsoEngine,PVSB,BaseWin,
    9 
    10   Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,
    11   ExtCtrls,ButtonB, ButtonBase, Menus;
     7  Protocol, ClientTools, Term, ScreenTools, IsoEngine, PVSB, BaseWin,
     8
     9  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
     10  ExtCtrls, ButtonB, ButtonBase, Menus;
    1211
    1312const
    14 MaxLayer=3;
     13  MaxLayer = 3;
    1514
    1615type
    17   TListKind=(kProject,kAdvance,kFarAdvance,kCities,kCityEvents,kModels,kEModels,
    18     kAllEModels,kTribe,kScience,kShipPart,kEShipPart,kChooseTech,
    19     kChooseETech,kChooseModel,kChooseEModel,kChooseCity,kChooseECity,
    20     kStealTech,kGov,kMission);
     16  TListKind = (kProject, kAdvance, kFarAdvance, kCities, kCityEvents, kModels,
     17    kEModels, kAllEModels, kTribe, kScience, kShipPart, kEShipPart, kChooseTech,
     18    kChooseETech, kChooseModel, kChooseEModel, kChooseCity, kChooseECity,
     19    kStealTech, kGov, kMission);
    2120
    2221  TListDlg = class(TFramedDlg)
     
    2726    ToggleBtn: TButtonB;
    2827    Popup: TPopupMenu;
    29     procedure PaintBox1MouseMove(Sender:TObject;Shift:TShiftState;x,
    30       y:integer);
    31     procedure FormCreate(Sender:TObject);
    32     procedure PaintBox1MouseDown(Sender:TObject;Button:TMouseButton;
    33       Shift:TShiftState;x,y:integer);
    34     procedure FormPaint(Sender:TObject);
    35     procedure CloseBtnClick(Sender:TObject);
     28    procedure PaintBox1MouseMove(Sender: TObject; Shift: TShiftState;
     29      x, y: integer);
     30    procedure FormCreate(Sender: TObject);
     31    procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
     32      Shift: TShiftState; x, y: integer);
     33    procedure FormPaint(Sender: TObject);
     34    procedure CloseBtnClick(Sender: TObject);
    3635    procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
    3736    procedure FormShow(Sender: TObject);
    3837    procedure ModeBtnClick(Sender: TObject);
    3938    procedure ToggleBtnClick(Sender: TObject);
    40     procedure FormKeyDown(Sender: TObject; var Key: word;
    41       Shift: TShiftState);
     39    procedure FormKeyDown(Sender: TObject; var Key: word; Shift: TShiftState);
    4240    procedure PlayerClick(Sender: TObject);
    4341    procedure FormDestroy(Sender: TObject);
     
    4543  public
    4644    result: integer;
    47     function OnlyChoice(TestKind: TListKind): integer; // -2=empty, -1=ambiguous, other=only choice
     45    function OnlyChoice(TestKind: TListKind): integer;
     46    // -2=empty, -1=ambiguous, other=only choice
    4847    procedure OffscreenPaint; override;
    4948    procedure ShowNewContent(NewMode: integer; ListKind: TListKind);
     
    5756  private
    5857    Kind: TListKind;
    59     LineDistance,MaxLines,cixProject,pView,Sel,DispLines,Layer,nColumn,
    60       TechNameSpace,ScienceNation: integer;
    61     sb:TPVScrollbar;
    62     Lines, FirstShrinkedLine: array[0..MaxLayer-1] of integer;
    63     code: array[0..MaxLayer-1,0..4095] of integer;
    64     Column: array[0..nPl-1] of integer;
    65     Closable,MultiPage: boolean;
     58    LineDistance, MaxLines, cixProject, pView, Sel, DispLines, Layer, nColumn,
     59      TechNameSpace, ScienceNation: integer;
     60    sb: TPVScrollbar;
     61    Lines, FirstShrinkedLine: array [0 .. MaxLayer - 1] of integer;
     62    code: array [0 .. MaxLayer - 1, 0 .. 4095] of integer;
     63    Column: array [0 .. nPl - 1] of integer;
     64    Closable, MultiPage: boolean;
    6665    ScienceNationDot: TBitmap;
    6766    procedure InitLines;
     
    6968    function RenameCity(cix: integer): boolean;
    7069    function RenameModel(mix: integer): boolean;
    71     procedure OnScroll(var m:TMessage); message WM_VSCROLL;
    72     procedure OnMouseWheel(var m:TMessage); message WM_MOUSEWHEEL;
    73     procedure OnMouseLeave(var Msg:TMessage); message CM_MOUSELEAVE;
    74   end;
    75 
    76   TModalSelectDlg=TListDlg;
     70    procedure OnScroll(var m: TMessage); message WM_VSCROLL;
     71    procedure OnMouseWheel(var m: TMessage); message WM_MOUSEWHEEL;
     72    procedure OnMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE;
     73  end;
     74
     75  TModalSelectDlg = TListDlg;
    7776
    7877const
    79 cpType=$10000;
    80 mixAll=$10000;
    81 adAll=$10000;
     78  cpType = $10000;
     79  mixAll = $10000;
     80  adAll = $10000;
    8281
    8382var
     
    8887
    8988uses
    90 CityScreen, Help, UnitStat, Tribes, Inp;
     89  CityScreen, Help, UnitStat, Tribes, Inp;
    9190
    9291{$R *.DFM}
    9392
    9493const
    95 CityNameSpace=127;
    96 
    97 MustChooseKind=[kTribe,kStealTech,kGov];
    98 
    99 
    100 procedure TListDlg.FormCreate(Sender:TObject);
    101 begin
    102 inherited;
    103 Canvas.Font.Assign(UniFont[ftNormal]);
    104 CreatePVSB(sb,Handle,2,361,2+422);
    105 InitButtons();
    106 Kind:=kMission;
    107 Layer0Btn.Hint:=Phrases.Lookup('BTN_IMPRS');
    108 Layer1Btn.Hint:=Phrases.Lookup('BTN_WONDERS');
    109 Layer2Btn.Hint:=Phrases.Lookup('BTN_CLASSES');
    110 ScienceNationDot:=TBitmap.Create;
    111 ScienceNationDot.PixelFormat:=pf24bit;
    112 ScienceNationDot.Width:=17; ScienceNationDot.Height:=17;
     94  CityNameSpace = 127;
     95
     96  MustChooseKind = [kTribe, kStealTech, kGov];
     97
     98procedure TListDlg.FormCreate(Sender: TObject);
     99begin
     100  inherited;
     101  Canvas.Font.Assign(UniFont[ftNormal]);
     102  CreatePVSB(sb, Handle, 2, 361, 2 + 422);
     103  InitButtons();
     104  Kind := kMission;
     105  Layer0Btn.Hint := Phrases.Lookup('BTN_IMPRS');
     106  Layer1Btn.Hint := Phrases.Lookup('BTN_WONDERS');
     107  Layer2Btn.Hint := Phrases.Lookup('BTN_CLASSES');
     108  ScienceNationDot := TBitmap.Create;
     109  ScienceNationDot.PixelFormat := pf24bit;
     110  ScienceNationDot.Width := 17;
     111  ScienceNationDot.Height := 17;
    113112end;
    114113
    115114procedure TListDlg.FormDestroy(Sender: TObject);
    116115begin
    117 ScienceNationDot.Free;
    118 end;
    119 
    120 procedure TListDlg.CloseBtnClick(Sender:TObject);
    121 begin
    122 Closable:=true; Close
    123 end;
    124 
    125 procedure TListDlg.FormCloseQuery(Sender: TObject;
    126   var CanClose: boolean);
    127 begin
    128 CanClose:=Closable or not(Kind in MustChooseKind)
    129 end;
    130 
    131 procedure TListDlg.OnScroll(var m:TMessage);
    132 begin
    133 if ProcessPVSB(sb,m) then
    134   begin Sel:=-2; SmartUpdateContent(true) end
    135 end;
    136 
    137 procedure TListDlg.OnMouseWheel(var m:TMessage);
    138 begin
    139 if ProcessMouseWheel(sb,m) then
    140   begin
    141   Sel:=-2;
    142   SmartUpdateContent(true);
    143   PaintBox1MouseMove(nil, [], m.lParam and $FFFF-Left, m.lParam shr 16-Top);
     116  ScienceNationDot.Free;
     117end;
     118
     119procedure TListDlg.CloseBtnClick(Sender: TObject);
     120begin
     121  Closable := true;
     122  Close
     123end;
     124
     125procedure TListDlg.FormCloseQuery(Sender: TObject; var CanClose: boolean);
     126begin
     127  CanClose := Closable or not(Kind in MustChooseKind)
     128end;
     129
     130procedure TListDlg.OnScroll(var m: TMessage);
     131begin
     132  if ProcessPVSB(sb, m) then
     133  begin
     134    Sel := -2;
     135    SmartUpdateContent(true)
    144136  end
    145137end;
    146138
    147 procedure TListDlg.OnMouseLeave(var Msg:TMessage);
    148 begin
    149 if not Closable and (Sel<>-2) then
    150   begin
    151   line(Canvas,Sel,false,false);
    152   Sel:=-2;
     139procedure TListDlg.OnMouseWheel(var m: TMessage);
     140begin
     141  if ProcessMouseWheel(sb, m) then
     142  begin
     143    Sel := -2;
     144    SmartUpdateContent(true);
     145    PaintBox1MouseMove(nil, [], m.lParam and $FFFF - Left,
     146      m.lParam shr 16 - Top);
    153147  end
    154148end;
    155149
    156 procedure TListDlg.FormPaint(Sender:TObject);
     150procedure TListDlg.OnMouseLeave(var Msg: TMessage);
     151begin
     152  if not Closable and (Sel <> -2) then
     153  begin
     154    line(Canvas, Sel, false, false);
     155    Sel := -2;
     156  end
     157end;
     158
     159procedure TListDlg.FormPaint(Sender: TObject);
    157160var
    158 s: string;
    159 begin
    160 inherited;
    161 Canvas.Font.Assign(UniFont[ftNormal]);
    162 if Sel<>-2 then line(Canvas,Sel,false,true);
    163 s:='';
    164 if (Kind=kAdvance) and (MyData.FarTech<>adNone) then
    165   s:=Format(Phrases.Lookup('TECHFOCUS'),
    166     [Phrases.Lookup('ADVANCES',MyData.FarTech)])
    167 else if Kind=kModels then s:=Tribe[me].TPhrase('SHORTNAME')
    168 else if Kind=kEModels then
    169   s:=Tribe[pView].TPhrase('SHORTNAME')
    170     +' ('+TurnToString(MyRO.EnemyReport[pView].TurnOfMilReport)+')';
    171 if s<>'' then
    172   LoweredTextOut(Canvas, -1, MainTexture,
    173     (ClientWidth-BiColorTextWidth(Canvas,s)) div 2, 31, s);
    174 if not MultiPage and (Kind in [kProject,kAdvance,kFarAdvance])
    175   and not Phrases2FallenBackToEnglish then
    176   begin
    177   s:=Phrases2.Lookup('SHIFTCLICK');
    178   LoweredTextOut(Canvas, -2, MainTexture,
    179     (ClientWidth-BiColorTextWidth(Canvas,s)) div 2, ClientHeight-29, s);
     161  s: string;
     162begin
     163  inherited;
     164  Canvas.Font.Assign(UniFont[ftNormal]);
     165  if Sel <> -2 then
     166    line(Canvas, Sel, false, true);
     167  s := '';
     168  if (Kind = kAdvance) and (MyData.FarTech <> adNone) then
     169    s := Format(Phrases.Lookup('TECHFOCUS'),
     170      [Phrases.Lookup('ADVANCES', MyData.FarTech)])
     171  else if Kind = kModels then
     172    s := Tribe[me].TPhrase('SHORTNAME')
     173  else if Kind = kEModels then
     174    s := Tribe[pView].TPhrase('SHORTNAME') + ' (' +
     175      TurnToString(MyRO.EnemyReport[pView].TurnOfMilReport) + ')';
     176  if s <> '' then
     177    LoweredTextOut(Canvas, -1, MainTexture,
     178      (ClientWidth - BiColorTextWidth(Canvas, s)) div 2, 31, s);
     179  if not MultiPage and (Kind in [kProject, kAdvance, kFarAdvance]) and not Phrases2FallenBackToEnglish
     180  then
     181  begin
     182    s := Phrases2.Lookup('SHIFTCLICK');
     183    LoweredTextOut(Canvas, -2, MainTexture,
     184      (ClientWidth - BiColorTextWidth(Canvas, s)) div 2, ClientHeight - 29, s);
    180185  end
    181186end;
     
    184189// paint a line
    185190
    186   procedure DisplayProject(x,y,pix: integer);
    187   begin
    188   if pix and (cpType or cpImp)=0 then
    189     with Tribe[me].ModelPicture[pix and cpIndex] do
    190       Sprite(offscreen,HGr,x,y,64,48,pix mod 10*65+1, pix div 10 *49+1)
    191   else
     191  procedure DisplayProject(x, y, pix: integer);
     192  begin
     193    if pix and (cpType or cpImp) = 0 then
     194      with Tribe[me].ModelPicture[pix and cpIndex] do
     195        Sprite(offscreen, HGr, x, y, 64, 48, pix mod 10 * 65 + 1,
     196          pix div 10 * 49 + 1)
     197    else
    192198    begin
    193     Frame(offscreen.Canvas,x+(16-1),y+(16-2),x+(16+xSizeSmall),
    194       y+(16-1+ySizeSmall),MainTexture.clBevelLight,MainTexture.clBevelShade);
    195     if pix and cpType=0 then
    196       if (pix and cpIndex=imPalace) and (MyRO.Government<>gAnarchy) then
    197         BitBlt(offscreen.Canvas.Handle,x+16,y+(16-1),xSizeSmall,ySizeSmall,
    198           SmallImp.Canvas.Handle,(MyRO.Government-1)*xSizeSmall,
    199           ySizeSmall,SRCCOPY)
    200       else BitBlt(offscreen.Canvas.Handle,x+16,y+(16-1),xSizeSmall,ySizeSmall,
    201         SmallImp.Canvas.Handle,pix and cpIndex mod 7*xSizeSmall,
    202         (pix and cpIndex+SystemIconLines*7) div 7*ySizeSmall,SRCCOPY)
    203     else BitBlt(offscreen.Canvas.Handle,x+16,y+(16-1),xSizeSmall,ySizeSmall,
    204       SmallImp.Canvas.Handle,(3+pix and cpIndex)*xSizeSmall, 0,SRCCOPY)
     199      Frame(offscreen.Canvas, x + (16 - 1), y + (16 - 2), x + (16 + xSizeSmall),
     200        y + (16 - 1 + ySizeSmall), MainTexture.clBevelLight,
     201        MainTexture.clBevelShade);
     202      if pix and cpType = 0 then
     203        if (pix and cpIndex = imPalace) and (MyRO.Government <> gAnarchy) then
     204          BitBlt(offscreen.Canvas.Handle, x + 16, y + (16 - 1), xSizeSmall,
     205            ySizeSmall, SmallImp.Canvas.Handle, (MyRO.Government - 1) *
     206            xSizeSmall, ySizeSmall, SRCCOPY)
     207        else
     208          BitBlt(offscreen.Canvas.Handle, x + 16, y + (16 - 1), xSizeSmall,
     209            ySizeSmall, SmallImp.Canvas.Handle, pix and cpIndex mod 7 *
     210            xSizeSmall, (pix and cpIndex + SystemIconLines * 7) div 7 *
     211            ySizeSmall, SRCCOPY)
     212      else
     213        BitBlt(offscreen.Canvas.Handle, x + 16, y + (16 - 1), xSizeSmall,
     214          ySizeSmall, SmallImp.Canvas.Handle, (3 + pix and cpIndex) *
     215          xSizeSmall, 0, SRCCOPY)
    205216    end;
    206217  end;
    207218
    208   procedure ReplaceText(x,y,Color: integer; s: string);
     219  procedure ReplaceText(x, y, Color: integer; s: string);
    209220  var
    210   TextSize: TSize;
    211   begin
    212   if ca=Canvas then
     221    TextSize: TSize;
     222  begin
     223    if ca = Canvas then
    213224    begin
    214     TextSize.cx:=BiColorTextWidth(ca,s);
    215     TextSize.cy:=ca.TextHeight(s);
    216     if y+TextSize.cy>=TitleHeight+InnerHeight then
    217       TextSize.cy:=TitleHeight+InnerHeight-y;
    218     Fill(ca,x,y,TextSize.cx,TextSize.cy,(wMaintexture-ClientWidth) div 2,
    219       (hMaintexture-ClientHeight) div 2);
     225      TextSize.cx := BiColorTextWidth(ca, s);
     226      TextSize.cy := ca.TextHeight(s);
     227      if y + TextSize.cy >= TitleHeight + InnerHeight then
     228        TextSize.cy := TitleHeight + InnerHeight - y;
     229      Fill(ca, x, y, TextSize.cx, TextSize.cy, (wMaintexture - ClientWidth)
     230        div 2, (hMaintexture - ClientHeight) div 2);
    220231    end;
    221   LoweredTextOut(ca,Color,MainTexture,x,y,s);
     232    LoweredTextOut(ca, Color, MainTexture, x, y, s);
    222233  end;
    223234
    224235var
    225 icon,ofs,x,y,y0,lix,i,j,TextColor,Available,first,test,FutureCount,
    226   growth,TrueFood,TrueProd:integer;
    227 CityReport: TCityReportNew;
    228 mox: ^TModelInfo;
    229 s,number: string;
    230 CanGrow: boolean;
    231 begin
    232 lix:=code[Layer,sb.si.npos+l];
    233 y0:=2+(l+1)*LineDistance;
    234 if sb.si.npos+l>=FirstShrinkedLine[Layer] then
    235   ofs:=(sb.si.npos+l-FirstShrinkedLine[Layer]) and 1 *33
    236 else {if FirstShrinkedLine[Layer]<Lines[Layer] then} ofs:=33;
    237 
    238 if Kind in [kCities,kCityEvents] then with MyCity[lix] do
    239   begin
    240   x:=104-76; y:=y0;
    241   if ca=Canvas then
    242     begin x:=x+SideFrame; y:=y+TitleHeight end;
    243   if lit then TextColor:=MainTexture.clLitText else TextColor:=-1;
    244   s:=CityName(ID);
    245   while BiColorTextWidth(ca,s)>CityNameSpace do
    246     delete(s,length(s),1);
    247   ReplaceText(x+15,y,TextColor,s);
    248 
    249   if NonText then with offscreen.canvas do
    250     begin // city size
    251     brush.color:=$000000;
    252     fillrect(rect(x-4-11,y+1,x-4+13,y+21));
    253     brush.color:=$FFFFFF;
    254     fillrect(rect(x-4-12,y,x-4+12,y+20));
    255     brush.style:=bsClear;
    256     font.color:=$000000;
    257     s:=inttostr(MyCity[lix].Size);
    258     TextOut(x-4-textwidth(s) div 2, y, s);
    259     end;
    260 
    261   if Kind=kCityEvents then
     236  icon, ofs, x, y, y0, lix, i, j, TextColor, Available, first, test,
     237    FutureCount, growth, TrueFood, TrueProd: integer;
     238  CityReport: TCityReportNew;
     239  mox: ^TModelInfo;
     240  s, number: string;
     241  CanGrow: boolean;
     242begin
     243  lix := code[Layer, sb.si.npos + l];
     244  y0 := 2 + (l + 1) * LineDistance;
     245  if sb.si.npos + l >= FirstShrinkedLine[Layer] then
     246    ofs := (sb.si.npos + l - FirstShrinkedLine[Layer]) and 1 * 33
     247  else { if FirstShrinkedLine[Layer]<Lines[Layer] then }
     248    ofs := 33;
     249
     250  if Kind in [kCities, kCityEvents] then
     251    with MyCity[lix] do
    262252    begin
    263     first:=-1;
    264     for j:=0 to nCityEventPriority-1 do
    265       if (Flags and CityRepMask and CityEventPriority[j]<>0) then
    266         begin first:=j; Break end;
    267     if first>=0 then
    268       begin
    269       i:=0;
    270       test:=1;
    271       while test<CityEventPriority[first] do
    272         begin inc(i); inc(test,test) end;
    273       s:=CityEventName(i);
    274 {      if CityEventPriority[first]=chNoGrowthWarning then
    275         if Built[imAqueduct]=0 then
    276           s:=Format(s,[Phrases.Lookup('IMPROVEMENTS',imAqueduct)])
    277         else begin s:=Format(s,[Phrases.Lookup('IMPROVEMENTS',imSewer)]); i:=17 end;}
    278       ReplaceText(x+(CityNameSpace+4+40+18+8),y,TextColor,s);
     253      x := 104 - 76;
     254      y := y0;
     255      if ca = Canvas then
     256      begin
     257        x := x + SideFrame;
     258        y := y + TitleHeight
     259      end;
     260      if lit then
     261        TextColor := MainTexture.clLitText
     262      else
     263        TextColor := -1;
     264      s := CityName(ID);
     265      while BiColorTextWidth(ca, s) > CityNameSpace do
     266        delete(s, length(s), 1);
     267      ReplaceText(x + 15, y, TextColor, s);
     268
    279269      if NonText then
    280         begin
    281         Sprite(offscreen,HGrSystem,105-76+CityNameSpace+4+40,y0+1,18,18,
    282           1+i mod 3 *19,1+i div 3 *19);
    283         x:=InnerWidth-26;
    284         for j:=nCityEventPriority-1 downto first+1 do
    285           if (Flags and CityRepMask and CityEventPriority[j]<>0) then
    286             begin
    287             i:=0;
    288             test:=1;
    289             while test<CityEventPriority[j] do
    290               begin inc(i); inc(test,test) end;
    291             if (CityEventPriority[j]=chNoGrowthWarning)
    292               and (Built[imAqueduct]>0) then
    293               i:=17;
    294             Sprite(offscreen,HGrSystem,x,y0+1,18,18,1+i mod 3 *19,
    295               1+i div 3 *19);
    296             dec(x,20)
    297             end
     270        with offscreen.Canvas do
     271        begin // city size
     272          brush.Color := $000000;
     273          fillrect(rect(x - 4 - 11, y + 1, x - 4 + 13, y + 21));
     274          brush.Color := $FFFFFF;
     275          fillrect(rect(x - 4 - 12, y, x - 4 + 12, y + 20));
     276          brush.style := bsClear;
     277          Font.Color := $000000;
     278          s := inttostr(MyCity[lix].Size);
     279          TextOut(x - 4 - textwidth(s) div 2, y, s);
     280        end;
     281
     282      if Kind = kCityEvents then
     283      begin
     284        first := -1;
     285        for j := 0 to nCityEventPriority - 1 do
     286          if (Flags and CityRepMask and CityEventPriority[j] <> 0) then
     287          begin
     288            first := j;
     289            Break
     290          end;
     291        if first >= 0 then
     292        begin
     293          i := 0;
     294          test := 1;
     295          while test < CityEventPriority[first] do
     296          begin
     297            inc(i);
     298            inc(test, test)
     299          end;
     300          s := CityEventName(i);
     301          { if CityEventPriority[first]=chNoGrowthWarning then
     302            if Built[imAqueduct]=0 then
     303            s:=Format(s,[Phrases.Lookup('IMPROVEMENTS',imAqueduct)])
     304            else begin s:=Format(s,[Phrases.Lookup('IMPROVEMENTS',imSewer)]); i:=17 end; }
     305          ReplaceText(x + (CityNameSpace + 4 + 40 + 18 + 8), y, TextColor, s);
     306          if NonText then
     307          begin
     308            Sprite(offscreen, HGrSystem, 105 - 76 + CityNameSpace + 4 + 40,
     309              y0 + 1, 18, 18, 1 + i mod 3 * 19, 1 + i div 3 * 19);
     310            x := InnerWidth - 26;
     311            for j := nCityEventPriority - 1 downto first + 1 do
     312              if (Flags and CityRepMask and CityEventPriority[j] <> 0) then
     313              begin
     314                i := 0;
     315                test := 1;
     316                while test < CityEventPriority[j] do
     317                begin
     318                  inc(i);
     319                  inc(test, test)
     320                end;
     321                if (CityEventPriority[j] = chNoGrowthWarning) and
     322                  (Built[imAqueduct] > 0) then
     323                  i := 17;
     324                Sprite(offscreen, HGrSystem, x, y0 + 1, 18, 18,
     325                  1 + i mod 3 * 19, 1 + i div 3 * 19);
     326                dec(x, 20)
     327              end
     328          end
    298329        end
    299330      end
     331      else
     332      begin
     333        CityReport.HypoTiles := -1;
     334        CityReport.HypoTaxRate := -1;
     335        CityReport.HypoLuxuryRate := -1;
     336        Server(sGetCityReportNew, me, lix, CityReport);
     337        TrueFood := Food;
     338        TrueProd := Prod;
     339        if supervising then
     340        begin // normalize city from after-turn state
     341          dec(TrueFood, CityReport.FoodSurplus);
     342          if TrueFood < 0 then
     343            TrueFood := 0; // shouldn't happen
     344          dec(TrueProd, CityReport.Production);
     345          if TrueProd < 0 then
     346            TrueProd := 0; // shouldn't happen
     347        end;
     348
     349        s := ''; // disorder info
     350        if Flags and chCaptured <> 0 then
     351          s := Phrases.Lookup('CITYEVENTS', 14)
     352        else if CityReport.HappinessBalance < 0 then
     353          s := Phrases.Lookup('CITYEVENTS', 0);
     354        if s <> '' then
     355        begin { disorder }
     356          if NonText then
     357          begin
     358            DarkGradient(offscreen.Canvas, 99 + 31 + CityNameSpace + 4,
     359              y0 + 2, 131, 3);
     360            ca.Font.Assign(UniFont[ftSmall]);
     361            RisedTextout(offscreen.Canvas, 103 + CityNameSpace + 4 + 31,
     362              y0 + 1, s);
     363            ca.Font.Assign(UniFont[ftNormal]);
     364          end
     365        end
     366        else
     367        begin
     368          { s:=IntToStr(CityReport.FoodSurplus);
     369            ReplaceText(x+(CityNameSpace+4+48)-BiColorTextWidth(ca,s),y,TextColor,s); }
     370          s := inttostr(CityReport.Science);
     371          ReplaceText(x + CityNameSpace + 4 + 370 + 48 - BiColorTextWidth(ca,
     372            s), y, TextColor, s);
     373          s := inttostr(CityReport.Production);
     374          ReplaceText(x + CityNameSpace + 4 + 132 - BiColorTextWidth(ca, s), y,
     375            TextColor, s);
     376          if NonText then
     377          begin
     378            // Sprite(offscreen,HGrSystem,x+CityNameSpace+4+333+1,y+6,10,10,66,115);
     379            Sprite(offscreen, HGrSystem, x + CityNameSpace + 4 + 370 + 48 + 1,
     380              y + 6, 10, 10, 77, 126);
     381            Sprite(offscreen, HGrSystem, x + CityNameSpace + 4 + 132 + 1, y + 6,
     382              10, 10, 88, 115);
     383          end
     384        end;
     385        s := inttostr(CityTaxBalance(lix, CityReport));
     386        ReplaceText(x + CityNameSpace + 4 + 370 - BiColorTextWidth(ca, s), y,
     387          TextColor, s);
     388        // if Project and (cpImp+cpIndex)<>cpImp+imTrGoods then
     389        // ReplaceText(x+CityNameSpace+4+333+1,y,TextColor,Format('%d/%d',[TrueProd,CityReport.ProjectCost]));
     390        if NonText then
     391        begin
     392          Sprite(offscreen, HGrSystem, x + CityNameSpace + 4 + 370 + 1, y + 6,
     393            10, 10, 132, 115);
     394
     395          // food progress
     396          CanGrow := (Size < MaxCitySize) and (MyRO.Government <> gFuture) and
     397            (CityReport.FoodSurplus > 0) and
     398            ((Size < NeedAqueductSize) or (Built[imAqueduct] = 1) and
     399            (Size < NeedSewerSize) or (Built[imSewer] = 1));
     400          PaintRelativeProgressBar(offscreen.Canvas, 1, x + 15 + CityNameSpace +
     401            4, y + 7, 68, TrueFood, CutCityFoodSurplus(CityReport.FoodSurplus,
     402            (MyRO.Government <> gAnarchy) and (Flags and chCaptured = 0),
     403            MyRO.Government, Size), CityReport.Storage, CanGrow, MainTexture);
     404
     405          if Project <> cpImp + imTrGoods then
     406          begin
     407            DisplayProject(ofs + 104 - 76 + x - 28 + CityNameSpace + 4 + 206 -
     408              60, y0 - 15, Project);
     409
     410            // production progress
     411            growth := CityReport.Production;
     412            if (growth < 0) or (MyRO.Government = gAnarchy) or
     413              (Flags and chCaptured <> 0) then
     414              growth := 0;
     415            PaintRelativeProgressBar(offscreen.Canvas, 4,
     416              x + CityNameSpace + 4 + 304 - 60 + 9, y + 7, 68, TrueProd, growth,
     417              CityReport.ProjectCost, true, MainTexture);
     418          end;
     419        end
     420      end;
    300421    end
     422  else if Kind in [kModels, kEModels] then
     423  begin
     424    x := 104;
     425    y := y0;
     426    if ca = Canvas then
     427    begin
     428      x := x + SideFrame;
     429      y := y + TitleHeight
     430    end;
     431    if lit then
     432      TextColor := MainTexture.clLitText
     433    else
     434      TextColor := -1;
     435    if Kind = kModels then
     436    begin
     437      Available := 0;
     438      for j := 0 to MyRO.nUn - 1 do
     439        if (MyUn[j].Loc >= 0) and (MyUn[j].mix = lix) then
     440          inc(Available);
     441      if MainScreen.mNames.Checked then
     442        s := Tribe[me].ModelName[lix]
     443      else
     444        s := Format(Tribe[me].TPhrase('GENMODEL'), [lix]);
     445      if NonText then
     446        DisplayProject(8 + ofs, y0 - 15, lix);
     447    end
     448    else
     449    begin
     450      Available := MyRO.EnemyReport[pView].UnCount[lix];
     451      if MainScreen.mNames.Checked then
     452        s := Tribe[pView].ModelName[lix]
     453      else
     454        s := Format(Tribe[pView].TPhrase('GENMODEL'), [lix]);
     455      if NonText then
     456        with Tribe[pView].ModelPicture[lix] do
     457          Sprite(offscreen, HGr, 8 + ofs, y0 - 15, 64, 48, pix mod 10 * 65 + 1,
     458            pix div 10 * 49 + 1);
     459    end;
     460    if Available > 0 then
     461      ReplaceText(x + 32 - BiColorTextWidth(ca, inttostr(Available)), y,
     462        TextColor, inttostr(Available));
     463    ReplaceText(x + 40, y, TextColor, s);
     464  end
    301465  else
    302     begin
    303     CityReport.HypoTiles:=-1;
    304     CityReport.HypoTaxRate:=-1;
    305     CityReport.HypoLuxuryRate:=-1;
    306     Server(sGetCityReportNew,me,lix,CityReport);
    307     TrueFood:=Food;
    308     TrueProd:=Prod;
    309     if supervising then
    310       begin // normalize city from after-turn state
    311       dec(TrueFood,CityReport.FoodSurplus);
    312       if TrueFood<0 then
    313         TrueFood:=0; // shouldn't happen
    314       dec(TrueProd,CityReport.Production);
    315       if TrueProd<0 then
    316         TrueProd:=0; // shouldn't happen
    317       end;
    318 
    319     s:=''; // disorder info
    320     if Flags and chCaptured<>0 then
    321       s:=Phrases.Lookup('CITYEVENTS',14)
    322     else if CityReport.HappinessBalance<0 then
    323       s:=Phrases.Lookup('CITYEVENTS',0);
    324     if s<>'' then
    325       begin {disorder}
    326       if NonText then
    327         begin
    328         DarkGradient(offscreen.Canvas,99+31+CityNameSpace+4,y0+2,131,3);
    329         ca.Font.Assign(UniFont[ftSmall]);
    330         RisedTextout(offscreen.canvas,103+CityNameSpace+4+31,y0+1,s);
    331         ca.Font.Assign(UniFont[ftNormal]);
    332         end
    333       end
    334     else
    335       begin
    336 {      s:=IntToStr(CityReport.FoodSurplus);
    337       ReplaceText(x+(CityNameSpace+4+48)-BiColorTextWidth(ca,s),y,TextColor,s);}
    338       s:=IntToStr(CityReport.Science);
    339       ReplaceText(x+CityNameSpace+4+370+48-BiColorTextWidth(ca,s),y,TextColor,s);
    340       s:=IntToStr(CityReport.Production);
    341       ReplaceText(x+CityNameSpace+4+132-BiColorTextWidth(ca,s),y,TextColor,s);
    342       if NonText then
    343         begin
    344         //Sprite(offscreen,HGrSystem,x+CityNameSpace+4+333+1,y+6,10,10,66,115);
    345         Sprite(offscreen,HGrSystem,x+CityNameSpace+4+370+48+1,y+6,10,10,77,126);
    346         Sprite(offscreen,HGrSystem,x+CityNameSpace+4+132+1,y+6,10,10,88,115);
    347         end
    348       end;
    349     s:=IntToStr(CityTaxBalance(lix, CityReport));
    350     ReplaceText(x+CityNameSpace+4+370-BiColorTextWidth(ca,s),y,TextColor,s);
    351     //if Project and (cpImp+cpIndex)<>cpImp+imTrGoods then
    352     //  ReplaceText(x+CityNameSpace+4+333+1,y,TextColor,Format('%d/%d',[TrueProd,CityReport.ProjectCost]));
    353     if NonText then
    354       begin
    355       Sprite(offscreen,HGrSystem,x+CityNameSpace+4+370+1,y+6,10,10,132,115);
    356 
    357       // food progress
    358       CanGrow:=(Size<MaxCitySize) and (MyRO.Government<>gFuture)
    359         and (CityReport.FoodSurplus>0)
    360         and ((Size<NeedAqueductSize)
    361           or (Built[imAqueduct]=1) and (Size<NeedSewerSize)
    362           or (Built[imSewer]=1));
    363       PaintRelativeProgressBar(offscreen.canvas,1,x+15+CityNameSpace+4,y+7,68,TrueFood,
    364         CutCityFoodSurplus(CityReport.FoodSurplus,
    365         (MyRO.Government<>gAnarchy) and (Flags and chCaptured=0),
    366         MyRO.Government,Size),CityReport.Storage,CanGrow,MainTexture);
    367 
    368       if Project<>cpImp+imTrGoods then
    369         begin
    370         DisplayProject(ofs+104-76+x-28+CityNameSpace+4+206-60,y0-15,Project);
    371 
    372         // production progress
    373         growth:=CityReport.Production;
    374         if (growth<0) or (MyRO.Government=gAnarchy)
    375           or (Flags and chCaptured<>0) then
    376           growth:=0;
    377         PaintRelativeProgressBar(offscreen.canvas,4,x+CityNameSpace+4+304-60+9,y+7,68,
    378           TrueProd,growth,CityReport.ProjectCost,true,MainTexture);
    379         end;
    380       end
    381     end;
    382   end
    383 else if Kind in [kModels,kEModels] then
    384   begin
    385   x:=104; y:=y0;
    386   if ca=Canvas then
    387     begin x:=x+SideFrame; y:=y+TitleHeight end;
    388   if lit then TextColor:=MainTexture.clLitText else TextColor:=-1;
    389   if Kind=kModels then
    390     begin
    391     Available:=0;
    392     for j:=0 to MyRO.nUn-1 do
    393       if (MyUn[j].Loc>=0) and (MyUn[j].mix=lix) then inc(Available);
    394     if MainScreen.mNames.Checked then
    395       s:=Tribe[me].ModelName[lix]
    396     else s:=Format(Tribe[me].TPhrase('GENMODEL'),[lix]);
    397     if NonText then DisplayProject(8+ofs,y0-15,lix);
    398     end
    399   else
    400     begin
    401     Available:=MyRO.EnemyReport[pView].UnCount[lix];
    402     if MainScreen.mNames.Checked then
    403       s:=Tribe[pView].ModelName[lix]
    404     else s:=Format(Tribe[pView].TPhrase('GENMODEL'),[lix]);
    405     if NonText then
    406       with Tribe[pView].ModelPicture[lix] do
    407         Sprite(offscreen,HGr,8+ofs,y0-15,64,48,pix mod 10*65+1, pix div 10 *49+1);
    408     end;
    409   if Available>0 then
    410     ReplaceText(x+32-BiColorTextWidth(ca,IntToStr(Available)),y,TextColor,
    411       IntToStr(Available));
    412   ReplaceText(x+40,y,TextColor,s);
    413   end
    414 else
    415   begin
    416   case Kind of
    417     kAllEModels, kChooseEModel:
    418       if lix=mixAll then s:=Phrases.Lookup('PRICECAT_ALLMODEL')
    419       else
    420         begin
    421         mox:=@MyRO.EnemyModel[lix];
    422         if MainScreen.mNames.Checked then
    423           begin
    424           s:=Tribe[mox.Owner].ModelName[mox.mix];
    425           if (Kind=kAllEModels) and (code[1,sb.si.npos+l]=0) then
    426             s:=Format(Tribe[mox.Owner].TPhrase('OWNED'), [s]);
     466  begin
     467    case Kind of
     468      kAllEModels, kChooseEModel:
     469        if lix = mixAll then
     470          s := Phrases.Lookup('PRICECAT_ALLMODEL')
     471        else
     472        begin
     473          mox := @MyRO.EnemyModel[lix];
     474          if MainScreen.mNames.Checked then
     475          begin
     476            s := Tribe[mox.Owner].ModelName[mox.mix];
     477            if (Kind = kAllEModels) and (code[1, sb.si.npos + l] = 0) then
     478              s := Format(Tribe[mox.Owner].TPhrase('OWNED'), [s]);
    427479          end
    428         else s:=Format(Tribe[mox.Owner].TPhrase('GENMODEL'),[mox.mix]);
    429         if NonText then
    430           with Tribe[mox.Owner].ModelPicture[mox.mix] do
    431             Sprite(offscreen,HGr,8+ofs,y0-15,64,48,pix mod 10*65+1, pix div 10 *49+1);
    432         end;
    433     kChooseModel:
    434       if lix=mixAll then s:=Phrases.Lookup('PRICECAT_ALLMODEL')
    435       else
    436         begin
    437         s:=Tribe[me].ModelName[lix];
    438         if NonText then DisplayProject(8+ofs,y0-15,lix);
    439         end;
    440     kProject:
    441       begin
    442       if lix and cpType<>0 then s:=Phrases.Lookup('CITYTYPE',lix and cpIndex)
    443       else if lix and cpImp=0 then with MyModel[lix and cpIndex] do
    444         begin
    445         s:=Tribe[me].ModelName[lix and cpIndex];
    446         if lix and cpConscripts<>0 then
    447           s:=Format(Phrases.Lookup('CONSCRIPTS'),[s]);
    448         end
    449       else
    450         begin
    451         s:=Phrases.Lookup('IMPROVEMENTS',lix and cpIndex);
    452         if (Imp[lix and cpIndex].Kind in [ikNatLocal,ikNatGlobal])
    453             and (MyRO.NatBuilt[lix and cpIndex]>0)
    454           or (lix and cpIndex in [imPower,imHydro,imNuclear])
    455             and (MyCity[cixProject].Built[imPower]
    456               +MyCity[cixProject].Built[imHydro]
    457               +MyCity[cixProject].Built[imNuclear]>0) then
    458           s:=Format(Phrases.Lookup('NATEXISTS'),[s]);
    459         end;
    460       if NonText then DisplayProject(8+ofs,y0-15,lix);
    461       end;
    462     kAdvance, kFarAdvance, kScience, kChooseTech, kChooseETech, kStealTech:
    463       begin
    464       if lix=adAll then s:=Phrases.Lookup('PRICECAT_ALLTECH')
    465       else
    466         begin
    467         if lix=adNexus then s:=Phrases.Lookup('NEXUS')
    468         else if lix=adNone then s:=Phrases.Lookup('NOFARTECH')
    469         else if lix=adMilitary then s:=Phrases.Lookup('INITUNIT')
     480          else
     481            s := Format(Tribe[mox.Owner].TPhrase('GENMODEL'), [mox.mix]);
     482          if NonText then
     483            with Tribe[mox.Owner].ModelPicture[mox.mix] do
     484              Sprite(offscreen, HGr, 8 + ofs, y0 - 15, 64, 48,
     485                pix mod 10 * 65 + 1, pix div 10 * 49 + 1);
     486        end;
     487      kChooseModel:
     488        if lix = mixAll then
     489          s := Phrases.Lookup('PRICECAT_ALLMODEL')
    470490        else
    471           begin
    472           s:=Phrases.Lookup('ADVANCES',lix);
    473           if (Kind=kAdvance) and (lix in FutureTech) then
    474             if MyRO.Tech[lix]<tsApplicable then s:=s+' 1'
    475             else s:=s+' '+IntToStr(MyRO.Tech[lix]+1);
    476           end;
    477         if BiColorTextWidth(ca,s)>TechNameSpace+8 then
    478           begin
    479           repeat
    480             delete(s,length(s),1);
    481           until BiColorTextWidth(ca,s)<=TechNameSpace+5;
    482           s:=s+'.';
    483           end;
    484 
    485         if NonText then
    486           begin // show tech icon
    487           if lix=adNexus then
     491        begin
     492          s := Tribe[me].ModelName[lix];
     493          if NonText then
     494            DisplayProject(8 + ofs, y0 - 15, lix);
     495        end;
     496      kProject:
     497        begin
     498          if lix and cpType <> 0 then
     499            s := Phrases.Lookup('CITYTYPE', lix and cpIndex)
     500          else if lix and cpImp = 0 then
     501            with MyModel[lix and cpIndex] do
    488502            begin
    489             Frame(offscreen.Canvas,(8+16-1),y0-1,(8+16+36),
    490               y0+20,MainTexture.clBevelLight,MainTexture.clBevelShade);
    491             Dump(offscreen,HGrSystem,(8+16),y0,36,20,223,295)
    492             end
    493           else if lix=adNone then
    494             begin
    495             Frame(offscreen.Canvas,(8+16-1),y0-1,(8+16+36),
    496               y0+20,MainTexture.clBevelLight,MainTexture.clBevelShade);
    497             Dump(offscreen,HGrSystem,(8+16),y0,36,20,260,295)
    498             end
    499           else if lix=adMilitary then
    500             begin
    501             Frame(offscreen.Canvas,(8+16-1),y0-1,(8+16+36),
    502               y0+20,MainTexture.clBevelLight,MainTexture.clBevelShade);
    503             Dump(offscreen,HGrSystem,(8+16),y0,36,20,38,295)
     503              s := Tribe[me].ModelName[lix and cpIndex];
     504              if lix and cpConscripts <> 0 then
     505                s := Format(Phrases.Lookup('CONSCRIPTS'), [s]);
    504506            end
    505507          else
     508          begin
     509            s := Phrases.Lookup('IMPROVEMENTS', lix and cpIndex);
     510            if (Imp[lix and cpIndex].Kind in [ikNatLocal, ikNatGlobal]) and
     511              (MyRO.NatBuilt[lix and cpIndex] > 0) or
     512              (lix and cpIndex in [imPower, imHydro, imNuclear]) and
     513              (MyCity[cixProject].Built[imPower] + MyCity[cixProject].Built
     514              [imHydro] + MyCity[cixProject].Built[imNuclear] > 0) then
     515              s := Format(Phrases.Lookup('NATEXISTS'), [s]);
     516          end;
     517          if NonText then
     518            DisplayProject(8 + ofs, y0 - 15, lix);
     519        end;
     520      kAdvance, kFarAdvance, kScience, kChooseTech, kChooseETech, kStealTech:
     521        begin
     522          if lix = adAll then
     523            s := Phrases.Lookup('PRICECAT_ALLTECH')
     524          else
     525          begin
     526            if lix = adNexus then
     527              s := Phrases.Lookup('NEXUS')
     528            else if lix = adNone then
     529              s := Phrases.Lookup('NOFARTECH')
     530            else if lix = adMilitary then
     531              s := Phrases.Lookup('INITUNIT')
     532            else
    506533            begin
    507             Frame(offscreen.Canvas,(8+16-1),y0-1,(8+16+xSizeSmall),
    508               y0+ySizeSmall,MainTexture.clBevelLight,MainTexture.clBevelShade);
    509             if AdvIcon[lix]<84 then
    510               BitBlt(offscreen.Canvas.Handle,(8+16),y0,xSizeSmall,ySizeSmall,
    511                 SmallImp.Canvas.Handle,(AdvIcon[lix]+SystemIconLines*7) mod 7*xSizeSmall,
    512                 (AdvIcon[lix]+SystemIconLines*7) div 7*ySizeSmall,SRCCOPY)
    513             else Dump(offscreen,HGrSystem,(8+16),y0,36,20,
    514               1+(AdvIcon[lix]-84) mod 8*37,295+(AdvIcon[lix]-84) div 8*21);
    515             j:=AdvValue[lix] div 1000;
    516             BitBlt(Handle,(8+16-4),y0+2,14,14,
    517               GrExt[HGrSystem].Mask.Canvas.Handle,127+j*15,85,SRCAND);
    518             Sprite(offscreen,HGrSystem,(8+16-5),y0+1,14,14,
    519               127+j*15,85);
     534              s := Phrases.Lookup('ADVANCES', lix);
     535              if (Kind = kAdvance) and (lix in FutureTech) then
     536                if MyRO.Tech[lix] < tsApplicable then
     537                  s := s + ' 1'
     538                else
     539                  s := s + ' ' + inttostr(MyRO.Tech[lix] + 1);
    520540            end;
    521           end;
    522         end;
    523 
    524       if NonText and (Kind in [kAdvance, kScience]) then
    525         begin // show research state
    526         for j:=0 to nColumn-1 do
    527           begin
    528           FutureCount:=0;
    529           if j=0 then // own science
    530             if lix=MyRO.ResearchTech then
     541            if BiColorTextWidth(ca, s) > TechNameSpace + 8 then
     542            begin
     543              repeat
     544                delete(s, length(s), 1);
     545              until BiColorTextWidth(ca, s) <= TechNameSpace + 5;
     546              s := s + '.';
     547            end;
     548
     549            if NonText then
     550            begin // show tech icon
     551              if lix = adNexus then
    531552              begin
    532               Server(sGetTechCost,me,0,icon);
    533               icon:=4+MyRO.Research*4 div icon;
    534               if icon>4+3 then icon:=4+3
     553                Frame(offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36),
     554                  y0 + 20, MainTexture.clBevelLight, MainTexture.clBevelShade);
     555                Dump(offscreen, HGrSystem, (8 + 16), y0, 36, 20, 223, 295)
    535556              end
    536             else if (lix>=adMilitary) then
    537               icon:=-1
    538             else if lix in FutureTech then
     557              else if lix = adNone then
    539558              begin
    540               icon:=-1;
    541               FutureCount:=MyRO.Tech[lix];
     559                Frame(offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36),
     560                  y0 + 20, MainTexture.clBevelLight, MainTexture.clBevelShade);
     561                Dump(offscreen, HGrSystem, (8 + 16), y0, 36, 20, 260, 295)
    542562              end
    543             else if MyRO.Tech[lix]=tsSeen then icon:=1
    544             else if MyRO.Tech[lix]>=tsApplicable then icon:=2
    545             else icon:=-1
    546           else with MyRO.EnemyReport[Column[j]]^ do // enemy science
    547             if (MyRO.Alive and (1 shl Column[j])<>0)
    548               and (TurnOfCivilReport>=0) and (lix=ResearchTech)
    549               and ((lix=adMilitary) or (lix in FutureTech)
    550                 or (Tech[lix]<tsApplicable)) then
     563              else if lix = adMilitary then
    551564              begin
    552               icon:=4+ResearchDone div 25;
    553               if icon>4+3 then icon:=4+3
     565                Frame(offscreen.Canvas, (8 + 16 - 1), y0 - 1, (8 + 16 + 36),
     566                  y0 + 20, MainTexture.clBevelLight, MainTexture.clBevelShade);
     567                Dump(offscreen, HGrSystem, (8 + 16), y0, 36, 20, 38, 295)
    554568              end
    555             else if lix=adMilitary then
    556               icon:=-1
    557             else if lix in FutureTech then
     569              else
    558570              begin
    559               icon:=-1;
    560               FutureCount:=Tech[lix]
     571                Frame(offscreen.Canvas, (8 + 16 - 1), y0 - 1,
     572                  (8 + 16 + xSizeSmall), y0 + ySizeSmall,
     573                  MainTexture.clBevelLight, MainTexture.clBevelShade);
     574                if AdvIcon[lix] < 84 then
     575                  BitBlt(offscreen.Canvas.Handle, (8 + 16), y0, xSizeSmall,
     576                    ySizeSmall, SmallImp.Canvas.Handle,
     577                    (AdvIcon[lix] + SystemIconLines * 7) mod 7 * xSizeSmall,
     578                    (AdvIcon[lix] + SystemIconLines * 7) div 7 *
     579                    ySizeSmall, SRCCOPY)
     580                else
     581                  Dump(offscreen, HGrSystem, (8 + 16), y0, 36, 20,
     582                    1 + (AdvIcon[lix] - 84) mod 8 * 37,
     583                    295 + (AdvIcon[lix] - 84) div 8 * 21);
     584                j := AdvValue[lix] div 1000;
     585                BitBlt(Handle, (8 + 16 - 4), y0 + 2, 14, 14,
     586                  GrExt[HGrSystem].Mask.Canvas.Handle, 127 + j * 15,
     587                  85, SRCAND);
     588                Sprite(offscreen, HGrSystem, (8 + 16 - 5), y0 + 1, 14, 14,
     589                  127 + j * 15, 85);
     590              end;
     591            end;
     592          end;
     593
     594          if NonText and (Kind in [kAdvance, kScience]) then
     595          begin // show research state
     596            for j := 0 to nColumn - 1 do
     597            begin
     598              FutureCount := 0;
     599              if j = 0 then // own science
     600                if lix = MyRO.ResearchTech then
     601                begin
     602                  Server(sGetTechCost, me, 0, icon);
     603                  icon := 4 + MyRO.Research * 4 div icon;
     604                  if icon > 4 + 3 then
     605                    icon := 4 + 3
     606                end
     607                else if (lix >= adMilitary) then
     608                  icon := -1
     609                else if lix in FutureTech then
     610                begin
     611                  icon := -1;
     612                  FutureCount := MyRO.Tech[lix];
     613                end
     614                else if MyRO.Tech[lix] = tsSeen then
     615                  icon := 1
     616                else if MyRO.Tech[lix] >= tsApplicable then
     617                  icon := 2
     618                else
     619                  icon := -1
     620              else
     621                with MyRO.EnemyReport[Column[j]]^ do // enemy science
     622                  if (MyRO.Alive and (1 shl Column[j]) <> 0) and
     623                    (TurnOfCivilReport >= 0) and (lix = ResearchTech) and
     624                    ((lix = adMilitary) or (lix in FutureTech) or
     625                    (Tech[lix] < tsApplicable)) then
     626                  begin
     627                    icon := 4 + ResearchDone div 25;
     628                    if icon > 4 + 3 then
     629                      icon := 4 + 3
     630                  end
     631                  else if lix = adMilitary then
     632                    icon := -1
     633                  else if lix in FutureTech then
     634                  begin
     635                    icon := -1;
     636                    FutureCount := Tech[lix]
     637                  end
     638                  else if Tech[lix] >= tsApplicable then
     639                    icon := 2
     640                  else if Tech[lix] = tsSeen then
     641                    icon := 1
     642                  else
     643                    icon := -1;
     644              if icon >= 0 then
     645                Sprite(offscreen, HGrSystem, 104 - 33 + 15 + 3 + TechNameSpace +
     646                  24 * j, y0 + 3, 14, 14, 67 + icon * 15, 85)
     647              else if (Kind = kScience) and (FutureCount > 0) then
     648              begin
     649                number := inttostr(FutureCount);
     650                RisedTextout(ca, 104 - 33 + 15 + 10 + TechNameSpace + 24 * j -
     651                  BiColorTextWidth(ca, number) div 2, y0, number);
    561652              end
    562             else if Tech[lix]>=tsApplicable then
    563               icon:=2
    564             else if Tech[lix]=tsSeen then
    565               icon:=1
    566             else icon:=-1;
    567           if icon>=0 then
    568             Sprite(offscreen,HGrSystem,104-33+15+3+TechNameSpace+24*j,y0+3,
    569               14,14,67+icon*15,85)
    570           else if (Kind=kScience) and (FutureCount>0) then
    571             begin
    572             number:=inttostr(FutureCount);
    573             RisedTextOut(ca,104-33+15+10+TechNameSpace+24*j
    574               -BiColorTextWidth(ca,number) div 2,y0,number);
    575653            end
     654          end;
     655        end; // kAdvance, kScience
     656      kTribe:
     657        s := TribeNames[lix];
     658      kShipPart:
     659        begin
     660          s := Phrases.Lookup('IMPROVEMENTS', imShipComp + lix) + ' (' +
     661            inttostr(MyRO.Ship[me].Parts[lix]) + ')';
     662          if NonText then
     663            DisplayProject(8 + ofs, y0 - 15, cpImp + imShipComp + lix);
     664        end;
     665      kEShipPart:
     666        begin
     667          s := Phrases.Lookup('IMPROVEMENTS', imShipComp + lix) + ' (' +
     668            inttostr(MyRO.Ship[DipMem[me].pContact].Parts[lix]) + ')';
     669          if NonText then
     670            DisplayProject(8 + ofs, y0 - 15, cpImp + imShipComp + lix);
     671        end;
     672      kGov:
     673        begin
     674          s := Phrases.Lookup('GOVERNMENT', lix);
     675          if NonText then
     676          begin
     677            Frame(offscreen.Canvas, 8 + 16 - 1, y0 - 15 + (16 - 2),
     678              8 + 16 + xSizeSmall, y0 - 15 + (16 - 1 + ySizeSmall),
     679              MainTexture.clBevelLight, MainTexture.clBevelShade);
     680            BitBlt(offscreen.Canvas.Handle, 8 + 16, y0 - 15 + (16 - 1),
     681              xSizeSmall, ySizeSmall, SmallImp.Canvas.Handle,
     682              (lix - 1) * xSizeSmall, ySizeSmall, SRCCOPY);
    576683          end
    577684        end;
    578       end; // kAdvance, kScience
    579     kTribe:
    580       s:=TribeNames[lix];
    581     kShipPart:
    582       begin
    583       s:=Phrases.Lookup('IMPROVEMENTS',imShipComp+lix)
    584         +' ('+inttostr(MyRO.Ship[me].Parts[lix])+')';
    585       if NonText then DisplayProject(8+ofs,y0-15,cpImp+imShipComp+lix);
    586       end;
    587     kEShipPart:
    588       begin
    589       s:=Phrases.Lookup('IMPROVEMENTS',imShipComp+lix)
    590         +' ('+inttostr(MyRO.Ship[DipMem[me].pContact].Parts[lix])+')';
    591       if NonText then DisplayProject(8+ofs,y0-15,cpImp+imShipComp+lix);
    592       end;
    593     kGov:
    594       begin
    595       s:=Phrases.Lookup('GOVERNMENT',lix);
    596       if NonText then
    597         begin
    598         Frame(offscreen.Canvas,8+16-1,y0-15+(16-2),8+16+xSizeSmall,
    599           y0-15+(16-1+ySizeSmall),MainTexture.clBevelLight,MainTexture.clBevelShade);
    600         BitBlt(offscreen.Canvas.Handle,8+16,y0-15+(16-1),xSizeSmall,ySizeSmall,
    601           SmallImp.Canvas.Handle,(lix-1)*xSizeSmall,ySizeSmall,SRCCOPY);
    602         end
    603       end;
    604     kMission:
    605       s:=Phrases.Lookup('SPYMISSION',lix);
     685      kMission:
     686        s := Phrases.Lookup('SPYMISSION', lix);
    606687    end;
    607   case Kind of
    608     kTribe,kMission: // center text
    609       if Lines[0]>MaxLines then
    610         x:=(InnerWidth-GetSystemMetrics(SM_CXVSCROLL)) div 2-BiColorTextWidth(ca,s) div 2
    611       else x:=InnerWidth div 2-BiColorTextWidth(ca,s) div 2;
    612     kAdvance, kFarAdvance, kScience, kChooseTech, kChooseETech, kStealTech, kGov:
    613       x:=104-33;
    614     kAllEModels: x:=104;
    615     else x:=104+15;
     688    case Kind of
     689      kTribe, kMission: // center text
     690        if Lines[0] > MaxLines then
     691          x := (InnerWidth - GetSystemMetrics(SM_CXVSCROLL)) div 2 -
     692            BiColorTextWidth(ca, s) div 2
     693        else
     694          x := InnerWidth div 2 - BiColorTextWidth(ca, s) div 2;
     695      kAdvance, kFarAdvance, kScience, kChooseTech, kChooseETech,
     696        kStealTech, kGov:
     697        x := 104 - 33;
     698      kAllEModels:
     699        x := 104;
     700    else
     701      x := 104 + 15;
    616702    end;
    617   y:=y0;
    618   if ca=Canvas then
    619     begin x:=x+SideFrame; y:=y+TitleHeight end;
    620   if lit then TextColor:=MainTexture.clLitText
    621   else TextColor:=-1;
    622 {  if Kind=kTribe then ReplaceText_Tribe(x,y,TextColor,
    623     integer(TribeNames.Objects[lix]),s)
    624   else} ReplaceText(x,y,TextColor,s);
     703    y := y0;
     704    if ca = Canvas then
     705    begin
     706      x := x + SideFrame;
     707      y := y + TitleHeight
     708    end;
     709    if lit then
     710      TextColor := MainTexture.clLitText
     711    else
     712      TextColor := -1;
     713    { if Kind=kTribe then ReplaceText_Tribe(x,y,TextColor,
     714      integer(TribeNames.Objects[lix]),s)
     715      else } ReplaceText(x, y, TextColor, s);
    625716  end
    626717end;
     
    628719procedure TListDlg.OffscreenPaint;
    629720var
    630 i,j: integer;
    631 begin
    632 case Kind of
    633   kCities: Caption:=Tribe[me].TPhrase('TITLE_CITIES');
    634   kCityEvents: Caption:=Format(Phrases.Lookup('TITLE_EVENTS'),[TurnToString(MyRO.Turn)]);
    635   end;
    636 
    637 inherited;
    638 offscreen.Canvas.Font.Assign(UniFont[ftNormal]);
    639 FillOffscreen(0,0,InnerWidth,InnerHeight);
    640 with offscreen.Canvas do
    641   begin
    642   if Kind=kScience then
    643     for i:=1 to nColumn-1 do
    644       begin
    645       Pen.Color:=$000000;
    646       MoveTo(104-33+15+TechNameSpace+24*i,0);
    647       LineTo(104-33+15+TechNameSpace+24*i,InnerHeight);
    648       MoveTo(104-33+15+TechNameSpace+9*2+24*i,0);
    649       LineTo(104-33+15+TechNameSpace+9*2+24*i,InnerHeight);
    650       if MyRO.EnemyReport[Column[i]].TurnOfCivilReport>=MyRO.Turn-1 then
    651         begin
    652         brush.color:=Tribe[Column[i]].Color;
    653         FillRect(Rect(104-33+14+TechNameSpace+24*i+1*2,0,
    654           104-33+17+TechNameSpace+24*i+8*2,InnerHeight));
    655         brush.style:=bsClear;
     721  i, j: integer;
     722begin
     723  case Kind of
     724    kCities:
     725      Caption := Tribe[me].TPhrase('TITLE_CITIES');
     726    kCityEvents:
     727      Caption := Format(Phrases.Lookup('TITLE_EVENTS'),
     728        [TurnToString(MyRO.Turn)]);
     729  end;
     730
     731  inherited;
     732  offscreen.Canvas.Font.Assign(UniFont[ftNormal]);
     733  FillOffscreen(0, 0, InnerWidth, InnerHeight);
     734  with offscreen.Canvas do
     735  begin
     736    if Kind = kScience then
     737      for i := 1 to nColumn - 1 do
     738      begin
     739        Pen.Color := $000000;
     740        MoveTo(104 - 33 + 15 + TechNameSpace + 24 * i, 0);
     741        LineTo(104 - 33 + 15 + TechNameSpace + 24 * i, InnerHeight);
     742        MoveTo(104 - 33 + 15 + TechNameSpace + 9 * 2 + 24 * i, 0);
     743        LineTo(104 - 33 + 15 + TechNameSpace + 9 * 2 + 24 * i, InnerHeight);
     744        if MyRO.EnemyReport[Column[i]].TurnOfCivilReport >= MyRO.Turn - 1 then
     745        begin
     746          brush.Color := Tribe[Column[i]].Color;
     747          fillrect(rect(104 - 33 + 14 + TechNameSpace + 24 * i + 1 * 2, 0,
     748            104 - 33 + 17 + TechNameSpace + 24 * i + 8 * 2, InnerHeight));
     749          brush.style := bsClear;
    656750        end
    657       else
     751        else
    658752        begin // colored player columns
    659         Pen.Color:=Tribe[Column[i]].Color;
    660         for j:=1 to 8 do
    661           begin
    662           MoveTo(104-33+15+TechNameSpace+24*i+j*2,0);
    663           LineTo(104-33+15+TechNameSpace+24*i+j*2,InnerHeight);
     753          Pen.Color := Tribe[Column[i]].Color;
     754          for j := 1 to 8 do
     755          begin
     756            MoveTo(104 - 33 + 15 + TechNameSpace + 24 * i + j * 2, 0);
     757            LineTo(104 - 33 + 15 + TechNameSpace + 24 * i + j * 2, InnerHeight);
    664758          end
    665759        end;
    666760      end;
    667   for i:=-1 to DispLines do if (i+sb.si.npos>=0) and (i+sb.si.npos<Lines[Layer]) then
    668     line(offscreen.Canvas,i,true,false)
    669   end;
    670 MarkUsedOffscreen(InnerWidth,8+48+DispLines*LineDistance);
    671 end;
    672 
    673 procedure TListDlg.PaintBox1MouseMove(Sender:TObject;
    674   Shift:TShiftState;x,y:integer);
     761    for i := -1 to DispLines do
     762      if (i + sb.si.npos >= 0) and (i + sb.si.npos < Lines[Layer]) then
     763        line(offscreen.Canvas, i, true, false)
     764  end;
     765  MarkUsedOffscreen(InnerWidth, 8 + 48 + DispLines * LineDistance);
     766end;
     767
     768procedure TListDlg.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState;
     769  x, y: integer);
    675770var
    676 i0,Sel0,iColumn,OldScienceNation,xScreen: integer;
    677 s: string;
    678 begin
    679 y:=y-TitleHeight;
    680 i0:=sb.si.npos;
    681 Sel0:=Sel;
    682 if (x>=SideFrame) and (x<SideFrame+InnerWidth) and (y>=0) and (y<InnerHeight)
    683   and (y mod LineDistance>=4) and (y mod LineDistance<20) then
    684   Sel:=y div LineDistance-1
    685 else Sel:=-2;
    686 if (Sel<-1) or (Sel>DispLines) or (Sel+i0<0) or (Sel+i0>=Lines[Layer]) then
    687   Sel:=-2;
    688 if Sel<>Sel0 then
    689   begin
    690   if Sel0<>-2 then line(Canvas,Sel0,false,false);
    691   if Sel<>-2 then line(Canvas,Sel,false,true)
    692   end;
    693 
    694 if Kind=kScience then
     771  i0, Sel0, iColumn, OldScienceNation, xScreen: integer;
     772  s: string;
     773begin
     774  y := y - TitleHeight;
     775  i0 := sb.si.npos;
     776  Sel0 := Sel;
     777  if (x >= SideFrame) and (x < SideFrame + InnerWidth) and (y >= 0) and
     778    (y < InnerHeight) and (y mod LineDistance >= 4) and (y mod LineDistance < 20)
     779  then
     780    Sel := y div LineDistance - 1
     781  else
     782    Sel := -2;
     783  if (Sel < -1) or (Sel > DispLines) or (Sel + i0 < 0) or
     784    (Sel + i0 >= Lines[Layer]) then
     785    Sel := -2;
     786  if Sel <> Sel0 then
     787  begin
     788    if Sel0 <> -2 then
     789      line(Canvas, Sel0, false, false);
     790    if Sel <> -2 then
     791      line(Canvas, Sel, false, true)
     792  end;
     793
     794  if Kind = kScience then
    695795  begin // show nation under cursor position
    696   OldScienceNation:=ScienceNation;
    697   ScienceNation:=-1;
    698   if (x>=SideFrame+(104-33+15+TechNameSpace)) and ((x-SideFrame-(104-33+15+TechNameSpace)) mod 24<=18)
    699     and (y>=0) and (y<InnerHeight) then
     796    OldScienceNation := ScienceNation;
     797    ScienceNation := -1;
     798    if (x >= SideFrame + (104 - 33 + 15 + TechNameSpace)) and
     799      ((x - SideFrame - (104 - 33 + 15 + TechNameSpace)) mod 24 <= 18) and
     800      (y >= 0) and (y < InnerHeight) then
    700801    begin
    701     iColumn:=(x-SideFrame-(104-33+15+TechNameSpace)) div 24;
    702     if (iColumn>=1) and (iColumn<nColumn) then
    703       ScienceNation:=Column[iColumn];
     802      iColumn := (x - SideFrame - (104 - 33 + 15 + TechNameSpace)) div 24;
     803      if (iColumn >= 1) and (iColumn < nColumn) then
     804        ScienceNation := Column[iColumn];
    704805    end;
    705   if ScienceNation<>OldScienceNation then
     806    if ScienceNation <> OldScienceNation then
    706807    begin
    707     Fill(Canvas,9,ClientHeight-29,ClientWidth-18,24,
    708       (wMaintexture-ClientWidth) div 2,(hMaintexture-ClientHeight) div 2);
    709     if ScienceNation>=0 then
    710       begin
    711       s:=Tribe[ScienceNation].TPhrase('SHORTNAME');
    712       if MyRO.Alive and (1 shl ScienceNation)=0 then
    713         s:=Format(Phrases.Lookup('SCIENCEREPORT_EXTINCT'),[s]) // extinct
    714       else if MyRO.EnemyReport[ScienceNation].TurnOfCivilReport<MyRO.Turn-1 then
    715         s:=s+' ('+TurnToString(MyRO.EnemyReport[ScienceNation].TurnOfCivilReport)+')'; // old report
    716       xScreen:=(ClientWidth-BiColorTextWidth(Canvas,s)) div 2;
    717       LoweredTextOut(Canvas, -1, MainTexture, xScreen+10, ClientHeight-29, s);
    718       BitBlt(ScienceNationDot.Canvas.Handle,0,0,17,17,Canvas.Handle,xScreen-10,
    719         ClientHeight-27,SRCCOPY);
    720       ImageOp_BCC(ScienceNationDot,Templates,0,0,114,211,17,17,
    721         MainTexture.clBevelShade,Tribe[ScienceNation].Color);
    722       BitBlt(Canvas.Handle,xScreen-10,ClientHeight-27,17,17,
    723         ScienceNationDot.Canvas.Handle,0,0,SRCCOPY);
     808      Fill(Canvas, 9, ClientHeight - 29, ClientWidth - 18, 24,
     809        (wMaintexture - ClientWidth) div 2,
     810        (hMaintexture - ClientHeight) div 2);
     811      if ScienceNation >= 0 then
     812      begin
     813        s := Tribe[ScienceNation].TPhrase('SHORTNAME');
     814        if MyRO.Alive and (1 shl ScienceNation) = 0 then
     815          s := Format(Phrases.Lookup('SCIENCEREPORT_EXTINCT'), [s]) // extinct
     816        else if MyRO.EnemyReport[ScienceNation].TurnOfCivilReport < MyRO.Turn - 1
     817        then
     818          s := s + ' (' + TurnToString(MyRO.EnemyReport[ScienceNation]
     819            .TurnOfCivilReport) + ')'; // old report
     820        xScreen := (ClientWidth - BiColorTextWidth(Canvas, s)) div 2;
     821        LoweredTextOut(Canvas, -1, MainTexture, xScreen + 10,
     822          ClientHeight - 29, s);
     823        BitBlt(ScienceNationDot.Canvas.Handle, 0, 0, 17, 17, Canvas.Handle,
     824          xScreen - 10, ClientHeight - 27, SRCCOPY);
     825        ImageOp_BCC(ScienceNationDot, Templates, 0, 0, 114, 211, 17, 17,
     826          MainTexture.clBevelShade, Tribe[ScienceNation].Color);
     827        BitBlt(Canvas.Handle, xScreen - 10, ClientHeight - 27, 17, 17,
     828          ScienceNationDot.Canvas.Handle, 0, 0, SRCCOPY);
    724829      end;
    725830    end
     
    729834function TListDlg.RenameCity(cix: integer): boolean;
    730835var
    731 CityNameInfo: TCityNameInfo;
    732 begin
    733 InputDlg.Caption:=Phrases.Lookup('TITLE_CITYNAME');
    734 InputDlg.EInput.Text:=CityName(MyCity[cix].ID);
    735 InputDlg.CenterToRect(BoundsRect);
    736 InputDlg.ShowModal;
    737 if (InputDlg.ModalResult=mrOK) and (InputDlg.EInput.Text<>'')
    738   and (InputDlg.EInput.Text<>CityName(MyCity[cix].ID)) then
    739   begin
    740   CityNameInfo.ID:=MyCity[cix].ID;
    741   CityNameInfo.NewName:=InputDlg.EInput.Text;
    742   Server(cSetCityName+(Length(CityNameInfo.NewName)+8) div 4,me,0,CityNameInfo);
    743   if CityDlg.Visible then begin CityDlg.FormShow(nil); CityDlg.Invalidate end;
    744   result:=true
     836  CityNameInfo: TCityNameInfo;
     837begin
     838  InputDlg.Caption := Phrases.Lookup('TITLE_CITYNAME');
     839  InputDlg.EInput.Text := CityName(MyCity[cix].ID);
     840  InputDlg.CenterToRect(BoundsRect);
     841  InputDlg.ShowModal;
     842  if (InputDlg.ModalResult = mrOK) and (InputDlg.EInput.Text <> '') and
     843    (InputDlg.EInput.Text <> CityName(MyCity[cix].ID)) then
     844  begin
     845    CityNameInfo.ID := MyCity[cix].ID;
     846    CityNameInfo.NewName := InputDlg.EInput.Text;
     847    Server(cSetCityName + (length(CityNameInfo.NewName) + 8) div 4, me, 0,
     848      CityNameInfo);
     849    if CityDlg.Visible then
     850    begin
     851      CityDlg.FormShow(nil);
     852      CityDlg.Invalidate
     853    end;
     854    result := true
    745855  end
    746 else result:=false
     856  else
     857    result := false
    747858end;
    748859
    749860function TListDlg.RenameModel(mix: integer): boolean;
    750861var
    751 ModelNameInfo: TModelNameInfo;
    752 begin
    753 InputDlg.Caption:=Phrases.Lookup('TITLE_MODELNAME');
    754 InputDlg.EInput.Text:=Tribe[me].ModelName[mix];
    755 InputDlg.CenterToRect(BoundsRect);
    756 InputDlg.ShowModal;
    757 if (InputDlg.ModalResult=mrOK) and (InputDlg.EInput.Text<>'')
    758   and (InputDlg.EInput.Text<>Tribe[me].ModelName[mix]) then
    759   begin
    760   ModelNameInfo.mix:=mix;
    761   ModelNameInfo.NewName:=InputDlg.EInput.Text;
    762   Server(cSetModelName+(Length(ModelNameInfo.NewName)+1+4+3) div 4,
    763     me,0,ModelNameInfo);
    764   if UnitStatDlg.Visible then begin UnitStatDlg.FormShow(nil); UnitStatDlg.Invalidate end;
    765   result:=true
     862  ModelNameInfo: TModelNameInfo;
     863begin
     864  InputDlg.Caption := Phrases.Lookup('TITLE_MODELNAME');
     865  InputDlg.EInput.Text := Tribe[me].ModelName[mix];
     866  InputDlg.CenterToRect(BoundsRect);
     867  InputDlg.ShowModal;
     868  if (InputDlg.ModalResult = mrOK) and (InputDlg.EInput.Text <> '') and
     869    (InputDlg.EInput.Text <> Tribe[me].ModelName[mix]) then
     870  begin
     871    ModelNameInfo.mix := mix;
     872    ModelNameInfo.NewName := InputDlg.EInput.Text;
     873    Server(cSetModelName + (length(ModelNameInfo.NewName) + 1 + 4 + 3) div 4,
     874      me, 0, ModelNameInfo);
     875    if UnitStatDlg.Visible then
     876    begin
     877      UnitStatDlg.FormShow(nil);
     878      UnitStatDlg.Invalidate
     879    end;
     880    result := true
    766881  end
    767 else result:=false 
    768 end;
    769 
    770 procedure TListDlg.PaintBox1MouseDown(Sender:TObject;Button:TMouseButton;
    771   Shift:TShiftState;x,y:integer);
     882  else
     883    result := false
     884end;
     885
     886procedure TListDlg.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
     887  Shift: TShiftState; x, y: integer);
    772888var
    773 lix: integer;
    774 begin
    775 if sb.si.npos+Sel>=0 then lix:=code[Layer,sb.si.npos+Sel];
    776 if Kind in [kScience,kCities,kCityEvents,kModels,kEModels,kAllEModels] then
    777   include(Shift, ssShift); // don't close list window
    778 if (ssLeft in Shift) and not(ssShift in Shift) then
    779   begin
    780   if Sel<>-2 then
    781     begin result:=lix; Closable:=true; Close end
     889  lix: integer;
     890begin
     891  if sb.si.npos + Sel >= 0 then
     892    lix := code[Layer, sb.si.npos + Sel];
     893  if Kind in [kScience, kCities, kCityEvents, kModels, kEModels, kAllEModels]
     894  then
     895    include(Shift, ssShift); // don't close list window
     896  if (ssLeft in Shift) and not(ssShift in Shift) then
     897  begin
     898    if Sel <> -2 then
     899    begin
     900      result := lix;
     901      Closable := true;
     902      Close
     903    end
    782904  end
    783 else if (ssLeft in Shift) and (ssShift in Shift) then
     905  else if (ssLeft in Shift) and (ssShift in Shift) then
    784906  begin // show help/info popup
    785   if Sel<>-2 then
    786     case Kind of
    787       kCities:
    788         MainScreen.ZoomToCity(MyCity[lix].Loc);
    789       kCityEvents:
    790         MainScreen.ZoomToCity(MyCity[lix].Loc, false, MyCity[lix].Flags and CityRepMask);
    791       kModels,kChooseModel:
    792         if lix<>mixAll then
    793           UnitStatDlg.ShowNewContent_OwnModel(FWindowMode or wmPersistent, lix);
    794       kEModels:
    795         UnitStatDlg.ShowNewContent_EnemyModel(FWindowMode or wmPersistent, code[1,sb.si.npos+Sel]);
    796       kAllEModels,kChooseEModel:
    797         if lix<>mixAll then
    798           UnitStatDlg.ShowNewContent_EnemyModel(FWindowMode or wmPersistent, lix);
    799       kAdvance,kFarAdvance,kScience,kChooseTech,kChooseETech,kStealTech:
    800         if lix=adMilitary then
    801           HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkText, HelpDlg.TextIndex('MILRES'))
    802         else if lix<adMilitary then
    803           HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkAdv, lix);
    804       kProject:
    805         if lix=cpImp+imTrGoods then
    806           HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkText,HelpDlg.TextIndex('TRADINGGOODS'))
    807         else if lix and (cpImp+cpType)=0 then
    808           UnitStatDlg.ShowNewContent_OwnModel(FWindowMode or wmPersistent, lix and cpIndex)
    809         else if (lix and cpType=0) and (lix<>cpImp+imTrGoods) then
    810           HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkImp, lix and cpIndex);
    811       kGov:
    812         HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkMisc, miscGovList);
    813       kShipPart,kEShipPart:;
     907    if Sel <> -2 then
     908      case Kind of
     909        kCities:
     910          MainScreen.ZoomToCity(MyCity[lix].Loc);
     911        kCityEvents:
     912          MainScreen.ZoomToCity(MyCity[lix].Loc, false, MyCity[lix].Flags and
     913            CityRepMask);
     914        kModels, kChooseModel:
     915          if lix <> mixAll then
     916            UnitStatDlg.ShowNewContent_OwnModel(FWindowMode or
     917              wmPersistent, lix);
     918        kEModels:
     919          UnitStatDlg.ShowNewContent_EnemyModel(FWindowMode or wmPersistent,
     920            code[1, sb.si.npos + Sel]);
     921        kAllEModels, kChooseEModel:
     922          if lix <> mixAll then
     923            UnitStatDlg.ShowNewContent_EnemyModel(FWindowMode or
     924              wmPersistent, lix);
     925        kAdvance, kFarAdvance, kScience, kChooseTech, kChooseETech, kStealTech:
     926          if lix = adMilitary then
     927            HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkText,
     928              HelpDlg.TextIndex('MILRES'))
     929          else if lix < adMilitary then
     930            HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkAdv, lix);
     931        kProject:
     932          if lix = cpImp + imTrGoods then
     933            HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkText,
     934              HelpDlg.TextIndex('TRADINGGOODS'))
     935          else if lix and (cpImp + cpType) = 0 then
     936            UnitStatDlg.ShowNewContent_OwnModel(FWindowMode or wmPersistent,
     937              lix and cpIndex)
     938          else if (lix and cpType = 0) and (lix <> cpImp + imTrGoods) then
     939            HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkImp,
     940              lix and cpIndex);
     941        kGov:
     942          HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkMisc,
     943            miscGovList);
     944        kShipPart, kEShipPart:
     945          ;
    814946      end
    815947  end
    816 else if ssRight in Shift then
    817   begin
    818   if Sel<>-2 then
    819     case Kind of
    820       kCities, kCityEvents:
    821         if RenameCity(lix) then SmartUpdateContent;
    822       kModels:
    823         if RenameModel(lix) then SmartUpdateContent;
     948  else if ssRight in Shift then
     949  begin
     950    if Sel <> -2 then
     951      case Kind of
     952        kCities, kCityEvents:
     953          if RenameCity(lix) then
     954            SmartUpdateContent;
     955        kModels:
     956          if RenameModel(lix) then
     957            SmartUpdateContent;
    824958      end
    825959  end
     
    828962procedure TListDlg.InitLines;
    829963var
    830 required: array[0..nAdv-1] of integer;
    831 
    832   procedure TryAddImpLine(Layer,Project: integer);
    833   begin
    834   if Server(sSetCityProject-sExecute,me,cixProject,Project)>=rExecuted then
    835     begin code[Layer,Lines[Layer]]:=Project; inc(Lines[Layer]); end;
     964  required: array [0 .. nAdv - 1] of integer;
     965
     966  procedure TryAddImpLine(Layer, Project: integer);
     967  begin
     968    if Server(sSetCityProject - sExecute, me, cixProject, Project) >= rExecuted
     969    then
     970    begin
     971      code[Layer, Lines[Layer]] := Project;
     972      inc(Lines[Layer]);
     973    end;
    836974  end;
    837975
    838976  procedure SortTechs;
    839977  var
    840   i,j,swap: integer;
     978    i, j, swap: integer;
    841979  begin // sort by advancedness
    842   for i:=0 to Lines[0]-2 do if code[0,i]<adMilitary then
    843     for j:=i+1 to Lines[0]-1 do
    844       if AdvValue[code[0,i]]*nAdv+code[0,i]<AdvValue[code[0,j]]*nAdv+code[0,j] then
    845         begin swap:=code[0,i]; code[0,i]:=code[0,j]; code[0,j]:=swap end;
     980    for i := 0 to Lines[0] - 2 do
     981      if code[0, i] < adMilitary then
     982        for j := i + 1 to Lines[0] - 1 do
     983          if AdvValue[code[0, i]] * nAdv + code[0, i] < AdvValue[code[0, j]] *
     984            nAdv + code[0, j] then
     985          begin
     986            swap := code[0, i];
     987            code[0, i] := code[0, j];
     988            code[0, j] := swap
     989          end;
    846990  end;
    847991
    848992  procedure SortCities;
    849993  var
    850   i,j,swap: integer;
    851   begin
    852   for i:=0 to Lines[0]-2 do
    853     for j:=i+1 to Lines[0]-1 do
    854       if CityName(MyCity[code[0,i]].ID)>CityName(MyCity[code[0,j]].ID) then
    855         begin swap:=code[0,i]; code[0,i]:=code[0,j]; code[0,j]:=swap end;
    856   end;
    857 
    858   function ModelSortValue(const mi: TModelInfo; MixPlayers: boolean = false): integer;
    859   begin
    860   result:=(mi.Domain+1) shl 28 -mi.mix;
    861   if MixPlayers then dec(result, ModelCode(mi) shl 16);
     994    i, j, swap: integer;
     995  begin
     996    for i := 0 to Lines[0] - 2 do
     997      for j := i + 1 to Lines[0] - 1 do
     998        if CityName(MyCity[code[0, i]].ID) > CityName(MyCity[code[0, j]].ID)
     999        then
     1000        begin
     1001          swap := code[0, i];
     1002          code[0, i] := code[0, j];
     1003          code[0, j] := swap
     1004        end;
     1005  end;
     1006
     1007  function ModelSortValue(const mi: TModelInfo;
     1008    MixPlayers: boolean = false): integer;
     1009  begin
     1010    result := (mi.Domain + 1) shl 28 - mi.mix;
     1011    if MixPlayers then
     1012      dec(result, ModelCode(mi) shl 16);
    8621013  end;
    8631014
    8641015  procedure SortModels;
    8651016  var
    866   i,j,swap: integer;
     1017    i, j, swap: integer;
    8671018  begin // sort by code[2]
    868   for i:=0 to Lines[0]-2 do for j:=i+1 to Lines[0]-1 do
    869     if code[2,i]>code[2,j] then
    870       begin
    871       swap:=code[0,i]; code[0,i]:=code[0,j]; code[0,j]:=swap;
    872       swap:=code[1,i]; code[1,i]:=code[1,j]; code[1,j]:=swap;
    873       swap:=code[2,i]; code[2,i]:=code[2,j]; code[2,j]:=swap;
    874       end;
     1019    for i := 0 to Lines[0] - 2 do
     1020      for j := i + 1 to Lines[0] - 1 do
     1021        if code[2, i] > code[2, j] then
     1022        begin
     1023          swap := code[0, i];
     1024          code[0, i] := code[0, j];
     1025          code[0, j] := swap;
     1026          swap := code[1, i];
     1027          code[1, i] := code[1, j];
     1028          code[1, j] := swap;
     1029          swap := code[2, i];
     1030          code[2, i] := code[2, j];
     1031          code[2, j] := swap;
     1032        end;
    8751033  end;
    8761034
    8771035  procedure MarkPreqs(i: integer);
    8781036  begin
    879   required[i]:=1;
    880   if MyRO.Tech[i]<tsSeen then
     1037    required[i] := 1;
     1038    if MyRO.Tech[i] < tsSeen then
    8811039    begin
    882     if (AdvPreq[i,0]>=0) then MarkPreqs(AdvPreq[i,0]);
    883     if (AdvPreq[i,1]>=0) then MarkPreqs(AdvPreq[i,1]);
     1040      if (AdvPreq[i, 0] >= 0) then
     1041        MarkPreqs(AdvPreq[i, 0]);
     1042      if (AdvPreq[i, 1] >= 0) then
     1043        MarkPreqs(AdvPreq[i, 1]);
    8841044    end
    8851045  end;
    8861046
    8871047var
    888 Loc1,i,j,p1,dx,dy,mix,emix,EnemyType,TestEnemyType:integer;
    889 mi: TModelInfo;
    890 PPicture, PTestPicture: ^TModelPicture;
    891 ModelOk: array[0..4095] of boolean;
    892 ok: boolean;
    893 begin
    894 for i:=0 to MaxLayer-1 do
    895   begin Lines[i]:=0; FirstShrinkedLine[i]:=MaxInt end;
    896 case Kind of
    897   kProject:
    898     begin
    899     // improvements
    900     code[0,0]:=cpImp+imTrGoods;
    901     Lines[0]:=1;
    902     for i:=28 to nImp-1 do
    903       if Imp[i].Kind=ikCommon then
    904         TryAddImpLine(0,i+cpImp);
    905     for i:=28 to nImp-1 do
    906       if not (Imp[i].Kind in [ikCommon,ikTrGoods])
    907         and ((MyRO.NatBuilt[i]=0) or (Imp[i].Kind=ikNatLocal)) then
    908         TryAddImpLine(0,i+cpImp);
    909     for i:=0 to nCityType-1 do if MyData.ImpOrder[i,0]>=0 then
    910       begin code[0,Lines[0]]:=cpType+i; inc(Lines[0]); end;
    911 
    912     // wonders
    913     for i:=0 to 27 do
    914       TryAddImpLine(1,i+cpImp);
    915 
    916     // units
    917     for i:=0 to MyRO.nModel-1 do
    918       begin
    919 {      if MyModel[i].Kind=mkSlaves then
    920         ok:= MyRO.Wonder[woPyramids].EffectiveOwner=me
    921       else} if MyModel[i].Domain=dSea then
    922         begin
    923         ok:=false;
    924         for dx:=-2 to 2 do for dy:=-2 to 2 do if abs(dx)+abs(dy)=2 then
    925           begin
    926           Loc1:=dLoc(MyCity[cixProject].Loc,dx,dy);
    927           if (Loc1>=0) and (Loc1<G.lx*G.ly)
    928             and ((MyMap[Loc1] and fTerrain=fShore) or (MyMap[Loc1] and fCanal>0)) then
    929             ok:=true;
     1048  Loc1, i, j, p1, dx, dy, mix, emix, EnemyType, TestEnemyType: integer;
     1049  mi: TModelInfo;
     1050  PPicture, PTestPicture: ^TModelPicture;
     1051  ModelOk: array [0 .. 4095] of boolean;
     1052  ok: boolean;
     1053begin
     1054  for i := 0 to MaxLayer - 1 do
     1055  begin
     1056    Lines[i] := 0;
     1057    FirstShrinkedLine[i] := MaxInt
     1058  end;
     1059  case Kind of
     1060    kProject:
     1061      begin
     1062        // improvements
     1063        code[0, 0] := cpImp + imTrGoods;
     1064        Lines[0] := 1;
     1065        for i := 28 to nImp - 1 do
     1066          if Imp[i].Kind = ikCommon then
     1067            TryAddImpLine(0, i + cpImp);
     1068        for i := 28 to nImp - 1 do
     1069          if not(Imp[i].Kind in [ikCommon, ikTrGoods]) and
     1070            ((MyRO.NatBuilt[i] = 0) or (Imp[i].Kind = ikNatLocal)) then
     1071            TryAddImpLine(0, i + cpImp);
     1072        for i := 0 to nCityType - 1 do
     1073          if MyData.ImpOrder[i, 0] >= 0 then
     1074          begin
     1075            code[0, Lines[0]] := cpType + i;
     1076            inc(Lines[0]);
     1077          end;
     1078
     1079        // wonders
     1080        for i := 0 to 27 do
     1081          TryAddImpLine(1, i + cpImp);
     1082
     1083        // units
     1084        for i := 0 to MyRO.nModel - 1 do
     1085        begin
     1086          { if MyModel[i].Kind=mkSlaves then
     1087            ok:= MyRO.Wonder[woPyramids].EffectiveOwner=me
     1088            else } if MyModel[i].Domain = dSea then
     1089          begin
     1090            ok := false;
     1091            for dx := -2 to 2 do
     1092              for dy := -2 to 2 do
     1093                if abs(dx) + abs(dy) = 2 then
     1094                begin
     1095                  Loc1 := dLoc(MyCity[cixProject].Loc, dx, dy);
     1096                  if (Loc1 >= 0) and (Loc1 < G.lx * G.ly) and
     1097                    ((MyMap[Loc1] and fTerrain = fShore) or
     1098                    (MyMap[Loc1] and fCanal > 0)) then
     1099                    ok := true;
     1100                end
    9301101          end
     1102          else
     1103            ok := true;
     1104          if ok then
     1105          begin
     1106            if MyModel[i].Status and msObsolete = 0 then
     1107            begin
     1108              code[2, Lines[2]] := i;
     1109              inc(Lines[2])
     1110            end;
     1111            if MyModel[i].Status and msAllowConscripts <> 0 then
     1112            begin
     1113              code[2, Lines[2]] := i + cpConscripts;
     1114              inc(Lines[2])
     1115            end;
     1116          end;
     1117        end;
     1118        FirstShrinkedLine[2] := 0;
     1119      end;
     1120    kAdvance:
     1121      begin
     1122        nColumn := 1;
     1123        if MyData.FarTech <> adNone then
     1124        begin
     1125          FillChar(required, SizeOf(required), 0);
     1126          MarkPreqs(MyData.FarTech);
     1127        end;
     1128        for i := 0 to nAdv - 1 do
     1129          if ((i in FutureTech) or (MyRO.Tech[i] < tsApplicable)) and
     1130            (Server(sSetResearch - sExecute, me, i, nil^) >= rExecuted) and
     1131            ((MyData.FarTech = adNone) or (required[i] > 0)) then
     1132          begin
     1133            code[0, Lines[0]] := i;
     1134            inc(Lines[0]);
     1135          end;
     1136        SortTechs;
     1137        if Lines[0] = 0 then // no more techs -- offer nexus
     1138        begin
     1139          code[0, Lines[0]] := adNexus;
     1140          inc(Lines[0]);
     1141        end;
     1142        ok := false;
     1143        for i := 0 to nDomains - 1 do
     1144          if (upgrade[i, 0].Preq = preNone) or
     1145            (MyRO.Tech[upgrade[i, 0].Preq] >= tsApplicable) then
     1146            ok := true;
     1147        if ok then { new unit class }
     1148        begin
     1149          code[0, Lines[0]] := adMilitary;
     1150          inc(Lines[0])
     1151        end;
     1152      end;
     1153    kFarAdvance:
     1154      begin
     1155        code[0, Lines[0]] := adNone;
     1156        inc(Lines[0]);
     1157        for i := 0 to nAdv - 1 do
     1158          if not(i in FutureTech) and (MyRO.Tech[i] < tsApplicable) and
     1159            ((AdvValue[i] < 2000) or (MyRO.Tech[adMassProduction] > tsNA)) and
     1160            ((AdvValue[i] < 1000) or (MyRO.Tech[adScience] > tsNA)) then
     1161          begin
     1162            code[0, Lines[0]] := i;
     1163            inc(Lines[0]);
     1164          end;
     1165        SortTechs;
     1166      end;
     1167    kChooseTech:
     1168      begin
     1169        for i := 0 to nAdv - 1 do
     1170          if not(i in FutureTech) and (MyRO.Tech[i] >= tsApplicable) and
     1171            (MyRO.EnemyReport[DipMem[me].pContact].Tech[i] < tsSeen) then
     1172          begin
     1173            code[0, Lines[0]] := i;
     1174            inc(Lines[0]);
     1175          end;
     1176        SortTechs;
     1177        // if Lines[0]>1 then
     1178        begin
     1179          code[0, Lines[0]] := adAll;
     1180          inc(Lines[0]);
     1181        end;
     1182      end;
     1183    kChooseETech:
     1184      begin
     1185        for i := 0 to nAdv - 1 do
     1186          if not(i in FutureTech) and (MyRO.Tech[i] < tsSeen) and
     1187            (MyRO.EnemyReport[DipMem[me].pContact].Tech[i] >= tsApplicable) then
     1188          begin
     1189            code[0, Lines[0]] := i;
     1190            inc(Lines[0]);
     1191          end;
     1192        SortTechs;
     1193        // if Lines[0]>1 then
     1194        begin
     1195          code[0, Lines[0]] := adAll;
     1196          inc(Lines[0]);
     1197        end;
     1198      end;
     1199    kStealTech:
     1200      begin
     1201        for i := 0 to nAdv - 1 do
     1202          if Server(sStealTech - sExecute, me, i, nil^) >= rExecuted then
     1203          begin
     1204            code[0, Lines[0]] := i;
     1205            inc(Lines[0]);
     1206          end;
     1207        SortTechs;
     1208      end;
     1209    kScience:
     1210      begin
     1211        Column[0] := me;
     1212        nColumn := 1;
     1213        for EnemyType := 0 to 2 do
     1214          for p1 := 0 to nPl - 1 do
     1215            if (MyRO.EnemyReport[p1] <> nil) and
     1216              ((MyRO.EnemyReport[p1].TurnOfContact >= 0) or
     1217              (MyRO.EnemyReport[p1].TurnOfCivilReport >= 0)) then
     1218            begin
     1219              if MyRO.Alive and (1 shl p1) = 0 then
     1220                TestEnemyType := 2 // extinct enemy -- move to right end
     1221              else if MyRO.EnemyReport[p1].TurnOfCivilReport >= MyRO.Turn - 1
     1222              then
     1223                TestEnemyType := 0 // current report -- move to left end
     1224              else
     1225                TestEnemyType := 1;
     1226              if TestEnemyType = EnemyType then
     1227              begin
     1228                Column[nColumn] := p1;
     1229                inc(nColumn);
     1230              end;
     1231            end;
     1232        for i := 0 to nAdv - 1 do
     1233        begin
     1234          ok := (MyRO.Tech[i] <> tsNA) or (MyRO.ResearchTech = i);
     1235          for j := 1 to nColumn - 1 do
     1236            with MyRO.EnemyReport[Column[j]]^ do
     1237              if (Tech[i] <> tsNA) or (TurnOfCivilReport >= 0) and
     1238                (ResearchTech = i) then
     1239                ok := true;
     1240          if ok then
     1241          begin
     1242            code[0, Lines[0]] := i;
     1243            inc(Lines[0]);
     1244          end;
     1245        end;
     1246        SortTechs;
     1247
     1248        ok := MyRO.ResearchTech = adMilitary;
     1249        for j := 1 to nColumn - 1 do
     1250          with MyRO.EnemyReport[Column[j]]^ do
     1251            if (MyRO.Alive and (1 shl Column[j]) <> 0) and
     1252              (TurnOfCivilReport >= 0) and (ResearchTech = adMilitary) then
     1253              ok := true;
     1254        if ok then
     1255        begin
     1256          code[0, Lines[0]] := adMilitary;
     1257          inc(Lines[0]);
    9311258        end
    932       else ok:=true;
    933       if ok then
    934         begin
    935         if MyModel[i].Status and msObsolete=0 then
    936           begin code[2,Lines[2]]:=i; inc(Lines[2]) end;
    937         if MyModel[i].Status and msAllowConscripts<>0 then
    938           begin code[2,Lines[2]]:=i+cpConscripts; inc(Lines[2]) end;
    939         end;
    940       end;
    941     FirstShrinkedLine[2]:=0;
    942     end;
    943   kAdvance:
    944     begin
    945     nColumn:=1;
    946     if MyData.FarTech<>adNone then
    947       begin
    948       FillChar(required,SizeOf(required),0);
    949       MarkPreqs(MyData.FarTech);
    950       end;
    951     for i:=0 to nAdv-1 do
    952       if ((i in FutureTech) or (MyRO.Tech[i]<tsApplicable))
    953         and (Server(sSetResearch-sExecute,me,i,nil^)>=rExecuted)
    954         and ((MyData.FarTech=adNone) or (required[i]>0)) then
    955         begin code[0,Lines[0]]:=i; inc(Lines[0]); end;
    956     SortTechs;
    957     if Lines[0]=0 then // no more techs -- offer nexus
    958       begin code[0,Lines[0]]:=adNexus; inc(Lines[0]); end;
    959     ok:=false;
    960     for i:=0 to nDomains-1 do
    961       if (upgrade[i,0].Preq=preNone)
    962         or (MyRO.Tech[upgrade[i,0].Preq]>=tsApplicable) then
    963         ok:=true;
    964     if ok then {new unit class}
    965       begin code[0,Lines[0]]:=adMilitary; inc(Lines[0]) end;
    966     end;
    967   kFarAdvance:
    968     begin
    969     code[0,Lines[0]]:=adNone; inc(Lines[0]);
    970     for i:=0 to nAdv-1 do
    971       if not (i in FutureTech) and (MyRO.Tech[i]<tsApplicable)
    972         and ((AdvValue[i]<2000) or (MyRO.Tech[adMassProduction]>tsNA))
    973         and ((AdvValue[i]<1000) or (MyRO.Tech[adScience]>tsNA)) then
    974         begin code[0,Lines[0]]:=i; inc(Lines[0]); end;
    975     SortTechs;
    976     end;
    977   kChooseTech:
    978     begin
    979     for i:=0 to nAdv-1 do
    980       if not (i in FutureTech) and (MyRO.Tech[i]>=tsApplicable)
    981         and (MyRO.EnemyReport[DipMem[me].pContact].Tech[i]<tsSeen) then
    982         begin code[0,Lines[0]]:=i; inc(Lines[0]); end;
    983     SortTechs;
    984 //    if Lines[0]>1 then
    985       begin code[0,Lines[0]]:=adAll; inc(Lines[0]); end;
    986     end;
    987   kChooseETech:
    988     begin
    989     for i:=0 to nAdv-1 do
    990       if not (i in FutureTech) and (MyRO.Tech[i]<tsSeen)
    991         and (MyRO.EnemyReport[DipMem[me].pContact].Tech[i]>=tsApplicable) then
    992         begin code[0,Lines[0]]:=i; inc(Lines[0]); end;
    993     SortTechs;
    994 //    if Lines[0]>1 then
    995       begin code[0,Lines[0]]:=adAll; inc(Lines[0]); end;
    996     end;
    997   kStealTech:
    998     begin
    999     for i:=0 to nAdv-1 do
    1000       if Server(sStealTech-sExecute, me, i, nil^)>=rExecuted then
    1001         begin code[0,Lines[0]]:=i; inc(Lines[0]); end;
    1002     SortTechs;
    1003     end;
    1004   kScience:
    1005     begin
    1006     Column[0]:=me;
    1007     nColumn:=1;
    1008     for EnemyType:=0 to 2 do
    1009       for p1:=0 to nPl-1 do
    1010         if (MyRO.EnemyReport[p1]<>nil)
    1011           and ((MyRO.EnemyReport[p1].TurnOfContact>=0)
    1012             or (MyRO.EnemyReport[p1].TurnOfCivilReport>=0)) then
    1013           begin
    1014           if MyRO.Alive and (1 shl p1)=0 then
    1015             TestEnemyType:=2 // extinct enemy -- move to right end
    1016           else if MyRO.EnemyReport[p1].TurnOfCivilReport>=MyRO.Turn-1 then
    1017             TestEnemyType:=0 // current report -- move to left end
    1018           else TestEnemyType:=1;
    1019           if TestEnemyType=EnemyType then
    1020             begin Column[nColumn]:=p1; inc(nColumn); end;
    1021           end;
    1022     for i:=0 to nAdv-1 do
    1023       begin
    1024       ok:= (MyRO.Tech[i]<>tsNA) or (MyRO.ResearchTech=i);
    1025       for j:=1 to nColumn-1 do with MyRO.EnemyReport[Column[j]]^ do
    1026         if (Tech[i]<>tsNA) or (TurnOfCivilReport>=0) and (ResearchTech=i) then
    1027           ok:=true;
    1028       if ok then
    1029         begin code[0,Lines[0]]:=i; inc(Lines[0]); end;
    1030       end;
    1031     SortTechs;
    1032 
    1033     ok:= MyRO.ResearchTech=adMilitary;
    1034     for j:=1 to nColumn-1 do with MyRO.EnemyReport[Column[j]]^ do
    1035       if (MyRO.Alive and (1 shl Column[j])<>0)
    1036         and (TurnOfCivilReport>=0) and (ResearchTech=adMilitary) then
    1037         ok:=true;
    1038     if ok then
    1039       begin code[0,Lines[0]]:=adMilitary; inc(Lines[0]); end
    1040     end;
    1041   kCities{, kChooseCity}:
    1042     begin
    1043     if ClientMode<scContact then
    1044       for i:=0 to MyRO.nCity-1 do if MyCity[i].Loc>=0 then
    1045         begin code[0,Lines[0]]:=i; inc(Lines[0]) end;
    1046     SortCities;
    1047     FirstShrinkedLine[0]:=0
    1048     end;
    1049   kCityEvents:
    1050     begin
    1051     for i:=0 to MyRO.nCity-1 do
    1052       if (MyCity[i].Loc>=0) and (MyCity[i].Flags and CityRepMask<>0) then
    1053         begin code[0,Lines[0]]:=i; inc(Lines[0]) end;
    1054     SortCities;
    1055     FirstShrinkedLine[0]:=0
    1056     end;
    1057 {  kChooseECity:
    1058     begin
    1059     for i:=0 to MyRO.nEnemyCity-1 do
     1259      end;
     1260    kCities { , kChooseCity } :
     1261      begin
     1262        if ClientMode < scContact then
     1263          for i := 0 to MyRO.nCity - 1 do
     1264            if MyCity[i].Loc >= 0 then
     1265            begin
     1266              code[0, Lines[0]] := i;
     1267              inc(Lines[0])
     1268            end;
     1269        SortCities;
     1270        FirstShrinkedLine[0] := 0
     1271      end;
     1272    kCityEvents:
     1273      begin
     1274        for i := 0 to MyRO.nCity - 1 do
     1275          if (MyCity[i].Loc >= 0) and (MyCity[i].Flags and CityRepMask <> 0)
     1276          then
     1277          begin
     1278            code[0, Lines[0]] := i;
     1279            inc(Lines[0])
     1280          end;
     1281        SortCities;
     1282        FirstShrinkedLine[0] := 0
     1283      end;
     1284    { kChooseECity:
     1285      begin
     1286      for i:=0 to MyRO.nEnemyCity-1 do
    10601287      if (MyRO.EnemyCity[i].Loc>=0)
    1061         and (MyRO.EnemyCity[i].owner=DipMem[me].pContact) then
    1062         begin code[0,Lines[0]]:=i; inc(Lines[0]); end;
    1063     FirstShrinkedLine:=0
    1064     end;}
    1065   kModels:
    1066     begin
    1067     for mix:=0 to MyRO.nModel-1 do
    1068       begin
    1069       code[0,mix]:=mix;
    1070       MakeModelInfo(me, mix, MyModel[mix], mi);
    1071       code[2,mix]:=ModelSortValue(mi);
    1072       end;
    1073     Lines[0]:=MyRO.nModel;
    1074     SortModels;
    1075     FirstShrinkedLine[0]:=0
    1076     end;
    1077   kChooseModel:
    1078     begin
    1079     for mix:=3 to MyRO.nModel-1 do
    1080       begin // check if opponent already has this model
    1081       MakeModelInfo(me,mix,MyModel[mix],mi);
    1082       ok:=true;
    1083       for emix:=0 to MyRO.nEnemyModel-1 do
    1084          if (MyRO.EnemyModel[emix].Owner=DipMem[me].pContact)
    1085            and IsSameModel(MyRO.EnemyModel[emix],mi) then
    1086            ok:=false;
    1087       if ok then
    1088         begin
    1089         code[0,Lines[0]]:=mix;
    1090         MakeModelInfo(me, mix, MyModel[mix], mi);
    1091         code[2,Lines[0]]:=ModelSortValue(mi);
    1092         inc(Lines[0]);
    1093         end;
    1094       end;
    1095     SortModels;
    1096 //    if Lines[0]>1 then
    1097       begin code[0,Lines[0]]:=mixAll; inc(Lines[0]); end;
    1098     FirstShrinkedLine[0]:=0
    1099     end;
    1100   kChooseEModel:
    1101     begin
    1102     if MyRO.TestFlags and tfUncover<>0 then
    1103       Server(sGetModels,me,0,nil^);
    1104     for emix:=0 to MyRO.nEnemyModel-1 do
    1105       ModelOk[emix]:= MyRO.EnemyModel[emix].Owner=DipMem[me].pContact;
    1106     for mix:=0 to MyRO.nModel-1 do
    1107       begin // don't list models I already have
    1108       MakeModelInfo(me,mix,MyModel[mix],mi);
    1109       for emix:=0 to MyRO.nEnemyModel-1 do
    1110         ModelOk[emix]:=ModelOk[emix]
    1111           and not IsSameModel(MyRO.EnemyModel[emix],mi);
    1112       end;
    1113     for emix:=0 to MyRO.nEnemyModel-1 do if ModelOk[emix] then
    1114       begin
    1115       if Tribe[DipMem[me].pContact].ModelPicture[MyRO.EnemyModel[emix].mix].HGr=0 then
    1116         InitEnemyModel(emix);
    1117       code[0,Lines[0]]:=emix;
    1118       code[2,Lines[0]]:=ModelSortValue(MyRO.EnemyModel[emix]);
    1119       inc(Lines[0]);
    1120       end;
    1121     SortModels;
    1122 //    if not IsMilReportNew(DipMem[me].pContact) or (Lines[0]>1) then
    1123       begin code[0,Lines[0]]:=mixAll; inc(Lines[0]); end;
    1124     FirstShrinkedLine[0]:=0
    1125     end;
    1126   kEModels:
    1127     begin
    1128     for i:=0 to MyRO.EnemyReport[pView].nModelCounted-1 do
    1129       begin
    1130       code[1,Lines[0]]:=MyRO.nEnemyModel-1;
    1131       while (code[1,Lines[0]]>=0)
    1132         and not ((MyRO.EnemyModel[code[1,Lines[0]]].Owner=pView)
    1133         and (MyRO.EnemyModel[code[1,Lines[0]]].mix=i)) do
    1134         dec(code[1,Lines[0]]);
    1135       if Tribe[pView].ModelPicture[i].HGr=0 then
    1136         InitEnemyModel(code[1,Lines[0]]);
    1137       code[0,Lines[0]]:=i;
    1138       code[2,Lines[0]]:=ModelSortValue(MyRO.EnemyModel[code[1,Lines[0]]]);
    1139       inc(Lines[0]);
    1140       end;
    1141     SortModels;
    1142     FirstShrinkedLine[0]:=0
    1143     end;
    1144   kAllEModels:
    1145     begin
    1146     if (MyRO.TestFlags and tfUncover<>0) or (G.Difficulty[me]=0) then
    1147       Server(sGetModels,me,0,nil^);
    1148     for emix:=0 to MyRO.nEnemyModel-1 do
    1149       if (MyRO.EnemyModel[emix].mix>=3)
    1150         and (MyRO.EnemyModel[emix].Kind in [mkSelfDeveloped,mkEnemyDeveloped]) then
    1151         begin
    1152         PPicture:=@Tribe[MyRO.EnemyModel[emix].Owner].ModelPicture[MyRO.EnemyModel[emix].mix];
    1153         if PPicture.HGr=0 then InitEnemyModel(emix);
    1154         ok:=true;
    1155         if MainScreen.mNames.Checked then
    1156           for j:=0 to Lines[0]-1 do
     1288      and (MyRO.EnemyCity[i].owner=DipMem[me].pContact) then
     1289      begin code[0,Lines[0]]:=i; inc(Lines[0]); end;
     1290      FirstShrinkedLine:=0
     1291      end; }
     1292    kModels:
     1293      begin
     1294        for mix := 0 to MyRO.nModel - 1 do
     1295        begin
     1296          code[0, mix] := mix;
     1297          MakeModelInfo(me, mix, MyModel[mix], mi);
     1298          code[2, mix] := ModelSortValue(mi);
     1299        end;
     1300        Lines[0] := MyRO.nModel;
     1301        SortModels;
     1302        FirstShrinkedLine[0] := 0
     1303      end;
     1304    kChooseModel:
     1305      begin
     1306        for mix := 3 to MyRO.nModel - 1 do
     1307        begin // check if opponent already has this model
     1308          MakeModelInfo(me, mix, MyModel[mix], mi);
     1309          ok := true;
     1310          for emix := 0 to MyRO.nEnemyModel - 1 do
     1311            if (MyRO.EnemyModel[emix].Owner = DipMem[me].pContact) and
     1312              IsSameModel(MyRO.EnemyModel[emix], mi) then
     1313              ok := false;
     1314          if ok then
     1315          begin
     1316            code[0, Lines[0]] := mix;
     1317            MakeModelInfo(me, mix, MyModel[mix], mi);
     1318            code[2, Lines[0]] := ModelSortValue(mi);
     1319            inc(Lines[0]);
     1320          end;
     1321        end;
     1322        SortModels;
     1323        // if Lines[0]>1 then
     1324        begin
     1325          code[0, Lines[0]] := mixAll;
     1326          inc(Lines[0]);
     1327        end;
     1328        FirstShrinkedLine[0] := 0
     1329      end;
     1330    kChooseEModel:
     1331      begin
     1332        if MyRO.TestFlags and tfUncover <> 0 then
     1333          Server(sGetModels, me, 0, nil^);
     1334        for emix := 0 to MyRO.nEnemyModel - 1 do
     1335          ModelOk[emix] := MyRO.EnemyModel[emix].Owner = DipMem[me].pContact;
     1336        for mix := 0 to MyRO.nModel - 1 do
     1337        begin // don't list models I already have
     1338          MakeModelInfo(me, mix, MyModel[mix], mi);
     1339          for emix := 0 to MyRO.nEnemyModel - 1 do
     1340            ModelOk[emix] := ModelOk[emix] and
     1341              not IsSameModel(MyRO.EnemyModel[emix], mi);
     1342        end;
     1343        for emix := 0 to MyRO.nEnemyModel - 1 do
     1344          if ModelOk[emix] then
     1345          begin
     1346            if Tribe[DipMem[me].pContact].ModelPicture
     1347              [MyRO.EnemyModel[emix].mix].HGr = 0 then
     1348              InitEnemyModel(emix);
     1349            code[0, Lines[0]] := emix;
     1350            code[2, Lines[0]] := ModelSortValue(MyRO.EnemyModel[emix]);
     1351            inc(Lines[0]);
     1352          end;
     1353        SortModels;
     1354        // if not IsMilReportNew(DipMem[me].pContact) or (Lines[0]>1) then
     1355        begin
     1356          code[0, Lines[0]] := mixAll;
     1357          inc(Lines[0]);
     1358        end;
     1359        FirstShrinkedLine[0] := 0
     1360      end;
     1361    kEModels:
     1362      begin
     1363        for i := 0 to MyRO.EnemyReport[pView].nModelCounted - 1 do
     1364        begin
     1365          code[1, Lines[0]] := MyRO.nEnemyModel - 1;
     1366          while (code[1, Lines[0]] >= 0) and
     1367            not((MyRO.EnemyModel[code[1, Lines[0]]].Owner = pView) and
     1368            (MyRO.EnemyModel[code[1, Lines[0]]].mix = i)) do
     1369            dec(code[1, Lines[0]]);
     1370          if Tribe[pView].ModelPicture[i].HGr = 0 then
     1371            InitEnemyModel(code[1, Lines[0]]);
     1372          code[0, Lines[0]] := i;
     1373          code[2, Lines[0]] :=
     1374            ModelSortValue(MyRO.EnemyModel[code[1, Lines[0]]]);
     1375          inc(Lines[0]);
     1376        end;
     1377        SortModels;
     1378        FirstShrinkedLine[0] := 0
     1379      end;
     1380    kAllEModels:
     1381      begin
     1382        if (MyRO.TestFlags and tfUncover <> 0) or (G.Difficulty[me] = 0) then
     1383          Server(sGetModels, me, 0, nil^);
     1384        for emix := 0 to MyRO.nEnemyModel - 1 do
     1385          if (MyRO.EnemyModel[emix].mix >= 3) and
     1386            (MyRO.EnemyModel[emix].Kind in [mkSelfDeveloped, mkEnemyDeveloped])
     1387          then
     1388          begin
     1389            PPicture := @Tribe[MyRO.EnemyModel[emix].Owner].ModelPicture
     1390              [MyRO.EnemyModel[emix].mix];
     1391            if PPicture.HGr = 0 then
     1392              InitEnemyModel(emix);
     1393            ok := true;
     1394            if MainScreen.mNames.Checked then
     1395              for j := 0 to Lines[0] - 1 do
     1396              begin
     1397                PTestPicture := @Tribe[MyRO.EnemyModel[code[0, j]].Owner]
     1398                  .ModelPicture[MyRO.EnemyModel[code[0, j]].mix];
     1399                if (PPicture.HGr = PTestPicture.HGr) and
     1400                  (PPicture.pix = PTestPicture.pix) and
     1401                  (ModelHash(MyRO.EnemyModel[emix])
     1402                  = ModelHash(MyRO.EnemyModel[code[0, j]])) then
     1403                begin
     1404                  code[1, j] := 1;
     1405                  ok := false;
     1406                  Break
     1407                end;
     1408              end;
     1409            if ok then
    11571410            begin
    1158             PTestPicture:=@Tribe[MyRO.EnemyModel[code[0,j]].Owner].ModelPicture[MyRO.EnemyModel[code[0,j]].mix];
    1159             if (PPicture.HGr=PTestPicture.HGr) and (PPicture.pix=PTestPicture.pix)
    1160               and (ModelHash(MyRO.EnemyModel[emix])=ModelHash(MyRO.EnemyModel[code[0,j]])) then
    1161               begin code[1,j]:=1; ok:=false; Break end;
    1162             end;
    1163         if ok then
    1164           begin
    1165           code[0,Lines[0]]:=emix;
    1166           code[1,Lines[0]]:=0;
    1167           code[2,Lines[0]]:=ModelSortValue(MyRO.EnemyModel[emix],true);
    1168           inc(Lines[0]);
    1169           end
    1170         end;
    1171     SortModels;
    1172     FirstShrinkedLine[0]:=0
    1173     end;
    1174   kTribe:
    1175     for i:=0 to TribeNames.Count-1 do
    1176       begin code[0,Lines[0]]:=i; inc(Lines[0]) end;
    1177 (*  kDeliver:
    1178     if MyRO.Treaty[DipMem[me].pContact]<trAlliance then
     1411              code[0, Lines[0]] := emix;
     1412              code[1, Lines[0]] := 0;
     1413              code[2, Lines[0]] := ModelSortValue(MyRO.EnemyModel[emix], true);
     1414              inc(Lines[0]);
     1415            end
     1416          end;
     1417        SortModels;
     1418        FirstShrinkedLine[0] := 0
     1419      end;
     1420    kTribe:
     1421      for i := 0 to TribeNames.Count - 1 do
     1422      begin
     1423        code[0, Lines[0]] := i;
     1424        inc(Lines[0])
     1425      end;
     1426    (* kDeliver:
     1427      if MyRO.Treaty[DipMem[me].pContact]<trAlliance then
    11791428      begin // suggest next treaty level
    11801429      code[0,Lines[0]]:=opTreaty+MyRO.Treaty[DipMem[me].pContact]+1;
    11811430      inc(Lines[0]);
    11821431      end;
    1183     if MyRO.Treaty[DipMem[me].pContact]=trNone then
     1432      if MyRO.Treaty[DipMem[me].pContact]=trNone then
    11841433      begin // suggest peace
    11851434      code[0,Lines[0]]:=opTreaty+trPeace;
    11861435      inc(Lines[0]);
    11871436      end;
    1188     if MyRO.Treaty[DipMem[me].pContact]>trNone then
     1437      if MyRO.Treaty[DipMem[me].pContact]>trNone then
    11891438      begin // suggest next treaty level
    11901439      code[0,Lines[0]]:=opTreaty+MyRO.Treaty[DipMem[me].pContact]-1;
    11911440      inc(Lines[0]);
    1192       end;*)
    1193   kShipPart:
     1441      end; *)
     1442    kShipPart:
     1443      begin
     1444        Lines[0] := 0;
     1445        for i := 0 to nShipPart - 1 do
     1446          if MyRO.Ship[me].Parts[i] > 0 then
     1447          begin
     1448            code[0, Lines[0]] := i;
     1449            inc(Lines[0]);
     1450          end;
     1451      end;
     1452    kEShipPart:
     1453      begin
     1454        Lines[0] := 0;
     1455        for i := 0 to nShipPart - 1 do
     1456          if MyRO.Ship[DipMem[me].pContact].Parts[i] > 0 then
     1457          begin
     1458            code[0, Lines[0]] := i;
     1459            inc(Lines[0]);
     1460          end;
     1461      end;
     1462    kGov:
     1463      for i := 1 to nGov - 1 do
     1464        if (GovPreq[i] <> preNA) and
     1465          ((GovPreq[i] = preNone) or (MyRO.Tech[GovPreq[i]] >= tsApplicable))
     1466        then
     1467        begin
     1468          code[0, Lines[0]] := i;
     1469          inc(Lines[0])
     1470        end;
     1471    kMission:
     1472      for i := 0 to nSpyMission - 1 do
     1473      begin
     1474        code[0, Lines[0]] := i;
     1475        inc(Lines[0])
     1476      end;
     1477  end;
     1478
     1479  if Kind = kProject then // test if choice fitting to one screen
     1480    if Lines[0] + Lines[1] + Lines[2] <= MaxLines then
    11941481    begin
    1195     Lines[0]:=0;
    1196     for i:=0 to nShipPart-1 do
    1197       if MyRO.Ship[me].Parts[i]>0 then
    1198         begin code[0,Lines[0]]:=i; inc(Lines[0]); end;
    1199     end;
    1200   kEShipPart:
    1201     begin
    1202     Lines[0]:=0;
    1203     for i:=0 to nShipPart-1 do
    1204       if MyRO.Ship[DipMem[me].pContact].Parts[i]>0 then
    1205         begin code[0,Lines[0]]:=i; inc(Lines[0]); end;
    1206     end;
    1207   kGov:
    1208     for i:=1 to nGov-1 do
    1209       if (GovPreq[i]<>preNA) and ((GovPreq[i]=preNone)
    1210         or (MyRO.Tech[GovPreq[i]]>=tsApplicable)) then
    1211         begin code[0,Lines[0]]:=i; inc(Lines[0]) end;
    1212   kMission:
    1213     for i:=0 to nSpyMission-1 do
    1214       begin code[0,Lines[0]]:=i; inc(Lines[0]) end;
    1215   end;
    1216 
    1217 if Kind=kProject then // test if choice fitting to one screen
    1218   if Lines[0]+Lines[1]+Lines[2]<=MaxLines then
    1219     begin
    1220     for i:=0 to Lines[1]-1 do // add wonders to first page
    1221       begin code[0,Lines[0]]:=code[1,i]; inc(Lines[0]); end;
    1222     Lines[1]:=0;
    1223     FirstShrinkedLine[0]:=Lines[0];
    1224     for i:=0 to Lines[2]-1 do // add models to first page
    1225       begin code[0,Lines[0]]:=code[2,i]; inc(Lines[0]); end;
    1226     Lines[2]:=0;
     1482      for i := 0 to Lines[1] - 1 do // add wonders to first page
     1483      begin
     1484        code[0, Lines[0]] := code[1, i];
     1485        inc(Lines[0]);
     1486      end;
     1487      Lines[1] := 0;
     1488      FirstShrinkedLine[0] := Lines[0];
     1489      for i := 0 to Lines[2] - 1 do // add models to first page
     1490      begin
     1491        code[0, Lines[0]] := code[2, i];
     1492        inc(Lines[0]);
     1493      end;
     1494      Lines[2] := 0;
    12271495    end;
    12281496end; // InitLines
     
    12301498function TListDlg.OnlyChoice(TestKind: TListKind): integer;
    12311499begin
    1232 Kind:=TestKind;
    1233 InitLines;
    1234 if Lines[0]=0 then result:=-2
    1235 else if Lines[0]>1 then result:=-1
    1236 else result:=code[0,0];
     1500  Kind := TestKind;
     1501  InitLines;
     1502  if Lines[0] = 0 then
     1503    result := -2
     1504  else if Lines[0] > 1 then
     1505    result := -1
     1506  else
     1507    result := code[0, 0];
    12371508end;
    12381509
    12391510procedure TListDlg.FormShow(Sender: TObject);
    12401511var
    1241 i: integer;
    1242 begin
    1243 result:=-1;
    1244 Closable:=false;
    1245 
    1246 if Kind=kTribe then
    1247   begin
    1248   LineDistance:=21; // looks ugly with scrollbar
    1249   MaxLines:=(hMainTexture-(24+TitleHeight+NarrowFrame)) div LineDistance -1;
     1512  i: integer;
     1513begin
     1514  result := -1;
     1515  Closable := false;
     1516
     1517  if Kind = kTribe then
     1518  begin
     1519    LineDistance := 21; // looks ugly with scrollbar
     1520    MaxLines := (hMaintexture - (24 + TitleHeight + NarrowFrame))
     1521      div LineDistance - 1;
    12501522  end
    1251 else
    1252   begin
    1253   LineDistance:=24;
    1254   MaxLines:=(hMainTexture-(24+TitleHeight+WideFrame)) div LineDistance -1;
    1255   end;
    1256 InitLines;
    1257 
    1258 MultiPage:=false;
    1259 for i:=1 to MaxLayer-1 do if Lines[i]>0 then MultiPage:=true;
    1260 WideBottom:=MultiPage or (Kind=kScience)
    1261   or not Phrases2FallenBackToEnglish
    1262     and (Kind in [kProject,kAdvance,kFarAdvance]);
    1263 if (Kind=kAdvance) and (MyData.FarTech<>adNone)
    1264   or (Kind=kModels) or (Kind=kEModels) then
    1265   TitleHeight:=WideFrame+20
    1266 else TitleHeight:=WideFrame;
    1267 
    1268 DispLines:=Lines[0];
    1269 for i:=0 to MaxLayer-1 do if Lines[i]>DispLines then DispLines:=Lines[i];
    1270 if WideBottom then
    1271   begin
    1272   if DispLines>MaxLines then
    1273     DispLines:=MaxLines;
    1274   InnerHeight:=LineDistance*(DispLines+1)+24;
    1275   ClientHeight:=InnerHeight+TitleHeight+WideFrame
     1523  else
     1524  begin
     1525    LineDistance := 24;
     1526    MaxLines := (hMaintexture - (24 + TitleHeight + WideFrame))
     1527      div LineDistance - 1;
     1528  end;
     1529  InitLines;
     1530
     1531  MultiPage := false;
     1532  for i := 1 to MaxLayer - 1 do
     1533    if Lines[i] > 0 then
     1534      MultiPage := true;
     1535  WideBottom := MultiPage or (Kind = kScience) or
     1536    not Phrases2FallenBackToEnglish and
     1537    (Kind in [kProject, kAdvance, kFarAdvance]);
     1538  if (Kind = kAdvance) and (MyData.FarTech <> adNone) or (Kind = kModels) or
     1539    (Kind = kEModels) then
     1540    TitleHeight := WideFrame + 20
     1541  else
     1542    TitleHeight := WideFrame;
     1543
     1544  DispLines := Lines[0];
     1545  for i := 0 to MaxLayer - 1 do
     1546    if Lines[i] > DispLines then
     1547      DispLines := Lines[i];
     1548  if WideBottom then
     1549  begin
     1550    if DispLines > MaxLines then
     1551      DispLines := MaxLines;
     1552    InnerHeight := LineDistance * (DispLines + 1) + 24;
     1553    ClientHeight := InnerHeight + TitleHeight + WideFrame
    12761554  end
    1277 else
    1278   begin
    1279   if DispLines>MaxLines then
    1280     DispLines:=MaxLines;
    1281   InnerHeight:=LineDistance*(DispLines+1)+24;
    1282   ClientHeight:=InnerHeight+TitleHeight+NarrowFrame;
    1283   end;
    1284 assert(ClientHeight<=hMainTexture);
    1285 
    1286 TechNameSpace:=224;
    1287 case Kind of
    1288   kGov: InnerWidth:=272;
    1289   kCities, kCityEvents: InnerWidth:=640-18;
    1290   kTribe:
    1291     if Lines[0]>MaxLines then InnerWidth:=280+GetSystemMetrics(SM_CXVSCROLL)
    1292     else InnerWidth:=280;
    1293   kScience:
    1294     begin
    1295     InnerWidth:=104-33+15+8+TechNameSpace+24*nColumn+GetSystemMetrics(SM_CXVSCROLL);
    1296     if InnerWidth+2*SideFrame>640 then
    1297       begin
    1298       TechNameSpace:=TechNameSpace+640-InnerWidth-2*SideFrame;
    1299       InnerWidth:=640-2*SideFrame
    1300       end
    1301     end;
    1302   kAdvance,kFarAdvance:
    1303     InnerWidth:=104-33+15+8+TechNameSpace+24+GetSystemMetrics(SM_CXVSCROLL);
    1304   kChooseTech, kChooseETech, kStealTech:
    1305     InnerWidth:=104-33+15+8+TechNameSpace+GetSystemMetrics(SM_CXVSCROLL);
    1306   else InnerWidth:=363;
    1307   end;
    1308 ClientWidth:=InnerWidth+2*SideFrame;
    1309 
    1310 CloseBtn.Left:=ClientWidth-38;
    1311 CaptionLeft:=ToggleBtn.Left+ToggleBtn.Width;
    1312 CaptionRight:=CloseBtn.Left;
    1313 SetWindowPos(sb.h,0,SideFrame+InnerWidth-GetSystemMetrics(SM_CXVSCROLL),
    1314   TitleHeight,GetSystemMetrics(SM_CXVSCROLL),LineDistance*DispLines+48,
    1315   SWP_NOZORDER or SWP_NOREDRAW);
    1316 
    1317 if WindowMode=wmModal then
    1318   begin {center on screen}
    1319   if Kind=kTribe then
    1320     Left:=(Screen.Width-800)*3 div 8+130
    1321   else Left:=(Screen.Width-Width) div 2;
    1322   Top:=(Screen.Height-Height) div 2;
    1323   if Kind=kProject then
    1324     Top:=Top+48;
    1325   end;
    1326 
    1327 Layer0Btn.Visible:= MultiPage and (Lines[0]>0);
    1328 Layer1Btn.Visible:= MultiPage and (Lines[1]>0);
    1329 Layer2Btn.Visible:= MultiPage and (Lines[2]>0);
    1330 if Kind=kProject then
    1331   begin
    1332   Layer0Btn.Top:=ClientHeight-31;
    1333   Layer0Btn.Left:=ClientWidth div 2-(12+29);
    1334   Layer0Btn.Down:=true;
    1335   Layer1Btn.Top:=ClientHeight-31;
    1336   Layer1Btn.Left:=ClientWidth div 2-(12-29);
    1337   Layer1Btn.Down:=false;
    1338   Layer2Btn.Top:=ClientHeight-31;
    1339   Layer2Btn.Left:=ClientWidth div 2-12;
    1340   Layer2Btn.Down:=false;
    1341   end;
    1342 
    1343 Layer:=0;
    1344 Sel:=-2;
    1345 ScienceNation:=-1;
    1346 InitPVSB(sb,Lines[Layer]-1,DispLines);
    1347 
    1348 OffscreenPaint;
     1555  else
     1556  begin
     1557    if DispLines > MaxLines then
     1558      DispLines := MaxLines;
     1559    InnerHeight := LineDistance * (DispLines + 1) + 24;
     1560    ClientHeight := InnerHeight + TitleHeight + NarrowFrame;
     1561  end;
     1562  assert(ClientHeight <= hMaintexture);
     1563
     1564  TechNameSpace := 224;
     1565  case Kind of
     1566    kGov:
     1567      InnerWidth := 272;
     1568    kCities, kCityEvents:
     1569      InnerWidth := 640 - 18;
     1570    kTribe:
     1571      if Lines[0] > MaxLines then
     1572        InnerWidth := 280 + GetSystemMetrics(SM_CXVSCROLL)
     1573      else
     1574        InnerWidth := 280;
     1575    kScience:
     1576      begin
     1577        InnerWidth := 104 - 33 + 15 + 8 + TechNameSpace + 24 * nColumn +
     1578          GetSystemMetrics(SM_CXVSCROLL);
     1579        if InnerWidth + 2 * SideFrame > 640 then
     1580        begin
     1581          TechNameSpace := TechNameSpace + 640 - InnerWidth - 2 * SideFrame;
     1582          InnerWidth := 640 - 2 * SideFrame
     1583        end
     1584      end;
     1585    kAdvance, kFarAdvance:
     1586      InnerWidth := 104 - 33 + 15 + 8 + TechNameSpace + 24 +
     1587        GetSystemMetrics(SM_CXVSCROLL);
     1588    kChooseTech, kChooseETech, kStealTech:
     1589      InnerWidth := 104 - 33 + 15 + 8 + TechNameSpace +
     1590        GetSystemMetrics(SM_CXVSCROLL);
     1591  else
     1592    InnerWidth := 363;
     1593  end;
     1594  ClientWidth := InnerWidth + 2 * SideFrame;
     1595
     1596  CloseBtn.Left := ClientWidth - 38;
     1597  CaptionLeft := ToggleBtn.Left + ToggleBtn.Width;
     1598  CaptionRight := CloseBtn.Left;
     1599  SetWindowPos(sb.h, 0, SideFrame + InnerWidth - GetSystemMetrics(SM_CXVSCROLL),
     1600    TitleHeight, GetSystemMetrics(SM_CXVSCROLL), LineDistance * DispLines + 48,
     1601    SWP_NOZORDER or SWP_NOREDRAW);
     1602
     1603  if WindowMode = wmModal then
     1604  begin { center on screen }
     1605    if Kind = kTribe then
     1606      Left := (Screen.Width - 800) * 3 div 8 + 130
     1607    else
     1608      Left := (Screen.Width - Width) div 2;
     1609    Top := (Screen.Height - Height) div 2;
     1610    if Kind = kProject then
     1611      Top := Top + 48;
     1612  end;
     1613
     1614  Layer0Btn.Visible := MultiPage and (Lines[0] > 0);
     1615  Layer1Btn.Visible := MultiPage and (Lines[1] > 0);
     1616  Layer2Btn.Visible := MultiPage and (Lines[2] > 0);
     1617  if Kind = kProject then
     1618  begin
     1619    Layer0Btn.Top := ClientHeight - 31;
     1620    Layer0Btn.Left := ClientWidth div 2 - (12 + 29);
     1621    Layer0Btn.Down := true;
     1622    Layer1Btn.Top := ClientHeight - 31;
     1623    Layer1Btn.Left := ClientWidth div 2 - (12 - 29);
     1624    Layer1Btn.Down := false;
     1625    Layer2Btn.Top := ClientHeight - 31;
     1626    Layer2Btn.Left := ClientWidth div 2 - 12;
     1627    Layer2Btn.Down := false;
     1628  end;
     1629
     1630  Layer := 0;
     1631  Sel := -2;
     1632  ScienceNation := -1;
     1633  InitPVSB(sb, Lines[Layer] - 1, DispLines);
     1634
     1635  OffscreenPaint;
    13491636end;
    13501637
    13511638procedure TListDlg.ShowNewContent(NewMode: integer; ListKind: TListKind);
    13521639var
    1353 i: integer;
    1354 ShowFocus, forceclose: boolean;
    1355 begin
    1356 forceclose:= (ListKind<>Kind)
    1357   and not ((Kind=kCities) and (ListKind=kCityEvents))
    1358   and not ((Kind=kCityEvents) and (ListKind=kCities))
    1359   and not ((Kind=kModels) and (ListKind=kEModels))
    1360   and not ((Kind=kEModels) and (ListKind=kModels));
    1361 
    1362 Kind:=ListKind;
    1363 ModalIndication:= not (Kind in MustChooseKind);
    1364 case Kind of
    1365   kProject: Caption:=Phrases.Lookup('TITLE_PROJECT');
    1366   kAdvance: Caption:=Phrases.Lookup('TITLE_TECHSELECT');
    1367   kFarAdvance: Caption:=Phrases.Lookup('TITLE_FARTECH');
    1368   kModels, kEModels: Caption:=Phrases.Lookup('FRMILREP');
    1369   kAllEModels: Caption:=Phrases.Lookup('TITLE_EMODELS');
    1370   kTribe: Caption:=Phrases.Lookup('TITLE_TRIBE');
    1371   kScience: Caption:=Phrases.Lookup('TITLE_SCIENCE');
    1372   kShipPart, kEShipPart: Caption:=Phrases.Lookup('TITLE_CHOOSESHIPPART');
    1373   kChooseTech, kChooseETech: Caption:=Phrases.Lookup('TITLE_CHOOSETECH');
    1374   kChooseModel, kChooseEModel: Caption:=Phrases.Lookup('TITLE_CHOOSEMODEL');
    1375   kStealTech: Caption:=Phrases.Lookup('TITLE_CHOOSETECH');
    1376   kGov: Caption:=Phrases.Lookup('TITLE_GOV');
    1377   kMission: Caption:=Phrases.Lookup('TITLE_SPYMISSION');
    1378   end;
    1379 
    1380 case Kind of
    1381   kMission: HelpContext:='SPYMISSIONS';
    1382   else HelpContext:='CONCEPTS'
    1383   end;
    1384 
    1385 if Kind=kAdvance then
    1386   begin
    1387   ToggleBtn.ButtonIndex:=13;
    1388   ToggleBtn.Hint:=Phrases.Lookup('FARTECH')
     1640  i: integer;
     1641  ShowFocus, forceclose: boolean;
     1642begin
     1643  forceclose := (ListKind <> Kind) and
     1644    not((Kind = kCities) and (ListKind = kCityEvents)) and
     1645    not((Kind = kCityEvents) and (ListKind = kCities)) and
     1646    not((Kind = kModels) and (ListKind = kEModels)) and
     1647    not((Kind = kEModels) and (ListKind = kModels));
     1648
     1649  Kind := ListKind;
     1650  ModalIndication := not(Kind in MustChooseKind);
     1651  case Kind of
     1652    kProject:
     1653      Caption := Phrases.Lookup('TITLE_PROJECT');
     1654    kAdvance:
     1655      Caption := Phrases.Lookup('TITLE_TECHSELECT');
     1656    kFarAdvance:
     1657      Caption := Phrases.Lookup('TITLE_FARTECH');
     1658    kModels, kEModels:
     1659      Caption := Phrases.Lookup('FRMILREP');
     1660    kAllEModels:
     1661      Caption := Phrases.Lookup('TITLE_EMODELS');
     1662    kTribe:
     1663      Caption := Phrases.Lookup('TITLE_TRIBE');
     1664    kScience:
     1665      Caption := Phrases.Lookup('TITLE_SCIENCE');
     1666    kShipPart, kEShipPart:
     1667      Caption := Phrases.Lookup('TITLE_CHOOSESHIPPART');
     1668    kChooseTech, kChooseETech:
     1669      Caption := Phrases.Lookup('TITLE_CHOOSETECH');
     1670    kChooseModel, kChooseEModel:
     1671      Caption := Phrases.Lookup('TITLE_CHOOSEMODEL');
     1672    kStealTech:
     1673      Caption := Phrases.Lookup('TITLE_CHOOSETECH');
     1674    kGov:
     1675      Caption := Phrases.Lookup('TITLE_GOV');
     1676    kMission:
     1677      Caption := Phrases.Lookup('TITLE_SPYMISSION');
     1678  end;
     1679
     1680  case Kind of
     1681    kMission:
     1682      HelpContext := 'SPYMISSIONS';
     1683  else
     1684    HelpContext := 'CONCEPTS'
     1685  end;
     1686
     1687  if Kind = kAdvance then
     1688  begin
     1689    ToggleBtn.ButtonIndex := 13;
     1690    ToggleBtn.Hint := Phrases.Lookup('FARTECH')
    13891691  end
    1390 else if Kind=kCities then
    1391   begin
    1392   ToggleBtn.ButtonIndex:=15;
    1393   ToggleBtn.Hint:=Phrases.Lookup('BTN_PAGE')
     1692  else if Kind = kCities then
     1693  begin
     1694    ToggleBtn.ButtonIndex := 15;
     1695    ToggleBtn.Hint := Phrases.Lookup('BTN_PAGE')
    13941696  end
    1395 else
    1396   begin
    1397   ToggleBtn.ButtonIndex:=28;
    1398   ToggleBtn.Hint:=Phrases.Lookup('BTN_SELECT')
    1399   end;
    1400 
    1401 if Kind=kAdvance then // show focus button?
    1402   if MyData.FarTech<>adNone then
    1403     ShowFocus:=true
    14041697  else
     1698  begin
     1699    ToggleBtn.ButtonIndex := 28;
     1700    ToggleBtn.Hint := Phrases.Lookup('BTN_SELECT')
     1701  end;
     1702
     1703  if Kind = kAdvance then // show focus button?
     1704    if MyData.FarTech <> adNone then
     1705      ShowFocus := true
     1706    else
    14051707    begin
    1406     ShowFocus:=false;
    1407     for i:=0 to nAdv-1 do
    1408       if not (i in FutureTech) and (MyRO.Tech[i]<tsApplicable)
    1409         and ((AdvValue[i]<2000) or (MyRO.Tech[adMassProduction]>tsNA))
    1410         and ((AdvValue[i]<1000) or (MyRO.Tech[adScience]>tsNA))
    1411         and (Server(sSetResearch-sExecute,me,i,nil^)<rExecuted) then
    1412         ShowFocus:=true;
     1708      ShowFocus := false;
     1709      for i := 0 to nAdv - 1 do
     1710        if not(i in FutureTech) and (MyRO.Tech[i] < tsApplicable) and
     1711          ((AdvValue[i] < 2000) or (MyRO.Tech[adMassProduction] > tsNA)) and
     1712          ((AdvValue[i] < 1000) or (MyRO.Tech[adScience] > tsNA)) and
     1713          (Server(sSetResearch - sExecute, me, i, nil^) < rExecuted) then
     1714          ShowFocus := true;
    14131715    end;
    1414 ToggleBtn.Visible:= (Kind=kCities) and not supervising
    1415   or (Kind=kAdvance) and ShowFocus
    1416   or (Kind=kModels)
    1417   or (Kind=kEModels);
    1418 CloseBtn.Visible:= not(Kind in MustChooseKind);
    1419 
    1420 inherited ShowNewContent(NewMode, forceclose);
     1716  ToggleBtn.Visible := (Kind = kCities) and not supervising or (Kind = kAdvance)
     1717    and ShowFocus or (Kind = kModels) or (Kind = kEModels);
     1718  CloseBtn.Visible := not(Kind in MustChooseKind);
     1719
     1720  inherited ShowNewContent(NewMode, forceclose);
    14211721end; // ShowNewContent
    14221722
    14231723procedure TListDlg.ShowNewContent_CityProject(NewMode, cix: integer);
    14241724begin
    1425 cixProject:=cix;
    1426 ShowNewContent(NewMode, kProject);
     1725  cixProject := cix;
     1726  ShowNewContent(NewMode, kProject);
    14271727end;
    14281728
    14291729procedure TListDlg.ShowNewContent_MilReport(NewMode, p: integer);
    14301730begin
    1431 pView:=p;
    1432 if p=me then ShowNewContent(NewMode, kModels)
    1433 else ShowNewContent(NewMode, kEModels)
     1731  pView := p;
     1732  if p = me then
     1733    ShowNewContent(NewMode, kModels)
     1734  else
     1735    ShowNewContent(NewMode, kEModels)
    14341736end;
    14351737
    14361738procedure TListDlg.PlayerClick(Sender: TObject);
    14371739begin
    1438 if TComponent(Sender).Tag=me then Kind:=kModels
    1439 else
    1440   begin
    1441   Kind:=kEModels;
    1442   pView:=TComponent(Sender).Tag;
    1443   end;
    1444 InitLines;
    1445 Sel:=-2;
    1446 InitPVSB(sb,Lines[Layer]-1,DispLines);
    1447 OffscreenPaint;
    1448 Invalidate
     1740  if TComponent(Sender).Tag = me then
     1741    Kind := kModels
     1742  else
     1743  begin
     1744    Kind := kEModels;
     1745    pView := TComponent(Sender).Tag;
     1746  end;
     1747  InitLines;
     1748  Sel := -2;
     1749  InitPVSB(sb, Lines[Layer] - 1, DispLines);
     1750  OffscreenPaint;
     1751  Invalidate
    14491752end;
    14501753
    14511754procedure TListDlg.ModeBtnClick(Sender: TObject);
    14521755begin
    1453 Layer0Btn.Down:= Sender=Layer0Btn;
    1454 Layer1Btn.Down:= Sender=Layer1Btn;
    1455 Layer2Btn.Down:= Sender=Layer2Btn;
    1456 Layer:=TComponent(Sender).Tag;
    1457 
    1458 Sel:=-2;
    1459 InitPVSB(sb,Lines[Layer]-1,DispLines);
    1460 SmartUpdateContent
     1756  Layer0Btn.Down := Sender = Layer0Btn;
     1757  Layer1Btn.Down := Sender = Layer1Btn;
     1758  Layer2Btn.Down := Sender = Layer2Btn;
     1759  Layer := TComponent(Sender).Tag;
     1760
     1761  Sel := -2;
     1762  InitPVSB(sb, Lines[Layer] - 1, DispLines);
     1763  SmartUpdateContent
    14611764end;
    14621765
    14631766procedure TListDlg.ToggleBtnClick(Sender: TObject);
    14641767var
    1465 p1: integer;
    1466 m: TMenuItem;
    1467 begin
    1468 case Kind of
    1469   kAdvance:
    1470     begin
    1471     result:=adFar;
    1472     Closable:=true;
    1473     Close
    1474     end;
    1475   kCities, kCityEvents:
    1476     begin
    1477     if Kind=kCities then Kind:=kCityEvents
    1478     else Kind:=kCities;
    1479     OffscreenPaint;
    1480     Invalidate;
    1481     end;
    1482   kModels, kEModels:
    1483     begin
    1484     EmptyMenu(Popup.Items);
    1485     if G.Difficulty[me]>0 then
    1486       begin
    1487       m:=TMenuItem.Create(Popup);
    1488       m.RadioItem:=true;
    1489       m.Caption:=Tribe[me].TPhrase('SHORTNAME');
    1490       m.Tag:=me;
    1491       m.OnClick:=PlayerClick;
    1492       if Kind=kModels then m.Checked:=true;
    1493       Popup.Items.Add(m);
    1494       end;
    1495     for p1:=0 to nPl-1 do
    1496       if (p1<>me) and (MyRO.EnemyReport[p1]<>nil)
    1497         and (MyRO.EnemyReport[p1].TurnOfMilReport>=0) then
    1498         begin
    1499         m:=TMenuItem.Create(Popup);
    1500         m.RadioItem:=true;
    1501         m.Caption:=Tribe[p1].TPhrase('SHORTNAME');
    1502         m.Tag:=p1;
    1503         m.OnClick:=PlayerClick;
    1504         if (Kind=kEModels) and (p1=pView) then m.Checked:=true;
    1505         Popup.Items.Add(m);
    1506         end;
    1507     Popup.Popup(Left+ToggleBtn.Left, Top+ToggleBtn.Top+ToggleBtn.Height);
    1508     end
     1768  p1: integer;
     1769  m: TMenuItem;
     1770begin
     1771  case Kind of
     1772    kAdvance:
     1773      begin
     1774        result := adFar;
     1775        Closable := true;
     1776        Close
     1777      end;
     1778    kCities, kCityEvents:
     1779      begin
     1780        if Kind = kCities then
     1781          Kind := kCityEvents
     1782        else
     1783          Kind := kCities;
     1784        OffscreenPaint;
     1785        Invalidate;
     1786      end;
     1787    kModels, kEModels:
     1788      begin
     1789        EmptyMenu(Popup.Items);
     1790        if G.Difficulty[me] > 0 then
     1791        begin
     1792          m := TMenuItem.Create(Popup);
     1793          m.RadioItem := true;
     1794          m.Caption := Tribe[me].TPhrase('SHORTNAME');
     1795          m.Tag := me;
     1796          m.OnClick := PlayerClick;
     1797          if Kind = kModels then
     1798            m.Checked := true;
     1799          Popup.Items.Add(m);
     1800        end;
     1801        for p1 := 0 to nPl - 1 do
     1802          if (p1 <> me) and (MyRO.EnemyReport[p1] <> nil) and
     1803            (MyRO.EnemyReport[p1].TurnOfMilReport >= 0) then
     1804          begin
     1805            m := TMenuItem.Create(Popup);
     1806            m.RadioItem := true;
     1807            m.Caption := Tribe[p1].TPhrase('SHORTNAME');
     1808            m.Tag := p1;
     1809            m.OnClick := PlayerClick;
     1810            if (Kind = kEModels) and (p1 = pView) then
     1811              m.Checked := true;
     1812            Popup.Items.Add(m);
     1813          end;
     1814        Popup.Popup(Left + ToggleBtn.Left, Top + ToggleBtn.Top +
     1815          ToggleBtn.Height);
     1816      end
    15091817  end
    15101818end;
     
    15131821  Shift: TShiftState);
    15141822begin
    1515 if (Key=VK_F2) and (Kind in [kModels,kEModels]) then // my key
    1516   // !!! toggle
    1517 else if (Key=VK_F3) and (Kind in [kCities,kCityEvents]) then // my key
    1518   ToggleBtnClick(nil)
    1519 else if ((Key=VK_ESCAPE) or (Key=VK_RETURN)) and not CloseBtn.Visible then // prevent closing
    1520 else inherited
     1823  if (Key = VK_F2) and (Kind in [kModels, kEModels]) then // my key
     1824    // !!! toggle
     1825  else if (Key = VK_F3) and (Kind in [kCities, kCityEvents]) then // my key
     1826    ToggleBtnClick(nil)
     1827  else if ((Key = VK_ESCAPE) or (Key = VK_RETURN)) and not CloseBtn.Visible then
     1828  // prevent closing
     1829  else
     1830    inherited
    15211831end;
    15221832
    15231833procedure TListDlg.EcoChange;
    15241834begin
    1525 if Visible and (Kind=kCities) then SmartUpdateContent
     1835  if Visible and (Kind = kCities) then
     1836    SmartUpdateContent
    15261837end;
    15271838
    15281839procedure TListDlg.TechChange;
    15291840begin
    1530 if Visible and (Kind=kScience) then
    1531   begin
    1532   FormShow(nil);
    1533   Invalidate;
     1841  if Visible and (Kind = kScience) then
     1842  begin
     1843    FormShow(nil);
     1844    Invalidate;
    15341845  end;
    15351846end;
     
    15371848procedure TListDlg.AddCity;
    15381849begin
    1539 if Visible and (Kind=kCities) then
    1540   begin
    1541   FormShow(nil);
    1542   Invalidate;
     1850  if Visible and (Kind = kCities) then
     1851  begin
     1852    FormShow(nil);
     1853    Invalidate;
    15431854  end;
    15441855end;
     
    15461857procedure TListDlg.RemoveUnit;
    15471858begin
    1548 if ListDlg.Visible and (Kind=kModels) then
    1549   SmartUpdateContent;
     1859  if ListDlg.Visible and (Kind = kModels) then
     1860    SmartUpdateContent;
    15501861end;
    15511862
    15521863end.
    1553 
Note: See TracChangeset for help on using the changeset viewer.