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/Enhance.pas

    r303 r349  
    77  UDpiControls, ScreenTools, BaseWin, Protocol, ClientTools, Term, LCLIntf, LCLType,
    88
    9   SysUtils, Classes, Graphics, Controls, Forms,
     9  SysUtils, Classes, Graphics, Controls, Forms, IsoEngine,
    1010  ButtonB, ButtonC, Menus;
    1111
     
    2828    Popup: TDpiPopupMenu;
    2929    procedure FormCreate(Sender: TObject);
     30    procedure FormDestroy(Sender: TObject);
    3031    procedure FormPaint(Sender: TObject);
    3132    procedure FormShow(Sender: TObject);
     
    3536    procedure JobClick(Sender: TObject);
    3637    procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
     38  private
     39    NoMap: TIsoMap;
    3740  public
    3841    procedure ShowNewContent(NewMode: integer; TerrType: integer = -1);
     
    4548  EnhanceDlg: TEnhanceDlg;
    4649
     50
    4751implementation
    4852
    49 uses Help;
     53uses
     54  Help, UKeyBindings;
    5055
    5156{$R *.lfm}
     
    5762begin
    5863  inherited;
     64  NoMap := TIsoMap.Create;
    5965  CaptionRight := CloseBtn.Left;
    6066  CaptionLeft := ToggleBtn.Left + ToggleBtn.Width;
     
    8591end;
    8692
     93procedure TEnhanceDlg.FormDestroy(Sender: TObject);
     94begin
     95  FreeAndNil(NoMap);
     96end;
     97
    8798procedure TEnhanceDlg.FormPaint(Sender: TObject);
    8899var
     
    97108    if Controls[i] is TButtonC then
    98109      DpiBitCanvas(Canvas, Controls[i].Left + 2, Controls[i].Top - 11, 8, 8,
    99         GrExt[HGrSystem].Data.Canvas, 121 + Controls[i].Tag mod 7 * 9,
     110        HGrSystem.Data.Canvas, 121 + Controls[i].Tag mod 7 * 9,
    100111        1 + Controls[i].Tag div 7 * 9);
    101112end;
     
    129140  while (EndStage < 5) and (MyData.EnhancementJobs[Page, EndStage] <> jNone) do
    130141    inc(EndStage);
    131   x := InnerWidth div 2 - xxt - (xxt + 3) * EndStage;
     142  with NoMap do
     143    x := InnerWidth div 2 - xxt - (xxt + 3) * EndStage;
    132144
    133145  TerrType := Page;
     
    185197    end;
    186198
    187     if TerrType < fForest then
    188       Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
    189         1 + TerrType * (xxt * 2 + 1), 1 + yyt)
    190     else
    191     begin
    192       Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
    193         1 + 2 * (xxt * 2 + 1), 1 + yyt + 2 * (yyt * 3 + 1));
    194       Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
    195         1 + 7 * (xxt * 2 + 1), 1 + yyt + 2 * (2 + TerrType - fForest) *
    196         (yyt * 3 + 1));
    197     end;
    198     if TileImp and fTerImp = tiFarm then
    199       Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
    200         1 + (xxt * 2 + 1), 1 + yyt + 12 * (yyt * 3 + 1))
    201     else if TileImp and fTerImp = tiIrrigation then
    202       Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1,
    203         1 + yyt + 12 * (yyt * 3 + 1));
    204     if TileImp and fRR <> 0 then
    205     begin
    206       Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
    207         1 + 6 * (xxt * 2 + 1), 1 + yyt + 10 * (yyt * 3 + 1));
    208       Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
    209         1 + 2 * (xxt * 2 + 1), 1 + yyt + 10 * (yyt * 3 + 1));
    210     end
    211     else if TileImp and fRoad <> 0 then
    212     begin
    213       Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
    214         1 + 6 * (xxt * 2 + 1), 1 + yyt + 9 * (yyt * 3 + 1));
    215       Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
    216         1 + 2 * (xxt * 2 + 1), 1 + yyt + 9 * (yyt * 3 + 1));
    217     end;
    218     if TileImp and fTerImp = tiMine then
    219       Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
    220         1 + 2 * (xxt * 2 + 1), 1 + yyt + 12 * (yyt * 3 + 1));
    221     inc(x, xxt * 2 + 6)
     199    with NoMap do begin
     200      if TerrType < fForest then
     201        Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     202          1 + TerrType * (xxt * 2 + 1), 1 + yyt)
     203      else
     204      begin
     205        Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     206          1 + 2 * (xxt * 2 + 1), 1 + yyt + 2 * (yyt * 3 + 1));
     207        Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     208          1 + 7 * (xxt * 2 + 1), 1 + yyt + 2 * (2 + TerrType - fForest) *
     209          (yyt * 3 + 1));
     210      end;
     211      if TileImp and fTerImp = tiFarm then
     212        Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     213          1 + (xxt * 2 + 1), 1 + yyt + 12 * (yyt * 3 + 1))
     214      else if TileImp and fTerImp = tiIrrigation then
     215        Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1,
     216          1 + yyt + 12 * (yyt * 3 + 1));
     217      if TileImp and fRR <> 0 then
     218      begin
     219        Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     220          1 + 6 * (xxt * 2 + 1), 1 + yyt + 10 * (yyt * 3 + 1));
     221        Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     222          1 + 2 * (xxt * 2 + 1), 1 + yyt + 10 * (yyt * 3 + 1));
     223      end
     224      else if TileImp and fRoad <> 0 then
     225      begin
     226        Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     227          1 + 6 * (xxt * 2 + 1), 1 + yyt + 9 * (yyt * 3 + 1));
     228        Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     229          1 + 2 * (xxt * 2 + 1), 1 + yyt + 9 * (yyt * 3 + 1));
     230      end;
     231      if TileImp and fTerImp = tiMine then
     232        Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     233          1 + 2 * (xxt * 2 + 1), 1 + yyt + 12 * (yyt * 3 + 1));
     234      inc(x, xxt * 2 + 6);
     235    end;
    222236  end;
    223237
     
    289303procedure TEnhanceDlg.CloseBtnClick(Sender: TObject);
    290304begin
    291   Close
     305  Close;
    292306end;
    293307
     
    304318begin
    305319  Page := TComponent(Sender).Tag;
    306   SmartUpdateContent
     320  SmartUpdateContent;
    307321end;
    308322
     
    324338          move(MyData.EnhancementJobs[Page, stage + 1],
    325339            MyData.EnhancementJobs[Page, stage], 4 - stage);
    326         MyData.EnhancementJobs[Page, 4] := jNone
     340        MyData.EnhancementJobs[Page, 4] := jNone;
    327341      end
    328342      else
     
    351365    begin
    352366      MyData.EnhancementJobs[Page, stage] := jRoad;
    353       inc(stage)
     367      inc(stage);
    354368    end;
    355369    if (NewJob = jFarm) and not(jIrr in Done) then
    356370    begin
    357371      MyData.EnhancementJobs[Page, stage] := jIrr;
    358       inc(stage)
    359     end;
    360     MyData.EnhancementJobs[Page, stage] := NewJob
    361   end;
    362   SmartUpdateContent
     372      inc(stage);
     373    end;
     374    MyData.EnhancementJobs[Page, stage] := NewJob;
     375  end;
     376  SmartUpdateContent;
    363377end;
    364378
    365379procedure TEnhanceDlg.FormKeyDown(Sender: TObject; var Key: Word;
    366380  Shift: TShiftState);
    367 begin
    368   if Key = VK_F1 then
     381var
     382  ShortCut: TShortCut;
     383begin
     384  ShortCut := KeyToShortCut(Key, Shift);
     385  if BHelp.Test(ShortCut) then
    369386    HelpDlg.ShowNewContent(FWindowMode or wmPersistent, hkText,
    370387      HelpDlg.TextIndex('MACRO'))
Note: See TracChangeset for help on using the changeset viewer.