Changeset 19 for trunk


Ignore:
Timestamp:
Feb 27, 2014, 7:43:00 AM (11 years ago)
Author:
chronos
Message:
  • Modified: Center map to screen after new game is started.
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/UFormMain.pas

    r18 r19  
    210210procedure TFormMain.PaintBox1MouseWheelDown(Sender: TObject;
    211211  Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
    212 begin
    213   with Game.CurrentPlayer do
     212var
     213  D: TPoint;
     214begin
     215  with Game.CurrentPlayer do begin
     216    D := Point(Trunc(MousePos.X - Game.CurrentPlayer.View.Left / ViewZoom),
     217      Trunc(MousePos.Y - Game.CurrentPlayer.View.Top / ViewZoom));
    214218    ViewZoom := ViewZoom / ZoomFactor;
     219    //View := Bounds(Trunc((D.X - MousePos.X) * ViewZoom),
     220    //  Trunc((D.Y - MousePos.Y) * ViewZoom),
     221    //  View.Right - View.Left,
     222    //  View.Bottom - View.Top);
     223  end;
    215224  Redraw;
    216225end;
  • trunk/UFormNew.pas

    r18 r19  
    114114  CheckBoxVoid.Checked := Game.VoidEnabled;
    115115  for I := 0 to Players.Count - 1 do
    116     TPlayer(Players[I]).Free;
     116    Players[I] := nil;
    117117  Players.Count := Game.Players.Count;
    118118  for I := 0 to Game.Players.Count - 1 do begin
  • trunk/UGame.pas

    r18 r19  
    6666    procedure ClearCellMoves;
    6767    procedure ComputePlayerStats;
     68    function GetPixelSize: TPoint;
    6869    property Size: TPoint read FSize write SetSize;
    6970  end;
     
    445446      StartCell.Power := TPlayer(Players[I]).StartUnits;
    446447    end;
     448    ViewZoom := 1;
     449    // Center board
     450    View := Bounds(-(View.Right - View.Left) div 2 + Map.GetPixelSize.X div 2,
     451      -(View.Bottom - View.Top) div 2 + Map.GetPixelSize.Y div 2,
     452      View.Right - View.Left,
     453      View.Bottom - View.Top);
    447454  end;
    448455  CurrentPlayer := TPlayer(Players[0]);
     
    667674end;
    668675
     676function THexMap.GetPixelSize: TPoint;
     677begin
     678  Result := Point(Size.X * DefaultCellSize.X, Size.Y * DefaultCellSize.Y);
     679end;
     680
    669681end.
    670682
Note: See TracChangeset for help on using the changeset viewer.