close Warning: Can't synchronize with repository "(default)" (No changeset 184 in the repository). Look in the Trac log for more information.

Ignore:
Timestamp:
Nov 23, 2017, 5:02:49 PM (6 years ago)
Author:
chronos
Message:
  • Modified: UGeometry unit rewritten to use generics and define own TPoint and TRect types.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.pas

    r158 r170  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
    9   UGame, LCLType, Menus, ActnList, ComCtrls, types, dateutils, XMLConf, DOM;
     9  UGame, LCLType, Menus, ActnList, ComCtrls, dateutils, XMLConf, DOM,
     10  UGeometry;
    1011
    1112const
     
    137138  if Assigned(Core.CurrentClient) then
    138139  with Core.CurrentClient do begin
    139     View.DestRect := Bounds(0, 0, PaintBox1.Width, PaintBox1.Height);
     140    View.DestRect := TRect.CreateBounds(TPoint.Create(0, 0), TPoint.Create(PaintBox1.Width, PaintBox1.Height));
    140141    if csOpaque in PaintBox1.ControlStyle then begin
    141142      TempBitmap.SetSize(PaintBox1.Width, PaintBox1.Height);
     
    166167  if Assigned(Core.CurrentClient) then
    167168  with Core.CurrentClient do
    168     View.DestRect := Bounds(0, 0, PaintBox1.Width, PaintBox1.Height);
     169    View.DestRect := TRect.CreateBounds(TPoint.Create(0, 0), TPoint.Create(PaintBox1.Width, PaintBox1.Height));
    169170  Redraw;
    170171end;
     
    252253  with Core, Game, CurrentClient, View do begin
    253254    MapRect := Map.CalculatePixelRect;
    254     Factor := FloatPoint((DestRect.Right - DestRect.Left) / (MapRect.Right - MapRect.Left),
    255       (DestRect.Bottom - DestRect.Top) / (MapRect.Bottom - MapRect.Top));
     255    Factor := FloatPoint(DestRect.Size.X / MapRect.Size.X,
     256      DestRect.Size.Y / MapRect.Size.Y);
    256257    if Factor.X < Factor.Y then NewZoom := Factor.X
    257258      else NewZoom := Factor.Y;
     
    342343  if Button = mbLeft then begin
    343344    if Assigned(Core.CurrentClient) then begin
    344       StartMousePoint := Point(X, Y);
    345       StartViewPoint := Core.CurrentClient.View.SourceRect.TopLeft;
     345      StartMousePoint := TPoint.Create(X, Y);
     346      StartViewPoint := Core.CurrentClient.View.SourceRect.P1;
    346347      MoveActive := True;
    347348    end;
     
    366367    (Abs(StartMousePoint.Y - Y) > Trunc(Screen.PixelsPerInch * MouseMinDiff)) then
    367368    with Core.Game.CurrentPlayer, Core.CurrentClient do begin
    368       View.SourceRect := Bounds(Trunc(StartViewPoint.X + (StartMousePoint.X - X) / View.Zoom),
    369         Trunc(StartViewPoint.Y + (StartMousePoint.Y - Y) / View.Zoom),
    370         View.SourceRect.Right - View.SourceRect.Left,
    371         View.SourceRect.Bottom - View.SourceRect.Top);
     369      View.SourceRect := TRect.CreateBounds(TPoint.Create(Trunc(StartViewPoint.X + (StartMousePoint.X - X) / View.Zoom),
     370        Trunc(StartViewPoint.Y + (StartMousePoint.Y - Y) / View.Zoom)),
     371        View.SourceRect.Size);
    372372      Redraw;
    373373    end;
     
    375375    OldCell := Core.CurrentClient.View.FocusedCell;
    376376    with Core.Game do
    377       Cell := Map.PosToCell(Core.CurrentClient.View.CanvasToCellPos(Point(X, Y)), Core.CurrentClient.View );
     377      Cell := Map.PosToCell(Core.CurrentClient.View.CanvasToCellPos(TPoint.Create(X, Y)), Core.CurrentClient.View );
    378378    if Assigned(Cell) then begin
    379379      Core.CurrentClient.View.FocusedCell := Cell;
     
    384384      StatusBar1.Panels[0].Text := '';
    385385    end;
    386     CellPos := Core.CurrentClient.View.CanvasToCellPos(Point(X, Y));
     386    CellPos := Core.CurrentClient.View.CanvasToCellPos(TPoint.Create(X, Y));
    387387    StatusBar1.Panels[2].Text := 'CellPos: ' + IntToStr(CellPos.X) + ', ' + IntToStr(CellPos.Y);
    388388    if Cell <> OldCell then Redraw;
     
    396396  (Abs(StartMousePoint.Y - Y) < Trunc(Screen.PixelsPerInch * MouseMinDiff)) then begin
    397397    if Core.Game.Running and (Core.Game.CurrentPlayer.Mode = pmHuman) then begin
    398       Core.CurrentClient.View.SelectCell(Point(X, Y), Core.Game.CurrentPlayer, Shift);
     398      Core.CurrentClient.View.SelectCell(TPoint.Create(X, Y), Core.Game.CurrentPlayer, Shift);
    399399      Redraw;
    400400    end;
Note: See TracChangeset for help on using the changeset viewer.