Ignore:
Timestamp:
Mar 7, 2014, 11:03:30 PM (11 years ago)
Author:
chronos
Message:
  • Added: Zoom all action to show entire map.
  • Added: Actions Zoom in and Zoom out which keep view center.
  • Fixed: Form resize now keep view center.
  • Modified: Attacking is now using mutiple dice rolls system.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.pas

    r34 r35  
    1717
    1818  TFormMain = class(TForm)
     19    AZoomIn: TAction;
     20    AZoomAll: TAction;
     21    AZoomOut: TAction;
     22    ActionList1: TActionList;
    1923    MainMenu1: TMainMenu;
    2024    MenuItem1: TMenuItem;
     25    MenuItem10: TMenuItem;
     26    MenuItem11: TMenuItem;
     27    MenuItem12: TMenuItem;
     28    MenuItem13: TMenuItem;
    2129    MenuItem2: TMenuItem;
    2230    MenuItem3: TMenuItem;
     
    3644    ToolButton4: TToolButton;
    3745    ToolButton5: TToolButton;
     46    procedure AZoomAllExecute(Sender: TObject);
     47    procedure AZoomInExecute(Sender: TObject);
     48    procedure AZoomOutExecute(Sender: TObject);
    3849    procedure FormActivate(Sender: TObject);
    3950    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
     
    136147end;
    137148
     149procedure TFormMain.AZoomAllExecute(Sender: TObject);
     150var
     151  Factor: TFloatPoint;
     152  MapRect: TRect;
     153begin
     154  with Core.Game, CurrentPlayer, View do begin
     155    MapRect := Map.GetPixelRect;
     156    Factor := FloatPoint((DestRect.Right - DestRect.Left) / (MapRect.Right - MapRect.Left),
     157      (DestRect.Bottom - DestRect.Top) / (MapRect.Bottom - MapRect.Top));
     158    if Factor.X < Factor.Y then Zoom := Factor.X
     159      else Zoom := Factor.Y;
     160    CenterMap;
     161  end;
     162  Redraw;
     163end;
     164
     165procedure TFormMain.AZoomInExecute(Sender: TObject);
     166begin
     167  with Core.Game.CurrentPlayer do begin
     168    View.Zoom := View.Zoom * ZoomFactor;
     169  end;
     170  Redraw;
     171end;
     172
     173procedure TFormMain.AZoomOutExecute(Sender: TObject);
     174var
     175  D: TPoint;
     176begin
     177  with Core.Game.CurrentPlayer do begin
     178    //D := Point(Trunc(MousePos.X - View.Left / ViewZoom),
     179    //  Trunc(MousePos.Y - View.Top / ViewZoom));
     180    View.Zoom := View.Zoom / ZoomFactor;
     181    //View := Bounds(Trunc((D.X - MousePos.X) * ViewZoom),
     182    //  Trunc((D.Y - MousePos.Y) * ViewZoom),
     183    //  View.Right - View.Left,
     184    //  View.Bottom - View.Top);
     185  end;
     186  Redraw;
     187end;
     188
    138189procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
    139190begin
     
    172223  Cell: TCell;
    173224  OldCell: TCell;
     225  CellPos: TPoint;
    174226begin
    175227  if Assigned(Core.Game.CurrentPlayer) then begin
     
    195247      StatusBar1.Panels[0].Text := '';
    196248    end;
     249    CellPos := Core.Game.CurrentPlayer.View.CanvasToCellPos(Point(X, Y));
     250    StatusBar1.Panels[2].Text := 'CellPos: ' + IntToStr(CellPos.X) + ', ' + IntToStr(CellPos.Y);
    197251    if Cell <> OldCell then Redraw;
    198252  end else StatusBar1.Panels[0].Text := '';
     
    213267procedure TFormMain.PaintBox1MouseWheelDown(Sender: TObject;
    214268  Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
    215 var
    216   D: TPoint;
    217 begin
    218   with Core.Game.CurrentPlayer do begin
    219     //D := Point(Trunc(MousePos.X - View.Left / ViewZoom),
    220     //  Trunc(MousePos.Y - View.Top / ViewZoom));
    221     View.Zoom := View.Zoom / ZoomFactor;
    222     //View := Bounds(Trunc((D.X - MousePos.X) * ViewZoom),
    223     //  Trunc((D.Y - MousePos.Y) * ViewZoom),
    224     //  View.Right - View.Left,
    225     //  View.Bottom - View.Top);
    226   end;
    227   Redraw;
     269begin
     270  AZoomOut.Execute;
    228271end;
    229272
     
    231274  MousePos: TPoint; var Handled: Boolean);
    232275begin
    233   with Core.Game.CurrentPlayer do
    234     View.Zoom := View.Zoom * ZoomFactor;
    235   Redraw;
     276  AZoomIn.Execute;
    236277end;
    237278
Note: See TracChangeset for help on using the changeset viewer.