Ignore:
Timestamp:
Mar 26, 2021, 2:16:04 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Reworker IsoEngine unit to support multiple iso maps with different tile sizes.
  • Modified: Changing tile size in main windows map doesn't affect other tile drawing on panel and in other windows like help window.
  • Modified: Optimized tile size switching. Graphic assets needed for given tile size is prepared only once. Then switching between them is just about changing references to objects and redrawing.
  • Modified: Code cleanup.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/Enhance.pas

    r313 r330  
    77  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: TPopupMenu;
    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);
     
    4750implementation
    4851
    49 uses Help;
     52uses
     53  Help;
    5054
    5155{$R *.lfm}
     
    5761begin
    5862  inherited;
     63  NoMap := TIsoMap.Create;
    5964  CaptionRight := CloseBtn.Left;
    6065  CaptionLeft := ToggleBtn.Left + ToggleBtn.Width;
     
    8590end;
    8691
     92procedure TEnhanceDlg.FormDestroy(Sender: TObject);
     93begin
     94  FreeAndNil(NoMap);
     95end;
     96
    8797procedure TEnhanceDlg.FormPaint(Sender: TObject);
    8898var
     
    129139  while (EndStage < 5) and (MyData.EnhancementJobs[Page, EndStage] <> jNone) do
    130140    inc(EndStage);
    131   x := InnerWidth div 2 - xxt - (xxt + 3) * EndStage;
     141  with NoMap do
     142    x := InnerWidth div 2 - xxt - (xxt + 3) * EndStage;
    132143
    133144  TerrType := Page;
     
    185196    end;
    186197
    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)
     198    with NoMap do begin
     199      if TerrType < fForest then
     200        Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     201          1 + TerrType * (xxt * 2 + 1), 1 + yyt)
     202      else
     203      begin
     204        Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     205          1 + 2 * (xxt * 2 + 1), 1 + yyt + 2 * (yyt * 3 + 1));
     206        Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     207          1 + 7 * (xxt * 2 + 1), 1 + yyt + 2 * (2 + TerrType - fForest) *
     208          (yyt * 3 + 1));
     209      end;
     210      if TileImp and fTerImp = tiFarm then
     211        Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     212          1 + (xxt * 2 + 1), 1 + yyt + 12 * (yyt * 3 + 1))
     213      else if TileImp and fTerImp = tiIrrigation then
     214        Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2, 1,
     215          1 + yyt + 12 * (yyt * 3 + 1));
     216      if TileImp and fRR <> 0 then
     217      begin
     218        Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     219          1 + 6 * (xxt * 2 + 1), 1 + yyt + 10 * (yyt * 3 + 1));
     220        Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     221          1 + 2 * (xxt * 2 + 1), 1 + yyt + 10 * (yyt * 3 + 1));
     222      end
     223      else if TileImp and fRoad <> 0 then
     224      begin
     225        Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     226          1 + 6 * (xxt * 2 + 1), 1 + yyt + 9 * (yyt * 3 + 1));
     227        Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     228          1 + 2 * (xxt * 2 + 1), 1 + yyt + 9 * (yyt * 3 + 1));
     229      end;
     230      if TileImp and fTerImp = tiMine then
     231        Sprite(offscreen, HGrTerrain, x, 64 - yyt, xxt * 2, yyt * 2,
     232          1 + 2 * (xxt * 2 + 1), 1 + yyt + 12 * (yyt * 3 + 1));
     233      inc(x, xxt * 2 + 6)
     234    end;
    222235  end;
    223236
Note: See TracChangeset for help on using the changeset viewer.