Changeset 125 for trunk/Forms


Ignore:
Timestamp:
Jun 17, 2017, 2:24:51 AM (7 years ago)
Author:
chronos
Message:
  • Modified: Introduced TClient class for real user accessing particular player or spectator. TPlayer is now just player in the game.
  • Fixed: Exception if no human player was selected.
Location:
trunk/Forms
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.lfm

    r111 r125  
    1414  OnKeyUp = FormKeyUp
    1515  OnShow = FormShow
    16   LCLVersion = '1.6.0.4'
     16  LCLVersion = '1.6.4.0'
    1717  WindowState = wsMaximized
    1818  object StatusBar1: TStatusBar
  • trunk/Forms/UFormMain.pas

    r111 r125  
    131131begin
    132132  DrawStart := Now;
    133   if Assigned(Core.Player) then
    134   with Core.Player do begin
     133  if Assigned(Core.CurrentClient) then
     134  with Core.CurrentClient do begin
    135135    View.DestRect := Bounds(0, 0, PaintBox1.Width, PaintBox1.Height);
    136136    if csOpaque in PaintBox1.ControlStyle then begin
     
    138138      TempBitmap.Canvas.Brush.Color := clBackground; //PaintBox1.GetColorResolvingParent;
    139139      TempBitmap.Canvas.FillRect(0, 0, PaintBox1.Width, PaintBox1.Height);
    140       Paint(TempBitmap.Canvas);
     140      if Assigned(ControlPlayer) then ControlPlayer.Paint(TempBitmap.Canvas, View)
     141        else Core.Game.Map.Paint(TempBitmap.Canvas, View);
    141142      PaintBox1.Canvas.Draw(0, 0, TempBitmap);
    142143    end else begin
     
    145146      PaintBox1.Canvas.FillRect(0, 0, PaintBox1.Width, PaintBox1.Height);
    146147      {$endif}
    147       Paint(PaintBox1.Canvas);
     148      if Assigned(ControlPlayer) then ControlPlayer.Paint(PaintBox1.Canvas, View)
     149        else Core.Game.Map.Paint(PaintBox1.Canvas, View);
    148150    end;
    149151  end;
     
    158160procedure TFormMain.PaintBox1Resize(Sender: TObject);
    159161begin
    160   if Assigned(Core.Player) then
    161   with Core.Player do
     162  if Assigned(Core.CurrentClient) then
     163  with Core.CurrentClient do
    162164    View.DestRect := Bounds(0, 0, PaintBox1.Width, PaintBox1.Height);
    163165  Redraw;
     
    251253  NewZoom: Single;
    252254begin
    253   with Core, Game, Player, View do begin
     255  with Core, Game, CurrentClient, View do begin
    254256    MapRect := Map.GetPixelRect;
    255257    Factor := FloatPoint((DestRect.Right - DestRect.Left) / (MapRect.Right - MapRect.Left),
     
    284286procedure TFormMain.AZoomInExecute(Sender: TObject);
    285287begin
    286   with Core.Player do begin
     288  with Core.CurrentClient do begin
    287289    View.Zoom := View.Zoom * ZoomFactor;
    288290  end;
     
    294296  D: TPoint;
    295297begin
    296   with Core.Player do begin
     298  with Core.CurrentClient do begin
    297299    //D := Point(Trunc(MousePos.X - View.Left / ViewZoom),
    298300    //  Trunc(MousePos.Y - View.Top / ViewZoom));
     
    323325  if (Key = 27) or (Key = 17) then
    324326  if Assigned(Core.Game.CurrentPlayer) then begin
    325     Core.Game.CurrentPlayer.View.SelectedCell := nil;
     327    Core.CurrentClient.View.SelectedCell := nil;
    326328    Redraw;
    327329  end;
     
    341343begin
    342344  if Button = mbLeft then begin
    343     if Core.Game.CurrentPlayer.Mode = pmHuman then begin
     345    if Assigned(Core.CurrentClient) then begin
    344346      StartMousePoint := Point(X, Y);
    345       StartViewPoint := Core.Game.CurrentPlayer.View.SourceRect.TopLeft;
     347      StartViewPoint := Core.CurrentClient.View.SourceRect.TopLeft;
    346348      MoveActive := True;
    347349    end;
     
    361363  CellPos: TPoint;
    362364begin
    363   if Assigned(Core.Game.CurrentPlayer) then begin
     365  if Assigned(Core.CurrentClient) then begin
    364366    if MoveActive then
    365367    if (Abs(StartMousePoint.X - X) > Trunc(Screen.PixelsPerInch * MouseMinDiff)) or
    366368    (Abs(StartMousePoint.Y - Y) > Trunc(Screen.PixelsPerInch * MouseMinDiff)) then
    367     with Core.Game.CurrentPlayer do begin
    368       if Mode = pmHuman then begin
    369         View.SourceRect := Bounds(Trunc(StartViewPoint.X + (StartMousePoint.X - X) / View.Zoom),
    370           Trunc(StartViewPoint.Y + (StartMousePoint.Y - Y) / View.Zoom),
    371           View.SourceRect.Right - View.SourceRect.Left,
    372           View.SourceRect.Bottom - View.SourceRect.Top);
    373         Redraw;
    374       end;
     369    with Core.Game.CurrentPlayer, Core.CurrentClient do begin
     370      View.SourceRect := Bounds(Trunc(StartViewPoint.X + (StartMousePoint.X - X) / View.Zoom),
     371        Trunc(StartViewPoint.Y + (StartMousePoint.Y - Y) / View.Zoom),
     372        View.SourceRect.Right - View.SourceRect.Left,
     373        View.SourceRect.Bottom - View.SourceRect.Top);
     374      Redraw;
    375375    end;
    376376    Cell := nil;
    377     OldCell := Core.Game.CurrentPlayer.View.FocusedCell;
     377    OldCell := Core.CurrentClient.View.FocusedCell;
    378378    with Core.Game do
    379       Cell := Map.PosToCell(CurrentPlayer.View.CanvasToCellPos(Point(X, Y)), CurrentPlayer.View );
     379      Cell := Map.PosToCell(Core.CurrentClient.View.CanvasToCellPos(Point(X, Y)), Core.CurrentClient.View );
    380380    if Assigned(Cell) then begin
    381       Core.Game.CurrentPlayer.View.FocusedCell := Cell;
     381      Core.CurrentClient.View.FocusedCell := Cell;
    382382      StatusBar1.Panels[0].Text := '[' + IntToStr(Cell.PosPx.X) + ', ' + IntToStr(Cell.PosPx.Y) +
    383383        '] (' + IntToStr(Cell.MovesFrom.Count) + ', ' + IntToStr(Cell.MovesTo.Count) + ')';
    384384    end else begin
    385       Core.Game.CurrentPlayer.View.FocusedCell := nil;
     385      Core.CurrentClient.View.FocusedCell := nil;
    386386      StatusBar1.Panels[0].Text := '';
    387387    end;
    388     CellPos := Core.Game.CurrentPlayer.View.CanvasToCellPos(Point(X, Y));
     388    CellPos := Core.CurrentClient.View.CanvasToCellPos(Point(X, Y));
    389389    StatusBar1.Panels[2].Text := 'CellPos: ' + IntToStr(CellPos.X) + ', ' + IntToStr(CellPos.Y);
    390390    if Cell <> OldCell then Redraw;
     
    398398  (Abs(StartMousePoint.Y - Y) < Trunc(Screen.PixelsPerInch * MouseMinDiff)) then begin
    399399    if Core.Game.Running and (Core.Game.CurrentPlayer.Mode = pmHuman) then begin
    400       Core.Game.CurrentPlayer.View.SelectCell(Point(X, Y), Core.Game.CurrentPlayer, Shift);
     400      Core.CurrentClient.View.SelectCell(Point(X, Y), Core.Game.CurrentPlayer, Shift);
    401401      Redraw;
    402402    end;
  • trunk/Forms/UFormNew.pas

    r102 r125  
    241241  ReloadView;
    242242  //Height := Trunc(1.5 * Height);
     243  PageControl1.TabIndex := 0;
    243244end;
    244245
Note: See TracChangeset for help on using the changeset viewer.