Ignore:
Timestamp:
Apr 9, 2021, 5:56:50 PM (3 years ago)
Author:
chronos
Message:
  • Modified: Merged changes from trunk r360 into highdpi branch.
File:
1 edited

Legend:

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

    r349 r361  
    1515type
    1616  TCityCloseAction = (None, RestoreFocus, StepFocus);
     17  TSmallMapMode = (smSupportedUnits, smImprovements);
    1718
    1819  TCityDlg = class(TBufferedDrawDlg)
     
    5960    cix: Integer;
    6061    cLoc: Integer;
    61     Mode: Integer;
     62    SmallMapMode: TSmallMapMode;
    6263    ZoomArea: Integer;
    6364    Page: Integer;
     
    7374    CityAreaInfo: TCityAreaInfo;
    7475    AreaMap: TIsoMap;
     76    NoMap: TIsoMap;
    7577    CityMapTemplate: TDpiBitmap;
    7678    SmallCityMapTemplate: TDpiBitmap;
     
    8284    ProdHint: Boolean;
    8385    AllowChange: Boolean;
     86    RedTex: TTexture;
     87    BarTex: TTexture;
    8488    procedure InitSmallCityMap;
    8589    procedure InitZoomCityMap;
     
    109113
    110114const
    111   { modes }
    112   mSupp = 1;
    113   mImp = 2;
    114 
    115115  wBar = 106;
    116116  xDiv = 400;
     
    197197begin
    198198  inherited;
     199  RedTex := TTexture.Create;
     200  BarTex := TTexture.Create;
     201  NoMap := TIsoMap.Create;
    199202  AreaMap := TIsoMap.Create;
    200203  AreaMap.SetOutput(offscreen);
    201204  AreaMap.SetPaintBounds(xmArea - 192, ymArea - 96 - 32, xmArea + 192,
    202205    ymArea + 96);
    203   Mode := mImp;
     206  SmallMapMode := smImprovements;
    204207  ZoomArea := 1;
    205208  ProdHint := false;
     
    208211  AgePrepared := -2;
    209212  Optimize_cixTileChange := -1;
    210   InitButtons();
     213  InitButtons;
    211214  // InitWindowRegion;
    212215  CloseBtn.Caption := Phrases.Lookup('BTN_OK');
     
    252255procedure TCityDlg.FormDestroy(Sender: TObject);
    253256begin
     257  FreeAndNil(NoMap);
    254258  FreeAndNil(AreaMap);
    255259  FreeAndNil(SmallCityMap);
     
    259263  FreeAndNil(Template);
    260264  FreeAndNil(Back);
     265  FreeAndNil(RedTex);
     266  FreeAndNil(BarTex);
    261267end;
    262268
    263269procedure TCityDlg.Reset;
    264270begin
    265   Mode := mImp;
     271  SmallMapMode := smImprovements;
    266272  ZoomArea := 1;
    267273end;
     
    269275procedure TCityDlg.CheckAge;
    270276begin
    271   if MainTextureAge <> AgePrepared then
    272   begin
    273     AgePrepared := MainTextureAge;
     277  if MainTexture.Age <> AgePrepared then begin
     278    AgePrepared := MainTexture.Age;
    274279
    275280    UnshareBitmap(Back);
     
    370375  DpiBitCanvas(ZoomCityMap.Canvas, 0, 0, wZoomMap, hZoomMap,
    371376    Back.Canvas, xZoomMap, yZoomMap);
    372   if Mode = mImp then begin
     377  if SmallMapMode = smImprovements then begin
    373378    if ZoomArea < 3 then begin
    374379      ImageOp_B(ZoomCityMap, CityMapTemplate, 0, 0, 376 * SizeClass,
     
    388393  procedure FillBar(x, y, pos, Growth, max, Kind: integer;
    389394    IndicateComplete: boolean);
    390   var
    391     Tex: TTexture;
    392   begin
    393     Tex := MainTexture;
    394     if Kind = 3 then
    395     begin
    396       Tex.clBevelLight := HGrSystem.Data.Canvas.Pixels[104, 36];
    397       Tex.clBevelShade := Tex.clBevelLight;
     395  begin
     396    BarTex.Assign(MainTexture);
     397    if Kind = 3 then begin
     398      BarTex.ColorBevelLight := HGrSystem.Data.Canvas.Pixels[104, 36];
     399      BarTex.ColorBevelShade := BarTex.ColorBevelLight;
    398400    end;
    399401    PaintRelativeProgressBar(offscreen.Canvas, Kind, x - 3, y, wBar - 4, pos,
    400       Growth, max, IndicateComplete, Tex);
     402      Growth, max, IndicateComplete, BarTex);
    401403  end;
    402404
     
    492494  UnitInfo: TUnitInfo;
    493495  UnitReport: TUnitReport;
    494   RedTex: TTexture;
    495496  IsCityAlive, CanGrow: boolean;
    496497begin
     
    524525    Report.Working := c.Size;
    525526
    526   RedTex := MainTexture;
    527   RedTex.clBevelLight := $0000FF;
    528   RedTex.clBevelShade := $000000;
    529   RedTex.clTextLight := $000000;
    530   RedTex.clTextShade := $0000FF;
     527  RedTex.Assign(MainTexture);
     528  RedTex.ColorBevelLight := $0000FF;
     529  RedTex.ColorBevelShade := $000000;
     530  RedTex.ColorTextLight := $000000;
     531  RedTex.ColorTextShade := $0000FF;
    531532
    532533  DpiBitCanvas(offscreen.Canvas, 0, 0, 640, 480, Back.Canvas, 0, 0);
     
    596597
    597598  with AreaMap do begin
    598   rx := (192 + xxt * 2 - 1) div (xxt * 2);
    599   ry := (96 + yyt * 2 - 1) div (yyt * 2);
    600   AreaMap.Paint(xmArea - xxt * 2 * rx, ymArea - yyt * 2 * ry - 3 * yyt,
    601     dLoc(cLoc, -2 * rx + 1, -2 * ry - 1), 4 * rx - 1, 4 * ry + 1, cLoc, cOwner,
    602     false, AllowChange and IsCityAlive and
    603     (c.Status and csResourceWeightsMask = 0));
    604   DpiBitCanvas(offscreen.Canvas, xmArea + 102, 42, 90, 33, Back.Canvas,
    605     xmArea + 102, 42);
    606 
    607   if IsCityAlive then
    608     for dy := -3 to 3 do
    609       for dx := -3 to 3 do
    610         if ((dx + dy) and 1 = 0) and (dx * dx * dy * dy < 81) then
    611         begin
    612           Loc1 := dLoc(cLoc, dx, dy);
    613           av := CityAreaInfo.Available[(dy + 3) shl 2 + (dx + 3) shr 1];
    614           if ((av = faNotAvailable) or (av = faTreaty) or (av = faInvalid)) and
    615             ((Loc1 < 0) or (Loc1 >= G.lx * G.ly) or (MyMap[Loc1] and fCity = 0))
    616           then
    617             Sprite(offscreen, HGrTerrain, xmArea - xxt + xxt * dx,
    618               ymArea - yyt + yyt * dy, xxt * 2, yyt * 2, 1 + 5 * (xxt * 2 + 1),
    619               1 + yyt + 15 * (yyt * 3 + 1));
    620           if (1 shl ((dy + 3) shl 2 + (dx + 3) shr 1) and c.Tiles <> 0) then
    621             PaintResources(xmArea - xxt + xxt * dx, ymArea - yyt + yyt * dy,
    622               Loc1, (dx = 0) and (dy = 0));
    623         end;
     599    rx := (192 + xxt * 2 - 1) div (xxt * 2);
     600    ry := (96 + yyt * 2 - 1) div (yyt * 2);
     601    AreaMap.Paint(xmArea - xxt * 2 * rx, ymArea - yyt * 2 * ry - 3 * yyt,
     602      dLoc(cLoc, -2 * rx + 1, -2 * ry - 1), 4 * rx - 1, 4 * ry + 1, cLoc, cOwner,
     603      false, AllowChange and IsCityAlive and
     604      (c.Status and csResourceWeightsMask = 0));
     605    DpiBitCanvas(offscreen.Canvas, xmArea + 102, 42, 90, 33, Back.Canvas,
     606      xmArea + 102, 42);
     607
     608    if IsCityAlive then
     609      for dy := -3 to 3 do
     610        for dx := -3 to 3 do
     611          if ((dx + dy) and 1 = 0) and (dx * dx * dy * dy < 81) then begin
     612            Loc1 := dLoc(cLoc, dx, dy);
     613            av := CityAreaInfo.Available[(dy + 3) shl 2 + (dx + 3) shr 1];
     614            if ((av = faNotAvailable) or (av = faTreaty) or (av = faInvalid)) and
     615              ((Loc1 < 0) or (Loc1 >= G.lx * G.ly) or (MyMap[Loc1] and fCity = 0))
     616            then
     617              Sprite(offscreen, HGrTerrain, xmArea - xxt + xxt * dx,
     618                ymArea - yyt + yyt * dy, xxt * 2, yyt * 2, 1 + 5 * (xxt * 2 + 1),
     619                1 + yyt + 15 * (yyt * 3 + 1));
     620            if (1 shl ((dy + 3) shl 2 + (dx + 3) shr 1) and c.Tiles <> 0) then
     621              PaintResources(xmArea - xxt + xxt * dx, ymArea - yyt + yyt * dy,
     622                Loc1, (dx = 0) and (dy = 0));
     623          end;
    624624  end;
    625625
     
    794794  DpiBitCanvas(offscreen.Canvas, xSmallMap, ySmallMap, wSmallMap, hSmallMap,
    795795    SmallCityMap.Canvas, 0, 0);
    796   if Mode = mImp then
     796  if SmallMapMode = smImprovements then
    797797    Frame(offscreen.Canvas, xSmallMap + 48 * (ZoomArea div 3),
    798798      ySmallMap + 24 * (ZoomArea mod 3), xSmallMap + 48 * (ZoomArea div 3) + 49,
    799       ySmallMap + 24 * (ZoomArea mod 3) + 25, MainTexture.clMark,
    800       MainTexture.clMark);
     799      ySmallMap + 24 * (ZoomArea mod 3) + 25, MainTexture.ColorMark,
     800      MainTexture.ColorMark);
    801801  Frame(offscreen.Canvas, xSmallMap - 1, ySmallMap - 1, xSmallMap + wSmallMap,
    802802    ySmallMap + hSmallMap, $B0B0B0, $FFFFFF);
     
    810810  x := xSupport + wSupport div 2;
    811811  y := ySupport + hSupport div 2;
    812   if Mode = mSupp then
    813   begin
    814     offscreen.Canvas.brush.Color := MainTexture.clMark;
     812  if SmallMapMode = smSupportedUnits then
     813  begin
     814    offscreen.Canvas.brush.Color := MainTexture.ColorMark;
    815815    offscreen.Canvas.FillRect(Rect(x - 27, y - 6, x + 27, y + 6));
    816816    offscreen.Canvas.brush.style := bsClear;
     
    825825  for i := 0 to 5 do
    826826    imix[i] := -1;
    827   if Mode = mImp then
     827  if SmallMapMode = smImprovements then
    828828  begin
    829829    if ZoomArea = 5 then
     
    917917      Imp5Area.Hint := '';
    918918  end
    919   else { if mode=mSupp then }
     919  else { if SmallMapMode = smSupportedUnits then }
    920920  begin
    921921    LoweredTextout(offscreen.Canvas, -1, MainTexture, xZoomMap + 6,
     
    934934            y := ((Cnt - 6 * Page) div 3) * 52 + yZoomMap + 20;
    935935            MakeUnitInfo(me, MyUn[i], UnitInfo);
    936             AreaMap.SetOutput(offscreen);
    937             AreaMap.PaintUnit(x, y, UnitInfo, MyUn[i].Status);
     936            NoMap.SetOutput(offscreen);
     937            NoMap.PaintUnit(x, y, UnitInfo, MyUn[i].Status);
    938938
    939939            for j := 0 to UnitReport.FoodSupport - 1 do
     
    10481048  else { enemy city }
    10491049  begin
    1050     Mode := mImp;
     1050    SmallMapMode := smImprovements;
    10511051    Server(sGetCity, me, cLoc, GetCityData);
    10521052    c := GetCityData.c;
     
    11461146    (y >= ySmallMap) and (y < ySmallMap + hSmallMap) then
    11471147  begin
    1148     Mode := mImp;
     1148    SmallMapMode := smImprovements;
    11491149    ZoomArea := (y - ySmallMap) * 3 div hSmallMap + 3 *
    11501150      ((x - xSmallMap) * 2 div wSmallMap);
     
    11571157    (y >= ySupport) and (y < ySupport + hSupport) then
    11581158  begin
    1159     Mode := mSupp;
     1159    SmallMapMode := smSupportedUnits;
    11601160    Page := 0;
    11611161    InitZoomCityMap;
     
    11891189        ChooseProject;
    11901190      end
    1191     else if (Mode = mImp) and (x >= xZoomMap) and (x < xZoomMap + wZoomMap) and
     1191    else if (SmallMapMode = smImprovements) and (x >= xZoomMap) and (x < xZoomMap + wZoomMap) and
    11921192      (y >= yZoomMap) and (y < yZoomMap + hZoomMap) then
    11931193    begin
     
    12031203        if iix >= 0 then
    12041204          if ssShift in Shift then
    1205             HelpDlg.ShowNewContent(Mode or wmPersistent, hkImp, iix)
     1205            HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkImp, iix)
    12061206          else if (ClientMode < scContact) then
    12071207            with MessgExDlg do
     
    13001300      end;
    13011301    end
    1302     else if (Mode = mSupp) and (x >= xZoomMap) and (x < xZoomMap + wZoomMap) and
     1302    else if (SmallMapMode = smSupportedUnits) and (x >= xZoomMap) and (x < xZoomMap + wZoomMap) and
    13031303      (y >= yZoomMap) and (y < yZoomMap + hZoomMap) then
    13041304    begin
     
    13211321    else if (x >= xmArea - 192) and (x < xmArea + 192) and (y >= ymArea - 96)
    13221322      and (y < ymArea + 96) then
    1323     with AreaMap do
    1324     begin
     1323    with AreaMap do begin
    13251324      qx := ((4000 * xxt * yyt) + (x - xmArea) * (yyt * 2) + (y - ymArea + yyt)
    13261325        * (xxt * 2)) div (xxt * yyt * 4) - 1000;
     
    13351334          Loc1 := dLoc(cLoc, dx, dy);
    13361335          if (Loc1 >= 0) and (Loc1 < G.lx * G.ly) then
    1337             HelpOnTerrain(Loc1, Mode or wmPersistent)
     1336            HelpOnTerrain(Loc1, FWindowMode or wmPersistent)
    13381337        end
    13391338        else if (ClientMode < scContact) and (cGov <> gAnarchy) and
Note: See TracChangeset for help on using the changeset viewer.