Changeset 210


Ignore:
Timestamp:
May 9, 2020, 4:02:07 PM (18 months ago)
Author:
chronos
Message:
  • Modified: Improved HighDPI branch. Imported new changes from trunk branch.
Location:
branches/highdpi
Files:
47 added
73 edited
1 moved

Legend:

Unmodified
Added
Removed
  • branches/highdpi/Back.lfm

    r178 r210  
    11object Background: TBackground
    22  Left = 581
    3   Height = 258
     3  Height = 172
    44  Top = 638
    5   Width = 303
     5  Width = 202
    66  BorderIcons = []
    77  BorderStyle = bsNone
    88  Caption = 'C-evo'
    99  Color = clBlack
    10   DesignTimePPI = 144
    1110  Font.Color = clWindowText
    12   Font.Height = -20
     11  Font.Height = -13
    1312  Font.Name = 'MS Sans Serif'
    1413  OnClose = FormClose
     
    1716  OnPaint = FormPaint
    1817  OnShow = FormShow
    19   LCLVersion = '2.0.2.0'
     18  LCLVersion = '1.6.2.0'
    2019  WindowState = wsMaximized
    2120end
  • branches/highdpi/Back.pas

    r193 r210  
    55
    66uses
    7   LCLIntf, LCLType, SysUtils, Classes, Graphics, Forms, Controls, UDpiControls;
     7  UDpiControls, LCLIntf, LCLType, SysUtils, Classes, Graphics, Forms, Controls;
    88
    99type
     
    1111  { TBackground }
    1212
    13   TBackground = class(TForm)
     13  TBackground = class(TDpiForm)
    1414    procedure FormDestroy(Sender: TObject);
    1515    procedure FormPaint(Sender: TObject);
     
    1919  private
    2020    Img: TDpiBitmap;
     21  public
     22    procedure UpdateInterface;
    2123  end;
    2224
     
    3739
    3840procedure TBackground.FormShow(Sender: TObject);
     41begin
     42  UpdateInterface;
     43end;
     44
     45procedure TBackground.FormDestroy(Sender: TObject);
     46begin
     47  if Assigned(Img) then FreeAndNil(Img);
     48end;
     49
     50procedure TBackground.FormPaint(Sender: TObject);
     51begin
     52  if Assigned(Img) then
     53    DpiBitCanvas(Canvas, DpiScreen.Width - Img.Width - (DpiScreen.Width - 800) *
     54      3 div 8, (DpiScreen.Height - 600) div 3, Img.Width, Img.Height,
     55      Img.Canvas, 0, 0);
     56end;
     57
     58procedure TBackground.FormClose(Sender: TObject; var Action: TCloseAction);
     59begin
     60end;
     61
     62procedure TBackground.UpdateInterface;
    3963var
    4064  FileName: string;
    4165begin
    4266  if FullScreen then begin
     67    WindowState := wsMaximized;
    4368    if not Assigned(Img) then begin
    44       FileName := HomeDir + 'Graphics' + DirectorySeparator + 'Background.png';
     69      FileName := GetGraphicsDir + DirectorySeparator + 'Background.png';
    4570      if FileExists(FileName) then begin
    4671        Img := TDpiBitmap.Create;
     
    5782end;
    5883
    59 procedure TBackground.FormDestroy(Sender: TObject);
    60 begin
    61   if Assigned(Img) then FreeAndNil(Img);
    62 end;
    63 
    64 procedure TBackground.FormPaint(Sender: TObject);
    65 begin
    66   if Assigned(Img) then
    67     DpiBitBlt(Canvas.Handle, DpiScreen.Width - Img.Width - (DpiScreen.Width - 800) *
    68       3 div 8, (DpiScreen.Height - 600) div 3, Img.Width, Img.Height,
    69       Img.Canvas.Handle, 0, 0, SRCCOPY);
    70 end;
    71 
    72 procedure TBackground.FormClose(Sender: TObject; var Action: TCloseAction);
    73 begin
    74 end;
    75 
    7684end.
  • branches/highdpi/CityProcessing.pas

    r38 r210  
    630630  TileInfo: TTileInfo;
    631631begin
     632  BestDist := MaxInt;
    632633{$IFOPT O-}assert(1 shl p and InvalidTreatyMap = 0); {$ENDIF}
    633634  Best := 0;
     
    660661              result := Loc1;
    661662              Best := Resources;
    662               BestDist := Dist
    663             end
    664           end
    665         end
    666       end;
    667   end
     663              BestDist := Dist;
     664            end;
     665          end;
     666        end;
     667      end;
     668  end;
    668669end;
    669670
  • branches/highdpi/Database.pas

    r144 r210  
    1111const
    1212  // additional test flags
    13   FastContact = false; { extra small world with railroad everywhere }
     13  //{$DEFINE FastContact} { extra small world with railroad everywhere }
    1414
    1515  neumax = 4096;
     
    957957    end;
    958958    if (RealMap[Loc] xor Cardinal(OldTile)) and fTerrain <> 0 then
    959       result := true
     959      result := true;
    960960  end;
    961961end;
     
    991991    begin
    992992      z0 := 6 * y div ly;
    993       ZPlus := 6 * y / ly - z0
     993      ZPlus := 6 * y / ly - z0;
    994994    end
    995995    else
    996996    begin
    997997      z0 := 6 * (ly - 1 - y) div ly;
    998       ZPlus := 6 * (ly - 1 - y) / ly - z0
     998      ZPlus := 6 * (ly - 1 - y) / ly - z0;
    999999    end;
    10001000    p0 := 1;
     
    10061006      begin
    10071007        RndLow := i;
    1008         Break
    1009       end;
    1010       p0 := p0 - p
     1008        Break;
     1009      end;
     1010      p0 := p0 - p;
    10111011    end;
    10121012  end;
     
    10531053            Cost := 0;
    10541054          if Q.Put(Loc1, T + Cost shl 8 + 1) then
    1055             From[Loc1] := Loc
    1056         end
    1057       end
     1055            From[Loc1] := Loc;
     1056        end;
     1057      end;
    10581058    end;
    10591059    Loc1 := Loc;
     
    10751075        else if RealMap[Loc] and fTerrain >= fGrass then
    10761076          RealMap[Loc] := RealMap[Loc] or fRiver;
    1077       end
     1077      end;
    10781078    end
    10791079    else
    10801080      result := 0;
    1081     Q.Free
     1081    Q.Free;
    10821082  end;
    10831083
     
    14041404            CityLoc[c, nCityLoc[c]] := Loc;
    14051405            inc(nCityLoc[c])
    1406           end
    1407         end
     1406          end;
     1407        end;
    14081408      end;
    14091409      Loc := (Loc + 1) * primitive mod (MapSize + 1) - 1;
     
    15371537      IrrLoc[j] := IrrLoc[nIrrLoc - 1];
    15381538      dec(nIrrLoc);
    1539       dec(i)
     1539      dec(i);
    15401540    end;
    15411541  end;
     
    15901590            StartLoc2[p1] := Loc1;
    15911591        end;
    1592       end
     1592      end;
    15931593    end;
    15941594end; { StartPositions }
     
    16571657  i, p, p1, uix, Loc1: integer;
    16581658begin
    1659   if FastContact then { Railroad everywhere }
     1659  {$IFDEF FastContact}
     1660    { Railroad everywhere }
    16601661    for Loc1 := 0 to MapSize - 1 do
    16611662      if RealMap[Loc1] and fTerrain >= fGrass then
    16621663        RealMap[Loc1] := RealMap[Loc1] or fRR;
     1664  {$ENDIF}
    16631665
    16641666  { !!!for Loc1:=0 to MapSize-1 do
     
    17951797  StartPositions;
    17961798  InitGame;
    1797 end; { InitRandomGame }
     1799end;
    17981800
    17991801procedure InitMapGame(Human: integer);
     
    18031805  PredefinedStartPositions(Human);
    18041806  InitGame;
    1805 end; { InitMapGame }
     1807end;
    18061808
    18071809procedure ReleaseGame;
     
    18241826      FreeMem(RW[p1].MapObservedLast);
    18251827      FreeMem(RW[p1].Map);
    1826     end
     1828    end;
    18271829end;
    18281830
     
    19441946      begin
    19451947        result := eNoPreq;
    1946         exit
     1948        exit;
    19471949      end;
    19481950    end;
     
    19581960    begin
    19591961      result := eInvalid;
    1960       exit
     1962      exit;
    19611963    end; // no city found here
    19621964
     
    21142116          Det := TestDet;
    21152117          Cost := TestCost;
    2116         end
    2117       end
    2118     end
     2118        end;
     2119      end;
     2120    end;
    21192121  end;
    21202122end;
     
    21782180                UnitReport.ReportFlags := UnitReport.ReportFlags or urfDeployed;
    21792181          end;
    2180         end
     2182        end;
    21812183      end;
    21822184    end;
     
    23732375          end
    23742376          else
    2375             AddFlags := AddFlags or Map[Loc] and (fStealthUnit or fHiddenUnit)
    2376         end
     2377            AddFlags := AddFlags or Map[Loc] and (fStealthUnit or fHiddenUnit);
     2378        end;
    23772379    end; // if Mode>moLoading_Fast
    23782380
     
    24312433    ObserveLevel[Loc] := ObserveLevel[Loc] and not(3 shl (2 * pTell)) or
    24322434      Cardinal(Level) shl (2 * pTell);
    2433   end
     2435  end;
    24342436end; // DiscoverTile
    24352437
     
    24602462              result := DiscoverTile(Loc1, p, pTell, Level, EnableContact)
    24612463                or result;
    2462           end
     2464          end;
    24632465      end
    24642466      else
     
    24672469        if Level > OldLevel then
    24682470          result := DiscoverTile(Loc1, p, p, Level, EnableContact) or result;
    2469       end
     2471      end;
    24702472  end;
    24712473end;
     
    25002502              result := DiscoverTile(Loc1, p, pTell, Level, EnableContact)
    25012503                or result;
    2502           end
     2504          end;
    25032505      end
    25042506      else
     
    25072509        if Level > OldLevel then
    25082510          result := DiscoverTile(Loc1, p, p, Level, EnableContact) or result;
    2509       end
     2511      end;
    25102512    end;
    25112513    AdjacentFlags := AdjacentFlags shr 1;
     
    25702572            RW[pTell].EnemyCity[ecix].Loc := -1;
    25712573            RW[pTell].Map[Loc] := RW[pTell].Map[Loc] and not fCity
    2572           end
    2573         end
    2574       end
     2574          end;
     2575        end;
     2576      end;
    25752577    end;
    25762578end;
     
    25942596        RWemix[p, Occupant[Loc], unx.mix];
    25952597      inc(result);
    2596     end
    2597   end
     2598    end;
     2599  end;
    25982600end;
    25992601
     
    26552657            ClearFlags := ClearFlags or fOwnZoCUnit;
    26562658          RW[p].Map[Loc] := RW[p].Map[Loc] and not ClearFlags or AddFlags;
    2657         end
    2658       end
    2659     end
     2659        end;
     2660      end;
     2661    end;
    26602662end;
    26612663
     
    26912693            Tile1^ := Tile1^ or fInEnemyZoC;
    26922694            Break
    2693           end
    2694         end
    2695       end;
    2696     end
    2697   end
     2695          end;
     2696        end;
     2697      end;
     2698    end;
     2699  end;
    26982700end;
    26992701
     
    27212723          if (Loc1 >= 0) and (Loc1 < MapSize) then
    27222724            RW[p].Map[Loc1] := RW[p].Map[Loc1] or fInEnemyZoC
    2723         end
    2724       end
    2725     end
     2725        end;
     2726      end;
     2727    end;
    27262728end;
    27272729
     
    27402742  for Loc := 0 to MapSize - 1 do
    27412743    if PeacePlayer[RW[p].Territory[Loc]] then
    2742       RW[p].Map[Loc] := RW[p].Map[Loc] or fPeace
     2744      RW[p].Map[Loc] := RW[p].Map[Loc] or fPeace;
    27432745end;
    27442746
     
    27542756  p1: integer;
    27552757begin
    2756   assert(p >= 0); // no player's territory indicated by p=nPl
    2757   dec(TerritoryCount[RealMap[Loc] shr 27]);
    2758   inc(TerritoryCount[p]);
     2758  Assert(p >= 0); // no player's territory indicated by p=nPl
     2759  Dec(TerritoryCount[RealMap[Loc] shr 27]);
     2760  Inc(TerritoryCount[p]);
    27592761  RealMap[Loc] := RealMap[Loc] and not($F shl 27) or Cardinal(p) shl 27;
    27602762  if p = $F then
     
    27702772        else
    27712773          RW[p1].Map[Loc] := RW[p1].Map[Loc] and not fPeace;
    2772       end
     2774      end;
    27732775end;
    27742776
     
    27972799          ChangeTerritory(Loc, NewOwner);
    27982800        inc(i);
    2799       end
    2800   end
     2801      end;
     2802  end;
    28012803end;
    28022804
     
    28392841            then
    28402842              StolenDist[Loc1] := NewDist;
    2841           end
    2842         end
     2843          end;
     2844        end;
    28432845    end;
    28442846  end;
     
    28752877            Country[Loc1] := FormerCountry[Loc];
    28762878            Dist[Loc1] := NewDist;
    2877           end
    2878         end
    2879       end
     2879          end;
     2880        end;
     2881      end;
    28802882  end;
    28812883
     
    30263028    if RW[p].Model[mix].Flags and mdZOC <> 0 then
    30273029      ZoCMap[Loc] := 1;
    3028   end
     3030  end;
    30293031end;
    30303032
    30313033procedure CountLost(p, mix, Enemy: integer);
    30323034begin
    3033   inc(RW[p].Model[mix].Lost);
     3035  Inc(RW[p].Model[mix].Lost);
    30343036  TellAboutModel(Enemy, p, mix);
    3035   inc(Destroyed[Enemy, p, mix]);
     3037  Inc(Destroyed[Enemy, p, mix]);
    30363038end;
    30373039
     
    30643066    if Enemy >= 0 then
    30653067      CountLost(p, mix, Enemy);
    3066   end
    3067 end; { RemoveUnit }
     3068  end;
     3069end;
    30683070
    30693071procedure RemoveUnit_UpdateMap(p, uix: integer);
    30703072var
    3071   Loc0: integer;
     3073  Loc0: Integer;
    30723074begin
    30733075  Loc0 := RW[p].Un[uix].Loc;
     
    31383140    ChangeTerritory(Loc, p)
    31393141  end;
    3140 end; { FoundCity }
     3142end;
    31413143
    31423144procedure StealCity(p, cix: integer; SaveUnits: boolean);
     
    31783180        else
    31793181          RemoveUnit(p, uix1); // destroy supported units
    3180 end; // StealCity
     3182end;
    31813183
    31823184procedure DestroyCity(p, cix: integer; SaveUnits: boolean);
     
    31973199    RealMap[Loc] := RealMap[Loc] and not fCity;
    31983200    Loc := -1
    3199   end
    3200 end; // DestroyCity
     3201  end;
     3202end;
    32013203
    32023204procedure ChangeCityOwner(pOld, cixOld, pNew: integer);
     
    32753277    ChangeTerritory(Loc, pNew);
    32763278  end;
    3277 end; // ChangeCityOwner
     3279end;
    32783280
    32793281procedure CompleteJob(p, Loc, Job: integer);
     
    34113413      if RW[pAbout].Un[uix].Loc >= 0 then
    34123414        inc(UnCount[RW[pAbout].Un[uix].mix]);
    3413   end
     3415  end;
    34143416end;
    34153417
     
    34263428      begin
    34273429      end; }
    3428   end
     3430  end;
    34293431end;
    34303432
     
    34473449    rTarget.ResearchTech := rSender.ResearchTech;
    34483450    rTarget.ResearchDone := rSender.ResearchDone;
    3449     result := true
     3451    result := true;
    34503452  end;
    34513453  for i := 0 to nAdv - 1 do
     
    34533455    begin
    34543456      rTarget.Tech[i] := rSender.Tech[i];
    3455       result := true
    3456     end
     3457      result := true;
     3458    end;
    34573459end;
    34583460
     
    34743476    for mix := 0 to rTarget.nModelCounted - 1 do
    34753477      TellAboutModel(pTarget, pAbout, mix);
    3476     result := true
    3477   end
     3478    result := true;
     3479  end;
    34783480end;
    34793481
     
    34913493    MakeModelInfo(pTarget, i, RW[pTarget].Model[i], miTarget);
    34923494    if IsSameModel(miSender, miTarget) then
    3493       ok := false
     3495      ok := false;
    34943496  end;
    34953497  if ok then
     
    35093511    inc(Researched[pTarget]);
    35103512    TellAboutModel(pSender, pTarget, RW[pTarget].nModel - 1);
    3511   end
     3513  end;
    35123514end;
    35133515
     
    36623664            RecalcPeaceMap(pSender);
    36633665            RecalcPeaceMap(pTarget);
    3664           end
    3665         end
     3666          end;
     3667        end;
    36663668      end;
    36673669    opShipParts: // + number + part type shl 16
     
    36813683              RW[pSender].Ship[pTarget].Parts[i] := GShip[pTarget].Parts[i];
    36823684              RW[pTarget].Ship[pTarget].Parts[i] := GShip[pTarget].Parts[i];
    3683             end
    3684           end
     3685            end;
     3686          end;
    36853687        end
    36863688        else
     
    36953697          dec(RW[pSender].Money, Price - opMoney);
    36963698          inc(RW[pTarget].Money, Price - opMoney);
    3697         end
     3699        end;
    36983700      end
    36993701      else
     
    37103712          SeeTech(pTarget, Price - opTech);
    37113713          RW[pSender].EnemyReport[pTarget].Tech[Price - opTech] := tsSeen;
    3712         end
     3714        end;
    37133715      end
    37143716      else
     
    38073809      RecalcMapZoC(p);
    38083810      RecalcMapZoC(pWith);
    3809     end
     3811    end;
    38103812  end;
    38113813  if OldTreaty in [trPeace, trAlliance] then
     
    38133815    RecalcPeaceMap(p);
    38143816    RecalcPeaceMap(pWith);
    3815   end
     3817  end;
    38163818end;
    38173819
     
    38543856              if CopyMilReport(pCity, p, p1) then
    38553857                result := result or (2 shl (2 * p1));
    3856           end
     3858          end;
    38573859      end;
    38583860  end;
     
    39113913              if RW[p2].EnemyReport[p1].Tech[AgePreq[i]] < tsApplicable then
    39123914                RW[p2].EnemyReport[p1].Tech[AgePreq[i]] := tsCheat;
    3913       end
     3915      end;
    39143916    end;
    39153917
     
    39253927          GiveCivilReport(p, p1);
    39263928          GiveMilReport(p, p1);
    3927         end
    3928       end
     3929        end;
     3930      end;
    39293931  end;
    39303932end;
  • branches/highdpi/Direct.pas

    r143 r210  
    55
    66uses
    7   Messg,
     7  UDpiControls, Messg,
    88
    99  LCLIntf, LCLType, {$IFDEF Linux}LMessages, {$ENDIF}Messages, SysUtils, Classes,
     
    129129          ShowModal;
    130130          if ModalResult = mrOK then
    131             OpenURL('http://c-evo.org/_sg/contact/cevobug.html');
     131            OpenURL(CevoContactBug);
    132132        end
    133133    *)
     
    216216  if Brains.Count = 3 then
    217217  begin
    218     Application.MessageBox(PChar(Phrases.Lookup('NOAI')), 'C-evo', 0);
     218    DpiApplication.MessageBox(PChar(Phrases.Lookup('NOAI')), 'C-evo', 0);
    219219    Close;
    220     exit
     220    exit;
    221221  end;
    222222  Quick := false;
     
    244244      begin
    245245        SimpleMessage(Phrases.Lookup('LOADERR'));
    246         Close
    247       end
    248     end
    249   end;
    250   if not Quick then
    251   begin
     246        Close;
     247      end;
     248    end;
     249  end;
     250  if not Quick then begin
    252251    background.Show;
    253     StartDlg.Show
    254   end
     252    StartDlg.Show;
     253  end;
    255254end;
    256255
     
    267266procedure TDirectDlg.OnAIException(var Msg: TMessage);
    268267begin
    269   Application.MessageBox(PChar(Format(Phrases.Lookup('AIEXCEPTION'),
     268  DpiApplication.MessageBox(PChar(Format(Phrases.Lookup('AIEXCEPTION'),
    270269    [Brains[Msg.WParam].Name])), 'C-evo', 0);
    271270end;
     
    310309    PaintProgressBar(Canvas, 6, ClientWidth div 2 - 64, 40, State, 128 - State,
    311310      128, MainTexture);
    312   end
     311  end;
    313312end;
    314313
  • branches/highdpi/GameServer.pas

    r178 r210  
    77
    88uses
    9   Protocol, Database, dynlibs, Platform, dateutils, fgl, FileUtil, Graphics,
    10   UDpiControls;
     9  UDpiControls, Protocol, Database, dynlibs, Platform, dateutils, fgl, LazFileUtils, Graphics;
    1110
    1211const
     
    117116function PreviewMap(lm: integer): pointer;
    118117
     118
    119119implementation
    120120
    121121uses
    122   Directories, CityProcessing, UnitProcessing, CmdList,
    123 
    124   LCLIntf, LCLType, LMessages, Classes, SysUtils;
     122  Directories, CityProcessing, UnitProcessing, CmdList, LCLIntf, LCLType,
     123  LMessages, Classes, SysUtils;
     124
     125resourcestring
     126  SNoAiFound = 'No AI libraries found in directory %s';
    125127
    126128var
     
    257259  BrainBeginner := nil;
    258260
    259   if FindFirst(HomeDir + 'AI' + DirectorySeparator + '*', faDirectory or faArchive or faReadOnly, f) = 0 then
     261  if FindFirst(GetAiDir + DirectorySeparator + '*', faDirectory or faArchive or faReadOnly, f) = 0 then
    260262  repeat
    261     BasePath := HomeDir + 'AI' + DirectorySeparator + f.Name;
     263    BasePath := GetAiDir + DirectorySeparator + f.Name;
    262264    if (f.Name <> '.') and (f.Name <> '..') and DirectoryExists(BasePath) then begin
    263265      NewBrain := Brains.AddNew;
     
    273275
    274276  if Brains.GetKindCount(btAI) = 0 then
    275     raise Exception.Create(Format('No AI libraries found in directory %s', [HomeDir + 'AI']));
     277    raise Exception.Create(Format(SNoAiFound, [GetAiDir]));
    276278end;
    277279
     
    305307  end;
    306308  CreateMap(true);
    307   result := @RealMap;
     309  Result := @RealMap;
    308310end;
    309311
     
    557559  s: string[255];
    558560begin
    559   MapFile := TFileStream.Create(DataDir + 'Maps' + DirectorySeparator + FileName,
     561  MapFile := TFileStream.Create(GetMapsDir + DirectorySeparator + FileName,
    560562    fmCreate or fmShareExclusive);
    561563  MapFile.Position := 0;
     
    580582  MapFile := nil;
    581583  try
    582     MapFile := TFileStream.Create(DataDir + 'Maps' + DirectorySeparator + FileName,
     584    MapFile := TFileStream.Create(GetMapsDir + DirectorySeparator + FileName,
    583585      fmOpenRead or fmShareExclusive);
    584586    MapFile.Position := 0;
     
    13671369  LogFileName := FileName;
    13681370  MapFileName := Map;
    1369   if FastContact then
    1370   begin
     1371  {$IFDEF FastContact}
    13711372    lx := 24;
    13721373    ly := 42;
    1373   end
    1374   else
    1375   begin
     1374  {$ELSE}
    13761375    lx := Newlx;
    1377     ly := Newly
    1378   end;
     1376    ly := Newly;
     1377  {$ENDIF}
    13791378  MapSize := lx * ly;
    13801379  if MapFileName <> '' then
     
    26982697  end;
    26992698
    2700 const
    2701   Dirx: array [0 .. 7] of integer = (1, 2, 1, 0, -1, -2, -1, 0);
    2702   Diry: array [0 .. 7] of integer = (-1, 0, 1, 2, 1, 0, -1, -2);
    2703 
    27042699var
    27052700  d, i, j, p1, p2, pt0, pt1, uix1, cix1, Loc0, Loc1, dx, dy, NewCap, MinCap,
     
    27072702    StopTurn, FutureMCost, NewProject, OldImp, mix, V8, V21, AStr, DStr,
    27082703    ABaseDamage, DBaseDamage: integer;
    2709   CityReport, AltCityReport: TCityReport;
     2704  CityReport: TCityReport;
    27102705  FormerCLState: TCmdListState;
    2711   EndTime: int64;
    27122706  Adjacent: TVicinity8Loc;
    27132707  Radius: TVicinity21Loc;
     
    45854579constructor TBrain.Create;
    45864580begin
    4587   Picture := nil;
     4581  Picture := TDpiBitmap.Create;
     4582  Picture.SetSize(64, 64);
    45884583end;
    45894584
    45904585destructor TBrain.Destroy;
    45914586begin
    4592   if Assigned(Picture) then Picture.Free;
     4587  FreeAndNil(Picture);
    45934588  inherited Destroy;
    45944589end;
  • branches/highdpi/Inp.pas

    r193 r210  
    55
    66uses
    7   ScreenTools, Messg,
     7  UDpiControls, ScreenTools, Messg,
    88  LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Forms, DrawDlg,
    9   ButtonA, StdCtrls, UDpiControls;
     9  ButtonA, StdCtrls;
    1010
    1111type
  • branches/highdpi/Install/deb/debian/control

    r178 r210  
    88Package: c-evo
    99Architecture: any
    10 Depends: ${shlibs:Depends}, ${misc:Depends},
     10Depends: ${shlibs:Depends}, ${misc:Depends}, sox, libsox-fmt-mp3
    1111Description: Empire building game
    1212HomePage: https://app.zdechov.net/c-evo
  • branches/highdpi/Install/win/C-evo.iss

    r160 r210  
    1919AppVersion={#MyAppVersion}
    2020AppVerName={#MyAppName} {#MyAppVersion}
     21UninstallDisplayName={#MyAppName}
     22UninstallDisplayIcon="{app}\{#MyAppExeName}"
     23VersionInfoVersion={#MyAppVersion}
     24VersionInfoCompany={#MyAppPublisher} 
    2125AppPublisher={#MyAppPublisher}
    2226AppPublisherURL={#MyAppURL}
     
    8084Name: "ai\seti"; Description: "SETI"; Types: full; Check: not Is64BitInstallMode;
    8185Name: "ai\shah"; Description: "Shah"; Types: full; Check: not Is64BitInstallMode;
     86Name: "ai_template"; Description: "AI template"; Types: full
    8287
    8388[Files]
     
    97102Source: "{#MyAppSubDir}\Language.txt"; DestDir: "{app}"; Flags: ignoreversion; Components: main
    98103Source: "{#MyAppSubDir}\Language2.txt"; DestDir: "{app}"; Flags: ignoreversion; Components: main
     104Source: "{#MyAppSubDir}\AI Template\*.*"; DestDir: "{app}\AI Template"; Flags: ignoreversion recursesubdirs; Components: ai_template
    99105Source: "{#MyAppSubDir}\AI\StdAI\lib\x86_64-win64-Release\StdAI.dll"; DestDir: "{app}\AI\StdAI"; DestName: "StdAI-win64.dll"; Flags: ignoreversion; Components: ai\stdai
    100106Source: "{#MyAppSubDir}\AI\StdAI\lib\i386-win32-Release\StdAI.dll"; DestDir: "{app}\AI\StdAI"; DestName: "StdAI-win32.dll"; Flags: ignoreversion; Components: ai\stdai
  • branches/highdpi/Integrated.lpi

    r193 r210  
    1616      <ResourceType Value="res"/>
    1717      <UseXPManifest Value="True"/>
    18       <XPManifest>
    19         <DpiAware Value="True"/>
    20       </XPManifest>
    2118      <Icon Value="0"/>
    2219      <Resources Count="2">
     
    10299      </Item3>
    103100    </RequiredPackages>
    104     <Units Count="40">
     101    <Units Count="41">
    105102      <Unit0>
    106103        <Filename Value="Integrated.lpr"/>
     
    163160        <ComponentName Value="Background"/>
    164161        <HasResources Value="True"/>
    165         <ResourceBaseClass Value="Form"/>
    166162      </Unit11>
    167163      <Unit12>
     
    328324        <ComponentName Value="LocaleDlg"/>
    329325        <HasResources Value="True"/>
     326        <ResourceBaseClass Value="Form"/>
    330327      </Unit38>
    331328      <Unit39>
     
    333330        <IsPartOfProject Value="True"/>
    334331      </Unit39>
     332      <Unit40>
     333        <Filename Value="Global.pas"/>
     334        <IsPartOfProject Value="True"/>
     335      </Unit40>
    335336    </Units>
    336337  </ProjectOptions>
     
    366367    <Linking>
    367368      <Debugging>
     369        <UseHeaptrc Value="True"/>
    368370        <UseExternalDbgSyms Value="True"/>
    369371      </Debugging>
     
    382384  </CompilerOptions>
    383385  <Debugging>
    384     <Exceptions Count="4">
     386    <Exceptions Count="3">
    385387      <Item1>
    386388        <Name Value="EAbort"/>
     
    392394        <Name Value="EFOpenError"/>
    393395      </Item3>
    394       <Item4>
    395         <Name Value="EReadError"/>
    396       </Item4>
    397396    </Exceptions>
    398397  </Debugging>
  • branches/highdpi/Integrated.lpr

    r180 r210  
    33
    44uses
    5   Forms, Interfaces, SysUtils,
    6   Protocol in 'Protocol.pas',
    7   CmdList in 'CmdList.pas',
    8   Database in 'Database.pas',
    9   GameServer in 'GameServer.pas',
    10   CityProcessing in 'CityProcessing.pas',
    11   UnitProcessing in 'UnitProcessing.pas',
    12   Direct in 'Direct.pas' {DirectDlg} ,
    13   Start in 'Start.pas' {StartDlg} ,
    14   Messg in 'Messg.pas' {MessgDlg} ,
    15   Inp in 'Inp.pas' {InputDlg} ,
    16   Back in 'Back.pas' {Background} ,
    17   Log in 'Log.pas' {LogDlg} ,
    18   PVSB in 'LocalPlayer\PVSB.pas',
    19   LocalPlayer in 'LocalPlayer\LocalPlayer.pas',
    20   ClientTools in 'LocalPlayer\ClientTools.pas',
    21   Diplomacy in 'LocalPlayer\Diplomacy.pas',
    22   Tribes in 'LocalPlayer\Tribes.pas',
    23   IsoEngine in 'LocalPlayer\IsoEngine.pas',
    24   Term in 'LocalPlayer\Term.pas' {MainScreen} ,
    25   MessgEx in 'LocalPlayer\MessgEx.pas' {MessgExDlg} ,
    26   Help in 'LocalPlayer\Help.pas' {HelpDlg} ,
    27   Select in 'LocalPlayer\Select.pas' {ListDlg} ,
    28   CityScreen in 'LocalPlayer\CityScreen.pas' {CityDlg} ,
    29   UnitStat in 'LocalPlayer\UnitStat.pas' {UnitStatDlg} ,
    30   Draft in 'LocalPlayer\Draft.pas' {DraftDlg} ,
    31   NatStat in 'LocalPlayer\NatStat.pas' {NatStatDlg} ,
    32   Diagram in 'LocalPlayer\Diagram.pas' {DiaDlg} ,
    33   Wonders in 'LocalPlayer\Wonders.pas' {WonderDlg} ,
    34   Nego in 'LocalPlayer\Nego.pas' {NegoDlg} ,
    35   CityType in 'LocalPlayer\CityType.pas' {CityTypeDlg} ,
    36   Enhance in 'LocalPlayer\Enhance.pas' {EnhanceDlg} ,
    37   NoTerm in 'NoTerm.pas' {NoTermDlg} ,
    38   Battle in 'LocalPlayer\Battle.pas' {BattleDlg} ,
    39   Rates in 'LocalPlayer\Rates.pas' {RatesDlg} ,
    40   TechTree in 'LocalPlayer\TechTree.pas' {TechTreeDlg},
    41   ScreenTools, Directories, UDpiControls;
     5  UDpiControls, Forms, Interfaces, SysUtils, Protocol, GameServer, Direct, Start, Messg, Inp,
     6  Back, Log, LocalPlayer, ClientTools, Tribes, IsoEngine, Term, CityScreen, Nego,
     7  NoTerm, ScreenTools, Directories;
    428
    439{$if declared(UseHeapTrace)}
     
    5824  DpiApplication.Initialize;
    5925  DpiApplication.Title := 'c-evo';
    60   Directories.InitUnit;
     26  Directories.UnitInit;
    6127  ScreenTools.UnitInit;
    6228  DpiApplication.CreateForm(TDirectDlg, DirectDlg);
  • branches/highdpi/Language.txt

    r178 r210  
    942942Hurry\Production
    943943Maximize\Production
     944
     945#SETTINGS
     946Full screen
  • branches/highdpi/LocalPlayer/Battle.pas

    r193 r210  
    55
    66uses
    7   ScreenTools, Protocol, Messg, ButtonBase, ButtonA, Types, LCLIntf, LCLType,
    8   SysUtils, Classes, Graphics, Controls, Forms, DrawDlg, UDpiControls;
     7  UDpiControls, ScreenTools, Protocol, ButtonBase, ButtonA, Types, LCLIntf, LCLType,
     8  SysUtils, Classes, Graphics, Controls, Forms, DrawDlg;
    99
    1010type
     
    107107    VLightGradient(ca, xm - 8, ym + 8 + LABaseDamage, LADamage - LABaseDamage,
    108108      FanaticColor);
    109   DpiBitBlt(ca.Handle, xm - 12, ym - 12, 24, 24,
    110     GrExt[HGrSystem].Mask.Canvas.Handle, 26, 146, SRCAND);
    111   DpiBitBlt(ca.Handle, xm - 12, ym - 12, 24, 24,
    112     GrExt[HGrSystem].Data.Canvas.Handle, 26, 146, SRCPAINT);
     109  DpiBitCanvas(ca, xm - 12, ym - 12, 24, 24,
     110    GrExt[HGrSystem].Mask.Canvas, 26, 146, SRCAND);
     111  DpiBitCanvas(ca, xm - 12, ym - 12, 24, 24,
     112    GrExt[HGrSystem].Data.Canvas, 26, 146, SRCPAINT);
    113113
    114114  LabelText := Format('%d', [Forecast.AStr]);
     
    132132  if Forecast.EndHealthDef <= 0 then
    133133  begin
    134     DpiBitBlt(ca.Handle, xm + 9 + LDDamage - 7, ym - 6, 14, 17,
    135       GrExt[HGrSystem].Mask.Canvas.Handle, 51, 153, SRCAND);
    136     DpiBitBlt(ca.Handle, xm + 8 + LDDamage - 7, ym - 7, 14, 17,
    137       GrExt[HGrSystem].Mask.Canvas.Handle, 51, 153, SRCAND);
    138     DpiBitBlt(ca.Handle, xm + 8 + LDDamage - 7, ym - 7, 14, 17,
    139       GrExt[HGrSystem].Data.Canvas.Handle, 51, 153, SRCPAINT);
     134    DpiBitCanvas(ca, xm + 9 + LDDamage - 7, ym - 6, 14, 17,
     135      GrExt[HGrSystem].Mask.Canvas, 51, 153, SRCAND);
     136    DpiBitCanvas(ca, xm + 8 + LDDamage - 7, ym - 7, 14, 17,
     137      GrExt[HGrSystem].Mask.Canvas, 51, 153, SRCAND);
     138    DpiBitCanvas(ca, xm + 8 + LDDamage - 7, ym - 7, 14, 17,
     139      GrExt[HGrSystem].Data.Canvas, 51, 153, SRCPAINT);
    140140  end;
    141141  LabelText := Format('%d', [DDamage]);
     
    152152  if Forecast.EndHealthAtt <= 0 then
    153153  begin
    154     DpiBitBlt(ca.Handle, xm - 6, ym + 9 + LADamage - 7, 14, 17,
    155       GrExt[HGrSystem].Mask.Canvas.Handle, 51, 153, SRCAND);
    156     DpiBitBlt(ca.Handle, xm - 7, ym + 8 + LADamage - 7, 14, 17,
    157       GrExt[HGrSystem].Mask.Canvas.Handle, 51, 153, SRCAND);
    158     DpiBitBlt(ca.Handle, xm - 7, ym + 8 + LADamage - 7, 14, 17,
    159       GrExt[HGrSystem].Data.Canvas.Handle, 51, 153, SRCPAINT);
     154    DpiBitCanvas(ca, xm - 6, ym + 9 + LADamage - 7, 14, 17,
     155      GrExt[HGrSystem].Mask.Canvas, 51, 153, SRCAND);
     156    DpiBitCanvas(ca, xm - 7, ym + 8 + LADamage - 7, 14, 17,
     157      GrExt[HGrSystem].Mask.Canvas, 51, 153, SRCAND);
     158    DpiBitCanvas(ca, xm - 7, ym + 8 + LADamage - 7, 14, 17,
     159      GrExt[HGrSystem].Data.Canvas, 51, 153, SRCPAINT);
    160160  end;
    161161  LabelText := Format('%d', [MyUn[uix].Health - Forecast.EndHealthAtt]);
     
    173173
    174174  NoMap.SetOutput(Buffer);
    175   DpiBitBlt(Buffer.Canvas.Handle, 0, 0, 66, 48, ca.Handle, xm + 8 + 4,
    176     ym - 8 - 12 - 48, SRCCOPY);
     175  DpiBitCanvas(Buffer.Canvas, 0, 0, 66, 48, ca, xm + 8 + 4,
     176    ym - 8 - 12 - 48);
    177177  { if TerrType<fForest then
    178178    Sprite(Buffer,HGrTerrain,0,16,66,32,1+TerrType*(xxt*2+1),1+yyt)
     
    185185    end; }
    186186  NoMap.PaintUnit(1, 0, UnitInfo, 0);
    187   DpiBitBlt(ca.Handle, xm + 8 + 4, ym - 8 - 12 - 48, 66, 48, Buffer.Canvas.Handle,
    188     0, 0, SRCCOPY);
    189 
    190   DpiBitBlt(Buffer.Canvas.Handle, 0, 0, 66, 48, ca.Handle, xm - 8 - 4 - 66,
    191     ym + 8 + 12, SRCCOPY);
     187  DpiBitCanvas(ca, xm + 8 + 4, ym - 8 - 12 - 48, 66, 48, Buffer.Canvas,
     188    0, 0);
     189
     190  DpiBitCanvas(Buffer.Canvas, 0, 0, 66, 48, ca, xm - 8 - 4 - 66,
     191    ym + 8 + 12);
    192192  MakeUnitInfo(me, MyUn[uix], UnitInfo);
    193193  UnitInfo.Flags := UnitInfo.Flags and not unFortified;
    194194  NoMap.PaintUnit(1, 0, UnitInfo, 0);
    195   DpiBitBlt(ca.Handle, xm - 8 - 4 - 66, ym + 8 + 12, 66, 48, Buffer.Canvas.Handle,
    196     0, 0, SRCCOPY);
     195  DpiBitCanvas(ca, xm - 8 - 4 - 66, ym + 8 + 12, 66, 48, Buffer.Canvas, 0, 0);
    197196end; { PaintBattleOutcome }
    198197
  • branches/highdpi/LocalPlayer/CityScreen.pas

    r193 r210  
    55
    66uses
    7   {$IFDEF LINUX}
     7  UDpiControls, {$IFDEF LINUX}
    88  LMessages,
    99  {$ENDIF}
    10   Protocol, ClientTools, Term, ScreenTools, IsoEngine, BaseWin, UDpiControls,
     10  Protocol, ClientTools, Term, ScreenTools, IsoEngine, BaseWin,
    1111  LCLIntf, LCLType, Messages, SysUtils, Classes, Graphics, Controls, Forms, ExtCtrls,
    1212  ButtonA, ButtonC, Area, GraphType;
     
    9090
    9191uses
    92   Select, Messg, MessgEx, Help, Tribes, Directories, Math;
     92  Select, Messg, MessgEx, Help, Tribes, Directories, Math, UPixelPointer, Sound;
    9393
    9494{$R *.lfm}
     
    216216  Template := TDpiBitmap.Create;
    217217  Template.PixelFormat := pf24bit;
    218   LoadGraphicFile(Template, HomeDir + 'Graphics' + DirectorySeparator + 'City.png', gfNoGamma);
     218  LoadGraphicFile(Template, GetGraphicsDir + DirectorySeparator + 'City.png', gfNoGamma);
    219219  CityMapTemplate := TDpiBitmap.Create;
    220220  CityMapTemplate.PixelFormat := pf24bit;
    221   LoadGraphicFile(CityMapTemplate, HomeDir + 'Graphics' + DirectorySeparator + 'BigCityMap.png', gfNoGamma);
     221  LoadGraphicFile(CityMapTemplate, GetGraphicsDir + DirectorySeparator + 'BigCityMap.png', gfNoGamma);
    222222  SmallCityMapTemplate := TDpiBitmap.Create;
    223223  SmallCityMapTemplate.PixelFormat := pf24bit;
    224   LoadGraphicFile(SmallCityMapTemplate, HomeDir + 'Graphics' + DirectorySeparator + 'SmallCityMap.png',
     224  LoadGraphicFile(SmallCityMapTemplate, GetGraphicsDir + DirectorySeparator + 'SmallCityMap.png',
    225225    gfNoGamma);
    226226  SmallCityMap := TDpiBitmap.Create;
     
    260260    Back.Canvas.FillRect(0, 0, ClientWidth, ClientHeight);
    261261
    262     Dpibitblt(Back.Canvas.Handle, 0, 0, ClientWidth, ClientHeight,
    263       MainTexture.Image.Canvas.Handle, 0, 0, SRCCOPY);
     262    DpiBitCanvas(Back.Canvas, 0, 0, ClientWidth, ClientHeight,
     263      MainTexture.Image.Canvas, 0, 0);
    264264    ImageOp_B(Back, Template, 0, 0, 0, 0, ClientWidth, ClientHeight);
    265265  end;
     
    291291  Color2 := Colors.Canvas.Pixels[clkAge0 + Age, cliHouse];
    292292  SmallCityMap.Canvas.FillRect(0, 0, SmallCityMap.Width, SmallCityMap.Height);
    293   Dpibitblt(SmallCityMap.Canvas.Handle, 0, 0, 83, hSmallMap,
    294     SmallCityMapTemplate.Canvas.Handle, 83 * SizeClass, 0, SRCCOPY);
     293  DpiBitCanvas(SmallCityMap.Canvas, 0, 0, 83, hSmallMap,
     294    SmallCityMapTemplate.Canvas, 83 * SizeClass, 0);
    295295  if IsPort then
    296296  begin
    297     Dpibitblt(SmallCityMap.Canvas.Handle, 83, 0, 15, hSmallMap,
    298       SmallCityMapTemplate.Canvas.Handle, 332 + 15, 0, SRCCOPY);
     297    DpiBitCanvas(SmallCityMap.Canvas, 83, 0, 15, hSmallMap,
     298      SmallCityMapTemplate.Canvas, 332 + 15, 0);
    299299    ImageOp_CCC(SmallCityMap, 0, 0, 83, hSmallMap, Color0, Color1, Color2);
    300300    Color2 := Colors.Canvas.Pixels[clkCity, cliWater];
     
    303303  else
    304304  begin
    305     Dpibitblt(SmallCityMap.Canvas.Handle, 83, 0, 15, hSmallMap,
    306       SmallCityMapTemplate.Canvas.Handle, 332, 0, SRCCOPY);
     305    DpiBitCanvas(SmallCityMap.Canvas, 83, 0, 15, hSmallMap,
     306      SmallCityMapTemplate.Canvas, 332, 0);
    307307    ImageOp_CCC(SmallCityMap, 0, 0, wSmallMap, hSmallMap, Color0,
    308308      Color1, Color2);
     
    311311  with SmallCityMap.Canvas do
    312312  begin
    313     brush.Color := ScreenTools.Colors.Canvas.Pixels[clkAge0 + Age, cliImp];
     313    Brush.Color := ScreenTools.Colors.Canvas.Pixels[clkAge0 + Age, cliImp];
    314314    for i := 0 to 29 do
    315315    begin
     
    359359  ZoomCityMap.Canvas.FillRect(0, 0, ZoomCityMap.Width, ZoomCityMap.Height);
    360360
    361   Dpibitblt(ZoomCityMap.Canvas.Handle, 0, 0, wZoomMap, hZoomMap,
    362     Back.Canvas.Handle, xZoomMap, yZoomMap, SRCCOPY);
     361  DpiBitCanvas(ZoomCityMap.Canvas, 0, 0, wZoomMap, hZoomMap,
     362    Back.Canvas, xZoomMap, yZoomMap);
    363363  if Mode = mImp then begin
    364364    if ZoomArea < 3 then begin
     
    442442    PixelPtr: TPixelPointer;
    443443  begin
     444    X := ScaleToVcl(X);
     445    Y := ScaleToVcl(Y);
     446    W := ScaleToVcl(W);
     447    H := ScaleToVcl(H);
    444448    Offscreen.BeginUpdate;
    445     PixelPtr.Init(Offscreen, X, Y);
     449    PixelPtr := PixelPointer(Offscreen, X, Y);
    446450    for YY := 0 to H - 1 do begin
    447451      for XX := 0 to W - 1 do begin
     
    498502
    499503var
    500   x, y, xGr, i, i1, j, iix, d, dx, dy, PrCost, Cnt, Loc1, FreeSupp, Paintiix,
     504  x, y, xGr, i, j, iix, d, dx, dy, PrCost, Cnt, Loc1, FreeSupp, Paintiix,
    501505    HappyGain, OptiType, rx, ry, TrueFood, TrueProd, TruePoll: integer;
    502506  av: integer;
     
    542546  RedTex.clTextShade := $0000FF;
    543547
    544   Dpibitblt(offscreen.Canvas.Handle, 0, 0, 640, 480, Back.Canvas.Handle, 0,
    545     0, SRCCOPY);
    546 
    547   offscreen.Canvas.Font.Assign(UniFont[ftCaption]);
     548  DpiBitCanvas(offscreen.Canvas, 0, 0, 640, 480, Back.Canvas, 0, 0);
     549
     550  Offscreen.Canvas.Font.Assign(UniFont[ftCaption]);
    548551  RisedTextOut(offscreen.Canvas, 42, 7, Caption);
    549552  with offscreen.Canvas do
     
    558561    TextOut(8 + 14 - textwidth(s) div 2, 7, s);
    559562  end;
    560   offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
     563  Offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
    561564
    562565  if not IsCityAlive then
     
    614617    false, AllowChange and IsCityAlive and
    615618    (c.Status and csResourceWeightsMask = 0));
    616   Dpibitblt(offscreen.Canvas.Handle, xmArea + 102, 42, 90, 33, Back.Canvas.Handle,
    617     xmArea + 102, 42, SRCCOPY);
     619  DpiBitCanvas(offscreen.Canvas, xmArea + 102, 42, 90, 33, Back.Canvas,
     620    xmArea + 102, 42);
    618621
    619622  if IsCityAlive then
     
    645648    else
    646649      xGr := 141;
    647     Dpibitblt(offscreen.Canvas.Handle, xmArea - 192 + 5 + i * d, ymArea - 96 - 29,
    648       27, 30, GrExt[HGrSystem].Mask.Canvas.Handle, xGr, 171, SRCAND); { shadow }
     650    DpiBitCanvas(offscreen.Canvas, xmArea - 192 + 5 + i * d, ymArea - 96 - 29,
     651      27, 30, GrExt[HGrSystem].Mask.Canvas, xGr, 171, SRCAND); { shadow }
    649652    Sprite(offscreen, HGrSystem, xmArea - 192 + 4 + i * d, ymArea - 96 - 30, 27,
    650653      30, xGr, 171);
     
    657660  begin
    658661    xGr := 1 + 112;
    659     Dpibitblt(offscreen.Canvas.Handle, xmArea + 192 - 27 + 1 - i * d, 29 + 1, 27,
    660       30, GrExt[HGrSystem].Mask.Canvas.Handle, xGr, 171, SRCAND); { shadow }
     662    DpiBitCanvas(offscreen.Canvas, xmArea + 192 - 27 + 1 - i * d, 29 + 1, 27,
     663      30, GrExt[HGrSystem].Mask.Canvas, xGr, 171, SRCAND); { shadow }
    661664    Sprite(offscreen, HGrSystem, xmArea + 192 - 27 - i * d, 29, 27, 30,
    662665      xGr, 171);
     
    803806
    804807  // small map
    805   Dpibitblt(offscreen.Canvas.Handle, xSmallMap, ySmallMap, wSmallMap, hSmallMap,
    806     SmallCityMap.Canvas.Handle, 0, 0, SRCCOPY);
     808  DpiBitCanvas(offscreen.Canvas, xSmallMap, ySmallMap, wSmallMap, hSmallMap,
     809    SmallCityMap.Canvas, 0, 0);
    807810  if Mode = mImp then
    808811    Frame(offscreen.Canvas, xSmallMap + 48 * (ZoomArea div 3),
     
    831834  Sprite(offscreen, HGrSystem, x + 6, y - 5, 10, 10, 154, 126);
    832835
    833   Dpibitblt(offscreen.Canvas.Handle, xZoomMap, yZoomMap, wZoomMap, hZoomMap,
    834     ZoomCityMap.Canvas.Handle, 0, 0, SRCCOPY);
     836  DpiBitCanvas(offscreen.Canvas, xZoomMap, yZoomMap, wZoomMap, hZoomMap,
     837    ZoomCityMap.Canvas, 0, 0);
    835838
    836839  for i := 0 to 5 do
     
    16201623      with Canvas do
    16211624      begin
    1622         Dpibitblt(Canvas.Handle, xView + 5, yView + 1, 64, 2, Back.Canvas.Handle,
    1623           xView + 5, yView + 1, SRCCOPY);
    1624         Dpibitblt(Canvas.Handle, xView + 5, yView + 3, 2, 42, Back.Canvas.Handle,
    1625           xView + 5, yView + 3, SRCCOPY);
    1626         Dpibitblt(Canvas.Handle, xView + 5 + 62, yView + 3, 2, 42,
    1627           Back.Canvas.Handle, xView + 5 + 62, yView + 3, SRCCOPY);
     1625        DpiBitCanvas(Canvas, xView + 5, yView + 1, 64, 2, Back.Canvas,
     1626          xView + 5, yView + 1);
     1627        DpiBitCanvas(Canvas, xView + 5, yView + 3, 2, 42, Back.Canvas,
     1628          xView + 5, yView + 3);
     1629        DpiBitCanvas(Canvas, xView + 5 + 62, yView + 3, 2, 42,
     1630          Back.Canvas, xView + 5 + 62, yView + 3);
    16281631        ScreenTools.Frame(Canvas, xView + 9 - 1, yView + 5 - 1, xView + 9 + xSizeBig,
    16291632          yView + 5 + ySizeBig, $B0B0B0, $FFFFFF);
    16301633        RFrame(Canvas, xView + 9 - 2, yView + 5 - 2, xView + 9 + xSizeBig + 1,
    16311634          yView + 5 + ySizeBig + 1, $FFFFFF, $B0B0B0);
    1632         brush.Color := $000000;
     1635        Brush.Color := $000000;
    16331636        FillRect(Rect(xView + 9, yView + 5, xView + 1 + 72 - 8,
    16341637          yView + 5 + 40));
    1635         brush.style := bsClear;
     1638        Brush.style := bsClear;
    16361639      end
    16371640    else if BlinkTime = 6 then
     
    16441647      else if c.Project and cpImp = 0 then
    16451648      begin // project is unit
    1646         Dpibitblt(Canvas.Handle, xView + 9, yView + 5, xSizeBig, ySizeBig,
    1647           bigimp.Canvas.Handle, 0, 0, SRCCOPY);
     1649        DpiBitCanvas(Canvas, xView + 9, yView + 5, xSizeBig, ySizeBig,
     1650          Bigimp.Canvas, 0, 0);
    16481651        with Tribe[cOwner].ModelPicture[c.Project and cpIndex] do
    16491652          Sprite(Canvas, HGr, xView + 5, yView + 1, 64, 44, pix mod 10 * 65 + 1,
  • branches/highdpi/LocalPlayer/CityType.pas

    r179 r210  
    55
    66uses
    7   Protocol, ClientTools, Term, ScreenTools, BaseWin, LCLIntf, LCLType,
     7  UDpiControls, Protocol, ClientTools, Term, ScreenTools, BaseWin, LCLIntf, LCLType,
    88  SysUtils, Classes, Graphics, Controls, Forms,
    99  ButtonB, ExtCtrls;
     
    3939  CityTypeDlg: TCityTypeDlg;
    4040
    41 
    4241implementation
    4342
    44 uses
    45   Help, UDpiControls;
     43uses Help;
    4644
    4745{$R *.lfm}
     
    116114        xSwitch + 38 + i * 42, ySwitch + 22, MainTexture.clBevelLight,
    117115        MainTexture.clBevelShade);
    118     DpiBitBlt(offscreen.Canvas.Handle, xSwitch + 2 + i * 42, ySwitch + 2,
    119       xSizeSmall, ySizeSmall, SmallImp.Canvas.Handle, (i + 3) * xSizeSmall,
    120       0, SRCCOPY)
     116    DpiBitCanvas(offscreen.Canvas, xSwitch + 2 + i * 42, ySwitch + 2,
     117      xSizeSmall, ySizeSmall, SmallImp.Canvas, (i + 3) * xSizeSmall, 0);
    121118  end;
    122119  RisedTextOut(offscreen.Canvas, 8, yList + 32 * nListRow + 2,
     
    151148      yList + 16 + ySizeSmall div 2 + i div nListCol * 32,
    152149      MainTexture.clBevelLight, MainTexture.clBevelShade);
    153     DpiBitBlt(offscreen.Canvas.Handle, xList + 21 - xSizeSmall div 2 +
     150    DpiBitCanvas(offscreen.Canvas, xList + 21 - xSizeSmall div 2 +
    154151      i mod nListCol * 42, yList + 16 - ySizeSmall div 2 + i div nListCol * 32,
    155       xSizeSmall, ySizeSmall, SmallImp.Canvas.Handle,
     152      xSizeSmall, ySizeSmall, SmallImp.Canvas,
    156153      MyData.ImpOrder[ctype, i] mod 7 * xSizeSmall,
    157154      (MyData.ImpOrder[ctype, i] + SystemIconLines * 7) div 7 *
    158       ySizeSmall, SRCCOPY);
     155      ySizeSmall);
    159156    inc(i);
    160157  end;
     
    174171        nPool div nPoolCol * 32, MainTexture.clBevelLight,
    175172        MainTexture.clBevelShade);
    176       DpiBitBlt(offscreen.Canvas.Handle, xPool + 21 - xSizeSmall div 2 +
     173      DpiBitCanvas(offscreen.Canvas, xPool + 21 - xSizeSmall div 2 +
    177174        nPool mod nPoolCol * 42, yPool + 16 - ySizeSmall div 2 +
    178         nPool div nPoolCol * 32, xSizeSmall, ySizeSmall, SmallImp.Canvas.Handle,
     175        nPool div nPoolCol * 32, xSizeSmall, ySizeSmall, SmallImp.Canvas,
    179176        iix mod 7 * xSizeSmall, (iix + SystemIconLines * 7) div 7 *
    180         ySizeSmall, SRCCOPY);
    181       inc(nPool)
     177        ySizeSmall);
     178      inc(nPool);
    182179    end;
    183180  DeleteBtn.Visible := MyData.ImpOrder[ctype, 0] >= 0;
     
    254251    begin
    255252      dragiix := MyData.ImpOrder[ctype, i];
    256       Screen.Cursor := crImpDrag;
     253      DpiScreen.Cursor := crImpDrag;
    257254      SmartUpdateContent
    258255    end;
     
    270267    begin
    271268      dragiix := Pooliix[i];
    272       Screen.Cursor := crImpDrag;
     269      DpiScreen.Cursor := crImpDrag;
    273270      SmartUpdateContent
    274271    end;
     
    332329    SmartUpdateContent
    333330  end;
    334   Screen.Cursor := crDefault
     331  DpiScreen.Cursor := crDefault
    335332end;
    336333
  • branches/highdpi/LocalPlayer/ClientTools.pas

    r70 r210  
    695695initialization
    696696
    697 assert(nImp < 128);
     697Assert(nImp < 128);
    698698CalculateAdvValues;
    699699
  • branches/highdpi/LocalPlayer/Diagram.pas

    r193 r210  
    55
    66uses
    7   BaseWin, LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Forms,
    8   ButtonB, Menus, UDpiControls;
     7  UDpiControls, BaseWin, LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Forms,
     8  ButtonB, Menus;
    99
    1010type
  • branches/highdpi/LocalPlayer/Draft.pas

    r193 r210  
    55
    66uses
    7   Protocol, ClientTools, Term, ScreenTools, BaseWin, UDpiControls,
     7  UDpiControls, Protocol, ClientTools, Term, ScreenTools, BaseWin,
     8
    89  LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Forms, ExtCtrls,
    910  ButtonA,
     
    9192  Template := TDpiBitmap.Create;
    9293  Template.PixelFormat := pf24bit;
    93   LoadGraphicFile(Template, HomeDir + 'Graphics' + DirectorySeparator + 'MiliRes.png', gfNoGamma);
     94  LoadGraphicFile(Template, GetGraphicsDir + DirectorySeparator + 'MiliRes.png', gfNoGamma);
    9495end;
    9596
     
    238239  // assemble background from 2 texture tiles
    239240  begin
    240     Dpibitblt(Back.Canvas.Handle, 0, 0, ClientWidth, 64,
    241       MainTexture.Image.Canvas.Handle, (wMainTexture - ClientWidth) div 2,
    242       hMainTexture - 64, SRCCOPY);
    243     Dpibitblt(Back.Canvas.Handle, 0, 64, ClientWidth, ClientHeight - 64,
    244       MainTexture.Image.Canvas.Handle, (wMainTexture - ClientWidth) div 2,
    245       0, SRCCOPY);
     241    DpiBitCanvas(Back.Canvas, 0, 0, ClientWidth, 64,
     242      MainTexture.Image.Canvas, (wMainTexture - ClientWidth) div 2,
     243      hMainTexture - 64);
     244    DpiBitCanvas(Back.Canvas, 0, 64, ClientWidth, ClientHeight - 64,
     245      MainTexture.Image.Canvas, (wMainTexture - ClientWidth) div 2,
     246      0);
    246247  end
    247248  else
    248     Dpibitblt(Back.Canvas.Handle, 0, 0, ClientWidth, ClientHeight,
    249       MainTexture.Image.Canvas.Handle, (wMainTexture - ClientWidth) div 2,
    250       (hMainTexture - ClientHeight) div 2, SRCCOPY);
     249    DpiBitCanvas(Back.Canvas, 0, 0, ClientWidth, ClientHeight,
     250      MainTexture.Image.Canvas, (wMainTexture - ClientWidth) div 2,
     251      (hMainTexture - ClientHeight) div 2);
    251252  ImageOp_B(Back, Template, 0, 0, 0, 0, Template.Width, 64);
    252253  ImageOp_B(Back, Template, 0, 64, 0, 64 + Cut, Template.Width,
    253254    Template.Height - 64 - Cut);
    254255
    255   Dpibitblt(offscreen.Canvas.Handle, 0, 0, ClientWidth, ClientHeight,
    256     Back.Canvas.Handle, 0, 0, SRCCOPY);
     256  DpiBitCanvas(offscreen.Canvas, 0, 0, ClientWidth, ClientHeight,
     257    Back.Canvas, 0, 0);
    257258
    258259  offscreen.Canvas.Font.Assign(UniFont[ftCaption]);
  • branches/highdpi/LocalPlayer/Enhance.pas

    r179 r210  
    55
    66uses
    7   ScreenTools, BaseWin, Protocol, ClientTools, Term, LCLIntf, LCLType,
     7  UDpiControls, ScreenTools, BaseWin, Protocol, ClientTools, Term, LCLIntf, LCLType,
    88
    99  SysUtils, Classes, Graphics, Controls, Forms,
     
    4545  EnhanceDlg: TEnhanceDlg;
    4646
    47 
    4847implementation
    4948
    50 uses
    51   Help, UDpiControls;
     49uses Help;
    5250
    5351{$R *.lfm}
     
    9896  for i := 0 to ControlCount - 1 do
    9997    if Controls[i] is TButtonC then
    100       DpiBitBlt(Canvas.Handle, Controls[i].Left + 2, Controls[i].Top - 11, 8, 8,
    101         GrExt[HGrSystem].Data.Canvas.Handle, 121 + Controls[i].Tag mod 7 * 9,
    102         1 + Controls[i].Tag div 7 * 9, SRCCOPY);
     98      DpiBitCanvas(Canvas, Controls[i].Left + 2, Controls[i].Top - 11, 8, 8,
     99        GrExt[HGrSystem].Data.Canvas, 121 + Controls[i].Tag mod 7 * 9,
     100        1 + Controls[i].Tag div 7 * 9);
    103101end;
    104102
  • branches/highdpi/LocalPlayer/Help.lfm

    r193 r210  
    11object HelpDlg: THelpDlg
    22  Left = 394
    3   Height = 718
    43  Top = 180
    5   Width = 840
    64  BorderIcons = []
    75  BorderStyle = bsNone
    8   ClientHeight = 718
    9   ClientWidth = 840
     6  ClientHeight = 479
     7  ClientWidth = 560
    108  Color = clBtnFace
    11   DesignTimePPI = 144
     9  Font.Charset = DEFAULT_CHARSET
    1210  Font.Color = clWindowText
    13   Font.Height = -20
     11  Font.Height = -13
    1412  Font.Name = 'MS Sans Serif'
     13  Font.Style = []
    1514  FormStyle = fsStayOnTop
    1615  OnClose = FormClose
     
    1817  OnDestroy = FormDestroy
    1918  OnKeyDown = FormKeyDown
     19  OnMouseWheel = FormMouseWheel
    2020  OnMouseDown = PaintBox1MouseDown
    2121  OnMouseMove = PaintBox1MouseMove
    22   OnMouseWheel = FormMouseWheel
    2322  OnPaint = FormPaint
    24   LCLVersion = '2.0.8.0'
     23  PixelsPerInch = 96
    2524  object CloseBtn: TButtonB
    26     Left = 783
    27     Height = 38
    28     Top = 9
    29     Width = 38
     25    Left = 522
     26    Top = 6
     27    Width = 25
     28    Height = 25
    3029    Down = False
    3130    Permanent = False
     
    3433  end
    3534  object BackBtn: TButtonB
    36     Left = 63
    37     Height = 38
    38     Top = 9
    39     Width = 38
     35    Left = 42
     36    Top = 6
     37    Width = 25
     38    Height = 25
    4039    Down = False
    4140    Permanent = False
     
    4443  end
    4544  object TopBtn: TButtonB
    46     Left = 20
    47     Height = 38
    48     Top = 9
    49     Width = 38
     45    Left = 13
     46    Top = 6
     47    Width = 25
     48    Height = 25
    5049    Down = False
    5150    Permanent = False
     
    5453  end
    5554  object SearchBtn: TButtonB
    56     Left = 740
    57     Height = 38
    58     Top = 9
    59     Width = 38
     55    Left = 493
     56    Top = 6
     57    Width = 25
     58    Height = 25
    6059    Down = False
    6160    Permanent = False
  • branches/highdpi/LocalPlayer/Help.pas

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

    r179 r210  
    55
    66uses
    7   Protocol, ClientTools, ScreenTools, Tribes, UDpiControls,
    8 {$IFNDEF SCR}Term, {$ENDIF}
    9   LCLIntf, LCLType, SysUtils, Classes, Graphics;
     7  UDpiControls, Protocol, ClientTools, ScreenTools, Tribes, {$IFNDEF SCR}Term, {$ENDIF}
     8  LCLIntf, LCLType, SysUtils, Classes, Graphics, UPixelPointer;
    109
    1110type
     
    2423    procedure PaintCity(x, y: integer; const CityInfo: TCityInfo;
    2524      accessory: boolean = true);
    26     procedure BitBlt(Src: TDpiBitmap; x, y, Width, Height, xSrc, ySrc,
     25    procedure BitBltBitmap(Src: TDpiBitmap; x, y, Width, Height, xSrc, ySrc,
    2726      Rop: integer);
    2827
     
    4039    FLeft, FTop, FRight, FBottom, RealTop, RealBottom, AttLoc, DefLoc,
    4140      DefHealth, FAdviceLoc: integer;
    42     DataDC, MaskDC: HDC;
     41    DataCanvas: TDpiCanvas;
     42    MaskCanvas: TDpiCanvas;
    4343    function Connection4(Loc, Mask, Value: integer): integer;
    4444    function Connection8(Loc, Mask: integer): integer;
     
    8989
    9090  // sprites indexes
    91   spDeadLands = 2 * TerrainIconCols + 6;
     91  spRow2 = 2 * TerrainIconCols + 6;
    9292  spBlink1 = 1 * TerrainIconCols + 8;
    9393  spBlink2 = 2 * TerrainIconCols + 8;
     
    107107  spPollution = 12 * TerrainIconCols + 6;
    108108  spFortBack = 12 * TerrainIconCols + 7;
     109  spMinerals = 12 * TerrainIconCols + 8;
    109110  spRiver = 13 * TerrainIconCols;
     111  spRiverMouths = 15 * TerrainIconCols;
     112  spGrid = 15 * TerrainIconCols + 6;
    110113  spJungle = 18 * TerrainIconCols;
     114  spCanalMouths = 20 * TerrainIconCols;
    111115
    112116var
     
    137141  i, x, y, xSrc, ySrc, HGrTerrainNew, HGrCitiesNew, age, size: integer;
    138142  LandMore, OceanMore, DitherMask, Mask24: TDpiBitmap;
    139   MaskLine: array [0 .. 32 * 3 - 1] of TPixelPointer; // 32 = assumed maximum for yyt
     143  MaskLine: array [0 .. 50 * 3 - 1] of TPixelPointer; // 32 = assumed maximum for yyt
    140144  Border: boolean;
    141145begin
     
    191195  DitherMask.SetSize(xxt * 2, yyt * 2);
    192196  DitherMask.Canvas.FillRect(0, 0, DitherMask.Width, DitherMask.Height);
    193   BitBlt(DitherMask.Canvas.Handle, 0, 0, xxt * 2, yyt * 2,
    194     GrExt[HGrTerrain].Mask.Canvas.Handle, 1 + 7 * (xxt * 2 + 1),
     197  DpiBitCanvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt * 2,
     198    GrExt[HGrTerrain].Mask.Canvas, 1 + 7 * (xxt * 2 + 1),
    195199    1 + yyt + 15 * (yyt * 3 + 1), SRCAND);
    196200
     
    213217    end;
    214218    for y := -1 to 6 do
    215       BitBlt(LandPatch.Canvas.Handle, (x + 2) * (xxt * 2), (y + 2) * yyt,
    216         xxt * 2, yyt, GrExt[HGrTerrain].Data.Canvas.Handle, xSrc, ySrc,
    217         SRCCOPY);
     219      DpiBitCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2), (y + 2) * yyt,
     220        xxt * 2, yyt, GrExt[HGrTerrain].Data.Canvas, xSrc, ySrc);
    218221    for y := -2 to 6 do
    219       BitBlt(LandPatch.Canvas.Handle, (x + 2) * (xxt * 2), (y + 2) * yyt, xxt,
    220         yyt, GrExt[HGrTerrain].Data.Canvas.Handle, xSrc + xxt, ySrc + yyt,
     222      DpiBitCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2), (y + 2) * yyt, xxt,
     223        yyt, GrExt[HGrTerrain].Data.Canvas, xSrc + xxt, ySrc + yyt,
    221224        SRCPAINT);
    222225    for y := -2 to 6 do
    223       BitBlt(LandPatch.Canvas.Handle, (x + 2) * (xxt * 2) + xxt, (y + 2) * yyt,
    224         xxt, yyt, GrExt[HGrTerrain].Data.Canvas.Handle, xSrc, ySrc + yyt,
     226      DpiBitCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2) + xxt, (y + 2) * yyt,
     227        xxt, yyt, GrExt[HGrTerrain].Data.Canvas, xSrc, ySrc + yyt,
    225228        SRCPAINT);
    226229    for y := -2 to 6 do
    227       BitBlt(LandPatch.Canvas.Handle, (x + 2) * (xxt * 2), (y + 2) * yyt, xxt,
    228         yyt, DitherMask.Canvas.Handle, xxt, yyt, SRCAND);
     230      DpiBitCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2), (y + 2) * yyt, xxt,
     231        yyt, DitherMask.Canvas, xxt, yyt, SRCAND);
    229232    for y := -2 to 6 do
    230       BitBlt(LandPatch.Canvas.Handle, (x + 2) * (xxt * 2) + xxt, (y + 2) * yyt,
    231         xxt, yyt, DitherMask.Canvas.Handle, 0, yyt, SRCAND);
     233      DpiBitCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2) + xxt, (y + 2) * yyt,
     234        xxt, yyt, DitherMask.Canvas, 0, yyt, SRCAND);
    232235  end;
    233236
     
    250253    end;
    251254    for x := -2 to 6 do
    252       BitBlt(LandMore.Canvas.Handle, (x + 2) * (xxt * 2), (y + 2) * yyt,
    253         xxt * 2, yyt, GrExt[HGrTerrain].Data.Canvas.Handle, xSrc, ySrc,
    254         SRCCOPY);
    255     BitBlt(LandMore.Canvas.Handle, xxt * 2, (y + 2) * yyt, xxt, yyt,
    256       GrExt[HGrTerrain].Data.Canvas.Handle, xSrc + xxt, ySrc + yyt, SRCPAINT);
     255      DpiBitCanvas(LandMore.Canvas, (x + 2) * (xxt * 2), (y + 2) * yyt,
     256        xxt * 2, yyt, GrExt[HGrTerrain].Data.Canvas, xSrc, ySrc);
     257    DpiBitCanvas(LandMore.Canvas, xxt * 2, (y + 2) * yyt, xxt, yyt,
     258      GrExt[HGrTerrain].Data.Canvas, xSrc + xxt, ySrc + yyt, SRCPAINT);
    257259    for x := 0 to 7 do
    258       BitBlt(LandMore.Canvas.Handle, (x + 2) * (xxt * 2) - xxt, (y + 2) * yyt,
    259         xxt * 2, yyt, GrExt[HGrTerrain].Data.Canvas.Handle, xSrc, ySrc + yyt,
     260      DpiBitCanvas(LandMore.Canvas, (x + 2) * (xxt * 2) - xxt, (y + 2) * yyt,
     261        xxt * 2, yyt, GrExt[HGrTerrain].Data.Canvas, xSrc, ySrc + yyt,
    260262        SRCPAINT);
    261263    for x := -2 to 6 do
    262       BitBlt(LandMore.Canvas.Handle, (x + 2) * (xxt * 2), (y + 2) * yyt,
    263         xxt * 2, yyt, DitherMask.Canvas.Handle, 0, 0, SRCAND);
     264      DpiBitCanvas(LandMore.Canvas, (x + 2) * (xxt * 2), (y + 2) * yyt,
     265        xxt * 2, yyt, DitherMask.Canvas, 0, 0, SRCAND);
    264266  end;
    265267
     
    273275      ySrc := 1 + yyt;
    274276      if (x >= 1) = (y >= 2) then
    275         BitBlt(OceanPatch.Canvas.Handle, x * (xxt * 2), y * yyt, xxt * 2, yyt,
    276           GrExt[HGrTerrain].Data.Canvas.Handle, xSrc, ySrc, SRCCOPY);
     277        DpiBitCanvas(OceanPatch.Canvas, x * (xxt * 2), y * yyt, xxt * 2, yyt,
     278          GrExt[HGrTerrain].Data.Canvas, xSrc, ySrc);
    277279      if (x >= 1) and ((y < 2) or (x >= 2)) then
    278280      begin
    279         BitBlt(OceanPatch.Canvas.Handle, x * (xxt * 2), y * yyt, xxt, yyt,
    280           GrExt[HGrTerrain].Data.Canvas.Handle, xSrc + xxt, ySrc + yyt,
     281        DpiBitCanvas(OceanPatch.Canvas, x * (xxt * 2), y * yyt, xxt, yyt,
     282          GrExt[HGrTerrain].Data.Canvas, xSrc + xxt, ySrc + yyt,
    281283          SRCPAINT);
    282         BitBlt(OceanPatch.Canvas.Handle, x * (xxt * 2) + xxt, y * yyt, xxt, yyt,
    283           GrExt[HGrTerrain].Data.Canvas.Handle, xSrc, ySrc + yyt, SRCPAINT);
     284        DpiBitCanvas(OceanPatch.Canvas, x * (xxt * 2) + xxt, y * yyt, xxt, yyt,
     285          GrExt[HGrTerrain].Data.Canvas, xSrc, ySrc + yyt, SRCPAINT);
    284286      end;
    285       BitBlt(OceanPatch.Canvas.Handle, x * (xxt * 2), y * yyt, xxt, yyt,
    286         DitherMask.Canvas.Handle, xxt, yyt, SRCAND);
    287       BitBlt(OceanPatch.Canvas.Handle, x * (xxt * 2) + xxt, y * yyt, xxt, yyt,
    288         DitherMask.Canvas.Handle, 0, yyt, SRCAND);
     287      DpiBitCanvas(OceanPatch.Canvas, x * (xxt * 2), y * yyt, xxt, yyt,
     288        DitherMask.Canvas, xxt, yyt, SRCAND);
     289      DpiBitCanvas(OceanPatch.Canvas, x * (xxt * 2) + xxt, y * yyt, xxt, yyt,
     290        DitherMask.Canvas, 0, yyt, SRCAND);
    289291    end;
    290292
     
    298300      ySrc := 1 + yyt;
    299301      if (x < 1) or (y >= 2) then
    300         BitBlt(OceanMore.Canvas.Handle, x * (xxt * 2), y * yyt, xxt * 2, yyt,
    301           GrExt[HGrTerrain].Data.Canvas.Handle, xSrc, ySrc, SRCCOPY);
     302        DpiBitCanvas(OceanMore.Canvas, x * (xxt * 2), y * yyt, xxt * 2, yyt,
     303          GrExt[HGrTerrain].Data.Canvas, xSrc, ySrc);
    302304      if (x = 1) and (y < 2) or (x >= 2) and (y >= 1) then
    303305      begin
    304         BitBlt(OceanMore.Canvas.Handle, x * (xxt * 2), y * yyt, xxt, yyt,
    305           GrExt[HGrTerrain].Data.Canvas.Handle, xSrc + xxt, ySrc + yyt,
     306        DpiBitCanvas(OceanMore.Canvas, x * (xxt * 2), y * yyt, xxt, yyt,
     307          GrExt[HGrTerrain].Data.Canvas, xSrc + xxt, ySrc + yyt,
    306308          SRCPAINT);
    307         BitBlt(OceanMore.Canvas.Handle, x * (xxt * 2) + xxt, y * yyt, xxt, yyt,
    308           GrExt[HGrTerrain].Data.Canvas.Handle, xSrc, ySrc + yyt, SRCPAINT);
     309        DpiBitCanvas(OceanMore.Canvas, x * (xxt * 2) + xxt, y * yyt, xxt, yyt,
     310          GrExt[HGrTerrain].Data.Canvas, xSrc, ySrc + yyt, SRCPAINT);
    309311      end;
    310       BitBlt(OceanMore.Canvas.Handle, x * (xxt * 2), y * yyt, xxt * 2, yyt,
    311         DitherMask.Canvas.Handle, 0, 0, SRCAND);
     312      DpiBitCanvas(OceanMore.Canvas, x * (xxt * 2), y * yyt, xxt * 2, yyt,
     313        DitherMask.Canvas, 0, 0, SRCAND);
    312314    end;
    313315
    314   BitBlt(DitherMask.Canvas.Handle, 0, 0, xxt * 2, yyt * 2,
    315     DitherMask.Canvas.Handle, 0, 0, DSTINVERT); { invert dither mask }
    316   BitBlt(DitherMask.Canvas.Handle, 0, 0, xxt * 2, yyt * 2,
    317     GrExt[HGrTerrain].Mask.Canvas.Handle, 1, 1 + yyt, SRCPAINT);
     316  DpiBitCanvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt * 2,
     317    DitherMask.Canvas, 0, 0, DSTINVERT); { invert dither mask }
     318  DpiBitCanvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt * 2,
     319    GrExt[HGrTerrain].Mask.Canvas, 1, 1 + yyt, SRCPAINT);
    318320
    319321  for x := -1 to 6 do
    320322    for y := -2 to 6 do
    321       BitBlt(LandPatch.Canvas.Handle, (x + 2) * (xxt * 2), (y + 2) * yyt,
    322         xxt * 2, yyt, DitherMask.Canvas.Handle, 0, 0, SRCAND);
     323      DpiBitCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2), (y + 2) * yyt,
     324        xxt * 2, yyt, DitherMask.Canvas, 0, 0, SRCAND);
    323325
    324326  for y := -1 to 6 do
    325327    for x := -2 to 7 do
    326       BitBlt(LandMore.Canvas.Handle, (x + 2) * (xxt * 2) - xxt, (y + 2) * yyt,
    327         xxt * 2, yyt, DitherMask.Canvas.Handle, 0, yyt, SRCAND);
    328 
    329   BitBlt(LandPatch.Canvas.Handle, 0, 0, (xxt * 2) * 9, yyt * 9,
    330     LandMore.Canvas.Handle, 0, 0, SRCPAINT);
     328      DpiBitCanvas(LandMore.Canvas, (x + 2) * (xxt * 2) - xxt, (y + 2) * yyt,
     329        xxt * 2, yyt, DitherMask.Canvas, 0, yyt, SRCAND);
     330
     331  DpiBitCanvas(LandPatch.Canvas, 0, 0, (xxt * 2) * 9, yyt * 9,
     332    LandMore.Canvas, 0, 0, SRCPAINT);
    331333
    332334  for x := 0 to 3 do
    333335    for y := 0 to 3 do
    334       BitBlt(OceanPatch.Canvas.Handle, x * (xxt * 2), y * yyt, xxt * 2, yyt,
    335         DitherMask.Canvas.Handle, 0, 0, SRCAND);
     336      DpiBitCanvas(OceanPatch.Canvas, x * (xxt * 2), y * yyt, xxt * 2, yyt,
     337        DitherMask.Canvas, 0, 0, SRCAND);
    336338
    337339  for y := 0 to 3 do
    338340    for x := 0 to 4 do
    339       BitBlt(OceanMore.Canvas.Handle, x * (xxt * 2) - xxt, y * yyt, xxt * 2,
    340         yyt, DitherMask.Canvas.Handle, 0, yyt, SRCAND);
    341 
    342   BitBlt(OceanPatch.Canvas.Handle, 0, 0, (xxt * 2) * 4, yyt * 4,
    343     OceanMore.Canvas.Handle, 0, 0, SRCPAINT);
     341      DpiBitCanvas(OceanMore.Canvas, x * (xxt * 2) - xxt, y * yyt, xxt * 2,
     342        yyt, DitherMask.Canvas, 0, yyt, SRCAND);
     343
     344  DpiBitCanvas(OceanPatch.Canvas, 0, 0, (xxt * 2) * 4, yyt * 4,
     345    OceanMore.Canvas, 0, 0, SRCPAINT);
    344346
    345347  with DitherMask.Canvas do
     
    348350    FillRect(Rect(0, 0, xxt * 2, yyt));
    349351  end;
    350   BitBlt(DitherMask.Canvas.Handle, 0, 0, xxt * 2, yyt,
    351     GrExt[HGrTerrain].Mask.Canvas.Handle, 1, 1 + yyt, SRCCOPY);
     352  DpiBitCanvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt,
     353    GrExt[HGrTerrain].Mask.Canvas, 1, 1 + yyt);
    352354
    353355  for x := 0 to 6 do
    354     BitBlt(LandPatch.Canvas.Handle, (x + 2) * (xxt * 2), yyt, xxt * 2, yyt,
    355       DitherMask.Canvas.Handle, 0, 0, SRCAND);
    356   BitBlt(DitherMask.Canvas.Handle, 0, 0, xxt * 2, yyt, DitherMask.Canvas.Handle,
     356    DpiBitCanvas(LandPatch.Canvas, (x + 2) * (xxt * 2), yyt, xxt * 2, yyt,
     357      DitherMask.Canvas, 0, 0, SRCAND);
     358  DpiBitCanvas(DitherMask.Canvas, 0, 0, xxt * 2, yyt, DitherMask.Canvas,
    357359    0, 0, DSTINVERT);
    358360
    359361  for y := 0 to 6 do
    360     BitBlt(LandPatch.Canvas.Handle, xxt * 2, (y + 2) * yyt, xxt * 2, yyt,
    361       DitherMask.Canvas.Handle, 0, 0, SRCAND);
     362    DpiBitCanvas(LandPatch.Canvas, xxt * 2, (y + 2) * yyt, xxt * 2, yyt,
     363      DitherMask.Canvas, 0, 0, SRCAND);
    362364
    363365  LandMore.Free;
     
    373375  begin
    374376    for i := 0 to yyt * 3 - 1 do
    375       MaskLine[i].Init(Mask24, 0, 1 + ySrc * (yyt * 3 + 1) + i);
     377      MaskLine[i] := PixelPointer(Mask24, 0, 1 + ySrc * (yyt * 3 + 1) + i);
    376378    for xSrc := 0 to 9 - 1 do
    377379    begin
     
    422424  Borders := TDpiBitmap.Create;
    423425  Borders.PixelFormat := pf24bit;
    424   Borders.SetSize(xxt * 2,(yyt * 2) * nPl);
     426  Borders.SetSize(xxt * 2, (yyt * 2) * nPl);
    425427  Borders.Canvas.FillRect(0, 0, Borders.Width, Borders.Height);
    426428  BordersOK := 0;
     
    474476  begin
    475477    Width := Width - (FLeft - x);
    476     x := FLeft
     478    x := FLeft;
    477479  end;
    478480  if y < FTop then
    479481  begin
    480482    Height := Height - (FTop - y);
    481     y := FTop
     483    y := FTop;
    482484  end;
    483485  if x + Width >= FRight then
     
    499501end;
    500502
    501 procedure TIsoMap.BitBlt(Src: TDpiBitmap; x, y, Width, Height, xSrc, ySrc,
     503procedure TIsoMap.BitBltBitmap(Src: TDpiBitmap; x, y, Width, Height, xSrc, ySrc,
    502504  Rop: integer);
    503505begin
     
    506508    Width := Width - (FLeft - x);
    507509    xSrc := xSrc + (FLeft - x);
    508     x := FLeft
     510    x := FLeft;
    509511  end;
    510512  if y < FTop then
     
    512514    Height := Height - (FTop - y);
    513515    ySrc := ySrc + (FTop - y);
    514     y := FTop
     516    y := FTop;
    515517  end;
    516518  if x + Width >= FRight then
     
    521523    exit;
    522524
    523   DpiBitBlt(FOutput.Canvas.Handle, x, y, Width, Height, Src.Canvas.Handle,
    524     xSrc, ySrc, Rop);
     525  DpiBitCanvas(FOutput.Canvas, x, y, Width, Height, Src.Canvas, xSrc, ySrc, Rop);
    525526end;
    526527
    527528procedure TIsoMap.Sprite(HGr, xDst, yDst, Width, Height, xGr, yGr: integer);
    528529begin
    529   BitBlt(GrExt[HGr].Mask, xDst, yDst, Width, Height, xGr, yGr, SRCAND);
    530   BitBlt(GrExt[HGr].Data, xDst, yDst, Width, Height, xGr, yGr, SRCPAINT);
     530  BitBltBitmap(GrExt[HGr].Mask, xDst, yDst, Width, Height, xGr, yGr, SRCAND);
     531  BitBltBitmap(GrExt[HGr].Data, xDst, yDst, Width, Height, xGr, yGr, SRCPAINT);
    531532end;
    532533
     
    561562    exit;
    562563
    563   DpiBitBlt(FOutput.Canvas.Handle, xDst, yDst, Width, Height, MaskDC, xSrc, ySrc, SRCAND);
     564  DpiBitCanvas(FOutput.Canvas, xDst, yDst, Width, Height, MaskCanvas, xSrc, ySrc, SRCAND);
    564565  if not PureBlack then
    565     DpiBitBlt(FOutput.Canvas.Handle, xDst, yDst, Width, Height, DataDC, xSrc, ySrc,
    566       SRCPAINT);
     566    DpiBitCanvas(FOutput.Canvas, xDst, yDst, Width, Height, DataCanvas, xSrc, ySrc, SRCPAINT);
    567567end;
    568568
     
    612612        xGr := 121 + j mod 7 * 9;
    613613        yGr := 1 + j div 7 * 9;
    614         BitBlt(GrExt[HGrSystem].Mask, x + xsh + 3, y + ysh + 9, 8, 8, xGr,
     614        BitBltBitmap(GrExt[HGrSystem].Mask, x + xsh + 3, y + ysh + 9, 8, 8, xGr,
    615615          yGr, SRCAND);
    616616        Sprite(HGrSystem, x + xsh + 2, y + ysh + 8, 8, 8, xGr, yGr);
     
    620620      if Flags and unFortified <> 0 then
    621621      begin
    622         { DataDC:=GrExt[HGrTerrain].Data.Canvas.Handle;
    623           MaskDC:=GrExt[HGrTerrain].Mask.Canvas.Handle;
     622        { DataCanvas:=GrExt[HGrTerrain].Data.Canvas;
     623          MaskCanvas:=GrExt[HGrTerrain].Mask.Canvas;
    624624          TSprite(x,y+16,12*9+7); }
    625625        Sprite(HGrStdUnits, x, y, xxu * 2, yyu * 2, 1 + 6 * (xxu * 2 + 1), 1);
    626       end
    627     end
     626      end;
     627    end;
    628628end; { PaintUnit }
    629629
     
    819819    exit;
    820820
    821   BitBlt(GrExt[HGrTerrain].Data, x + xxt div 2, y, xxt, yyt,
     821  BitBltBitmap(GrExt[HGrTerrain].Data, x + xxt div 2, y, xxt, yyt,
    822822    1 + (Conn shr 6 + Conn and 1 shl 2) * (xxt * 2 + 1),
    823823    1 + yyt + (16 + Tile and fTerrain) * (yyt * 3 + 1), SRCPAINT);
    824   BitBlt(GrExt[HGrTerrain].Data, x + xxt, y + yyt div 2, xxt, yyt,
     824  BitBltBitmap(GrExt[HGrTerrain].Data, x + xxt, y + yyt div 2, xxt, yyt,
    825825    1 + (Conn and 7) * (xxt * 2 + 1) + xxt,
    826826    1 + yyt * 2 + (16 + Tile and fTerrain) * (yyt * 3 + 1), SRCPAINT);
    827   BitBlt(GrExt[HGrTerrain].Data, x + xxt div 2, y + yyt, xxt, yyt,
     827  BitBltBitmap(GrExt[HGrTerrain].Data, x + xxt div 2, y + yyt, xxt, yyt,
    828828    1 + (Conn shr 2 and 7) * (xxt * 2 + 1) + xxt,
    829829    1 + yyt + (16 + Tile and fTerrain) * (yyt * 3 + 1), SRCPAINT);
    830   BitBlt(GrExt[HGrTerrain].Data, x, y + yyt div 2, xxt, yyt,
     830  BitBltBitmap(GrExt[HGrTerrain].Data, x, y + yyt div 2, xxt, yyt,
    831831    1 + (Conn shr 4 and 7) * (xxt * 2 + 1),
    832832    1 + yyt * 2 + (16 + Tile and fTerrain) * (yyt * 3 + 1), SRCPAINT);
    833833  Conn := Connection4(Loc, fTerrain, fUNKNOWN); { dither to black }
    834834  if Conn and 1 <> 0 then
    835     BitBlt(GrExt[HGrTerrain].Mask, x + xxt, y, xxt, yyt, 1 + 7 * (xxt * 2 + 1) +
     835    BitBltBitmap(GrExt[HGrTerrain].Mask, x + xxt, y, xxt, yyt, 1 + 7 * (xxt * 2 + 1) +
    836836      xxt, 1 + yyt + 15 * (yyt * 3 + 1), SRCAND);
    837837  if Conn and 2 <> 0 then
    838     BitBlt(GrExt[HGrTerrain].Mask, x + xxt, y + yyt, xxt, yyt,
     838    BitBltBitmap(GrExt[HGrTerrain].Mask, x + xxt, y + yyt, xxt, yyt,
    839839      1 + 7 * (xxt * 2 + 1) + xxt, 1 + yyt * 2 + 15 * (yyt * 3 + 1), SRCAND);
    840840  if Conn and 4 <> 0 then
    841     BitBlt(GrExt[HGrTerrain].Mask, x, y + yyt, xxt, yyt, 1 + 7 * (xxt * 2 + 1),
     841    BitBltBitmap(GrExt[HGrTerrain].Mask, x, y + yyt, xxt, yyt, 1 + 7 * (xxt * 2 + 1),
    842842      1 + yyt * 2 + 15 * (yyt * 3 + 1), SRCAND);
    843843  if Conn and 8 <> 0 then
    844     BitBlt(GrExt[HGrTerrain].Mask, x, y, xxt, yyt, 1 + 7 * (xxt * 2 + 1),
     844    BitBltBitmap(GrExt[HGrTerrain].Mask, x, y, xxt, yyt, 1 + 7 * (xxt * 2 + 1),
    845845      1 + yyt + 15 * (yyt * 3 + 1), SRCAND);
    846846end;
     
    876876  end
    877877  else if Tile and fDeadLands <> 0 then
    878     TSprite(x, y, spDeadLands);
     878    TSprite(x, y, spRow2);
    879879
    880880  if ShowObjects then
     
    898898    for Dir := 0 to 3 do
    899899      if Conn and (1 shl Dir) <> 0 then { river mouths }
    900         TSprite(x, y, 15 * TerrainIconCols + Dir);
     900        TSprite(x, y, spRiverMouths + Dir);
    901901    if ShowObjects then
    902902    begin
     
    904904      for Dir := 0 to 7 do
    905905        if Conn and (1 shl Dir) <> 0 then { canal mouths }
    906           TSprite(x, y, 20 * TerrainIconCols + 1 + Dir);
     906          TSprite(x, y, spCanalMouths + 1 + Dir);
    907907    end
    908908  end;
     
    10071007        if BordersOK and (1 shl p1) = 0 then
    10081008        begin
    1009           // Clearing before bitblt SRCCOPY shouldn't be neccesary but for some
     1009          // Clearing before BitBltBitmap SRCCOPY shouldn't be neccesary but for some
    10101010          // reason without it code works different then under Delphi
    10111011          Borders.Canvas.FillRect(Bounds(0, p1 * (yyt * 2), xxt * 2, yyt * 2));
    10121012
    1013           DpiBitBlt(Borders.Canvas.Handle, 0, p1 * (yyt * 2), xxt * 2,
    1014             yyt * 2, GrExt[HGrTerrain].Data.Canvas.Handle,
    1015             1 + 8 * (xxt * 2 + 1), 1 + yyt + 16 * (yyt * 3 + 1), SRCCOPY);
     1013          DpiBitCanvas(Borders.Canvas, 0, p1 * (yyt * 2), xxt * 2,
     1014            yyt * 2, GrExt[HGrTerrain].Data.Canvas,
     1015            1 + 8 * (xxt * 2 + 1), 1 + yyt + 16 * (yyt * 3 + 1));
    10161016          Borders.BeginUpdate;
    10171017          for dy := 0 to yyt * 2 - 1 do
    10181018          begin
    1019             PixelPtr.Init(Borders, 0, p1 * (yyt * 2) + dy);
     1019            PixelPtr := PixelPointer(Borders, 0, p1 * (yyt * 2) + dy);
    10201020            for dx := 0 to xxt * 2 - 1 do begin
    10211021              if PixelPtr.Pixel^.B = 99 then begin
     
    10431043              if p2 <> p1 then
    10441044              begin
    1045                 BitBlt(GrExt[HGrTerrain].Mask, x + dx * xxt, y + dy * yyt, xxt,
     1045                BitBltBitmap(GrExt[HGrTerrain].Mask, x + dx * xxt, y + dy * yyt, xxt,
    10461046                  yyt, 1 + 8 * (xxt * 2 + 1) + dx * xxt,
    10471047                  1 + yyt + 16 * (yyt * 3 + 1) + dy * yyt, SRCAND);
    1048                 BitBlt(Borders, x + dx * xxt, y + dy * yyt, xxt, yyt, dx * xxt,
     1048                BitBltBitmap(Borders, x + dx * xxt, y + dy * yyt, xxt, yyt, dx * xxt,
    10491049                  p1 * (yyt * 2) + dy * yyt, SRCPAINT);
    10501050              end
     
    11121112    end;
    11131113  end;
    1114   if Tile and fDeadLands <> 0 then
    1115     TSprite(x, y, (12 + Tile shr 25 and 3) * TerrainIconCols + 8);
     1114  if (Tile and fDeadLands) <> 0 then
     1115    TSprite(x, y, spMinerals + (Tile shr 25 and 3) * TerrainIconCols);
    11161116
    11171117  if Options and (1 shl moEditMode) <> 0 then
     
    11311131        1 + yyt + 15 * (yyt * 3 + 1))
    11321132    else
    1133       TSprite(x, y, 6 + TerrainIconCols * 15, xxt <> 33);
     1133      TSprite(x, y, spGrid, xxt <> 33);
    11341134
    11351135  if FoW and (Tile and fObserved = 0) then
     
    13401340  FOutput.BeginUpdate;
    13411341  for y := y0 to y1 - 1 do begin
    1342     Line.Init(FOutput, 0, y);
     1342    Line := PixelPointer(FOutput, 0, y);
    13431343    y_n := (y - ym) / yyt;
    13441344    if abs(y_n) < rShade then begin
     
    14871487                  bix := 0
    14881488                end;
    1489               BitBlt(OceanPatch, x + dx * xxt, y + dy * yyt, xxt, yyt,
     1489              BitBltBitmap(OceanPatch, x + dx * xxt, y + dy * yyt, xxt, yyt,
    14901490                Aix * (xxt * 2) + (dx + dy + 1) and 1 * xxt, bix * yyt, SRCCOPY)
    14911491            end
     
    15351535                bix := Aix;
    15361536            if Aix = -1 then
    1537               BitBlt(GrExt[HGrTerrain].Data, x + dx * xxt, y + dy * yyt, xxt,
     1537              BitBltBitmap(GrExt[HGrTerrain].Data, x + dx * xxt, y + dy * yyt, xxt,
    15381538                yyt, 1 + 6 * (xxt * 2 + 1) + (dx + dy + 1) and 1 * xxt, 1 + yyt,
    15391539                SRCCOPY) // arctic <-> ocean
    15401540            else if bix = -1 then
    1541               BitBlt(GrExt[HGrTerrain].Data, x + dx * xxt, y + dy * yyt, xxt,
     1541              BitBltBitmap(GrExt[HGrTerrain].Data, x + dx * xxt, y + dy * yyt, xxt,
    15421542                yyt, 1 + 6 * (xxt * 2 + 1) + xxt - (dx + dy + 1) and 1 * xxt,
    15431543                1 + yyt * 2, SRCCOPY) // arctic <-> ocean
    15441544            else
    1545               BitBlt(LandPatch, x + dx * xxt, y + dy * yyt, xxt, yyt,
     1545              BitBltBitmap(LandPatch, x + dx * xxt, y + dy * yyt, xxt, yyt,
    15461546                Aix * (xxt * 2) + (dx + dy + 1) and 1 * xxt, bix * yyt, SRCCOPY)
    15471547          end
    15481548      end;
    15491549
    1550   DataDC := GrExt[HGrTerrain].Data.Canvas.Handle;
    1551   MaskDC := GrExt[HGrTerrain].Mask.Canvas.Handle;
     1550  DataCanvas := GrExt[HGrTerrain].Data.Canvas;
     1551  MaskCanvas := GrExt[HGrTerrain].Mask.Canvas;
    15521552  for dy := -2 to ny + 1 do
    15531553    for dx := -1 to nx do
  • branches/highdpi/LocalPlayer/LocalPlayer.pas

    r155 r210  
    1111
    1212uses
    13   Term, CityScreen, Draft, MessgEx, Select, CityType, Help, UnitStat, Diagram,
     13  UDpiControls, Term, CityScreen, Draft, MessgEx, Select, CityType, Help, UnitStat, Diagram,
    1414  NatStat, Wonders, Nego, Enhance, BaseWin, Battle, Rates, TechTree,
    1515
     
    2525    FormsCreated := true;
    2626    // TODO: Changing application name in runtime will cause change of Linux XML registry file path
    27 //    Application.MainForm := MainScreen;
    28     Application.CreateForm(TMainScreen, MainScreen);
    29     Application.CreateForm(TCityDlg, CityDlg);
    30     Application.CreateForm(TModalSelectDlg, ModalSelectDlg);
    31     Application.CreateForm(TListDlg, ListDlg);
    32     Application.CreateForm(TMessgExDlg, MessgExDlg);
    33     Application.CreateForm(TDraftDlg, DraftDlg);
    34     Application.CreateForm(TCityTypeDlg, CityTypeDlg);
    35     Application.CreateForm(THelpDlg, HelpDlg);
    36     Application.CreateForm(TUnitStatDlg, UnitStatDlg);
    37     Application.CreateForm(TDiaDlg, DiaDlg);
    38     Application.CreateForm(TNatStatDlg, NatStatDlg);
    39     Application.CreateForm(TWondersDlg, WondersDlg);
    40     Application.CreateForm(TNegoDlg, NegoDlg);
    41     Application.CreateForm(TEnhanceDlg, EnhanceDlg);
    42     Application.CreateForm(TBattleDlg, BattleDlg);
    43     // Application.CreateForm(TAdvisorDlg, AdvisorDlg);
    44     Application.CreateForm(TRatesDlg, RatesDlg);
    45     Application.CreateForm(TTechTreeDlg, TechTreeDlg);
     27//    DpiApplication.MainForm := MainScreen;
     28    DpiApplication.CreateForm(TMainScreen, MainScreen);
     29    DpiApplication.CreateForm(TCityDlg, CityDlg);
     30    DpiApplication.CreateForm(TModalSelectDlg, ModalSelectDlg);
     31    DpiApplication.CreateForm(TListDlg, ListDlg);
     32    DpiApplication.CreateForm(TMessgExDlg, MessgExDlg);
     33    DpiApplication.CreateForm(TDraftDlg, DraftDlg);
     34    DpiApplication.CreateForm(TCityTypeDlg, CityTypeDlg);
     35    DpiApplication.CreateForm(THelpDlg, HelpDlg);
     36    DpiApplication.CreateForm(TUnitStatDlg, UnitStatDlg);
     37    DpiApplication.CreateForm(TDiaDlg, DiaDlg);
     38    DpiApplication.CreateForm(TNatStatDlg, NatStatDlg);
     39    DpiApplication.CreateForm(TWondersDlg, WondersDlg);
     40    DpiApplication.CreateForm(TNegoDlg, NegoDlg);
     41    DpiApplication.CreateForm(TEnhanceDlg, EnhanceDlg);
     42    DpiApplication.CreateForm(TBattleDlg, BattleDlg);
     43    // DpiApplication.CreateForm(TAdvisorDlg, AdvisorDlg);
     44    DpiApplication.CreateForm(TRatesDlg, RatesDlg);
     45    DpiApplication.CreateForm(TTechTreeDlg, TechTreeDlg);
    4646  end;
    4747  MainScreen.Client(Command, Player, Data);
  • branches/highdpi/LocalPlayer/MessgEx.pas

    r193 r210  
    55
    66uses
    7   Messg, Protocol, ScreenTools, Platform, DateUtils, UDpiControls,
     7  UDpiControls, Messg, Protocol, ScreenTools, Platform, DateUtils,
    88  LCLIntf, LCLType, Messages, SysUtils, Classes, Graphics, Controls, Forms, ButtonA,
    99  ButtonB, StdCtrls, DrawDlg;
     
    7373
    7474uses
    75   ClientTools, BaseWin, Term, Help, UnitStat, Tribes,
    76   IsoEngine, Diagram;
     75  ClientTools, BaseWin, Term, Help, UnitStat, Tribes, UPixelPointer,
     76  IsoEngine, Diagram, Sound;
    7777
    7878{$R *.lfm}
     
    209209      Ticks0 := NowPrecise;
    210210      repeat
    211         Application.ProcessMessages;
     211        DpiApplication.ProcessMessages;
    212212        Sleep(1);
    213213        Ticks := NowPrecise;
     
    246246    for iy := 0 to 39 do begin
    247247      for ix := 0 to 55 do begin
    248         SrcPtr.Init(BigImp, ix + xIcon, iy + yIcon);
     248        SrcPtr := PixelPointer(BigImp, ix + xIcon, iy + yIcon);
    249249        xR := ix * (37 + iy * 5 / 40) / 56;
    250250        xDst := Trunc(xR);
     
    291291
    292292  // paint
    293   BitBltCanvas(LogoBuffer.Canvas, 0, 0, wb, hb, ca, x, y, SRCCOPY);
     293  DpiBitCanvas(LogoBuffer.Canvas, 0, 0, wb, hb, ca, x, y);
    294294
    295295  if IconIndex >= 0 then
     
    304304  ImageOp_BCC(LogoBuffer, Templates, 0, 0, xb, yb, wb, hb, clCover, clPage);
    305305
    306   DpiBitBlt(ca.Handle, x, y, wb, hb, LogoBuffer.Canvas.Handle, 0, 0, SRCCOPY);
     306  DpiBitCanvas(ca, x, y, wb, hb, LogoBuffer.Canvas, 0, 0);
    307307end;
    308308
     
    328328      with MyRO.EnemyModel[emix], Tribe[Owner].ModelPicture[mix] do
    329329      begin
    330         DpiBitBlt(Canvas.Handle, x, y, 64, 48, GrExt[HGr].Mask.Canvas.Handle,
     330        DpiBitCanvas(Canvas, x, y, 64, 48, GrExt[HGr].Mask.Canvas,
    331331          pix mod 10 * 65 + 1, pix div 10 * 49 + 1, SRCAND);
    332         DpiBitBlt(Canvas.Handle, x, y, 64, 48, GrExt[HGr].Data.Canvas.Handle,
     332        DpiBitCanvas(Canvas, x, y, 64, 48, GrExt[HGr].Data.Canvas,
    333333          pix mod 10 * 65 + 1, pix div 10 * 49 + 1, SRCPAINT);
    334334      end;
     
    345345        if UnitsInLine > LostUnitsPerLine then
    346346          UnitsInLine := LostUnitsPerLine;
    347       end
     347      end;
    348348    end;
    349349end;
     
    371371      begin
    372372        p1 := MyRO.Wonder[IconIndex].EffectiveOwner;
    373         DpiBitBlt(Buffer.Canvas.Handle, 0, 0, xSizeBig + 2 * GlowRange,
    374           ySizeBig + 2 * GlowRange, Canvas.Handle,
    375           ClientWidth div 2 - (28 + GlowRange), 24 - GlowRange, SRCCOPY);
    376         DpiBitBlt(Buffer.Canvas.Handle, GlowRange, GlowRange, xSizeBig, ySizeBig,
    377           BigImp.Canvas.Handle, IconIndex mod 7 * xSizeBig,
    378           (IconIndex + SystemIconLines * 7) div 7 * ySizeBig, SRCCOPY);
     373        DpiBitCanvas(Buffer.Canvas, 0, 0, xSizeBig + 2 * GlowRange,
     374          ySizeBig + 2 * GlowRange, Canvas,
     375          ClientWidth div 2 - (28 + GlowRange), 24 - GlowRange);
     376        DpiBitCanvas(Buffer.Canvas, GlowRange, GlowRange, xSizeBig, ySizeBig,
     377          BigImp.Canvas, IconIndex mod 7 * xSizeBig,
     378          (IconIndex + SystemIconLines * 7) div 7 * ySizeBig);
    379379        if p1 < 0 then
    380380          GlowFrame(Buffer, GlowRange, GlowRange, xSizeBig, ySizeBig, $000000)
     
    382382          GlowFrame(Buffer, GlowRange, GlowRange, xSizeBig, ySizeBig,
    383383            Tribe[p1].Color);
    384         DpiBitBlt(Canvas.Handle, ClientWidth div 2 - (28 + GlowRange),
     384        DpiBitCanvas(Canvas, ClientWidth div 2 - (28 + GlowRange),
    385385          24 - GlowRange, xSizeBig + 2 * GlowRange, ySizeBig + 2 * GlowRange,
    386           Buffer.Canvas.Handle, 0, 0, SRCCOPY);
     386          Buffer.Canvas, 0, 0);
    387387      end
    388388      else
     
    400400        FrameImage(Canvas, BigImp, ClientWidth div 2 - 28, 24, xSizeBig,
    401401          ySizeBig, 0, 0);
    402         DpiBitBlt(Canvas.Handle, ClientWidth div 2 - 32, 20, 64, 44,
    403           GrExt[HGr].Mask.Canvas.Handle, pix mod 10 * 65 + 1,
     402        DpiBitCanvas(Canvas, ClientWidth div 2 - 32, 20, 64, 44,
     403          GrExt[HGr].Mask.Canvas, pix mod 10 * 65 + 1,
    404404          pix div 10 * 49 + 1, SRCAND);
    405         DpiBitBlt(Canvas.Handle, ClientWidth div 2 - 32, 20, 64, 44,
    406           GrExt[HGr].Data.Canvas.Handle, pix mod 10 * 65 + 1,
     405        DpiBitCanvas(Canvas, ClientWidth div 2 - 32, 20, 64, 44,
     406          GrExt[HGr].Data.Canvas, pix mod 10 * 65 + 1,
    407407          pix div 10 * 49 + 1, SRCPAINT);
    408408      end;
     
    415415        Frame(Canvas, ClientWidth div 2 - 32 - 1, 24 - 1,
    416416          ClientWidth div 2 + 32, 24 + 48, $000000, $000000);
    417         DpiBitBlt(Canvas.Handle, ClientWidth div 2 - 32, 24, 64, 48,
    418           GrExt[Tribe[IconIndex].faceHGr].Data.Canvas.Handle,
     417        DpiBitCanvas(Canvas, ClientWidth div 2 - 32, 24, 64, 48,
     418          GrExt[Tribe[IconIndex].faceHGr].Data.Canvas,
    419419          1 + Tribe[IconIndex].facepix mod 10 * 65,
    420           1 + Tribe[IconIndex].facepix div 10 * 49, SRCCOPY)
     420          1 + Tribe[IconIndex].facepix div 10 * 49)
    421421      end;
    422422    mikPureIcon:
     
    429429    mikEnemyShipComplete:
    430430      begin
    431         BitBltCanvas(Buffer.Canvas, 0, 0, 140, 120, Canvas,
    432           (ClientWidth - 140) div 2, 24, SRCCOPY);
     431        DpiBitCanvas(Buffer.Canvas, 0, 0, 140, 120, Canvas,
     432          (ClientWidth - 140) div 2, 24);
    433433        ImageOp_BCC(Buffer, Templates, 0, 0, 1, 279, 140, 120, 0, $FFFFFF);
    434         DpiBitBlt(Canvas.Handle, (ClientWidth - 140) div 2, 24, 140, 120,
    435           Buffer.Canvas.Handle, 0, 0, SRCCOPY);
     434        DpiBitCanvas(Canvas, (ClientWidth - 140) div 2, 24, 140, 120,
     435          Buffer.Canvas, 0, 0);
    436436      end;
    437437    mikMyArmy:
     
    450450  if OpenSound <> '' then
    451451    PostMessage(Handle, WM_PLAYSOUND, 0, 0);
    452 end; { FormPaint }
     452end;
    453453
    454454procedure TMessgExDlg.Button1Click(Sender: TObject);
     
    469469procedure TMessgExDlg.Button3Click(Sender: TObject);
    470470begin
    471   ModalResult := mrCancel
     471  ModalResult := mrCancel;
    472472end;
    473473
    474474procedure TMessgExDlg.RemoveBtnClick(Sender: TObject);
    475475begin
    476   ModalResult := mrNo
     476  ModalResult := mrNo;
    477477end;
    478478
     
    485485      ModalResult := mrCancel
    486486    else if Button2.Visible then
    487       ModalResult := mrIgnore
     487      ModalResult := mrIgnore;
    488488end;
    489489
     
    497497    Kind := mkOk;
    498498    ShowModal;
    499   end
     499  end;
    500500end;
    501501
     
    522522    Kind := QueryKind;
    523523    ShowModal;
    524     result := ModalResult
    525   end
     524    result := ModalResult;
     525  end;
    526526end;
    527527
     
    537537    HelpNo := ContextNo;
    538538    ShowModal;
    539   end
     539  end;
    540540end;
    541541
     
    552552end;
    553553
     554
    554555initialization
    555556
  • branches/highdpi/LocalPlayer/NatStat.pas

    r179 r210  
    55
    66uses
    7   Protocol, ClientTools, Term, ScreenTools, BaseWin, UDpiControls,
     7  UDpiControls, Protocol, ClientTools, Term, ScreenTools, BaseWin,
     8
    89  LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Forms,
    910  ButtonB, ButtonC, Menus, EOTButton;
     
    9293  Template := TDpiBitmap.Create;
    9394  Template.PixelFormat := pf24bit;
    94   LoadGraphicFile(Template, HomeDir + 'Graphics' + DirectorySeparator + 'Nation.png', gfNoGamma);
     95  LoadGraphicFile(Template, GetGraphicsDir + DirectorySeparator + 'Nation.png', gfNoGamma);
    9596end;
    9697
     
    108109  begin
    109110    AgePrepared := MainTextureAge;
    110     Dpibitblt(Back.Canvas.Handle, 0, 0, ClientWidth, ClientHeight,
    111       MainTexture.Image.Canvas.Handle, (wMainTexture - ClientWidth) div 2,
    112       (hMainTexture - ClientHeight) div 2, SRCCOPY);
     111    DpiBitCanvas(Back.Canvas, 0, 0, ClientWidth, ClientHeight,
     112      MainTexture.Image.Canvas, (wMainTexture - ClientWidth) div 2,
     113      (hMainTexture - ClientHeight) div 2);
    113114    ImageOp_B(Back, Template, 0, 0, 0, 0, ClientWidth, ClientHeight);
    114115  end
     
    263264  Extinct := 1 shl pView and MyRO.Alive = 0;
    264265
    265   Dpibitblt(offscreen.Canvas.Handle, 0, 0, ClientWidth, ClientHeight,
    266     Back.Canvas.Handle, 0, 0, SRCCOPY);
     266  DpiBitCanvas(offscreen.Canvas, 0, 0, ClientWidth, ClientHeight,
     267    Back.Canvas, 0, 0);
    267268
    268269  offscreen.Canvas.Font.Assign(UniFont[ftCaption]);
  • branches/highdpi/LocalPlayer/Nego.pas

    r178 r210  
    55
    66uses
    7   ScreenTools, BaseWin, Protocol, Term, LCLType, SysUtils, Classes, Graphics,
    8   Controls, Forms, ButtonA, ButtonB, ButtonN, UDpiControls;
     7  UDpiControls, ScreenTools, BaseWin, Protocol, Term, LCLType, SysUtils, Classes, Graphics,
     8  Controls, Forms, ButtonA, ButtonB, ButtonN;
    99
    1010const
     
    1515type
    1616  THistory = record
    17     n: integer;
    18     Text: array [0 .. MaxHistory - 1] of ansistring;
    19   end;
    20 
    21   TCommandAllowedEnum = scDipNoticeStart .. scDipBreakStart;
     17    n: Integer;
     18    Text: array[0 .. MaxHistory - 1] of ansistring;
     19  end;
     20
     21  TCommandAllowedEnum = scDipNoticeStart..scDipBreakStart;
    2222
    2323  { TNegoDlg }
  • branches/highdpi/LocalPlayer/PVSB.pas

    r178 r210  
    55
    66uses
    7   {$IFDEF WINDOWS}
     7  UDpiControls, {$IFDEF WINDOWS}
    88  Windows,
    99  {$ENDIF}
    1010  Classes, Controls, Forms, LCLIntf, LCLType, LMessages, Messages, SysUtils,
    11   StdCtrls, Math, UDpiControls;
     11  StdCtrls, Math;
    1212
    1313type
     
    109109    if Max < ScrollBar.PageSize then Result := False
    110110    else begin
    111       NewPos := ScrollBar.Position - Delta div 300;
     111      NewPos := ScrollBar.Position - Delta div 30;
    112112      if NewPos < 0 then NewPos := 0;
    113113      if NewPos > Max - ScrollBar.PageSize + 1 then
     
    153153begin
    154154  FMax := AValue;
    155   ScrollBar.Max := Math.Max(0, Max{$IFDEF LINUX} - PageSize + 1{$ENDIF});
     155  ScrollBar.Max := Math.Max(0, FMax);
    156156end;
    157157
  • branches/highdpi/LocalPlayer/Rates.pas

    r193 r210  
    55
    66uses
    7   Protocol, ScreenTools, BaseWin, LCLIntf, LCLType,
     7  UDpiControls, Protocol, ScreenTools, BaseWin, LCLIntf, LCLType,
    88
    99  SysUtils, Classes, Graphics, Controls, Forms,
     
    2929  RatesDlg: TRatesDlg;
    3030
    31 
    3231implementation
    3332
    3433uses
    35   ClientTools, Term, Tribes, UDpiControls;
     34  ClientTools, Term, Tribes;
    3635
    3736{$R *.lfm}
     
    9695    GlowFrame(Offscreen, ClientWidth div 2 - xSizeBig div 2, 52, xSizeBig,
    9796      ySizeBig, Tribe[me].Color);
    98     DpiBitBlt(Offscreen.Canvas.Handle, ClientWidth div 2 - xSizeBig div 2, 52,
    99       xSizeBig, ySizeBig, BigImp.Canvas.Handle, (woLiberty mod 7) * xSizeBig,
    100       (woLiberty div 7 + SystemIconLines) * ySizeBig, SRCCOPY);
     97    DpiBitCanvas(Offscreen.Canvas, ClientWidth div 2 - xSizeBig div 2, 52,
     98      xSizeBig, ySizeBig, BigImp.Canvas, (woLiberty mod 7) * xSizeBig,
     99      (woLiberty div 7 + SystemIconLines) * ySizeBig);
    101100  end
    102101  else
     
    123122    begin
    124123      for i := 0 to current div 8 - 1 do
    125         DpiBitBlt(Handle, x + max - 8 - i * 8, y, 8, 7,
    126           GrExt[HGrSystem].Data.Canvas.Handle, 104, 9 + 8 * 2, SRCCOPY);
    127       DpiBitBlt(Handle, x + max - current, y, current - 8 * (current div 8), 7,
    128         GrExt[HGrSystem].Data.Canvas.Handle, 104, 9 + 8 * 2, SRCCOPY);
     124        DpiBitCanvas(Offscreen.Canvas, x + max - 8 - i * 8, y, 8, 7,
     125          GrExt[HGrSystem].Data.Canvas, 104, 9 + 8 * 2);
     126      DpiBitCanvas(Offscreen.Canvas, x + max - current, y, current - 8 * (current div 8), 7,
     127        GrExt[HGrSystem].Data.Canvas, 104, 9 + 8 * 2);
    129128      Brush.Color := $000000;
    130129      FillRect(Rect(x, y, x + max - current, y + 7));
  • branches/highdpi/LocalPlayer/Select.pas

    r193 r210  
    55
    66uses
    7   Protocol, ClientTools, Term, ScreenTools, IsoEngine, PVSB, BaseWin, UDpiControls,
    8   LCLIntf, LCLType, LMessages, Messages, SysUtils, Classes, Graphics, Controls, Forms,
     7  UDpiControls, Protocol, ClientTools, Term, ScreenTools, IsoEngine, PVSB, BaseWin,
     8
     9  LCLIntf, LCLType, Messages, SysUtils, Classes, Graphics, Controls, Forms,
    910  ExtCtrls, ButtonB, ButtonBase, Menus, Types;
    1011
     
    196197      if pix and cpType = 0 then
    197198        if (pix and cpIndex = imPalace) and (MyRO.Government <> gAnarchy) then
    198           DpiBitBlt(offscreen.Canvas.Handle, x + 16, y + (16 - 1), xSizeSmall,
    199             ySizeSmall, SmallImp.Canvas.Handle, (MyRO.Government - 1) *
    200             xSizeSmall, ySizeSmall, SRCCOPY)
     199          DpiBitCanvas(offscreen.Canvas, x + 16, y + (16 - 1), xSizeSmall,
     200            ySizeSmall, SmallImp.Canvas, (MyRO.Government - 1) *
     201            xSizeSmall, ySizeSmall)
    201202        else
    202           DpiBitBlt(offscreen.Canvas.Handle, x + 16, y + (16 - 1), xSizeSmall,
    203             ySizeSmall, SmallImp.Canvas.Handle, pix and cpIndex mod 7 *
     203          DpiBitCanvas(offscreen.Canvas, x + 16, y + (16 - 1), xSizeSmall,
     204            ySizeSmall, SmallImp.Canvas, pix and cpIndex mod 7 *
    204205            xSizeSmall, (pix and cpIndex + SystemIconLines * 7) div 7 *
    205             ySizeSmall, SRCCOPY)
     206            ySizeSmall)
    206207      else
    207         DpiBitBlt(offscreen.Canvas.Handle, x + 16, y + (16 - 1), xSizeSmall,
    208           ySizeSmall, SmallImp.Canvas.Handle, (3 + pix and cpIndex) *
    209           xSizeSmall, 0, SRCCOPY)
     208        DpiBitCanvas(offscreen.Canvas, x + 16, y + (16 - 1), xSizeSmall,
     209          ySizeSmall, SmallImp.Canvas, (3 + pix and cpIndex) *
     210          xSizeSmall, 0);
    210211    end;
    211212  end;
     
    567568                  MainTexture.clBevelLight, MainTexture.clBevelShade);
    568569                if AdvIcon[lix] < 84 then
    569                   DpiBitBlt(offscreen.Canvas.Handle, (8 + 16), y0, xSizeSmall,
    570                     ySizeSmall, SmallImp.Canvas.Handle,
     570                  DpiBitCanvas(offscreen.Canvas, (8 + 16), y0, xSizeSmall,
     571                    ySizeSmall, SmallImp.Canvas,
    571572                    (AdvIcon[lix] + SystemIconLines * 7) mod 7 * xSizeSmall,
    572573                    (AdvIcon[lix] + SystemIconLines * 7) div 7 *
    573                     ySizeSmall, SRCCOPY)
     574                    ySizeSmall)
    574575                else
    575576                  Dump(offscreen, HGrSystem, (8 + 16), y0, 36, 20,
     
    577578                    295 + (AdvIcon[lix] - 84) div 8 * 21);
    578579                j := AdvValue[lix] div 1000;
    579                 DpiBitBlt(Handle, (8 + 16 - 4), y0 + 2, 14, 14,
    580                   GrExt[HGrSystem].Mask.Canvas.Handle, 127 + j * 15,
     580                DpiBitCanvas(Canvas, (8 + 16 - 4), y0 + 2, 14, 14,
     581                  GrExt[HGrSystem].Mask.Canvas, 127 + j * 15,
    581582                  85, SRCAND);
    582583                Sprite(offscreen, HGrSystem, (8 + 16 - 5), y0 + 1, 14, 14,
     
    672673              8 + 16 + xSizeSmall, y0 - 15 + (16 - 1 + ySizeSmall),
    673674              MainTexture.clBevelLight, MainTexture.clBevelShade);
    674             DpiBitBlt(offscreen.Canvas.Handle, 8 + 16, y0 - 15 + (16 - 1),
    675               xSizeSmall, ySizeSmall, SmallImp.Canvas.Handle,
    676               (lix - 1) * xSizeSmall, ySizeSmall, SRCCOPY);
     675            DpiBitCanvas(offscreen.Canvas, 8 + 16, y0 - 15 + (16 - 1),
     676              xSizeSmall, ySizeSmall, SmallImp.Canvas,
     677              (lix - 1) * xSizeSmall, ySizeSmall);
    677678          end
    678679        end;
     
    815816        LoweredTextOut(Canvas, -1, MainTexture, xScreen + 10,
    816817          ClientHeight - 29, s);
    817         BitBltCanvas(ScienceNationDot.Canvas, 0, 0, 17, 17, Canvas,
    818           xScreen - 10, ClientHeight - 27, SRCCOPY);
     818        DpiBitCanvas(ScienceNationDot.Canvas, 0, 0, 17, 17, Canvas,
     819          xScreen - 10, ClientHeight - 27);
    819820        ImageOp_BCC(ScienceNationDot, Templates, 0, 0, 114, 211, 17, 17,
    820821          MainTexture.clBevelShade, Tribe[ScienceNation].Color);
    821         DpiBitBlt(Canvas.Handle, xScreen - 10, ClientHeight - 27, 17, 17,
    822           ScienceNationDot.Canvas.Handle, 0, 0, SRCCOPY);
     822        DpiBitCanvas(Canvas, xScreen - 10, ClientHeight - 27, 17, 17,
     823          ScienceNationDot.Canvas, 0, 0);
    823824      end;
    824825    end
  • branches/highdpi/LocalPlayer/TechTree.pas

    r193 r210  
    55
    66uses
    7   ScreenTools, Messg, LCLIntf, LCLType, Messages, SysUtils, Classes, Graphics,
    8   Controls, Forms, ButtonBase, ButtonB, DrawDlg, UDpiControls;
     7  UDpiControls, ScreenTools, LCLIntf, LCLType, SysUtils, Classes, Graphics,
     8  Controls, Forms, ButtonB, DrawDlg;
    99
    1010type
     
    3030  TechTreeDlg: TTechTreeDlg;
    3131
     32
    3233implementation
    3334
     
    7778  X, w: Integer;
    7879begin
    79   with Canvas do
    80   begin
     80  with Canvas do begin
    8181    // black border
    8282    brush.color := $000000;
     
    107107        -BlackBorder - yOffset, Paper);
    108108  end;
    109   DpiBitBlt(Canvas.Handle, max(BlackBorder, BlackBorder + xOffset),
     109  DpiBitCanvas(Canvas, max(BlackBorder, BlackBorder + xOffset),
    110110    max(BlackBorder, BlackBorder + yOffset),
    111111    min(Image.width, min(Image.width + xOffset,
     
    113113    ), min(Image.height, min(Image.height + yOffset,
    114114    min(ClientHeight - 2 * BlackBorder, ClientHeight - 2 * BlackBorder -
    115     yOffset))), Image.Canvas.Handle, max(0, -xOffset),
    116     max(0, -yOffset), SRCCOPY);
     115    yOffset))), Image.Canvas, max(0, -xOffset),
     116    max(0, -yOffset));
    117117end;
    118118
    119119procedure TTechTreeDlg.FormShow(Sender: TObject);
    120120var
    121   X, Y, ad, TexWidth, TexHeight: Integer;
     121  X, Y, ad: Integer;
    122122  s: string;
    123   SrcPixel, DstPixel: TPixelPointer;
    124 begin
    125   if Image = nil then
    126   begin
     123const
     124  TransparentColor = $7F007F;
     125begin
     126  if Image = nil then begin
    127127    Image := TDpiBitmap.Create;
    128128    Image.PixelFormat := pf24bit;
    129129    LoadGraphicFile(Image, HomeDir + 'Help' + DirectorySeparator + 'AdvTree.png', gfNoGamma);
    130130
    131     with Image.Canvas do
    132     begin
     131    with Image.Canvas do begin
    133132      // write advance names
    134133      Font.Assign(UniFont[ftSmall]);
     
    146145            TextOut(xStart + X * xPitch + 2, yStart + Y * yPitch, s);
    147146            Pixels[xStart + X * xPitch + 10, yStart + Y * yPitch - 1]
    148               := $7F007F;
     147              := TransparentColor;
    149148          end
    150149        end;
     
    161160    end;
    162161
    163     // texturize background
    164     Image.BeginUpdate;
    165     TexWidth := Paper.Width;
    166     TexHeight := Paper.Height;
    167     DstPixel.Init(Image);
    168     SrcPixel.Init(Paper);
    169     for Y := 0 to Image.Height - 1 do begin
    170       for X := 0 to Image.Width - 1 do begin
    171         if (DstPixel.Pixel^.ARGB and $FFFFFF) = $7F007F then begin // transparent
    172           SrcPixel.SetXY(X mod TexWidth, Y mod TexHeight);
    173           DstPixel.Pixel^.B := SrcPixel.Pixel^.B;
    174           DstPixel.Pixel^.G := SrcPixel.Pixel^.G;
    175           DstPixel.Pixel^.R := SrcPixel.Pixel^.R;
    176         end;
    177         DstPixel.NextPixel;
    178       end;
    179       DstPixel.NextLine;
    180     end;
    181     Image.EndUpdate;
     162    Texturize(Image, Paper, TransparentColor);
    182163  end;
    183164
     
    204185    xDown := X;
    205186    yDown := Y;
    206   end
     187  end;
    207188end;
    208189
     
    234215
    235216    SmartInvalidate;
    236   end
     217  end;
    237218end;
    238219
     
    246227procedure TTechTreeDlg.CloseBtnClick(Sender: TObject);
    247228begin
    248   Close();
     229  Close;
    249230end;
    250231
  • branches/highdpi/LocalPlayer/Term.lfm

    r90 r210  
    11object MainScreen: TMainScreen
    22  Left = 231
    3   Height = 480
     3  Height = 600
    44  Top = 190
    5   Width = 800
     5  Width = 1000
    66  HorzScrollBar.Visible = False
    77  VertScrollBar.Visible = False
    88  Caption = 'C-evo'
    9   ClientHeight = 480
    10   ClientWidth = 800
     9  ClientHeight = 600
     10  ClientWidth = 1000
    1111  Color = clBtnFace
    12   Constraints.MinHeight = 480
    13   Constraints.MinWidth = 800
     12  Constraints.MinHeight = 600
     13  Constraints.MinWidth = 1000
     14  DesignTimePPI = 120
    1415  Font.Color = clWindowText
    15   Font.Height = -13
     16  Font.Height = -16
    1617  Font.Name = 'MS Sans Serif'
    1718  KeyPreview = True
     
    3031  OnShow = FormShow
    3132  Position = poDefault
    32   LCLVersion = '1.6.0.4'
     33  LCLVersion = '2.0.6.0'
    3334  WindowState = wsMaximized
    3435  object UnitBtn: TButtonB
    3536    Tag = 14
    36     Left = 208
    37     Height = 25
    38     Top = 384
    39     Width = 25
     37    Left = 260
     38    Height = 31
     39    Top = 480
     40    Width = 31
    4041    Visible = False
    4142    Down = False
     
    4647  object MapBtn0: TButtonC
    4748    Tag = 51
    48     Left = 16
    49     Height = 12
    50     Top = 304
    51     Width = 12
     49    Left = 20
     50    Height = 15
     51    Top = 380
     52    Width = 15
    5253    Visible = False
    5354    Down = False
     
    5859  object MapBtn1: TButtonC
    5960    Tag = 291
    60     Left = 16
    61     Height = 12
    62     Top = 320
    63     Width = 12
     61    Left = 20
     62    Height = 15
     63    Top = 400
     64    Width = 15
    6465    Visible = False
    6566    Down = False
     
    7071  object MapBtn4: TButtonC
    7172    Tag = 1028
    72     Left = 16
    73     Height = 12
    74     Top = 368
    75     Width = 12
     73    Left = 20
     74    Height = 15
     75    Top = 460
     76    Width = 15
    7677    Visible = False
    7778    Down = False
     
    8283  object MapBtn5: TButtonC
    8384    Tag = 1328
    84     Left = 16
    85     Height = 12
    86     Top = 384
    87     Width = 12
     85    Left = 20
     86    Height = 15
     87    Top = 480
     88    Width = 15
    8889    Visible = False
    8990    Down = False
     
    9495  object MapBtn6: TButtonC
    9596    Tag = 1541
    96     Left = 16
    97     Height = 12
    98     Top = 400
    99     Width = 12
     97    Left = 20
     98    Height = 15
     99    Top = 500
     100    Width = 15
    100101    Visible = False
    101102    Down = False
     
    106107  object TerrainBtn: TButtonB
    107108    Tag = 28
    108     Left = 240
    109     Height = 25
    110     Top = 384
    111     Width = 25
     109    Left = 300
     110    Height = 31
     111    Top = 480
     112    Width = 31
    112113    Visible = False
    113114    Down = False
     
    118119  object UnitInfoBtn: TButtonB
    119120    Tag = 15
    120     Left = 176
    121     Height = 25
    122     Top = 384
    123     Width = 25
     121    Left = 220
     122    Height = 31
     123    Top = 480
     124    Width = 31
    124125    Visible = False
    125126    Down = False
     
    129130  end
    130131  object EOT: TEOTButton
    131     Left = 712
    132     Height = 48
    133     Top = 368
    134     Width = 48
     132    Left = 890
     133    Height = 60
     134    Top = 460
     135    Width = 60
    135136    Visible = False
    136137    Down = False
     
    141142  object MenuArea: TArea
    142143    Left = 2
    143     Height = 36
     144    Height = 45
    144145    Top = 1
    145     Width = 36
     146    Width = 45
    146147  end
    147148  object TreasuryArea: TArea
    148     Left = 208
    149     Height = 36
     149    Left = 260
     150    Height = 45
    150151    Top = 1
    151     Width = 164
     152    Width = 205
    152153  end
    153154  object ResearchArea: TArea
    154     Left = 384
    155     Height = 36
     155    Left = 480
     156    Height = 45
    156157    Top = 1
    157     Width = 240
     158    Width = 300
    158159  end
    159160  object ManagementArea: TArea
    160     Left = 704
    161     Height = 40
    162     Top = 312
    163     Width = 56
     161    Left = 880
     162    Height = 50
     163    Top = 390
     164    Width = 70
    164165  end
    165166  object MovieSpeed1Btn: TButtonB
    166167    Tag = 256
    167     Left = 384
    168     Height = 25
    169     Top = 384
    170     Width = 25
     168    Left = 480
     169    Height = 31
     170    Top = 480
     171    Width = 31
    171172    Visible = False
    172173    Down = False
     
    177178  object MovieSpeed2Btn: TButtonB
    178179    Tag = 512
    179     Left = 416
    180     Height = 25
    181     Top = 384
    182     Width = 25
     180    Left = 520
     181    Height = 31
     182    Top = 480
     183    Width = 31
    183184    Visible = False
    184185    Down = False
     
    189190  object MovieSpeed3Btn: TButtonB
    190191    Tag = 768
    191     Left = 448
    192     Height = 25
    193     Top = 384
    194     Width = 25
     192    Left = 560
     193    Height = 31
     194    Top = 480
     195    Width = 31
    195196    Visible = False
    196197    Down = False
     
    201202  object MovieSpeed4Btn: TButtonB
    202203    Tag = 1024
    203     Left = 480
    204     Height = 25
    205     Top = 384
    206     Width = 25
     204    Left = 600
     205    Height = 31
     206    Top = 480
     207    Width = 31
    207208    Visible = False
    208209    Down = False
     
    215216    Interval = 50
    216217    OnTimer = Timer1Timer
    217     left = 8
    218     top = 48
     218    left = 10
     219    top = 60
    219220  end
    220221  object GamePopup: TPopupMenu
    221222    AutoPopup = False
    222     left = 40
    223     top = 48
     223    left = 50
     224    top = 60
    224225    object mHelp: TMenuItem
    225226      Tag = 7
     
    452453          RadioItem = True
    453454          OnClick = mNormalTilesClick
     455        end
     456        object mBigTiles: TMenuItem
     457          Caption = '90px'
     458          RadioItem = True
     459          OnClick = mBigTilesClick
    454460        end
    455461      end
     
    580586  object UnitPopup: TPopupMenu
    581587    AutoPopup = False
    582     left = 104
    583     top = 48
     588    left = 130
     589    top = 60
    584590    object mdisband: TMenuItem
    585591      Tag = 72
     
    663669  object StatPopup: TPopupMenu
    664670    AutoPopup = False
    665     left = 72
    666     top = 48
     671    left = 90
     672    top = 60
    667673    object mUnitStat: TMenuItem
    668674      Tag = 9
     
    719725  end
    720726  object EditPopup: TPopupMenu
    721     left = 168
    722     top = 48
     727    left = 210
     728    top = 60
    723729    object mCreateUnit: TMenuItem
    724730      Tag = 47
     
    726732  end
    727733  object TerrainPopup: TPopupMenu
    728     left = 136
    729     top = 48
     734    left = 170
     735    top = 60
    730736    object mtrans: TMenuItem
    731737      Tag = 273
  • branches/highdpi/LocalPlayer/Term.pas

    r193 r210  
    55
    66uses
    7 {$IFDEF Windows}
     7  UDpiControls, {$IFDEF Windows}
    88  Windows,
    99{$ENDIF}
     
    1313  Protocol, Tribes, PVSB, ClientTools, ScreenTools, BaseWin, Messg, ButtonBase,
    1414  LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, DrawDlg, Types,
    15   Forms, Menus, ExtCtrls, dateutils, Platform, ButtonB, ButtonC, EOTButton, Area,
    16   UDpiControls;
     15  Forms, Menus, ExtCtrls, dateutils, Platform, ButtonB, ButtonC, EOTButton, Area;
    1716
    1817const
     
    2726
    2827  TMainScreen = class(TDrawDlg)
     28    mBigTiles: TMenuItem;
    2929    Timer1: TTimer;
    3030    GamePopup: TPopupMenu;
     
    219219    procedure mSmallTilesClick(Sender: TObject);
    220220    procedure mNormalTilesClick(Sender: TObject);
     221    procedure mBigTilesClick(Sender: TObject);
    221222    procedure GrWallBtnDownChanged(Sender: TObject);
    222223    procedure BareBtnDownChanged(Sender: TObject);
     
    234235    Closable, RepaintOnResize, Tracking, TurnComplete, Edited, GoOnPhase,
    235236      HaveStrategyAdvice, FirstMovieTurn: boolean;
     237    function ChooseUnusedTribe: integer;
     238    procedure GetTribeList;
     239    procedure InitModule;
     240    procedure InitTurn(NewPlayer: integer);
    236241    procedure ScrollBarUpdate(Sender: TObject);
    237242    procedure ArrangeMidPanel;
     
    271276    procedure SetTileSize(x, y: integer);
    272277    procedure RectInvalidate(Left, Top, Rigth, Bottom: integer);
     278    procedure ShowEnemyShipChange(ShowShipChange: TShowShipChange);
    273279    procedure SmartRectInvalidate(Left, Top, Rigth, Bottom: integer);
     280    procedure LoadSettings;
    274281    procedure SaveSettings;
    275282    procedure OnScroll(var m: TMessage); message WM_VSCROLL;
    276283    procedure OnEOT(var Msg: TMessage); message WM_EOT;
     284    procedure SoundPreload(Check: integer);
    277285  public
    278286    UsedOffscreenWidth, UsedOffscreenHeight: integer;
     
    391399    'CITY_WONDEREX', 'CITY_EMDELAY', 'CITY_FOUNDED', 'CITY_FOUNDED', '',
    392400    'CITY_INVALIDTYPE');
     401
     402  // sound blocks for preload
     403  sbStart = $01;
     404  sbWonder = $02;
     405  sbScience = $04;
     406  sbContact = $08;
     407  sbTurn = $10;
     408  sbAll = $FF;
    393409
    394410type
     
    460476procedure HelpOnTerrain(Loc, NewMode: integer);
    461477
     478
    462479implementation
    463480
    464481uses
    465482  Directories, IsoEngine, CityScreen, Draft, MessgEx, Select, CityType, Help,
    466   UnitStat, Log, Diagram, NatStat, Wonders, Enhance, Nego,
    467   Battle, Rates, TechTree, Registry;
     483  UnitStat, Log, Diagram, NatStat, Wonders, Enhance, Nego, UPixelPointer, Sound,
     484  Battle, Rates, TechTree, Registry, Global;
    468485
    469486{$R *.lfm}
     
    560577        if ydivider > ySizeSmall then
    561578          ydivider := ySizeSmall;
    562         PixelPtr.Init(BigImp, 0, cut + iy * ySizeBig + y);
     579        PixelPtr := PixelPointer(BigImp, 0, cut + iy * ySizeBig + y);
    563580        for x := 0 to xSizeBig - 1 do
    564581        begin
     
    593610  SmallImp.BeginUpdate;
    594611  for y := 0 to ny - 1 do begin
    595     PixelPtr.Init(SmallImp, 0, y);
     612    PixelPtr := PixelPointer(SmallImp, 0, y);
    596613    for x := 0 to nx - 1 do
    597614      for ch := 0 to 2 do begin
     
    12921309end;
    12931310
    1294 procedure TMainScreen.Client(Command, NewPlayer: integer; var Data);
    1295 
    1296   procedure GetTribeList;
    1297   var
    1298     SearchRec: TSearchRec;
    1299     Color: TColor;
    1300     Name: string;
    1301     ok: boolean;
    1302   begin
    1303     UnusedTribeFiles.Clear;
    1304     ok := FindFirst(LocalizedFilePath('Tribes') + DirectorySeparator + '*.tribe.txt',
     1311procedure TMainScreen.SoundPreload(Check: integer);
     1312const
     1313  nStartBlock = 27;
     1314  StartBlock: array [0 .. nStartBlock - 1] of string = ('INVALID', 'TURNEND',
     1315    'DISBAND', 'CHEAT', 'MSG_DEFAULT', 'WARNING_DISORDER', 'WARNING_FAMINE',
     1316    'WARNING_LOWSUPPORT', 'WARNING_LOWFUNDS', 'MOVE_MOUNTAIN', 'MOVE_LOAD',
     1317    'MOVE_UNLOAD', 'MOVE_DIE', 'NOMOVE_TIME', 'NOMOVE_DOMAIN',
     1318    'NOMOVE_DEFAULT', 'CITY_SELLIMP', 'CITY_REBUILDIMP', 'CITY_BUYPROJECT',
     1319    'CITY_UTILIZE', 'NEWMODEL_0', 'NEWADVANCE_0', 'AGE_0', 'REVOLUTION',
     1320    'NEWGOV', 'CITY_INVALIDTYPE', 'MSG_GAMEOVER');
     1321
     1322  nWonderBlock = 6;
     1323  WonderBlock: array [0 .. nWonderBlock - 1] of string = ('WONDER_BUILT',
     1324    'WONDER_CAPTURED', 'WONDER_EXPIRED', 'WONDER_DESTROYED', 'MSG_COLDWAR',
     1325    'NEWADVANCE_GRLIB');
     1326
     1327  nScienceBlock = 17;
     1328  ScienceBlock: array [0 .. nScienceBlock - 1] of string = ('MOVE_PARACHUTE',
     1329    'MOVE_PLANESTART', 'MOVE_PLANELANDING', 'MOVE_COVERT', 'NEWMODEL_1',
     1330    'NEWMODEL_2', 'NEWMODEL_3', 'NEWADVANCE_1', 'NEWADVANCE_2',
     1331    'NEWADVANCE_3', 'AGE_1', 'AGE_2', 'AGE_3', 'SHIP_BUILT', 'SHIP_TRADED',
     1332    'SHIP_CAPTURED', 'SHIP_DESTROYED');
     1333
     1334  nContactBlock = 20;
     1335  ContactBlock: array [0 .. nContactBlock - 1] of string = ('NEWTREATY',
     1336    'CANCELTREATY', 'ACCEPTOFFER', 'MSG_WITHDRAW', 'MSG_BANKRUPT',
     1337    'CONTACT_0', 'CONTACT_1', 'CONTACT_2', 'CONTACT_3', 'CONTACT_4',
     1338    'CONTACT_5', 'CONTACT_5', 'CONTACT_6', 'NEGO_REJECTED', 'MOVE_CAPTURE',
     1339    'MOVE_EXPEL', 'NOMOVE_TREATY', 'NOMOVE_ZOC', 'NOMOVE_SUBMARINE',
     1340    'NOMOVE_STEALTH');
     1341
     1342var
     1343  i, cix, mix: integer;
     1344  need: boolean;
     1345  mi: TModelInfo;
     1346begin
     1347  if Check and sbStart and not SoundPreloadDone <> 0 then
     1348  begin
     1349    for i := 0 to nStartBlock - 1 do
     1350      PreparePlay(StartBlock[i]);
     1351    SoundPreloadDone := SoundPreloadDone or sbStart;
     1352  end;
     1353  if Check and sbWonder and not SoundPreloadDone <> 0 then
     1354  begin
     1355    need := false;
     1356    for i := 0 to 27 do
     1357      if MyRO.Wonder[i].CityID <> -1 then
     1358        need := true;
     1359    if need then
     1360    begin
     1361      for i := 0 to nWonderBlock - 1 do
     1362        PreparePlay(WonderBlock[i]);
     1363      SoundPreloadDone := SoundPreloadDone or sbWonder;
     1364    end;
     1365  end;
     1366  if (Check and sbScience and not SoundPreloadDone <> 0) and
     1367    (MyRO.Tech[adScience] >= tsApplicable) then
     1368  begin
     1369    for i := 0 to nScienceBlock - 1 do
     1370      PreparePlay(ScienceBlock[i]);
     1371    SoundPreloadDone := SoundPreloadDone or sbScience;
     1372  end;
     1373  if (Check and sbContact and not SoundPreloadDone <> 0) and
     1374    (MyRO.nEnemyModel + MyRO.nEnemyCity > 0) then
     1375  begin
     1376    for i := 0 to nContactBlock - 1 do
     1377      PreparePlay(ContactBlock[i]);
     1378    SoundPreloadDone := SoundPreloadDone or sbContact;
     1379  end;
     1380  if Check and sbTurn <> 0 then
     1381  begin
     1382    if MyRO.Happened and phShipComplete <> 0 then
     1383      PreparePlay('MSG_YOUWIN');
     1384    if MyData.ToldAlive <> MyRO.Alive then
     1385      PreparePlay('MSG_EXTINCT');
     1386    for cix := 0 to MyRO.nCity - 1 do
     1387      with MyCity[cix] do
     1388        if (Loc >= 0) and (Flags and CityRepMask <> 0) then
     1389          for i := 0 to 12 do
     1390            if 1 shl i and Flags and CityRepMask <> 0 then
     1391              PreparePlay(CityEventSoundItem[i]);
     1392    for mix := 0 to MyRO.nModel - 1 do
     1393      with MyModel[mix] do
     1394        if Attack > 0 then
     1395        begin
     1396          MakeModelInfo(me, mix, MyModel[mix], mi);
     1397          PreparePlay(AttackSound(ModelCode(mi)));
     1398        end;
     1399  end;
     1400end;
     1401
     1402procedure TMainScreen.GetTribeList;
     1403var
     1404  SearchRec: TSearchRec;
     1405  Color: TColor;
     1406  Name: string;
     1407  ok: boolean;
     1408begin
     1409  UnusedTribeFiles.Clear;
     1410  ok := FindFirst(LocalizedFilePath('Tribes') + DirectorySeparator + '*.tribe.txt',
     1411    faArchive + faReadOnly, SearchRec) = 0;
     1412  if not ok then
     1413  begin
     1414    FindClose(SearchRec);
     1415    ok := FindFirst(LocalizedFilePath('Tribes' + DirectorySeparator + '*.tribe.txt'),
    13051416      faArchive + faReadOnly, SearchRec) = 0;
    1306     if not ok then
    1307     begin
    1308       FindClose(SearchRec);
    1309       ok := FindFirst(LocalizedFilePath('Tribes' + DirectorySeparator + '*.tribe.txt'),
    1310         faArchive + faReadOnly, SearchRec) = 0;
     1417  end;
     1418  if ok then
     1419    repeat
     1420      SearchRec.Name := Copy(SearchRec.Name, 1, Length(SearchRec.Name) - 10);
     1421      if GetTribeInfo(SearchRec.Name, Name, Color) then
     1422        UnusedTribeFiles.AddObject(SearchRec.Name, TObject(Color));
     1423    until FindNext(SearchRec) <> 0;
     1424  FindClose(SearchRec);
     1425end;
     1426
     1427function TMainScreen.ChooseUnusedTribe: integer;
     1428var
     1429  i, j, ColorDistance, BestColorDistance, TestColorDistance,
     1430    CountBest: integer;
     1431begin
     1432  assert(UnusedTribeFiles.Count > 0);
     1433  result := -1;
     1434  BestColorDistance := -1;
     1435  for j := 0 to UnusedTribeFiles.Count - 1 do
     1436  begin
     1437    ColorDistance := 250; // consider differences more than this infinite
     1438    for i := 0 to nPl - 1 do
     1439      if Tribe[i] <> nil then
     1440      begin
     1441        TestColorDistance := abs(integer(UnusedTribeFiles.Objects[j])
     1442          shr 16 and $FF - Tribe[i].Color shr 16 and $FF) +
     1443          abs(integer(UnusedTribeFiles.Objects[j]) shr 8 and
     1444          $FF - Tribe[i].Color shr 8 and $FF) * 3 +
     1445          abs(integer(UnusedTribeFiles.Objects[j]) and
     1446          $FF - Tribe[i].Color and $FF) * 2;
     1447        if TestColorDistance < ColorDistance then
     1448          ColorDistance := TestColorDistance
     1449      end;
     1450    if ColorDistance > BestColorDistance then
     1451    begin
     1452      CountBest := 0;
     1453      BestColorDistance := ColorDistance
    13111454    end;
    1312     if ok then
    1313       repeat
    1314         SearchRec.Name := Copy(SearchRec.Name, 1, Length(SearchRec.Name) - 10);
    1315         if GetTribeInfo(SearchRec.Name, Name, Color) then
    1316           UnusedTribeFiles.AddObject(SearchRec.Name, TObject(Color));
    1317       until FindNext(SearchRec) <> 0;
    1318     FindClose(SearchRec);
    1319   end;
    1320 
    1321   function ChooseUnusedTribe: integer;
    1322   var
    1323     i, j, ColorDistance, BestColorDistance, TestColorDistance,
    1324       CountBest: integer;
    1325   begin
    1326     assert(UnusedTribeFiles.Count > 0);
    1327     result := -1;
    1328     BestColorDistance := -1;
    1329     for j := 0 to UnusedTribeFiles.Count - 1 do
    1330     begin
    1331       ColorDistance := 250; // consider differences more than this infinite
    1332       for i := 0 to nPl - 1 do
    1333         if Tribe[i] <> nil then
    1334         begin
    1335           TestColorDistance := abs(integer(UnusedTribeFiles.Objects[j])
    1336             shr 16 and $FF - Tribe[i].Color shr 16 and $FF) +
    1337             abs(integer(UnusedTribeFiles.Objects[j]) shr 8 and
    1338             $FF - Tribe[i].Color shr 8 and $FF) * 3 +
    1339             abs(integer(UnusedTribeFiles.Objects[j]) and
    1340             $FF - Tribe[i].Color and $FF) * 2;
    1341           if TestColorDistance < ColorDistance then
    1342             ColorDistance := TestColorDistance
     1455    if ColorDistance = BestColorDistance then
     1456    begin
     1457      inc(CountBest);
     1458      if DelphiRandom(CountBest) = 0 then
     1459        result := j
     1460    end
     1461  end;
     1462end;
     1463
     1464procedure TMainScreen.ShowEnemyShipChange(ShowShipChange: TShowShipChange);
     1465var
     1466  i, TestCost, MostCost: integer;
     1467  Ship1Plus, Ship2Plus: boolean;
     1468begin
     1469  with ShowShipChange, MessgExDlg do
     1470  begin
     1471    case Reason of
     1472      scrProduction:
     1473        begin
     1474          OpenSound := 'SHIP_BUILT';
     1475          MessgText := Tribe[Ship1Owner].TPhrase('SHIPBUILT');
     1476          IconKind := mikShip;
     1477          IconIndex := Ship1Owner;
    13431478        end;
    1344       if ColorDistance > BestColorDistance then
    1345       begin
    1346         CountBest := 0;
    1347         BestColorDistance := ColorDistance
     1479
     1480      scrDestruction:
     1481        begin
     1482          OpenSound := 'SHIP_DESTROYED';
     1483          MessgText := Tribe[Ship1Owner].TPhrase('SHIPDESTROYED');
     1484          IconKind := mikImp;
     1485        end;
     1486
     1487      scrTrade:
     1488        begin
     1489          OpenSound := 'SHIP_TRADED';
     1490          Ship1Plus := false;
     1491          Ship2Plus := false;
     1492          for i := 0 to nShipPart - 1 do
     1493          begin
     1494            if Ship1Change[i] > 0 then
     1495              Ship1Plus := true;
     1496            if Ship2Change[i] > 0 then
     1497              Ship2Plus := true;
     1498          end;
     1499          if Ship1Plus and Ship2Plus then
     1500            MessgText := Tribe[Ship1Owner].TPhrase('SHIPBITRADE1') + ' ' +
     1501              Tribe[Ship2Owner].TPhrase('SHIPBITRADE2')
     1502          else if Ship1Plus then
     1503            MessgText := Tribe[Ship1Owner].TPhrase('SHIPUNITRADE1') + ' ' +
     1504              Tribe[Ship2Owner].TPhrase('SHIPUNITRADE2')
     1505          else // if Ship2Plus then
     1506            MessgText := Tribe[Ship2Owner].TPhrase('SHIPUNITRADE1') + ' ' +
     1507              Tribe[Ship1Owner].TPhrase('SHIPUNITRADE2');
     1508          IconKind := mikImp;
     1509        end;
     1510
     1511      scrCapture:
     1512        begin
     1513          OpenSound := 'SHIP_CAPTURED';
     1514          MessgText := Tribe[Ship2Owner].TPhrase('SHIPCAPTURE1') + ' ' +
     1515            Tribe[Ship1Owner].TPhrase('SHIPCAPTURE2');
     1516          IconKind := mikShip;
     1517          IconIndex := Ship2Owner;
     1518        end
     1519    end;
     1520
     1521    if IconKind = mikImp then
     1522    begin
     1523      MostCost := 0;
     1524      for i := 0 to nShipPart - 1 do
     1525      begin
     1526        TestCost := abs(Ship1Change[i]) * Imp[imShipComp + i].Cost;
     1527        if TestCost > MostCost then
     1528        begin
     1529          MostCost := TestCost;
     1530          IconIndex := imShipComp + i
     1531        end
    13481532      end;
    1349       if ColorDistance = BestColorDistance then
    1350       begin
    1351         inc(CountBest);
    1352         if DelphiRandom(CountBest) = 0 then
    1353           result := j
    1354       end
    13551533    end;
    1356   end;
    1357 
    1358   procedure ShowEnemyShipChange(ShowShipChange: TShowShipChange);
    1359   var
    1360     i, TestCost, MostCost: integer;
    1361     Ship1Plus, Ship2Plus: boolean;
    1362   begin
    1363     with ShowShipChange, MessgExDlg do
    1364     begin
    1365       case Reason of
    1366         scrProduction:
    1367           begin
    1368             OpenSound := 'SHIP_BUILT';
    1369             MessgText := Tribe[Ship1Owner].TPhrase('SHIPBUILT');
    1370             IconKind := mikShip;
    1371             IconIndex := Ship1Owner;
    1372           end;
    1373 
    1374         scrDestruction:
    1375           begin
    1376             OpenSound := 'SHIP_DESTROYED';
    1377             MessgText := Tribe[Ship1Owner].TPhrase('SHIPDESTROYED');
    1378             IconKind := mikImp;
    1379           end;
    1380 
    1381         scrTrade:
    1382           begin
    1383             OpenSound := 'SHIP_TRADED';
    1384             Ship1Plus := false;
    1385             Ship2Plus := false;
    1386             for i := 0 to nShipPart - 1 do
    1387             begin
    1388               if Ship1Change[i] > 0 then
    1389                 Ship1Plus := true;
    1390               if Ship2Change[i] > 0 then
    1391                 Ship2Plus := true;
    1392             end;
    1393             if Ship1Plus and Ship2Plus then
    1394               MessgText := Tribe[Ship1Owner].TPhrase('SHIPBITRADE1') + ' ' +
    1395                 Tribe[Ship2Owner].TPhrase('SHIPBITRADE2')
    1396             else if Ship1Plus then
    1397               MessgText := Tribe[Ship1Owner].TPhrase('SHIPUNITRADE1') + ' ' +
    1398                 Tribe[Ship2Owner].TPhrase('SHIPUNITRADE2')
    1399             else // if Ship2Plus then
    1400               MessgText := Tribe[Ship2Owner].TPhrase('SHIPUNITRADE1') + ' ' +
    1401                 Tribe[Ship1Owner].TPhrase('SHIPUNITRADE2');
    1402             IconKind := mikImp;
    1403           end;
    1404 
    1405         scrCapture:
    1406           begin
    1407             OpenSound := 'SHIP_CAPTURED';
    1408             MessgText := Tribe[Ship2Owner].TPhrase('SHIPCAPTURE1') + ' ' +
    1409               Tribe[Ship1Owner].TPhrase('SHIPCAPTURE2');
    1410             IconKind := mikShip;
    1411             IconIndex := Ship2Owner;
    1412           end
    1413       end;
    1414 
    1415       if IconKind = mikImp then
    1416       begin
    1417         MostCost := 0;
    1418         for i := 0 to nShipPart - 1 do
    1419         begin
    1420           TestCost := abs(Ship1Change[i]) * Imp[imShipComp + i].Cost;
    1421           if TestCost > MostCost then
    1422           begin
    1423             MostCost := TestCost;
    1424             IconIndex := imShipComp + i
    1425           end
    1426         end;
    1427       end;
    1428 
    1429       Kind := mkOk;
    1430       ShowModal;
    1431     end;
    1432   end;
    1433 
    1434   procedure InitModule;
    1435   var
    1436     x, y, i, j, Domain: integer;
    1437   begin
    1438     { search icons for advances: }
    1439     for i := 0 to nAdv - 1 do
    1440       if i in FutureTech then
    1441         AdvIcon[i] := 96 + i - futResearchTechnology
    1442       else
    1443       begin
    1444         AdvIcon[i] := -1;
    1445         for Domain := 0 to nDomains - 1 do
    1446           for j := 0 to nUpgrade - 1 do
    1447             if upgrade[Domain, j].Preq = i then
    1448               if AdvIcon[i] >= 0 then
     1534
     1535    Kind := mkOk;
     1536    ShowModal;
     1537  end;
     1538end;
     1539
     1540procedure TMainScreen.InitModule;
     1541var
     1542  x, y, i, j, Domain: integer;
     1543begin
     1544  { search icons for advances: }
     1545  for i := 0 to nAdv - 1 do
     1546    if i in FutureTech then
     1547      AdvIcon[i] := 96 + i - futResearchTechnology
     1548    else
     1549    begin
     1550      AdvIcon[i] := -1;
     1551      for Domain := 0 to nDomains - 1 do
     1552        for j := 0 to nUpgrade - 1 do
     1553          if upgrade[Domain, j].Preq = i then
     1554            if AdvIcon[i] >= 0 then
     1555              AdvIcon[i] := 85
     1556            else
     1557              AdvIcon[i] := 86 + Domain;
     1558      for j := 0 to nFeature - 1 do
     1559        if Feature[j].Preq = i then
     1560          for Domain := 0 to nDomains - 1 do
     1561            if 1 shl Domain and Feature[j].Domains <> 0 then
     1562              if (AdvIcon[i] >= 0) and (AdvIcon[i] <> 86 + Domain) then
    14491563                AdvIcon[i] := 85
    14501564              else
    14511565                AdvIcon[i] := 86 + Domain;
    1452         for j := 0 to nFeature - 1 do
    1453           if Feature[j].Preq = i then
    1454             for Domain := 0 to nDomains - 1 do
    1455               if 1 shl Domain and Feature[j].Domains <> 0 then
    1456                 if (AdvIcon[i] >= 0) and (AdvIcon[i] <> 86 + Domain) then
    1457                   AdvIcon[i] := 85
    1458                 else
    1459                   AdvIcon[i] := 86 + Domain;
    1460         for j := 28 to nImp - 1 do
    1461           if Imp[j].Preq = i then
    1462             AdvIcon[i] := j;
    1463         for j := 28 to nImp - 1 do
    1464           if (Imp[j].Preq = i) and (Imp[j].Kind <> ikCommon) then
    1465             AdvIcon[i] := j;
    1466         for j := 0 to nJob - 1 do
    1467           if i = JobPreq[j] then
    1468             AdvIcon[i] := 84;
    1469         for j := 0 to 27 do
    1470           if Imp[j].Preq = i then
    1471             AdvIcon[i] := j;
    1472         if AdvIcon[i] < 0 then
    1473           if AdvValue[i] < 1000 then
    1474             AdvIcon[i] := -7
    1475           else
    1476             AdvIcon[i] := 24 + AdvValue[i] div 1000;
    1477         for j := 2 to nGov - 1 do
    1478           if GovPreq[j] = i then
    1479             AdvIcon[i] := j - 8;
    1480       end;
    1481     AdvIcon[adConscription] := 86 + dGround;
    1482 
    1483     UnusedTribeFiles := tstringlist.Create;
    1484     UnusedTribeFiles.Sorted := true;
    1485     TribeNames := tstringlist.Create;
    1486 
    1487     for x := 0 to 11 do
    1488       for y := 0 to 1 do
    1489         MiniColors[x, y] := GrExt[HGrSystem].Data.Canvas.Pixels[66 + x, 67 + y];
    1490     IsoEngine.Init(InitEnemyModel);
    1491     if not IsoEngine.ApplyTileSize(xxt, yyt) and ((xxt <> 48) or (yyt <> 24))
    1492     then
    1493       ApplyTileSize(48, 24);
    1494     // non-default tile size is missing a file, switch to default
    1495     MainMap := TIsoMap.Create;
    1496     MainMap.SetOutput(offscreen);
    1497 
    1498     HGrStdUnits := LoadGraphicSet('StdUnits.png');
    1499     SmallImp := TDpiBitmap.Create;
    1500     SmallImp.PixelFormat := pf24bit;
    1501     InitSmallImp;
    1502     SoundPreloadDone := 0;
    1503     StartRunning := false;
    1504     StayOnTop_Ensured := false;
    1505 
    1506     sb := TPVScrollbar.Create(Self);
    1507     sb.OnUpdate := ScrollBarUpdate;
    1508   end; { InitModule }
    1509 
    1510 // sound blocks for preload
     1566      for j := 28 to nImp - 1 do
     1567        if Imp[j].Preq = i then
     1568          AdvIcon[i] := j;
     1569      for j := 28 to nImp - 1 do
     1570        if (Imp[j].Preq = i) and (Imp[j].Kind <> ikCommon) then
     1571          AdvIcon[i] := j;
     1572      for j := 0 to nJob - 1 do
     1573        if i = JobPreq[j] then
     1574          AdvIcon[i] := 84;
     1575      for j := 0 to 27 do
     1576        if Imp[j].Preq = i then
     1577          AdvIcon[i] := j;
     1578      if AdvIcon[i] < 0 then
     1579        if AdvValue[i] < 1000 then
     1580          AdvIcon[i] := -7
     1581        else
     1582          AdvIcon[i] := 24 + AdvValue[i] div 1000;
     1583      for j := 2 to nGov - 1 do
     1584        if GovPreq[j] = i then
     1585          AdvIcon[i] := j - 8;
     1586    end;
     1587  AdvIcon[adConscription] := 86 + dGround;
     1588
     1589  UnusedTribeFiles := tstringlist.Create;
     1590  UnusedTribeFiles.Sorted := true;
     1591  TribeNames := tstringlist.Create;
     1592
     1593  for x := 0 to 11 do
     1594    for y := 0 to 1 do
     1595      MiniColors[x, y] := GrExt[HGrSystem].Data.Canvas.Pixels[66 + x, 67 + y];
     1596  IsoEngine.Init(InitEnemyModel);
     1597  if not IsoEngine.ApplyTileSize(xxt, yyt) and ((xxt <> 48) or (yyt <> 24) or (xxt <> 72))
     1598  then
     1599    ApplyTileSize(48, 24);
     1600  // non-default tile size is missing a file, switch to default
     1601  MainMap := TIsoMap.Create;
     1602  MainMap.SetOutput(offscreen);
     1603
     1604  HGrStdUnits := LoadGraphicSet('StdUnits.png');
     1605  SmallImp := TDpiBitmap.Create;
     1606  SmallImp.PixelFormat := pf24bit;
     1607  InitSmallImp;
     1608  SoundPreloadDone := 0;
     1609  StartRunning := false;
     1610  StayOnTop_Ensured := false;
     1611
     1612  sb := TPVScrollbar.Create(Self);
     1613  sb.OnUpdate := ScrollBarUpdate;
     1614end; { InitModule }
     1615
     1616procedure TMainScreen.InitTurn(NewPlayer: integer);
    15111617const
    1512   sbStart = $01;
    1513   sbWonder = $02;
    1514   sbScience = $04;
    1515   sbContact = $08;
    1516   sbTurn = $10;
    1517   sbAll = $FF;
    1518 
    1519   procedure SoundPreload(Check: integer);
    1520   const
    1521     nStartBlock = 27;
    1522     StartBlock: array [0 .. nStartBlock - 1] of string = ('INVALID', 'TURNEND',
    1523       'DISBAND', 'CHEAT', 'MSG_DEFAULT', 'WARNING_DISORDER', 'WARNING_FAMINE',
    1524       'WARNING_LOWSUPPORT', 'WARNING_LOWFUNDS', 'MOVE_MOUNTAIN', 'MOVE_LOAD',
    1525       'MOVE_UNLOAD', 'MOVE_DIE', 'NOMOVE_TIME', 'NOMOVE_DOMAIN',
    1526       'NOMOVE_DEFAULT', 'CITY_SELLIMP', 'CITY_REBUILDIMP', 'CITY_BUYPROJECT',
    1527       'CITY_UTILIZE', 'NEWMODEL_0', 'NEWADVANCE_0', 'AGE_0', 'REVOLUTION',
    1528       'NEWGOV', 'CITY_INVALIDTYPE', 'MSG_GAMEOVER');
    1529 
    1530     nWonderBlock = 6;
    1531     WonderBlock: array [0 .. nWonderBlock - 1] of string = ('WONDER_BUILT',
    1532       'WONDER_CAPTURED', 'WONDER_EXPIRED', 'WONDER_DESTROYED', 'MSG_COLDWAR',
    1533       'NEWADVANCE_GRLIB');
    1534 
    1535     nScienceBlock = 17;
    1536     ScienceBlock: array [0 .. nScienceBlock - 1] of string = ('MOVE_PARACHUTE',
    1537       'MOVE_PLANESTART', 'MOVE_PLANELANDING', 'MOVE_COVERT', 'NEWMODEL_1',
    1538       'NEWMODEL_2', 'NEWMODEL_3', 'NEWADVANCE_1', 'NEWADVANCE_2',
    1539       'NEWADVANCE_3', 'AGE_1', 'AGE_2', 'AGE_3', 'SHIP_BUILT', 'SHIP_TRADED',
    1540       'SHIP_CAPTURED', 'SHIP_DESTROYED');
    1541 
    1542     nContactBlock = 20;
    1543     ContactBlock: array [0 .. nContactBlock - 1] of string = ('NEWTREATY',
    1544       'CANCELTREATY', 'ACCEPTOFFER', 'MSG_WITHDRAW', 'MSG_BANKRUPT',
    1545       'CONTACT_0', 'CONTACT_1', 'CONTACT_2', 'CONTACT_3', 'CONTACT_4',
    1546       'CONTACT_5', 'CONTACT_5', 'CONTACT_6', 'NEGO_REJECTED', 'MOVE_CAPTURE',
    1547       'MOVE_EXPEL', 'NOMOVE_TREATY', 'NOMOVE_ZOC', 'NOMOVE_SUBMARINE',
    1548       'NOMOVE_STEALTH');
    1549 
    1550   var
    1551     i, cix, mix: integer;
    1552     need: boolean;
    1553     mi: TModelInfo;
    1554   begin
    1555     if Check and sbStart and not SoundPreloadDone <> 0 then
    1556     begin
    1557       for i := 0 to nStartBlock - 1 do
    1558         PreparePlay(StartBlock[i]);
    1559       SoundPreloadDone := SoundPreloadDone or sbStart;
    1560     end;
    1561     if Check and sbWonder and not SoundPreloadDone <> 0 then
    1562     begin
    1563       need := false;
    1564       for i := 0 to 27 do
    1565         if MyRO.Wonder[i].CityID <> -1 then
    1566           need := true;
    1567       if need then
    1568       begin
    1569         for i := 0 to nWonderBlock - 1 do
    1570           PreparePlay(WonderBlock[i]);
    1571         SoundPreloadDone := SoundPreloadDone or sbWonder;
    1572       end;
    1573     end;
    1574     if (Check and sbScience and not SoundPreloadDone <> 0) and
    1575       (MyRO.Tech[adScience] >= tsApplicable) then
    1576     begin
    1577       for i := 0 to nScienceBlock - 1 do
    1578         PreparePlay(ScienceBlock[i]);
    1579       SoundPreloadDone := SoundPreloadDone or sbScience;
    1580     end;
    1581     if (Check and sbContact and not SoundPreloadDone <> 0) and
    1582       (MyRO.nEnemyModel + MyRO.nEnemyCity > 0) then
    1583     begin
    1584       for i := 0 to nContactBlock - 1 do
    1585         PreparePlay(ContactBlock[i]);
    1586       SoundPreloadDone := SoundPreloadDone or sbContact;
    1587     end;
    1588     if Check and sbTurn <> 0 then
    1589     begin
    1590       if MyRO.Happened and phShipComplete <> 0 then
    1591         PreparePlay('MSG_YOUWIN');
    1592       if MyData.ToldAlive <> MyRO.Alive then
    1593         PreparePlay('MSG_EXTINCT');
    1594       for cix := 0 to MyRO.nCity - 1 do
    1595         with MyCity[cix] do
    1596           if (Loc >= 0) and (Flags and CityRepMask <> 0) then
    1597             for i := 0 to 12 do
    1598               if 1 shl i and Flags and CityRepMask <> 0 then
    1599                 PreparePlay(CityEventSoundItem[i]);
    1600       for mix := 0 to MyRO.nModel - 1 do
    1601         with MyModel[mix] do
    1602           if Attack > 0 then
    1603           begin
    1604             MakeModelInfo(me, mix, MyModel[mix], mi);
    1605             PreparePlay(AttackSound(ModelCode(mi)));
    1606           end
    1607     end
    1608   end;
    1609 
    1610   procedure InitTurn(p: integer);
    1611   const
    1612     nAdvBookIcon = 16;
    1613     AdvBookIcon: array [0 .. nAdvBookIcon - 1] of record Adv,
    1614       Icon: integer end = ((Adv: adPolyTheism; Icon: woZeus),
    1615       (Adv: adBronzeWorking; Icon: woColossus), (Adv: adMapMaking;
    1616       Icon: woLighthouse), (Adv: adPoetry; Icon: imTheater), (Adv: adMonotheism;
    1617       Icon: woMich), (Adv: adPhilosophy; Icon: woLeo), (Adv: adTheoryOfGravity;
    1618       Icon: woNewton), (Adv: adSteel; Icon: woEiffel), (Adv: adDemocracy;
    1619       Icon: woLiberty), (Adv: adAutomobile; Icon: imHighways),
    1620       (Adv: adSanitation; Icon: imSewer), (Adv: adElectronics; Icon: woHoover),
    1621       (Adv: adNuclearFission; Icon: woManhattan), (Adv: adRecycling;
    1622       Icon: imRecycling), (Adv: adComputers; Icon: imResLab),
    1623       (Adv: adSpaceFlight; Icon: woMIR));
    1624   var
    1625     Domain, p1, i, ad, uix, cix, MoveOptions, MoveResult, Loc1, Dist,
    1626       NewAgeCenterTo, Bankrupt, ShipMore, Winners, NewGovAvailable, dx,
    1627       dy: integer;
    1628     MoveAdviceData: TMoveAdviceData;
    1629     Picture: TModelPictureInfo;
    1630     s, Item, Item2: string;
    1631     UpdatePanel, OwnWonder, ok, Stop, ShowCityList, WondersOnly,
    1632       AllowCityScreen: boolean;
    1633   begin
    1634     if IsMultiPlayerGame and (p <> me) then
    1635     begin
    1636       UnitInfoBtn.Visible := false;
    1637       UnitBtn.Visible := false;
    1638       TerrainBtn.Visible := false;
    1639       EOT.Visible := false;
    1640     end;
    1641     if IsMultiPlayerGame and (p <> me) and
    1642       (G.RO[0].Happened and phShipComplete = 0) then
    1643     begin // inter player screen
    1644       for i := 0 to ControlCount - 1 do
    1645         if Controls[i] is TButtonC then
    1646           Controls[i].Visible := false;
    1647       me := -1;
    1648       SetMainTextureByAge(-1);
    1649       with Panel.Canvas do
    1650       begin
    1651         Brush.Color := $000000;
    1652         FillRect(Rect(0, 0, Panel.width, Panel.height));
    1653         Brush.Style := bsClear;
    1654       end;
    1655       with TopBar.Canvas do
    1656       begin
    1657         Brush.Color := $000000;
    1658         FillRect(Rect(0, 0, TopBar.width, TopBar.height));
    1659         Brush.Style := bsClear;
    1660       end;
    1661       Invalidate;
    1662 
    1663       s := TurnToString(G.RO[0].Turn);
    1664       if supervising then
    1665         SimpleMessage(Format(Phrases.Lookup('SUPERTURN'), [s]))
    1666       else
    1667         SimpleMessage(Format(Tribe[NewPlayer].TPhrase('TURN'), [s]));
    1668     end;
     1618  nAdvBookIcon = 16;
     1619  AdvBookIcon: array [0 .. nAdvBookIcon - 1] of record Adv,
     1620    Icon: integer end = ((Adv: adPolyTheism; Icon: woZeus),
     1621    (Adv: adBronzeWorking; Icon: woColossus), (Adv: adMapMaking;
     1622    Icon: woLighthouse), (Adv: adPoetry; Icon: imTheater), (Adv: adMonotheism;
     1623    Icon: woMich), (Adv: adPhilosophy; Icon: woLeo), (Adv: adTheoryOfGravity;
     1624    Icon: woNewton), (Adv: adSteel; Icon: woEiffel), (Adv: adDemocracy;
     1625    Icon: woLiberty), (Adv: adAutomobile; Icon: imHighways),
     1626    (Adv: adSanitation; Icon: imSewer), (Adv: adElectronics; Icon: woHoover),
     1627    (Adv: adNuclearFission; Icon: woManhattan), (Adv: adRecycling;
     1628    Icon: imRecycling), (Adv: adComputers; Icon: imResLab),
     1629    (Adv: adSpaceFlight; Icon: woMIR));
     1630var
     1631  p1, i, ad, uix, cix, MoveOptions, MoveResult, Loc1,
     1632    NewAgeCenterTo, Winners, NewGovAvailable, dx,
     1633    dy: integer;
     1634  MoveAdviceData: TMoveAdviceData;
     1635  Picture: TModelPictureInfo;
     1636  s, Item, Item2: string;
     1637  UpdatePanel, OwnWonder, ok, Stop, ShowCityList, WondersOnly,
     1638    AllowCityScreen: boolean;
     1639begin
     1640  if IsMultiPlayerGame and (NewPlayer <> me) then
     1641  begin
     1642    UnitInfoBtn.Visible := false;
     1643    UnitBtn.Visible := false;
     1644    TerrainBtn.Visible := false;
     1645    EOT.Visible := false;
     1646  end;
     1647  if IsMultiPlayerGame and (NewPlayer <> me) and
     1648    (G.RO[0].Happened and phShipComplete = 0) then
     1649  begin // inter player screen
    16691650    for i := 0 to ControlCount - 1 do
    16701651      if Controls[i] is TButtonC then
    1671         Controls[i].Visible := true;
    1672 
    1673     ItsMeAgain(p);
    1674     MyData := G.RO[p].Data;
    1675     if not supervising then
    1676       SoundPreload(sbAll);
    1677     if (me = 0) and ((MyRO.Turn = 0) or (ClientMode = cResume)) then
    1678       Invalidate; // colorize empty space
    1679 
    1680     if not supervising then
    1681     begin
    1682 
    1683       { if MyRO.Happened and phGameEnd<>0 then
    1684         begin
    1685         Age:=3;
    1686         SetMainTextureByAge(-1);
     1652        Controls[i].Visible := false;
     1653    me := -1;
     1654    SetMainTextureByAge(-1);
     1655    with Panel.Canvas do
     1656    begin
     1657      Brush.Color := $000000;
     1658      FillRect(Rect(0, 0, Panel.width, Panel.height));
     1659      Brush.Style := bsClear;
     1660    end;
     1661    with TopBar.Canvas do
     1662    begin
     1663      Brush.Color := $000000;
     1664      FillRect(Rect(0, 0, TopBar.width, TopBar.height));
     1665      Brush.Style := bsClear;
     1666    end;
     1667    Invalidate;
     1668
     1669    s := TurnToString(G.RO[0].Turn);
     1670    if supervising then
     1671      SimpleMessage(Format(Phrases.Lookup('SUPERTURN'), [s]))
     1672    else
     1673      SimpleMessage(Format(Tribe[NewPlayer].TPhrase('TURN'), [s]));
     1674  end;
     1675  for i := 0 to ControlCount - 1 do
     1676    if Controls[i] is TButtonC then
     1677      Controls[i].Visible := true;
     1678
     1679  ItsMeAgain(NewPlayer);
     1680  MyData := G.RO[NewPlayer].Data;
     1681  if not supervising then
     1682    SoundPreload(sbAll);
     1683  if (me = 0) and ((MyRO.Turn = 0) or (ClientMode = cResume)) then
     1684    Invalidate; // colorize empty space
     1685
     1686  if not supervising then
     1687  begin
     1688
     1689    { if MyRO.Happened and phGameEnd<>0 then
     1690      begin
     1691      Age:=3;
     1692      SetMainTextureByAge(-1);
     1693      end
     1694      else }
     1695    begin
     1696      Age := GetAge(me);
     1697      if SetMainTextureByAge(Age) then
     1698        EOT.Invalidate; // has visible background parts in its bounds
     1699    end;
     1700    // age:=MyRO.Turn mod 4; //!!!
     1701    if ClientMode = cMovieTurn then
     1702      EOT.ButtonIndex := eotCancel
     1703    else if ClientMode < scContact then
     1704      EOT.ButtonIndex := eotGray
     1705    else
     1706      EOT.ButtonIndex := eotBackToNego;
     1707  end
     1708  else
     1709  begin
     1710    Age := 0;
     1711    SetMainTextureByAge(-1);
     1712    if ClientMode = cMovieTurn then
     1713      EOT.ButtonIndex := eotCancel
     1714    else
     1715      EOT.ButtonIndex := eotBlinkOn;
     1716  end;
     1717  InitCityMark(MainTexture);
     1718  CityDlg.CheckAge;
     1719  NatStatDlg.CheckAge;
     1720  UnitStatDlg.CheckAge;
     1721  HelpDlg.Difficulty := G.Difficulty[me];
     1722
     1723  UnFocus := -1;
     1724  MarkCityLoc := -1;
     1725  BlinkON := false;
     1726  BlinkTime := -1;
     1727  Tracking := false;
     1728  TurnComplete := false;
     1729
     1730  if (ToldSlavery < 0) or
     1731    ((ToldSlavery = 1) <> (MyRO.Wonder[woPyramids].EffectiveOwner >= 0)) then
     1732  begin
     1733    if MyRO.Wonder[woPyramids].EffectiveOwner >= 0 then
     1734      ToldSlavery := 1
     1735    else
     1736      ToldSlavery := 0;
     1737    for p1 := 0 to nPl - 1 do
     1738      if (Tribe[p1] <> nil) and (Tribe[p1].mixSlaves >= 0) then
     1739        with Picture do
     1740        begin // replace unit picture
     1741          mix := Tribe[p1].mixSlaves;
     1742          if ToldSlavery = 1 then
     1743            pix := pixSlaves
     1744          else
     1745            pix := pixNoSlaves;
     1746          Hash := 0;
     1747          GrName := 'StdUnits.png';
     1748          Tribe[p1].SetModelPicture(Picture, true);
    16871749        end
    1688         else }
    1689       begin
    1690         Age := GetAge(me);
    1691         if SetMainTextureByAge(Age) then
    1692           EOT.Invalidate; // has visible background parts in its bounds
     1750  end;
     1751
     1752  if not supervising and (ClientMode = cTurn) then
     1753  begin
     1754    for cix := 0 to MyRO.nCity - 1 do
     1755      if (MyCity[cix].Loc >= 0) and
     1756        ((MyRO.Turn = 0) or (MyCity[cix].Flags and chFounded <> 0)) then
     1757        MyCity[cix].Status := MyCity[cix].Status and
     1758          not csResourceWeightsMask or (3 shl 4);
     1759    // new city, set to maximum growth
     1760  end;
     1761  if (ClientMode = cTurn) or (ClientMode = cContinue) then
     1762    CityOptimizer_BeginOfTurn; // maybe peace was made or has ended
     1763  SumCities(TaxSum, ScienceSum);
     1764
     1765  if ClientMode = cMovieTurn then
     1766  begin
     1767    UnitInfoBtn.Visible := false;
     1768    UnitBtn.Visible := false;
     1769    TerrainBtn.Visible := false;
     1770    EOT.Hint := Phrases.Lookup('BTN_STOP');
     1771</