Ignore:
Timestamp:
Apr 6, 2021, 8:11:02 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Merged trunk branch version r348 into highdpi branch.
File:
1 edited

Legend:

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

    r303 r349  
    55
    66uses
    7   UDpiControls, {$IFDEF LINUX}
    8   LMessages,
    9   {$ENDIF}
     7  UDpiControls, {$IFDEF LINUX}LMessages,{$ENDIF}
    108  Protocol, ClientTools, Term, ScreenTools, IsoEngine, BaseWin,
    119  LCLIntf, LCLType, Messages, SysUtils, Classes, Graphics, Controls, Forms, ExtCtrls,
     
    5351    procedure PageUpBtnClick(Sender: TObject);
    5452    procedure PageDownBtnClick(Sender: TObject);
    55 
     53  private
     54    c: TCity;
     55    Report: TCityReportNew;
     56    cOwner: Integer;
     57    cGov: Integer;
     58    emix: Integer; { enemy model index of produced unit }
     59    cix: Integer;
     60    cLoc: Integer;
     61    Mode: Integer;
     62    ZoomArea: Integer;
     63    Page: Integer;
     64    PageCount: Integer;
     65    BlinkTime: Integer;
     66    OpenSoundEvent: Integer;
     67    SizeClass: Integer;
     68    AgePrepared: Integer;
     69    Optimize_cixTileChange: Integer;
     70    Optimize_TilesBeforeChange: Integer;
     71    Happened: cardinal;
     72    imix: array [0 .. 15] of integer;
     73    CityAreaInfo: TCityAreaInfo;
     74    AreaMap: TIsoMap;
     75    CityMapTemplate: TDpiBitmap;
     76    SmallCityMapTemplate: TDpiBitmap;
     77    Back: TDpiBitmap;
     78    SmallCityMap: TDpiBitmap;
     79    ZoomCityMap: TDpiBitmap;
     80    Template: TDpiBitmap;
     81    IsPort: Boolean;
     82    ProdHint: Boolean;
     83    AllowChange: Boolean;
     84    procedure InitSmallCityMap;
     85    procedure InitZoomCityMap;
     86    procedure ChooseProject;
     87    procedure ChangeCity(d: integer);
     88    procedure ChangeResourceWeights(iResourceWeights: integer);
     89    procedure OnPlaySound(var Msg: TMessage); message WM_PLAYSOUND;
    5690  public
    5791    RestoreUnFocus: integer;
     
    6195    procedure Reset;
    6296    procedure CheckAge;
    63 
    64   private
    65     c: TCity;
    66     Report: TCityReportNew;
    67     cOwner, cGov, emix { enemy model index of produced unit } , cix, cLoc, Mode,
    68       ZoomArea, Page, PageCount, BlinkTime, OpenSoundEvent, SizeClass,
    69       AgePrepared: integer;
    70     Optimize_cixTileChange, Optimize_TilesBeforeChange: integer;
    71     Happened: cardinal;
    72     imix: array [0 .. 15] of integer;
    73     CityAreaInfo: TCityAreaInfo;
    74     AreaMap: TIsoMap;
    75     CityMapTemplate, SmallCityMapTemplate, Back, SmallCityMap, ZoomCityMap,
    76       Template: TDpiBitmap;
    77     IsPort, ProdHint, AllowChange: boolean;
    78     procedure InitSmallCityMap;
    79     procedure InitZoomCityMap;
    80     procedure ChooseProject;
    81     procedure ChangeCity(d: integer);
    82     procedure ChangeResourceWeights(iResourceWeights: integer);
    83     procedure OnPlaySound(var Msg: TMessage); message WM_PLAYSOUND;
    8497  end;
    8598
     
    87100  CityDlg: TCityDlg;
    88101
     102
    89103implementation
    90104
    91105uses
    92   Select, Messg, MessgEx, Help, Tribes, Directories, Math, UPixelPointer, Sound;
     106  Select, Messg, MessgEx, Help, Tribes, Directories, Math, Sound;
    93107
    94108{$R *.lfm}
     
    259273    AgePrepared := MainTextureAge;
    260274
    261     // TODO: FillRect should not be needed as BitBlt is with SRCCOPY
    262     Back.Canvas.FillRect(0, 0, ClientWidth, ClientHeight);
    263 
     275    UnshareBitmap(Back);
    264276    DpiBitCanvas(Back.Canvas, 0, 0, ClientWidth, ClientHeight,
    265277      MainTexture.Image.Canvas, 0, 0);
     
    280292    c := MyCity[cix];
    281293  case MyMap[cLoc] and fTerrain of
    282     fPrairie:
    283       cli1 := cliPrairie;
    284     fHills:
    285       cli1 := cliHills;
    286     fTundra:
    287       cli1 := cliTundra;
     294    fPrairie: cli1 := cliPrairie;
     295    fHills: cli1 := cliHills;
     296    fTundra: cli1 := cliTundra;
    288297  else
    289298    cli1 := cliPlains;
     
    316325    for i := 0 to 29 do
    317326    begin
    318       for iix := 28 to nImp - 1 do
     327      for iix := nWonder to nImp - 1 do
    319328        if (ImpPosition[iix] = i) and (c.Built[iix] > 0) then
    320329        begin
     
    327336    i := 30;
    328337    for iix := 0 to nImp do
    329       if (c.Built[iix] > 0) and ((iix < 28) or (ImpPosition[iix] < 0)) then
     338      if (c.Built[iix] > 0) and ((iix < nWonder) or (ImpPosition[iix] < 0)) then
    330339      begin
    331340        FillRect(Rect(5 + 16 * (i mod 3) + 48 * (i div 18),
     
    341350      if iix <> imTrGoods then
    342351      begin
    343         if (iix >= 28) and (ImpPosition[iix] >= 0) then
     352        if (iix >= nWonder) and (ImpPosition[iix] >= 0) then
    344353          i := ImpPosition[iix];
    345354        if i < 36 then
     
    358367procedure TCityDlg.InitZoomCityMap;
    359368begin
    360   // TODO: FillRect should not be needed as BitBlt is with SRCCOPY
    361   ZoomCityMap.Canvas.FillRect(0, 0, ZoomCityMap.Width, ZoomCityMap.Height);
    362 
     369  UnshareBitmap(ZoomCityMap);
    363370  DpiBitCanvas(ZoomCityMap.Canvas, 0, 0, wZoomMap, hZoomMap,
    364371    Back.Canvas, xZoomMap, yZoomMap);
     
    387394    if Kind = 3 then
    388395    begin
    389       Tex.clBevelLight := GrExt[HGrSystem].Data.Canvas.Pixels[104, 36];
     396      Tex.clBevelLight := HGrSystem.Data.Canvas.Pixels[104, 36];
    390397      Tex.clBevelShade := Tex.clBevelLight;
    391398    end;
     
    400407    rare: boolean;
    401408  begin
     409    with AreaMap do begin
    402410    if Server(sGetCityTileInfo, me, Loc, TileInfo) <> eOk then
    403411    begin
     
    435443      Sprite(offscreen, HGrSystem, x + xxt - 5 + d * (2 * i + 1 - Total),
    436444        y + yyt - 5, 10, 10, xGr, yGr);
     445    end;
    437446    end;
    438447  end;
     
    586595  end;
    587596
     597  with AreaMap do begin
    588598  rx := (192 + xxt * 2 - 1) div (xxt * 2);
    589599  ry := (96 + yyt * 2 - 1) div (yyt * 2);
     
    612622              Loc1, (dx = 0) and (dy = 0));
    613623        end;
     624  end;
    614625
    615626  if Report.Working > 1 then
     
    624635      xGr := 141;
    625636    DpiBitCanvas(offscreen.Canvas, xmArea - 192 + 5 + i * d, ymArea - 96 - 29,
    626       27, 30, GrExt[HGrSystem].Mask.Canvas, xGr, 171, SRCAND); { shadow }
     637      27, 30, HGrSystem.Mask.Canvas, xGr, 171, SRCAND); { shadow }
    627638    Sprite(offscreen, HGrSystem, xmArea - 192 + 4 + i * d, ymArea - 96 - 30, 27,
    628639      30, xGr, 171);
     
    636647    xGr := 1 + 112;
    637648    DpiBitCanvas(offscreen.Canvas, xmArea + 192 - 27 + 1 - i * d, 29 + 1, 27,
    638       30, GrExt[HGrSystem].Mask.Canvas, xGr, 171, SRCAND); { shadow }
     649      30, HGrSystem.Mask.Canvas, xGr, 171, SRCAND); { shadow }
    639650    Sprite(offscreen, HGrSystem, xmArea + 192 - 27 - i * d, 29, 27, 30,
    640651      xGr, 171);
     
    820831      Cnt := 0;
    821832      for iix := 0 to nImp - 1 do
    822         if ((iix < 28) or (ImpPosition[iix] < 0)) and (c.Built[iix] > 0) then
     833        if ((iix < nWonder) or (ImpPosition[iix] < 0)) and (c.Built[iix] > 0) then
    823834        begin
    824835          i := Cnt - Page * 6;
     
    831842    else
    832843    begin
    833       for iix := 28 to nImp - 1 do
     844      for iix := nWonder to nImp - 1 do
    834845      begin
    835846        i := ImpPosition[iix] - 6 * ZoomArea;
     
    923934            y := ((Cnt - 6 * Page) div 3) * 52 + yZoomMap + 20;
    924935            MakeUnitInfo(me, MyUn[i], UnitInfo);
    925             NoMap.SetOutput(offscreen);
    926             NoMap.PaintUnit(x, y, UnitInfo, MyUn[i].Status);
     936            AreaMap.SetOutput(offscreen);
     937            AreaMap.PaintUnit(x, y, UnitInfo, MyUn[i].Status);
    927938
    928939            for j := 0 to UnitReport.FoodSupport - 1 do
     
    10521063        (integer(MyRO.EnemyModel[emix].mix) <> c.Project and cpIndex)) do
    10531064        dec(emix);
    1054       if Tribe[cOwner].ModelPicture[c.Project and cpIndex].HGr = 0 then
     1065      if not Assigned(Tribe[cOwner].ModelPicture[c.Project and cpIndex].HGr) then
    10551066        InitEnemyModel(emix);
    10561067    end;
     
    13101321    else if (x >= xmArea - 192) and (x < xmArea + 192) and (y >= ymArea - 96)
    13111322      and (y < ymArea + 96) then
     1323    with AreaMap do
    13121324    begin
    13131325      qx := ((4000 * xxt * yyt) + (x - xmArea) * (yyt * 2) + (y - ymArea + yyt)
     
    13441356                not csResourceWeightsMask; // off
    13451357              c.Status := MyCity[cix].Status;
    1346               SmartUpdateContent
     1358              SmartUpdateContent;
    13471359            end;
    13481360            exit;
     
    17361748  end; }
    17371749
    1738 var
    1739   i, j, k: integer;
    1740 
    17411750procedure TCityDlg.PageUpBtnClick(Sender: TObject);
    17421751begin
     
    17441753  begin
    17451754    dec(Page);
    1746     SmartUpdateContent
     1755    SmartUpdateContent;
    17471756  end;
    17481757end;
     
    17531762  begin
    17541763    inc(Page);
    1755     SmartUpdateContent
     1764    SmartUpdateContent;
    17561765  end;
    17571766end;
     
    17751784end;
    17761785
     1786procedure SortImprovements;
     1787var
     1788  i, j, k: integer;
     1789begin
     1790  for i := 0 to nImp - 1 do
     1791    ImpSorted[i] := i;
     1792  for i := 0 to nImp - 2 do
     1793    for j := i + 1 to nImp - 1 do
     1794      if Prio(ImpSorted[i]) > Prio(ImpSorted[j]) then begin
     1795        k := ImpSorted[i];
     1796        ImpSorted[i] := ImpSorted[j];
     1797        ImpSorted[j] := k;
     1798      end;
     1799end;
     1800
    17771801initialization
    17781802
    1779 for i := 0 to nImp - 1 do
    1780   ImpSorted[i] := i;
    1781 for i := 0 to nImp - 2 do
    1782   for j := i + 1 to nImp - 1 do
    1783     if Prio(ImpSorted[i]) > Prio(ImpSorted[j]) then
    1784     begin
    1785       k := ImpSorted[i];
    1786       ImpSorted[i] := ImpSorted[j];
    1787       ImpSorted[j] := k;
    1788     end;
     1803SortImprovements;
    17891804
    17901805end.
Note: See TracChangeset for help on using the changeset viewer.