Ignore:
Timestamp:
Sep 20, 2018, 3:33:04 PM (6 years ago)
Author:
chronos
Message:
  • Added: Mouse focused and selected cells are now working.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormClient.pas

    r235 r236  
    169169  R: TRect;
    170170  StartP: TPoint;
    171   VS: TPoint;
    172171  CountP: TPoint;
    173172  X, Y: Integer;
     
    193192
    194193      if Game.CyclicMap then begin
    195         VS := View.CellToCanvasPos(Game.Map.Size);
    196194        TempView := TView.Create;
    197195        TempView.Game := Game;
     
    493491  OldCell: TPlayerCell;
    494492  CellPos: TPoint;
     493  P: TPoint;
     494  R: TRect;
    495495begin
    496496  if Assigned(Client) then begin
     497    P := TPoint.Create(X, Y);
    497498    if MoveActive then
    498499    if (Abs(StartMousePoint.X - X) > Trunc(Screen.PixelsPerInch * MouseMinDiff)) or
    499500    (Abs(StartMousePoint.Y - Y) > Trunc(Screen.PixelsPerInch * MouseMinDiff)) then
    500501    with Client do begin
    501       View.SourceRect := TRect.CreateBounds(TPoint.Create(Trunc(StartViewPoint.X + (StartMousePoint.X - X) / View.Zoom),
     502      View.SourceRect := TRect.CreateBounds(TPoint.Create(
     503        Trunc(StartViewPoint.X + (StartMousePoint.X - X) / View.Zoom),
    502504        Trunc(StartViewPoint.Y + (StartMousePoint.Y - Y) / View.Zoom)),
    503505        View.SourceRect.Size);
     
    507509    OldCell := Client.View.FocusedCell;
    508510    with Core.Game do
    509       if Assigned(Client.ControlPlayer) then
    510         Cell := Client.ControlPlayer.PlayerMap.PosToCell(Client.View.CanvasToCellPos(TPoint.Create(X, Y)));
    511         //else Cell := Client.Game.Map.PosToCell(Client.View.CanvasToCellPos(TPoint.Create(X, Y)), Client.View);
     511      if Assigned(Client.ControlPlayer) then begin
     512        if Map.Cyclic then begin
     513          R := Client.View.CellToCanvasRect(Map.PixelRect);
     514          CellPos := TPoint.Create(
     515            ModNeg(P.X - R.P1.X, R.Size.X) + R.P1.X,
     516            ModNeg(P.Y - R.P1.Y, R.Size.Y) + R.P1.Y
     517          );
     518          Cell := Client.ControlPlayer.PlayerMap.PosToCell(
     519          Client.View.CanvasToCellPos(CellPos));
     520        end else begin
     521          Cell := Client.ControlPlayer.PlayerMap.PosToCell(
     522            Client.View.CanvasToCellPos(P));
     523        end;
     524      end;
    512525    if Assigned(Cell) then begin
    513526      Client.View.FocusedCell := Cell;
     
    530543  (Abs(StartMousePoint.Y - Y) < Trunc(Screen.PixelsPerInch * MouseMinDiff)) then begin
    531544    if Core.Game.Running and (Core.Game.CurrentPlayer.Mode = pmHuman) and
    532       (Core.Game.CurrentPlayer = Client.ControlPlayer) then begin
     545    (Core.Game.CurrentPlayer = Client.ControlPlayer) then begin
    533546      Client.View.SelectCell(TPoint.Create(X, Y), Client.ControlPlayer, Shift);
    534547      Redraw;
Note: See TracChangeset for help on using the changeset viewer.